GroupsController.cs 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using NPOI.SS.UserModel;
  8. using NPOI.SS.Util;
  9. using NPOI.XSSF.UserModel;
  10. using OASystem.API.Middlewares;
  11. using OASystem.API.OAMethodLib;
  12. using OASystem.API.OAMethodLib.APNs;
  13. using OASystem.API.OAMethodLib.DeepSeekAPI;
  14. using OASystem.API.OAMethodLib.File;
  15. using OASystem.API.OAMethodLib.Hub.HubClients;
  16. using OASystem.API.OAMethodLib.Hub.Hubs;
  17. using OASystem.API.OAMethodLib.JuHeAPI;
  18. using OASystem.API.OAMethodLib.KiMiApi;
  19. using OASystem.API.OAMethodLib.Logging;
  20. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  21. using OASystem.Domain.AesEncryption;
  22. using OASystem.Domain.Attributes;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels.CRM;
  31. using OASystem.Domain.ViewModels.Financial;
  32. using OASystem.Domain.ViewModels.Groups;
  33. using OASystem.Domain.ViewModels.OCR;
  34. using OASystem.Infrastructure.Repositories.CRM;
  35. using OASystem.Infrastructure.Repositories.Financial;
  36. using OASystem.Infrastructure.Repositories.Groups;
  37. using Quartz.Logging;
  38. using Quartz.Util;
  39. using SqlSugar.Extensions;
  40. using System.Collections;
  41. using System.ComponentModel.DataAnnotations;
  42. using System.Data;
  43. using System.Diagnostics;
  44. using System.Globalization;
  45. using System.IO;
  46. using System.IO.Compression;
  47. using System.Text.Json;
  48. using System.Text.RegularExpressions;
  49. using System.Web;
  50. using static OASystem.API.OAMethodLib.JWTHelper;
  51. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  52. using Bookmark = Aspose.Words.Bookmark;
  53. using Cell = Aspose.Words.Tables.Cell;
  54. using Table = Aspose.Words.Tables.Table;
  55. namespace OASystem.API.Controllers
  56. {
  57. /// <summary>
  58. /// 团组相关
  59. /// </summary>
  60. //[Authorize]
  61. [Route("api/[controller]/[action]")]
  62. public class GroupsController : ControllerBase
  63. {
  64. private readonly ILogger<GroupsController> _logger;
  65. private readonly ITextFileLogger _eec_textLogger;
  66. private readonly IGroupTextFileLogger _groupTextLogger;
  67. private readonly GrpScheduleRepository _grpScheduleRep;
  68. private readonly IMapper _mapper;
  69. private readonly DelegationInfoRepository _groupRepository;
  70. private readonly TaskAssignmentRepository _taskAssignmentRep;
  71. private readonly AirTicketResRepository _airTicketResRep;
  72. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  73. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  74. private readonly DelegationEnDataRepository _delegationEnDataRep;
  75. private readonly DelegationVisaRepository _delegationVisaRep;
  76. private readonly VisaPriceRepository _visaPriceRep;
  77. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  78. private readonly HotelPriceRepository _hotelPriceRep;
  79. private readonly CustomersRepository _customersRep;
  80. private readonly MessageRepository _message;
  81. private readonly SqlSugarClient _sqlSugar;
  82. private readonly TourClientListRepository _tourClientListRep;
  83. private readonly TeamRateRepository _teamRateRep;
  84. #region 成本相关
  85. private readonly CheckBoxsRepository _checkBoxs;
  86. private readonly GroupCostRepository _GroupCostRepository;
  87. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  88. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  89. #endregion
  90. private readonly SetDataRepository _setDataRep;
  91. private string url;
  92. private string path;
  93. private readonly EnterExitCostRepository _enterExitCostRep;
  94. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  95. private readonly UsersRepository _usersRep;
  96. private readonly IJuHeApiService _juHeApi;
  97. private readonly InvertedListRepository _invertedListRep;
  98. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  99. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  100. private readonly ThreeCodeRepository _threeCodeRepository;
  101. private readonly HotelInquiryRepository _hotelInquiryRep;
  102. private readonly FeeAuditRepository _feeAuditRep;
  103. private readonly VisaCommissionRepository _visaCommissionRep;
  104. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  105. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  106. private readonly List<CurrencyInfo> _currencyInit;
  107. private readonly List<int> _portTypeData;
  108. private readonly TableOperationRecordRepository _tableorRep;
  109. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  110. private readonly RestaurantRepository _restaurantRep;
  111. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  112. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  113. private readonly VisaProcessRepository _visaProcessRep;
  114. private readonly IDeepSeekService _deepSeekService;
  115. /// <summary>
  116. /// 构造函数
  117. /// </summary>
  118. /// <param name="logger"></param>
  119. /// <param name="eec_textLogger"></param>
  120. /// <param name="groupTextLogger"></param>
  121. /// <param name="mapper"></param>
  122. /// <param name="hubContext"></param>
  123. /// <param name="sqlSugar"></param>
  124. /// <param name="grpScheduleRep"></param>
  125. /// <param name="groupRepository"></param>
  126. /// <param name="taskAssignmentRep"></param>
  127. /// <param name="airTicketResRep"></param>
  128. /// <param name="decreasePaymentsRep"></param>
  129. /// <param name="InvitationOfficialActivitiesRep"></param>
  130. /// <param name="delegationEnDataRep"></param>
  131. /// <param name="enterExitCostRep"></param>
  132. /// <param name="delegationVisaRep"></param>
  133. /// <param name="message"></param>
  134. /// <param name="visaPriceRep"></param>
  135. /// <param name="carTouristGuideGroundRep"></param>
  136. /// <param name="checkBoxs"></param>
  137. /// <param name="GroupCostRepository"></param>
  138. /// <param name="CostTypeHotelNumberRepository"></param>
  139. /// <param name="GroupCostParameterRepository"></param>
  140. /// <param name="hotelPriceRep"></param>
  141. /// <param name="customersRep"></param>
  142. /// <param name="setDataRep"></param>
  143. /// <param name="tourClientListRep"></param>
  144. /// <param name="teamRateRep"></param>
  145. /// <param name="usersRep"></param>
  146. /// <param name="juHeApi"></param>
  147. /// <param name="invertedListRep"></param>
  148. /// <param name="visaFeeInfoRep"></param>
  149. /// <param name="ticketBlackCodeRep"></param>
  150. /// <param name="hotelInquiryRep"></param>
  151. /// <param name="threeCodeRepository"></param>
  152. /// <param name="feeAuditRep"></param>
  153. /// <param name="visaCommissionRep"></param>
  154. /// <param name="ffrRep"></param>
  155. /// <param name="opinionaireRep"></param>
  156. /// <param name="tableorRep"></param>
  157. /// <param name="enterExitCostDraftRep"></param>
  158. /// <param name="restaurantRep"></param>
  159. /// <param name="enterExitCostQuoteRep"></param>
  160. /// <param name="grpOrderPreInfoRep"></param>
  161. /// <param name="visaProcessRep"></param>
  162. public GroupsController(
  163. ILogger<GroupsController> logger,
  164. ITextFileLogger eec_textLogger,
  165. IGroupTextFileLogger groupTextLogger,
  166. IMapper mapper,
  167. IHubContext<ChatHub, IChatClient> hubContext,
  168. SqlSugarClient sqlSugar,
  169. GrpScheduleRepository grpScheduleRep,
  170. DelegationInfoRepository groupRepository,
  171. TaskAssignmentRepository taskAssignmentRep,
  172. AirTicketResRepository airTicketResRep,
  173. DecreasePaymentsRepository decreasePaymentsRep,
  174. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  175. DelegationEnDataRepository delegationEnDataRep,
  176. EnterExitCostRepository enterExitCostRep,
  177. DelegationVisaRepository delegationVisaRep,
  178. MessageRepository message,
  179. VisaPriceRepository visaPriceRep,
  180. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  181. CheckBoxsRepository checkBoxs,
  182. GroupCostRepository GroupCostRepository,
  183. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  184. GroupCostParameterRepository GroupCostParameterRepository,
  185. HotelPriceRepository hotelPriceRep,
  186. CustomersRepository customersRep,
  187. SetDataRepository setDataRep,
  188. TourClientListRepository tourClientListRep,
  189. TeamRateRepository teamRateRep,
  190. UsersRepository usersRep,
  191. IJuHeApiService juHeApi,
  192. InvertedListRepository invertedListRep,
  193. VisaFeeInfoRepository visaFeeInfoRep,
  194. TicketBlackCodeRepository ticketBlackCodeRep,
  195. HotelInquiryRepository hotelInquiryRep,
  196. ThreeCodeRepository threeCodeRepository,
  197. FeeAuditRepository feeAuditRep,
  198. VisaCommissionRepository visaCommissionRep,
  199. ForeignReceivablesRepository ffrRep,
  200. OpinionaireRepository opinionaireRep,
  201. TableOperationRecordRepository tableorRep,
  202. EnterExitCostDraftRepository enterExitCostDraftRep,
  203. RestaurantRepository restaurantRep,
  204. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  205. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  206. VisaProcessRepository visaProcessRep,
  207. IDeepSeekService deepSeekService
  208. )
  209. {
  210. _logger = logger;
  211. _eec_textLogger = eec_textLogger;
  212. _groupTextLogger = groupTextLogger;
  213. _mapper = mapper;
  214. _grpScheduleRep = grpScheduleRep;
  215. _groupRepository = groupRepository;
  216. _taskAssignmentRep = taskAssignmentRep;
  217. _airTicketResRep = airTicketResRep;
  218. _sqlSugar = sqlSugar;
  219. url = AppSettingsHelper.Get("ExcelBaseUrl");
  220. path = AppSettingsHelper.Get("ExcelBasePath");
  221. if (!System.IO.Directory.Exists(path))
  222. {
  223. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  224. }
  225. _decreasePaymentsRep = decreasePaymentsRep;
  226. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  227. _delegationEnDataRep = delegationEnDataRep;
  228. _enterExitCostRep = enterExitCostRep;
  229. _delegationVisaRep = delegationVisaRep;
  230. _message = message;
  231. _visaPriceRep = visaPriceRep;
  232. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  233. _checkBoxs = checkBoxs;
  234. _GroupCostRepository = GroupCostRepository;
  235. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  236. _GroupCostParameterRepository = GroupCostParameterRepository;
  237. _hotelPriceRep = hotelPriceRep;
  238. _customersRep = customersRep;
  239. _setDataRep = setDataRep;
  240. _tourClientListRep = tourClientListRep;
  241. _teamRateRep = teamRateRep;
  242. _hubContext = hubContext;
  243. _usersRep = usersRep;
  244. _juHeApi = juHeApi;
  245. _invertedListRep = invertedListRep;
  246. _visaFeeInfoRep = visaFeeInfoRep;
  247. _ticketBlackCodeRep = ticketBlackCodeRep;
  248. _hotelInquiryRep = hotelInquiryRep;
  249. _threeCodeRepository = threeCodeRepository;
  250. _feeAuditRep = feeAuditRep;
  251. _visaCommissionRep = visaCommissionRep;
  252. _ffrRep = ffrRep;
  253. _opinionaireRep = opinionaireRep;
  254. _currencyInit = new List<CurrencyInfo>()
  255. {
  256. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  257. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  258. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  259. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  260. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  261. };
  262. _portTypeData = new List<int>() { 2, 3 };
  263. _tableorRep = tableorRep;
  264. _enterExitCostDraftRep = enterExitCostDraftRep;
  265. _restaurantRep = restaurantRep;
  266. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  267. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  268. _deepSeekService = deepSeekService;
  269. _visaProcessRep = visaProcessRep;
  270. }
  271. #region 流程管控
  272. /// <summary>
  273. /// 获取团组流程管控信息
  274. /// </summary>
  275. /// <param name="_jsonDto">查询参数</param>
  276. /// <returns></returns>
  277. [HttpPost]
  278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  279. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  280. {
  281. if (string.IsNullOrEmpty(_jsonDto.Paras))
  282. {
  283. return Ok(JsonView(false, "参数为空"));
  284. }
  285. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  286. if (_ScheduleDto != null)
  287. {
  288. if (_ScheduleDto.SearchType == 2)//获取列表
  289. {
  290. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  291. return Ok(JsonView(_grpScheduleViewList));
  292. }
  293. else//获取对象
  294. {
  295. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  296. if (_grpScheduleView != null)
  297. {
  298. return Ok(JsonView(_grpScheduleView));
  299. }
  300. }
  301. }
  302. else
  303. {
  304. return Ok(JsonView(false, "参数反序列化失败"));
  305. }
  306. return Ok(JsonView(false, "暂无数据!"));
  307. }
  308. /// <summary>
  309. /// 修改团组流程管控详细表数据
  310. /// </summary>
  311. /// <param name="dto"></param>
  312. /// <returns></returns>
  313. [HttpPost]
  314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  315. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  316. {
  317. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  318. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  319. .SetColumns(it => it.Duty == _detail.Duty)
  320. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  321. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  322. .SetColumns(it => it.JobContent == _detail.JobContent)
  323. .SetColumns(it => it.Remark == _detail.Remark)
  324. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  325. .Where(s => s.Id == dto.Id)
  326. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  327. .ExecuteCommandAsync();
  328. if (result > 0)
  329. {
  330. return Ok(JsonView(true, "保存成功!"));
  331. }
  332. return Ok(JsonView(false, "保存失败!"));
  333. }
  334. /// <summary>
  335. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  336. /// </summary>
  337. /// <param name="dto"></param>
  338. /// <returns></returns>
  339. [HttpPost]
  340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  341. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  342. {
  343. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  344. _detail.IsDel = 1;
  345. _detail.DeleteUserId = dto.Duty;
  346. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  347. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  348. .SetColumns(it => it.IsDel == _detail.IsDel)
  349. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  350. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  351. .Where(it => it.Id == dto.Id)
  352. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  353. //.WhereColumns(s => s.Id == dto.Id)
  354. .ExecuteCommandAsync();
  355. if (result > 0)
  356. {
  357. return Ok(JsonView(true, "删除成功!"));
  358. }
  359. return Ok(JsonView(false, "删除失败!"));
  360. }
  361. /// <summary>
  362. /// 增加团组流程管控详细表数据
  363. /// </summary>
  364. /// <param name="dto"></param>
  365. /// <returns></returns>
  366. [HttpPost]
  367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  368. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  369. {
  370. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  371. if (DateTime.Now < _detail.ExpectBeginDt)
  372. {
  373. _detail.StepStatus = 0;
  374. }
  375. else
  376. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  377. _detail.StepStatus = 1;
  378. }
  379. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  380. if (result > 0)
  381. {
  382. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  383. return Ok(JsonView(true, "添加成功!", _result));
  384. }
  385. return Ok(JsonView(false, "添加失败!"));
  386. }
  387. #endregion
  388. #region 团组前期信息
  389. /// <summary>
  390. /// 团组前期信息H5-URL(员工对应地址)
  391. /// </summary>
  392. /// <param name="name">用户名称</param>
  393. /// <returns></returns>
  394. [HttpGet]
  395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  396. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  397. {
  398. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  399. .Where(x => x.IsDel == 0)
  400. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  401. .OrderBy(x => x.Id)
  402. .Select(x => new
  403. {
  404. name = x.CnName,
  405. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  406. })
  407. .ToListAsync();
  408. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  409. }
  410. /// <summary>
  411. /// 团组前期信息 List
  412. /// </summary>
  413. /// <returns></returns>
  414. [HttpPost]
  415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  416. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  417. {
  418. var search = dto.Search;
  419. int[] nameTempIds = new int[] { 1, 12, 28 },
  420. countryTempIds = new int[] { 2, 13, 29 },
  421. daysTempIds = new int[] { 4, 15, 31 },
  422. ppNumTempIds = new int[] { 6 };
  423. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  424. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  425. .Where((opi, u) => opi.IsDel == 0)
  426. .OrderByDescending((opi, u) => opi.CreateTime)
  427. .Select((opi, u) => new GroupOrderPreInfoListView()
  428. {
  429. Id = opi.Id,
  430. Name = opi.Name,
  431. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  432. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  433. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  434. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  435. Operator = u.CnName,
  436. OperationTime = opi.CreateTime
  437. })
  438. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  439. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  440. .ToListAsync();
  441. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  442. int total = list.Count;
  443. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  444. var listPageData1 = listPageData
  445. .Skip((dto.PageIndex - 1) * dto.PageSize)
  446. .Take(dto.PageSize)
  447. .ToList();
  448. var infoIds = listPageData1.Select(x => x.Id).ToList();
  449. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  450. .Where(x => x.IsDel == 0 && x.STid == 109)
  451. .ToArrayAsync();
  452. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  453. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  454. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  455. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  456. .ToListAsync();
  457. foreach (var item in listPageData1)
  458. {
  459. var typeDatas1 = typeDatas.Select(x => new
  460. {
  461. x.Id,
  462. x.Name,
  463. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  464. }).ToArray();
  465. item.VersionDetails = typeDatas1;
  466. }
  467. return Ok(JsonView(listPageData1, listPageData1.Count));
  468. }
  469. /// <summary>
  470. /// 团组前期信息 Init
  471. /// </summary>
  472. /// <returns></returns>
  473. [HttpGet("{userId}")]
  474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  475. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  476. {
  477. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  478. }
  479. /// <summary>
  480. /// 国家数据源
  481. /// </summary>
  482. /// <param name="pageIndex">当前页码</param>
  483. /// <param name="pageSize">每页条数</param>
  484. /// <param name="search">查询条件</param>
  485. /// <returns></returns>
  486. [HttpGet]
  487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  488. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  489. {
  490. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  491. if (pageIndex == 0 && pageSize == 0)
  492. {
  493. //所有数据
  494. return Ok(JsonView(countrys, countrys.Count));
  495. }
  496. //分页
  497. int skip = (pageIndex - 1) * pageSize;
  498. int take = pageSize;
  499. if (!string.IsNullOrEmpty(search))
  500. {
  501. IEnumerable<char> charSequence = search.Select(c => c);
  502. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  503. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  504. return Ok(JsonView(pageData, pageResult1.Count));
  505. }
  506. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  507. return Ok(JsonView(pageResult2, countrys.Count));
  508. }
  509. /// <summary>
  510. /// 城市数据源
  511. /// </summary>
  512. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  513. /// <param name="pageIndex">当前页码</param>
  514. /// <param name="pageSize">每页条数</param>
  515. /// <param name="search">查询条件</param>
  516. /// <returns></returns>
  517. [HttpGet("{countryLabel}")]
  518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  519. public async Task<IActionResult> CityByCountry(
  520. string countryLabel,
  521. [FromQuery] int pageIndex,
  522. [FromQuery] int pageSize,
  523. [FromQuery] string search)
  524. {
  525. countryLabel = HttpUtility.UrlDecode(countryLabel);
  526. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  527. var citys = Array.Empty<string?>();
  528. if (countryList.Any())
  529. {
  530. var cityDatas = await _sqlSugar
  531. .Queryable<Grp_NationalTravelFee>()
  532. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  533. .ToArrayAsync();
  534. foreach (var item in cityDatas)
  535. {
  536. if (item.City.Contains("城市"))
  537. {
  538. item.City = item.Country + "-所有城市";
  539. }
  540. }
  541. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  542. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  543. }
  544. if (pageIndex == 0 && pageSize == 0)
  545. {
  546. //所有数据
  547. return Ok(JsonView(citys, citys?.Length ?? 0));
  548. }
  549. //分页
  550. int skip = (pageIndex - 1) * pageSize;
  551. int take = pageSize;
  552. if (!string.IsNullOrEmpty(search))
  553. {
  554. IEnumerable<char> charSequence = search.Select(c => c);
  555. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  556. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  557. return Ok(JsonView(pageData, pageResult1.Count));
  558. }
  559. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  560. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  561. }
  562. /// <summary>
  563. /// 团组前期信息 Info
  564. /// </summary>
  565. /// <param name="dto">Id</param>
  566. /// <returns></returns>
  567. [HttpGet("{Id}/{TempId}")]
  568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  569. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  570. {
  571. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  572. }
  573. /// <summary>
  574. /// 团组前期信息 移动端 Info
  575. /// </summary>
  576. /// <param name="dto">Id</param>
  577. /// <returns></returns>
  578. [HttpGet("{Id}/{TempId}")]
  579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  580. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  581. {
  582. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  583. }
  584. /// <summary>
  585. /// 团组前期信息 Save
  586. /// </summary>
  587. /// <param name="dto">Id</param>
  588. /// <returns></returns>
  589. [HttpPost]
  590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  591. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  592. {
  593. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  594. }
  595. /// <summary>
  596. /// 团组前期信息 Del
  597. /// </summary>
  598. /// <param name="dto">Id</param>
  599. /// <returns></returns>
  600. [HttpPost]
  601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  602. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  603. {
  604. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  605. }
  606. /// <summary>
  607. /// 团组前期信息 文件下载
  608. /// </summary>
  609. /// <param name="dto">Id</param>
  610. /// <returns></returns>
  611. [HttpGet("{Id}/{TempId}")]
  612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  613. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  614. {
  615. int id = dto.Id, tempId = dto.TempId;
  616. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  617. var data = view.Data as GrpOrderPreInfoView;
  618. #region Excel
  619. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  620. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  621. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  622. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  623. var fileNamePrefix = string.Empty;
  624. if (tempId == 1405)
  625. {
  626. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  627. fileNamePrefix = $"{data.Name}_无商邀版";
  628. }
  629. else if (tempId == 1406)
  630. {
  631. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  632. fileNamePrefix = $"{data.Name}_有商邀版";
  633. }
  634. else
  635. {
  636. //tempId == 1404 默认下载
  637. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  638. fileNamePrefix = $"{data.Name}_单接送机";
  639. }
  640. foreach (var item in data.Items)
  641. {
  642. var obj = item.NewValue;
  643. if (obj == null) item.OriginVal = "";
  644. else if (obj.Equals("有") || obj.Equals("无"))
  645. {
  646. item.OriginVal = obj.ToString();
  647. }
  648. else if (obj is object[] objArray)
  649. {
  650. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  651. item.OriginVal = string.Join("、", stringArray);
  652. }
  653. else if (obj is string[] stringArray)
  654. {
  655. item.OriginVal = string.Join("、", stringArray);
  656. }
  657. else if (obj.Equals("-"))
  658. {
  659. item.OriginVal = "";
  660. }
  661. }
  662. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  663. fileName = CommonFun.ValidFileName(fileName);
  664. //载入模板
  665. var designer = new WorkbookDesigner
  666. {
  667. Workbook = new Workbook(tempPath)
  668. };
  669. if (tempId == 1406)
  670. {
  671. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  672. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  673. for (int i = 1; i <= view2.Length; i++)
  674. {
  675. view2[i - 1].Index = i;
  676. }
  677. designer.SetDataSource("View1", view1);
  678. designer.SetDataSource("View2", view2);
  679. }
  680. else
  681. {
  682. designer.SetDataSource("View", data.Items);
  683. }
  684. designer.Process();
  685. if (!Directory.Exists(savePath))
  686. {
  687. Directory.CreateDirectory(savePath);
  688. }
  689. string serverPath = $"{savePath}{fileName}";
  690. designer.Workbook.Save(serverPath);
  691. string rst = $"{servicePath}{ftpPath}{fileName}";
  692. #endregion
  693. return Ok(JsonView(new { url = rst }));
  694. }
  695. #endregion
  696. #region 团组基本信息
  697. /// <summary>
  698. /// 接团信息列表
  699. /// </summary>
  700. /// <param name="dto">团组列表请求dto</param>
  701. /// <returns></returns>
  702. [HttpPost]
  703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  704. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  705. {
  706. var groupData = await _groupRepository.GetGroupList(dto);
  707. if (groupData.Code != 0)
  708. {
  709. return Ok(JsonView(false, groupData.Msg));
  710. }
  711. return Ok(JsonView(groupData.Data));
  712. }
  713. /// <summary>
  714. /// 分页查询团组列表
  715. /// </summary>
  716. /// <param name="dto"></param>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  721. {
  722. var watch = new Stopwatch();
  723. watch.Start();
  724. RefAsync<int> total = 0;
  725. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  726. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  727. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  728. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  729. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  730. .Distinct()
  731. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  732. watch.Stop();
  733. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  734. }
  735. /// <summary>
  736. /// 接团信息列表 Page Init
  737. /// </summary>
  738. /// <returns></returns>
  739. [HttpPost]
  740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  741. public async Task<IActionResult> PostGroupPageListInit()
  742. {
  743. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  744. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  745. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  746. var _view = new
  747. {
  748. depData = depDatas,
  749. rankData = rankDatas
  750. };
  751. return Ok(JsonView(true, "查询成功!", _view));
  752. }
  753. /// <summary>
  754. /// 接团信息列表 Page
  755. /// </summary>
  756. /// <param name="dto">团组列表请求dto</param>
  757. /// <returns></returns>
  758. [HttpPost]
  759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  760. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  761. {
  762. #region 参数验证
  763. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  764. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  765. #region 页面操作权限验证
  766. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  767. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  768. #endregion
  769. #endregion
  770. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  771. {
  772. string sqlWhere = string.Empty;
  773. if (dto.IsSure == 0) //未完成
  774. {
  775. sqlWhere += string.Format(@" And IsSure = 0");
  776. }
  777. else if (dto.IsSure == 1) //已完成
  778. {
  779. sqlWhere += string.Format(@" And IsSure = 1");
  780. }
  781. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  782. {
  783. string tj = dto.SearchCriteria;
  784. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  785. tj, tj, tj, tj, tj);
  786. }
  787. if (int.TryParse(dto.Rank, out int rankId))
  788. {
  789. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  790. }
  791. string sqlWhere1 = string.Empty;
  792. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  793. {
  794. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  795. }
  796. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  797. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  798. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  799. JietuanOperator,IsSure,CreateTime,IsBid,Step
  800. From (
  801. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  802. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  803. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  804. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,gdi.Step,
  805. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  806. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  807. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  808. From Grp_DelegationInfo gdi
  809. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  810. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  811. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  812. Where gdi.IsDel = 0 {0}
  813. ) temp {1}", sqlWhere, sqlWhere1);
  814. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  815. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  816. //处理 团组模块实际操作人
  817. _DelegationList.ForEach(async x =>
  818. {
  819. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  820. var operatorNames = new StringBuilder();
  821. //operatorNames.AppendLine("各模块实际操作人:");
  822. if (operators.Any())
  823. {
  824. operators.ForEach(y =>
  825. {
  826. string label = string.Empty;
  827. if (y.OperationUsers.Any())
  828. {
  829. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  830. label = string.Join('、', users);
  831. }
  832. else label = "暂未指定";
  833. operatorNames.AppendLine($"{y.CTableName}:{label}");
  834. operatorNames.AppendLine();
  835. });
  836. }
  837. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  838. });
  839. var _view = new
  840. {
  841. PageFuncAuth = pageFunAuthView,
  842. Data = _DelegationList
  843. };
  844. return Ok(JsonView(true, "查询成功!", _view, total));
  845. }
  846. else
  847. {
  848. return Ok(JsonView(false, "查询失败"));
  849. }
  850. }
  851. /// <summary>
  852. /// 团组列表
  853. /// </summary>
  854. /// <returns></returns>
  855. [HttpPost]
  856. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  857. {
  858. #region 参数验证
  859. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  860. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  861. #region 页面操作权限验证
  862. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  863. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  864. #endregion
  865. #endregion
  866. if (dto.PortType != 1 && dto.PortType != 2)
  867. {
  868. return Ok(JsonView(false, "查询失败!"));
  869. }
  870. string orderbyStr = "order by gdi.CreateTime Desc";
  871. string sqlWhere = string.Empty;
  872. if (dto.IsSure == 0) //未完成
  873. {
  874. sqlWhere += string.Format(@" And IsSure = 0");
  875. }
  876. else if (dto.IsSure == 1) //已完成
  877. {
  878. sqlWhere += string.Format(@" And IsSure = 1");
  879. }
  880. //团组类型
  881. if (dto.TeamDid > 0)
  882. {
  883. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  884. }
  885. //团组名称
  886. if (!string.IsNullOrEmpty(dto.TeamName))
  887. {
  888. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  889. }
  890. //客户名称
  891. if (!string.IsNullOrEmpty(dto.ClientName))
  892. {
  893. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  894. }
  895. //客户单位
  896. if (!string.IsNullOrEmpty(dto.ClientUnit))
  897. {
  898. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  899. }
  900. //出访时间
  901. if (!string.IsNullOrEmpty(dto.visitDataTime))
  902. {
  903. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  904. orderbyStr = "order by gdi.VisitDate";
  905. }
  906. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  907. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  908. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  909. JietuanOperator,IsSure,CreateTime
  910. From (
  911. Select row_number() over({0}) as Row_Number,
  912. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  913. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  914. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  915. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  916. From Grp_DelegationInfo gdi
  917. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  918. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  919. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  920. Where gdi.IsDel = 0 {1}
  921. ) temp ", orderbyStr, sqlWhere);
  922. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  923. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  924. #region 处理所属部门
  925. /*
  926. * 1.sq 和 gyy 等显示 市场部
  927. * 2.王鸽和主管及张总还有管理员号统一国交部
  928. * 2-1. 4 管理员 ,21 张海麟
  929. */
  930. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  931. var userIds1 = new List<int>() { 4, 21 };
  932. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  933. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  934. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  935. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  936. .ToList();
  937. foreach (var item in _DelegationList)
  938. {
  939. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  940. }
  941. #endregion
  942. var _view = new
  943. {
  944. PageFuncAuth = pageFunAuthView,
  945. Data = _DelegationList
  946. };
  947. return Ok(JsonView(true, "查询成功!", _view, total));
  948. }
  949. /// <summary>
  950. /// 接团信息详情
  951. /// </summary>
  952. /// <param name="dto">团组info请求dto</param>
  953. /// <returns></returns>
  954. [HttpPost]
  955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  956. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  957. {
  958. var groupData = await _groupRepository.GetGroupInfo(dto);
  959. if (groupData.Code != 0)
  960. {
  961. return Ok(JsonView(false, groupData.Msg));
  962. }
  963. return Ok(JsonView(groupData.Data));
  964. }
  965. /// <summary>
  966. /// 接团信息 编辑添加
  967. /// 基础信息数据源
  968. /// </summary>
  969. /// <param name="dto"></param>
  970. /// <returns></returns>
  971. [HttpPost]
  972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  973. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  974. {
  975. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  976. if (groupData.Code != 0)
  977. {
  978. return Ok(JsonView(false, groupData.Msg));
  979. }
  980. return Ok(JsonView(groupData.Data));
  981. }
  982. /// <summary>
  983. /// 成本修改团组信息
  984. /// </summary>
  985. /// <param name="dto"></param>
  986. /// <returns></returns>
  987. [HttpPost]
  988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  989. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  990. {
  991. var jw = JsonView(false, "操作失败");
  992. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  993. if (di == null)
  994. {
  995. jw.Msg = "参数有误!";
  996. return Ok(jw);
  997. }
  998. #region 添加出访起止时间
  999. var startTime = new DateTime();
  1000. var endTime = new DateTime();
  1001. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1002. {
  1003. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1004. }
  1005. else
  1006. {
  1007. jw.Msg = "参数有误!";
  1008. return Ok(jw);
  1009. }
  1010. #endregion
  1011. di.VisitDate = startTime;
  1012. di.VisitPNumber = dto.VisitPNumber;
  1013. di.VisitDays = dto.VisitDays;
  1014. di.VisitStartDate = startTime;
  1015. di.VisitEndDate = endTime;
  1016. var count = _sqlSugar.Updateable(di)
  1017. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1018. .ExecuteCommand();
  1019. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1020. }
  1021. /// <summary>
  1022. /// 接团信息 编辑添加
  1023. /// 省份-城市 基础信息数据源
  1024. /// </summary>
  1025. /// <param name="dto"></param>
  1026. /// <returns></returns>
  1027. [HttpPost]
  1028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1029. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1030. {
  1031. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1032. string search = dto.Search;
  1033. var data = await _groupRepository.CityBasicSource();
  1034. int total = data.Length;
  1035. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1036. .Skip((pageIndex - 1) * pageSize)
  1037. .Take(pageSize)
  1038. .ToArray();
  1039. return Ok(JsonView(data, total));
  1040. }
  1041. /// <summary>
  1042. /// 接团信息 操作(增改)
  1043. /// </summary>
  1044. /// <param name="dto"></param>
  1045. /// <returns></returns>
  1046. [HttpPost]
  1047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1048. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1049. {
  1050. // 创建 Stopwatch 实例
  1051. Stopwatch stopwatch = Stopwatch.StartNew();
  1052. decimal ffrPrice = 0.00M;
  1053. DateTime? visitDt = null;
  1054. if (dto.Status == 2)
  1055. {
  1056. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1057. if (groupInfo != null)
  1058. {
  1059. ffrPrice = groupInfo.PaymentMoney;
  1060. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1061. }
  1062. }
  1063. var groupData = await _groupRepository.GroupOperation(dto);
  1064. if (groupData.Code != 0)
  1065. {
  1066. return Ok(JsonView(false, groupData.Msg));
  1067. }
  1068. int diId = 0;
  1069. try
  1070. {
  1071. //添加时 默认加入团组汇率
  1072. if (dto.Status == 1) //添加
  1073. {
  1074. diId = groupData.Data;
  1075. //添加默认币种
  1076. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1077. //默认分配权限
  1078. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1079. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1080. var _managerIds = new List<int>() { 22, 32, 21 };
  1081. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1082. if (userIds.Count > 0)
  1083. {
  1084. userIds.Add(208);
  1085. //创建团组管控
  1086. GroupStepForDelegation.CreateWorkStep(diId);
  1087. //发送消息
  1088. string groupName = dto.TeamName;
  1089. string createGroupUser = string.Empty;
  1090. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1091. if (userInfo != null) createGroupUser = userInfo.CnName;
  1092. string title = $"系统通知";
  1093. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1094. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1095. }
  1096. //默认创建倒推表
  1097. await _invertedListRep._Create(dto.UserId, diId);
  1098. //默认创建签证流程
  1099. await _visaProcessRep.Create(dto.UserId, diId);
  1100. }
  1101. else if (dto.Status == 2)
  1102. {
  1103. diId = dto.Id;
  1104. }
  1105. #region 签证人员团组时间通知
  1106. #region 计算出访起止时间
  1107. var startTime = new DateTime();
  1108. var endTime = new DateTime();
  1109. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1110. {
  1111. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1112. }
  1113. #endregion
  1114. #endregion
  1115. #region 团组操作默认添加/修改收款账单
  1116. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1117. {
  1118. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1119. .Where(x => x.IsDel == 0 &&
  1120. x.Diid == diId &&
  1121. x.Remark.Equals("预付款")
  1122. )
  1123. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1124. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1125. .FirstAsync();
  1126. ffrInfo = new Fin_ForeignReceivables()
  1127. {
  1128. Diid = diId,
  1129. PriceName = dto.ClientUnit,
  1130. Price = dto.PaymentMoney,
  1131. Count = 1,
  1132. Unit = $"元",
  1133. ItemSumPrice = dto.PaymentMoney,
  1134. Rate = 1.0000M,
  1135. Currency = 836,
  1136. AddingWay = 0,
  1137. CreateUserId = dto.UserId,
  1138. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1139. Remark = $"预付款"
  1140. };
  1141. if (ffrInfo == null) //Add
  1142. {
  1143. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1144. }
  1145. else //修改
  1146. {
  1147. await _sqlSugar.Updateable(ffrInfo)
  1148. .UpdateColumns(x => new
  1149. {
  1150. x.PriceName,
  1151. x.Price,
  1152. x.ItemSumPrice,
  1153. x.CreateTime,
  1154. x.CreateUserId
  1155. })
  1156. .WhereColumns(x => x.Id)
  1157. .ExecuteCommandAsync();
  1158. }
  1159. }
  1160. #endregion
  1161. if (diId > 0)
  1162. {
  1163. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1164. }
  1165. // 停止计时
  1166. stopwatch.Stop();
  1167. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1168. }
  1169. catch (Exception ex)
  1170. {
  1171. // 停止计时
  1172. stopwatch.Stop();
  1173. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1174. Logs(ex.Message);
  1175. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1176. }
  1177. // 停止计时
  1178. stopwatch.Stop();
  1179. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1180. }
  1181. /// <summary>
  1182. /// 接团流程操作(增改)
  1183. /// 安卓端使用 建团时添加客户名单
  1184. /// </summary>
  1185. /// <param name="dto"></param>
  1186. /// <returns></returns>
  1187. [HttpPost]
  1188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1189. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1190. {
  1191. #region 参数验证
  1192. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1193. #region 页面操作权限验证
  1194. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1195. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1196. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1197. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1198. #endregion
  1199. #endregion
  1200. try
  1201. {
  1202. //_sqlSugar.BeginTran();
  1203. decimal ffrPrice = 0.00M;
  1204. DateTime? visitDt = null;
  1205. if (dto.Status == 2)
  1206. {
  1207. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1208. if (groupInfo != null)
  1209. {
  1210. ffrPrice = groupInfo.PaymentMoney;
  1211. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1212. }
  1213. }
  1214. var _dto = new GroupOperationDto();
  1215. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1216. var groupData = await _groupRepository.GroupOperation(_dto);
  1217. if (groupData.Code != 0)
  1218. {
  1219. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1220. }
  1221. int diId = 0;
  1222. //添加时 默认加入团组汇率
  1223. if (dto.Status == 1) //添加
  1224. {
  1225. diId = groupData.Data;
  1226. //添加默认币种
  1227. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1228. //默认分配权限
  1229. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1230. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1231. var _managerIds = new List<int>() { 21, 22, 32 };
  1232. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1233. if (userIds.Count > 0)
  1234. {
  1235. userIds.Add(208);
  1236. //创建团组管控
  1237. GroupStepForDelegation.CreateWorkStep(diId);
  1238. //发送消息
  1239. string groupName = dto.TeamName;
  1240. string createGroupUser = string.Empty;
  1241. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1242. if (userInfo != null) createGroupUser = userInfo.CnName;
  1243. string title = $"系统通知";
  1244. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1245. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1246. }
  1247. #region 应用推送
  1248. try
  1249. {
  1250. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1251. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1252. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1253. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1254. {
  1255. var userList = new List<string>() { users.QiyeChatUserId };
  1256. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1257. }
  1258. }
  1259. catch (Exception ex)
  1260. {
  1261. }
  1262. #endregion
  1263. //默认创建倒推表
  1264. await _invertedListRep._Create(dto.UserId, diId);
  1265. }
  1266. if (dto.Status == 2)
  1267. {
  1268. diId = dto.Id;
  1269. if (diId == 0)
  1270. {
  1271. //_sqlSugar.RollbackTran();
  1272. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1273. }
  1274. }
  1275. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1276. if (viewData.Code != 0)
  1277. {
  1278. //_sqlSugar.RollbackTran();
  1279. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1280. }
  1281. #region 团组操作默认添加/修改收款账单
  1282. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1283. {
  1284. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1285. .Where(x => x.IsDel == 0 &&
  1286. x.Diid == diId &&
  1287. x.Remark.Equals("预付款")
  1288. )
  1289. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1290. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1291. .FirstAsync();
  1292. ffrInfo = new Fin_ForeignReceivables()
  1293. {
  1294. Diid = diId,
  1295. PriceName = dto.ClientUnit,
  1296. Price = dto.PaymentMoney,
  1297. Count = 1,
  1298. Unit = $"元",
  1299. ItemSumPrice = dto.PaymentMoney,
  1300. Rate = 1.0000M,
  1301. Currency = 836,
  1302. AddingWay = 0,
  1303. CreateUserId = dto.UserId,
  1304. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1305. Remark = $"预付款"
  1306. };
  1307. if (ffrInfo == null) //Add
  1308. {
  1309. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1310. }
  1311. else //修改
  1312. {
  1313. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1314. .UpdateColumns(x => new
  1315. {
  1316. x.PriceName,
  1317. x.Price,
  1318. x.ItemSumPrice,
  1319. x.CreateTime,
  1320. x.CreateUserId
  1321. })
  1322. .WhereColumns(x => x.Id)
  1323. .ExecuteCommandAsync();
  1324. }
  1325. }
  1326. #endregion
  1327. #region 签证人员团组时间通知
  1328. #region 计算出访起止时间
  1329. var startTime = new DateTime();
  1330. var endTime = new DateTime();
  1331. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1332. {
  1333. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1334. }
  1335. #endregion
  1336. if (diId > 0)
  1337. {
  1338. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1339. }
  1340. #endregion
  1341. //_sqlSugar.CommitTran();
  1342. return Ok(JsonView(true, "添加成功"));
  1343. }
  1344. catch (Exception ex)
  1345. {
  1346. _sqlSugar.RollbackTran();
  1347. return Ok(JsonView(false, ex.Message));
  1348. }
  1349. }
  1350. /// <summary>
  1351. /// 接团流程操作(增改)
  1352. /// 安卓端使用 建团时添加客户名单
  1353. /// </summary>
  1354. /// <param name="dto"></param>
  1355. /// <returns></returns>
  1356. [HttpPost]
  1357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1358. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1359. {
  1360. #region 参数验证
  1361. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1362. #region 页面操作权限验证
  1363. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1364. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1365. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1366. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1367. #endregion
  1368. #endregion
  1369. _sqlSugar.BeginTran();
  1370. decimal ffrPrice = 0.00M;
  1371. DateTime? visitDt = null;
  1372. if (dto.Status == 2)
  1373. {
  1374. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1375. if (groupInfo != null)
  1376. {
  1377. ffrPrice = groupInfo.PaymentMoney;
  1378. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1379. }
  1380. }
  1381. var _dto = new GroupOperationDto();
  1382. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1383. var groupData = await _groupRepository.GroupOperation(_dto);
  1384. if (groupData.Code != 0)
  1385. {
  1386. _sqlSugar.RollbackTran();
  1387. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1388. }
  1389. try
  1390. {
  1391. int diId = 0;
  1392. //添加时 默认加入团组汇率
  1393. if (dto.Status == 1) //添加
  1394. {
  1395. diId = groupData.Data;
  1396. //添加默认币种
  1397. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1398. //默认分配权限
  1399. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1400. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1401. var _managerIds = new List<int>() { 21, 22, 32 };
  1402. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1403. if (userIds.Count > 0)
  1404. {
  1405. userIds.Add(208);
  1406. //创建团组管控
  1407. GroupStepForDelegation.CreateWorkStep(diId);
  1408. //发送消息
  1409. string groupName = dto.TeamName;
  1410. string createGroupUser = string.Empty;
  1411. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1412. if (userInfo != null) createGroupUser = userInfo.CnName;
  1413. string title = $"系统通知";
  1414. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1415. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1416. }
  1417. #region 应用推送
  1418. try
  1419. {
  1420. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1421. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1422. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1423. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1424. {
  1425. var userList = new List<string>() { users.QiyeChatUserId };
  1426. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1427. }
  1428. }
  1429. catch (Exception ex)
  1430. {
  1431. _sqlSugar.CommitTran();
  1432. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1433. }
  1434. #endregion
  1435. //默认创建倒推表
  1436. await _invertedListRep._Create(dto.UserId, diId);
  1437. }
  1438. else if (dto.Status == 2)
  1439. {
  1440. diId = dto.Id;
  1441. if (diId == 0)
  1442. {
  1443. _sqlSugar.RollbackTran();
  1444. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1445. }
  1446. }
  1447. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1448. if (viewData.Code != 0)
  1449. {
  1450. _sqlSugar.RollbackTran();
  1451. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1452. }
  1453. #region 团组操作默认添加/修改收款账单
  1454. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1455. {
  1456. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1457. .Where(x => x.IsDel == 0 &&
  1458. x.Diid == diId &&
  1459. x.Remark.Equals("预付款")
  1460. )
  1461. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1462. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1463. .FirstAsync();
  1464. ffrInfo = new Fin_ForeignReceivables()
  1465. {
  1466. Diid = diId,
  1467. PriceName = dto.ClientUnit,
  1468. Price = dto.PaymentMoney,
  1469. Count = 1,
  1470. Unit = $"元",
  1471. ItemSumPrice = dto.PaymentMoney,
  1472. Rate = 1.0000M,
  1473. Currency = 836,
  1474. AddingWay = 0,
  1475. CreateUserId = dto.UserId,
  1476. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1477. Remark = $"预付款"
  1478. };
  1479. if (ffrInfo == null) //Add
  1480. {
  1481. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1482. }
  1483. else //修改
  1484. {
  1485. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1486. .UpdateColumns(x => new
  1487. {
  1488. x.PriceName,
  1489. x.Price,
  1490. x.ItemSumPrice,
  1491. x.CreateTime,
  1492. x.CreateUserId
  1493. })
  1494. .WhereColumns(x => x.Id)
  1495. .ExecuteCommandAsync();
  1496. }
  1497. }
  1498. #endregion
  1499. #region 签证人员团组时间通知
  1500. #region 计算出访起止时间
  1501. var startTime = new DateTime();
  1502. var endTime = new DateTime();
  1503. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1504. {
  1505. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1506. }
  1507. #endregion
  1508. if (diId > 0)
  1509. {
  1510. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1511. }
  1512. #endregion
  1513. _sqlSugar.CommitTran();
  1514. return Ok(JsonView(true));
  1515. }
  1516. catch (Exception ex)
  1517. {
  1518. _sqlSugar.RollbackTran();
  1519. return Ok(JsonView(false, ex.Message));
  1520. }
  1521. }
  1522. /// <summary>
  1523. /// 接团信息 操作(删除)
  1524. /// </summary>
  1525. /// <param name="dto"></param>
  1526. /// <returns></returns>
  1527. [HttpPost]
  1528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1529. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1530. {
  1531. var diId = dto.Id;
  1532. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1533. #region 删除 验证
  1534. /*
  1535. * 1、收款账单数据:0 条
  1536. * 2、收款退还数据:0 条
  1537. * 3、机票费用数据:0 条
  1538. * 4、签证费用数据:0 条
  1539. * 5、保险费用数据:0 条
  1540. * 6、酒店费用数据:0 条
  1541. * 7、公务出访数据:1 条
  1542. * 8、邀请公务活动费用数据:1 条
  1543. * 9、OP费用数据:5 条
  1544. * 10、其他费用数据:0 条
  1545. * 11、团组日付报销费用数据:0 条
  1546. *
  1547. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1548. */
  1549. //收款账单
  1550. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1551. //收款退还
  1552. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1553. //机票费用
  1554. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1555. //签证费用
  1556. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1557. //保险费用
  1558. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1559. //酒店费用
  1560. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1561. //公务出访
  1562. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1563. //邀请公务活动费用
  1564. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1565. //OP费用
  1566. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1567. //其他费用
  1568. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1569. //团组日付报销费用
  1570. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1571. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1572. if (feeCount > 0)
  1573. {
  1574. var delMsgTips = new StringBuilder();
  1575. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1576. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1577. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1578. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1579. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1580. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1581. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1582. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1583. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1584. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1585. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1586. delMsgTips.AppendLine($"");
  1587. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1588. return Ok(JsonView(false, delMsgTips.ToString()));
  1589. }
  1590. #endregion
  1591. var groupData = await _groupRepository.GroupDel(dto);
  1592. if (groupData.Code != 0)
  1593. {
  1594. return Ok(JsonView(false, groupData.Msg));
  1595. }
  1596. return Ok(JsonView(true));
  1597. }
  1598. /// <summary>
  1599. /// 获取团组销售报价号
  1600. /// 团组添加时 使用
  1601. /// </summary>
  1602. /// <returns></returns>
  1603. [HttpPost]
  1604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1605. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1606. {
  1607. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1608. if (groupData.Code != 0)
  1609. {
  1610. return Ok(JsonView(false, groupData.Msg));
  1611. }
  1612. object salesQuoteNo = new
  1613. {
  1614. SalesQuoteNo = groupData.Data
  1615. };
  1616. return Ok(JsonView(salesQuoteNo));
  1617. }
  1618. /// <summary>
  1619. /// 设置确认出团
  1620. /// </summary>
  1621. /// <param name="dto"></param>
  1622. /// <returns></returns>
  1623. [HttpPost]
  1624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1625. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1626. {
  1627. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1628. if (groupData.Code != 0)
  1629. {
  1630. return Ok(JsonView(false, groupData.Msg));
  1631. }
  1632. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1633. #region OA消息推送
  1634. try
  1635. {
  1636. string groupName = groupInfo.TeamName;
  1637. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1638. string title = $"系统通知";
  1639. string content = $"团组[{groupName}]已确认出团!";
  1640. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1641. }
  1642. catch (Exception ex)
  1643. {
  1644. }
  1645. #endregion
  1646. #region 应用推送
  1647. try
  1648. {
  1649. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1650. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1651. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1652. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1653. {
  1654. var userList = new List<string>() { users.QiyeChatUserId };
  1655. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1656. }
  1657. }
  1658. catch (Exception ex)
  1659. {
  1660. }
  1661. #endregion
  1662. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1663. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1664. }
  1665. /// <summary>
  1666. /// 获取团组名称data And 签证国别Data
  1667. /// </summary>
  1668. /// <param name="dto"></param>
  1669. /// <returns></returns>
  1670. [HttpPost]
  1671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1672. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1673. {
  1674. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1675. if (groupData.Code != 0)
  1676. {
  1677. return Ok(JsonView(false, groupData.Msg));
  1678. }
  1679. return Ok(JsonView(groupData.Data));
  1680. }
  1681. /// <summary>
  1682. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1683. /// </summary>
  1684. /// <returns></returns>
  1685. [HttpPost]
  1686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1687. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1688. {
  1689. try
  1690. {
  1691. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1692. if (groupData.Code != 0)
  1693. {
  1694. return Ok(JsonView(false, groupData.Msg));
  1695. }
  1696. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1697. }
  1698. catch (Exception ex)
  1699. {
  1700. return Ok(JsonView(false, ex.Message));
  1701. throw;
  1702. }
  1703. }
  1704. /// <summary>
  1705. /// 团组清单 Excel
  1706. /// </summary>
  1707. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1708. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1709. /// <returns></returns>
  1710. [HttpGet]
  1711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1712. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1713. {
  1714. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1715. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1716. if (!beginBool && !endBool)
  1717. {
  1718. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1719. }
  1720. string sql = string.Format(@"
  1721. SELECT
  1722. ROW_NUMBER,
  1723. Id,
  1724. SalesQuoteNo,
  1725. TourCode,
  1726. TeamTypeId,
  1727. TeamType,
  1728. TeamLevId,
  1729. TeamLev,
  1730. TeamName,
  1731. ClientName,
  1732. ClientUnit,
  1733. VisitDate,
  1734. VisitDays,
  1735. VisitPNumber,
  1736. JietuanOperatorId,
  1737. JietuanOperator,
  1738. IsSure,
  1739. CreateUserName,
  1740. IsBid
  1741. FROM
  1742. (
  1743. SELECT
  1744. ROW_NUMBER() OVER(
  1745. ORDER BY
  1746. gdi.VisitDate Desc
  1747. ) AS ROW_NUMBER,
  1748. gdi.Id,
  1749. SalesQuoteNo,
  1750. TourCode,
  1751. ssd.Id TeamTypeId,
  1752. ssd.Name TeamType,
  1753. ssd1.Id TeamLevId,
  1754. ssd1.Name TeamLev,
  1755. TeamName,
  1756. ClientName,
  1757. ClientUnit,
  1758. VisitDate,
  1759. VisitDays,
  1760. VisitPNumber,
  1761. JietuanOperator JietuanOperatorId,
  1762. su.CnName JietuanOperator,
  1763. IsSure,
  1764. gdi.CreateTime,
  1765. su1.CnName As CreateUserName,
  1766. gdi.IsBid
  1767. FROM
  1768. Grp_DelegationInfo gdi
  1769. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1770. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1771. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1772. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1773. WHERE
  1774. gdi.IsDel = 0
  1775. AND gdi.IsBid = 0
  1776. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1777. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1778. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1779. #region 处理所属部门
  1780. /*
  1781. * 1.sq 和 gyy 等显示 市场部
  1782. * 2.王鸽和主管及张总还有管理员号统一国交部
  1783. * 2-1. 4 管理员 ,21 张海麟
  1784. */
  1785. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1786. var userIds1 = new List<int>() { 4, 21 };
  1787. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1788. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1789. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1790. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1791. .ToListAsync();
  1792. var droupIds = groupList.Select(it => it.Id).ToList();
  1793. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1794. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1795. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1796. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1797. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1798. {
  1799. DiId = tcl.DiId,
  1800. LastName = dc.LastName,
  1801. FirstName = dc.FirstName,
  1802. Sex = dc.Sex,
  1803. Birthday = dc.BirthDay,
  1804. Company = cc.CompanyFullName,
  1805. Job = dc.Job,
  1806. CreateTime = tcl.CreateTime,
  1807. })
  1808. .ToList();
  1809. foreach (var item in groupList)
  1810. {
  1811. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1812. string groupFirstName = "";
  1813. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1814. if (currDatas.Any())
  1815. {
  1816. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1817. }
  1818. item.GroupFirst = groupFirstName;
  1819. }
  1820. #endregion
  1821. #region Excel
  1822. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1823. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1824. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1825. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1826. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1827. //载入模板
  1828. var designer = new WorkbookDesigner
  1829. {
  1830. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1831. };
  1832. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1833. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1834. dt.TableName = "GroupList";
  1835. designer.SetDataSource(dt);
  1836. designer.Process();
  1837. if (!Directory.Exists(savePath))
  1838. {
  1839. Directory.CreateDirectory(savePath);
  1840. }
  1841. string serverPath = $"{savePath}{fileName}";
  1842. designer.Workbook.Save(serverPath);
  1843. string rst = $"{servicePath}{ftpPath}{fileName}";
  1844. #endregion
  1845. return Ok(JsonView(true, "操作成功!", rst));
  1846. }
  1847. /// <summary>
  1848. /// 团组合同下载(1.付款80% 2.付全款)
  1849. /// </summary>
  1850. /// <param name="dto"></param>
  1851. /// <returns></returns>
  1852. /// <exception cref="Exception"></exception>
  1853. [HttpPost]
  1854. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1855. {
  1856. var jw = JsonView(false);
  1857. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1858. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1859. if (di == null)
  1860. {
  1861. jw.Msg = "团组Id有误!";
  1862. return Ok(jw);
  1863. }
  1864. #region 权限校验
  1865. var allDownFile = new List<int>() { 21 };
  1866. try
  1867. {
  1868. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1869. .First(x => x.Id == 1418 && x.IsDel == 0);
  1870. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1871. }
  1872. catch (Exception)
  1873. { }
  1874. var guojiaoDownFile = new List<int>() { 330, 383 };
  1875. var shichangDownFile = new List<int>() { 95 };
  1876. if (allDownFile.Contains(dto.UserId))
  1877. {
  1878. }
  1879. else if (guojiaoDownFile.Contains(dto.UserId))
  1880. {
  1881. var guojiaobuDi = new List<int>() { 4, 21 };
  1882. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1883. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1884. .Where((d, u) => u.Id == di.JietuanOperator)
  1885. .Select((d, u) => d.DepName)
  1886. .First();
  1887. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1888. {
  1889. jw.Msg = "暂无下载权限!";
  1890. return Ok(jw);
  1891. }
  1892. }
  1893. else if (shichangDownFile.Contains(dto.UserId))
  1894. {
  1895. var dic = new Dictionary<int, int[]>()
  1896. {
  1897. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1898. };
  1899. try
  1900. {
  1901. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1902. if (sqSetting != null)
  1903. {
  1904. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1905. foreach (var item in result.Keys)
  1906. {
  1907. if (dic.ContainsKey(item))
  1908. {
  1909. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1910. Array.Copy(dic[item], dilatation, dic[item].Length);
  1911. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1912. dic[item] = dilatation;
  1913. }
  1914. else
  1915. {
  1916. dic.Add(item, result[item]);
  1917. }
  1918. }
  1919. }
  1920. if (!dic[95].Contains(di.CreateUserId))
  1921. {
  1922. jw.Msg = "暂无下载权限!";
  1923. return Ok(jw);
  1924. }
  1925. }
  1926. catch (Exception)
  1927. { }
  1928. }
  1929. else if (dto.UserId == di.CreateUserId)
  1930. {
  1931. }
  1932. else
  1933. {
  1934. jw.Msg = "暂无下载权限!";
  1935. return Ok(jw);
  1936. }
  1937. #endregion
  1938. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1939. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1940. .ToListAsync();
  1941. if (!blackCodeList.Any())
  1942. {
  1943. jw.Msg = "该团无机票行程代码!";
  1944. return Ok(jw);
  1945. }
  1946. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1947. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1948. if (groupEnterExitCost == null)
  1949. {
  1950. jw.Msg = "暂无三公费用信息!";
  1951. return Ok(jw);
  1952. }
  1953. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1954. rateList ??= new List<CurrencyInfo>();
  1955. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1956. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1957. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1958. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1959. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1960. .Select((x, a, b) => new
  1961. {
  1962. x.Index,
  1963. itemName = a.Name,
  1964. CurrencyStr = b.Name,
  1965. x.Cost,
  1966. x.SubTotal,
  1967. x.Remark
  1968. })
  1969. .OrderBy((x) => x.Index)
  1970. .ToList();
  1971. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1972. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1973. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1974. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1975. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1976. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1977. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1978. decimal subJJC = 0.00M,
  1979. subGWC = 0.00M,
  1980. subTDC = 0.00M;
  1981. //经济舱
  1982. if (groupEnterExitCost.SumJJC == 1)
  1983. {
  1984. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1985. }
  1986. //公务舱
  1987. if (groupEnterExitCost.SumGWC == 1)
  1988. {
  1989. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1990. }
  1991. //头等舱
  1992. if (groupEnterExitCost.SumTDC == 1)
  1993. {
  1994. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1995. }
  1996. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1997. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1998. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1999. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2000. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2001. .Select((x, s, dc, cc) => new GroupClints
  2002. {
  2003. Id = x.Id,
  2004. Name = s.Name,
  2005. IsAccompany = x.IsAccompany,
  2006. CompanyFullName = cc.CompanyFullName
  2007. })
  2008. .ToListAsync();
  2009. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2010. //获取舱位人数
  2011. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2012. .GroupBy(x => x.Name)
  2013. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2014. .ToList();
  2015. string cityPath = string.Empty;
  2016. string startCity = string.Empty;
  2017. string endCity = string.Empty;
  2018. foreach (var item in blackCodeList)
  2019. {
  2020. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2021. cityPath += city + "\r\n";
  2022. if (item.Equals(blackCodeList.First()))
  2023. {
  2024. var sp = city.Split('-');
  2025. startCity = sp[0];
  2026. endCity = sp[^1];
  2027. }
  2028. }
  2029. di.VisitCountry = Regex.Replace(di.VisitCountry, @"[|-]", "、");
  2030. var bookMarkDic = new Dictionary<string, string>
  2031. {
  2032. { "ClientUnit", di.ClientUnit },
  2033. { "VisitCountry", di.VisitCountry },
  2034. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2035. { "VisitPNumber", di.VisitPNumber.ToString() },
  2036. { "CityPath", cityPath },
  2037. { "StartCity", startCity },
  2038. { "EndCity", endCity },
  2039. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2040. };
  2041. Document doc = null;
  2042. var percentage = 0.8M;
  2043. var fileNameadd = "预付";
  2044. if (dto.FileType == 1)
  2045. {
  2046. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2047. }
  2048. else if (dto.FileType == 2)
  2049. {
  2050. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2051. percentage = 1;
  2052. fileNameadd = "全款";
  2053. }
  2054. else
  2055. {
  2056. throw new Exception("FileType有误!");
  2057. }
  2058. var builder = new DocumentBuilder(doc);
  2059. decimal totalPrice = 0.00M;
  2060. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2061. if (firstTable != null)
  2062. {
  2063. // 遍历表格的行和单元格
  2064. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2065. {
  2066. for (int i = 0; i < row.Cells.Count; i++)
  2067. {
  2068. var cell = row.Cells[i];
  2069. // 读取单元格内容
  2070. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2071. if (cellTextFirst.Contains("舱位"))
  2072. {
  2073. break;
  2074. }
  2075. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2076. {
  2077. if (i == 2)
  2078. {
  2079. if (cellTextFirst == "经济舱")
  2080. {
  2081. // 设置单元格内容
  2082. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2083. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2084. }
  2085. else
  2086. {
  2087. // 设置单元格内容
  2088. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2089. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2090. }
  2091. }
  2092. if (i == 3)
  2093. {
  2094. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2095. if (count != null)
  2096. {
  2097. // 设置单元格内容
  2098. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2099. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2100. }
  2101. }
  2102. if (i == 4)
  2103. {
  2104. var rowPrice = 0.00M;
  2105. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2106. count ??= 0;
  2107. if (cellTextFirst == "经济舱")
  2108. {
  2109. rowPrice = subJJC * (int)count;
  2110. }
  2111. else
  2112. {
  2113. rowPrice = subGWC * (int)count;
  2114. }
  2115. totalPrice += rowPrice;
  2116. // 设置单元格内容
  2117. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2118. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2119. }
  2120. }
  2121. }
  2122. }
  2123. }
  2124. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2125. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2126. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2127. //--合同表格部分
  2128. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2129. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2130. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2131. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2132. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2133. bookMarkDic.Add("CityPath1", cityPath);
  2134. bookMarkDic.Add("CityPath2", cityPath);
  2135. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2136. if (contractTable != null)
  2137. {
  2138. //数据源
  2139. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2140. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2141. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2142. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2143. .Select((it, y, s) => new
  2144. {
  2145. it.Cost,
  2146. it.SubTotal,
  2147. it.Type,
  2148. y.Id,
  2149. y.City,
  2150. s.Name,
  2151. CurrencyCodeCn = s.Remark
  2152. })
  2153. .ToList()
  2154. .Select(x => new
  2155. {
  2156. CurrencyCode = x.Name,
  2157. CityId = x.Id,
  2158. x.City,
  2159. di.VisitPNumber,
  2160. x.Type,
  2161. x.Cost,
  2162. x.SubTotal,
  2163. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2164. x.CurrencyCodeCn,
  2165. });
  2166. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2167. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2168. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2169. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2170. var tableSettings = new List<tableSetting>()
  2171. {
  2172. new(){ Index = 1 , Property = "City"},
  2173. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2174. new(){ Index = 3 , Property = "Cost"},
  2175. new(){ Index = 4 , Property = "VisitPNumber"},
  2176. //new tableSetting{ Index = 5 , Property = ""},
  2177. //new tableSetting{ Index = 6 , Property = ""},
  2178. new(){ Index = 7 , Property = "Rate"},
  2179. //new tableSetting{ Index = 8 , Property = ""},
  2180. };
  2181. //1.住宿费
  2182. int cloneRow = 8;
  2183. int startDayPrice = 8; //写入index
  2184. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2185. foreach (var dac in dac1)
  2186. {
  2187. var first = dac.First();
  2188. var dayCount = dac.Count();
  2189. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2190. for (int i = 1; i < row.Cells.Count; i++)
  2191. {
  2192. var cell = row.Cells[i];
  2193. var findProperty = tableSettings.Find(x => x.Index == i);
  2194. if (findProperty != null)
  2195. {
  2196. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2197. // 设置单元格内容
  2198. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2199. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2200. }
  2201. else
  2202. {
  2203. switch (i)
  2204. {
  2205. case 5:
  2206. cell.FirstParagraph.Runs.Clear();
  2207. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2208. break;
  2209. case 6:
  2210. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2211. cell.FirstParagraph.Runs.Clear();
  2212. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2213. break;
  2214. case 8:
  2215. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2216. cell.FirstParagraph.Runs.Clear();
  2217. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2218. ZSPriceSum += xiaojiRMB;
  2219. break;
  2220. default:
  2221. break;
  2222. }
  2223. }
  2224. }
  2225. startDayPrice++;
  2226. if (!dac1.Last().Equals(dac))
  2227. {
  2228. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2229. // 将克隆的行追加到原行后面
  2230. contractTable.Rows.Insert(startDayPrice, newRow);
  2231. }
  2232. else
  2233. {
  2234. cloneRow += dac1.Count + 1;
  2235. startDayPrice = cloneRow;
  2236. }
  2237. }
  2238. //2.伙食费
  2239. foreach (var dac in dac2)
  2240. {
  2241. var first = dac.First();
  2242. var dayCount = dac.Count();
  2243. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2244. for (int i = 1; i < row.Cells.Count; i++)
  2245. {
  2246. var cell = row.Cells[i];
  2247. var findProperty = tableSettings.Find(x => x.Index == i);
  2248. if (findProperty != null)
  2249. {
  2250. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2251. // 设置单元格内容
  2252. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2253. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2254. }
  2255. else
  2256. {
  2257. switch (i)
  2258. {
  2259. case 5:
  2260. cell.FirstParagraph.Runs.Clear();
  2261. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2262. break;
  2263. case 6:
  2264. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2265. cell.FirstParagraph.Runs.Clear();
  2266. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2267. break;
  2268. case 8:
  2269. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2270. cell.FirstParagraph.Runs.Clear();
  2271. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2272. HSPriceSum += xiaojiRMB;
  2273. break;
  2274. default:
  2275. break;
  2276. }
  2277. }
  2278. }
  2279. startDayPrice++;
  2280. if (!dac2.Last().Equals(dac))
  2281. {
  2282. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2283. // 将克隆的行追加到原行后面
  2284. contractTable.Rows.Insert(startDayPrice, newRow);
  2285. }
  2286. else
  2287. {
  2288. cloneRow += dac2.Count + 1;
  2289. startDayPrice = cloneRow;
  2290. }
  2291. }
  2292. //3.公杂费
  2293. foreach (var dac in dac3)
  2294. {
  2295. var first = dac.First();
  2296. var dayCount = dac.Count();
  2297. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2298. for (int i = 1; i < row.Cells.Count; i++)
  2299. {
  2300. var cell = row.Cells[i];
  2301. var findProperty = tableSettings.Find(x => x.Index == i);
  2302. if (findProperty != null)
  2303. {
  2304. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2305. // 设置单元格内容
  2306. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2307. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2308. }
  2309. else
  2310. {
  2311. switch (i)
  2312. {
  2313. case 5:
  2314. cell.FirstParagraph.Runs.Clear();
  2315. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2316. break;
  2317. case 6:
  2318. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2319. cell.FirstParagraph.Runs.Clear();
  2320. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2321. break;
  2322. case 8:
  2323. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2324. cell.FirstParagraph.Runs.Clear();
  2325. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2326. GZPriceSum += xiaojiRMB;
  2327. break;
  2328. default:
  2329. break;
  2330. }
  2331. }
  2332. }
  2333. startDayPrice++;
  2334. if (!dac3.Last().Equals(dac))
  2335. {
  2336. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2337. // 将克隆的行追加到原行后面
  2338. contractTable.Rows.Insert(startDayPrice, newRow);
  2339. }
  2340. else
  2341. {
  2342. cloneRow += dac3.Count + 1;
  2343. startDayPrice = cloneRow;
  2344. }
  2345. }
  2346. //合并单元格
  2347. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2348. {
  2349. var currentRow = contractTable.Rows[i];
  2350. var nextRow = contractTable.Rows[i + 1];
  2351. // 获取当前行和下一行的第一个单元格
  2352. Cell currentCell = currentRow.Cells[0];
  2353. Cell nextCell = nextRow.Cells[0];
  2354. // 检查单元格内容是否一致(去除尾部的换行符)
  2355. string currentText = currentCell.GetText().Trim();
  2356. string nextText = nextCell.GetText().Trim();
  2357. if (currentText == nextText)
  2358. {
  2359. // 如果当前单元格已经被合并,找到合并的起始单元格
  2360. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2361. {
  2362. // 找到合并的起始单元格
  2363. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2364. // 将下一行的单元格设置为合并的后续单元格
  2365. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2366. }
  2367. else
  2368. {
  2369. // 如果当前单元格是合并的起始单元格
  2370. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2371. // 将下一行的单元格设置为合并的后续单元格
  2372. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2373. }
  2374. }
  2375. else
  2376. {
  2377. // 如果内容不一致,重置当前单元格的合并属性
  2378. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2379. {
  2380. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2381. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2382. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2383. }
  2384. else
  2385. {
  2386. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2387. }
  2388. }
  2389. }
  2390. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2391. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2392. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2393. }
  2394. foreach (var bookmarkName in bookMarkDic.Keys)
  2395. {
  2396. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2397. if (bookmark != null)
  2398. {
  2399. if (bookmarkName == "ClientUnit")
  2400. {
  2401. // 移动到书签位置
  2402. builder.MoveTo(bookmark.BookmarkStart);
  2403. // 设置字体样式为下划线
  2404. builder.Font.Underline = Aspose.Words.Underline.Single;
  2405. // 插入书签值
  2406. builder.Write(bookMarkDic[bookmarkName]);
  2407. // 清除字体格式,避免影响后续文本
  2408. builder.Font.ClearFormatting();
  2409. }
  2410. else
  2411. {
  2412. builder.MoveToBookmark(bookmarkName);
  2413. builder.Write(bookMarkDic[bookmarkName]);
  2414. }
  2415. }
  2416. }
  2417. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2418. doc.Save(savePaht);
  2419. jw.Msg = "生成成功!";
  2420. jw.Code = 200;
  2421. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2422. return Ok(jw);
  2423. }
  2424. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2425. {
  2426. int index = rowIndex;
  2427. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2428. {
  2429. index--;
  2430. }
  2431. return index;
  2432. }
  2433. /// <summary>
  2434. /// 报批完成企微通知
  2435. /// </summary>
  2436. /// <param name="dto"></param>
  2437. /// <returns></returns>
  2438. [HttpPost]
  2439. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2440. {
  2441. int currUserId = dto.currUserId;
  2442. int diid = dto.diid;
  2443. var jw = JsonView(true);
  2444. var users = new List<string>();
  2445. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2446. .First(x => x.Id == 1460);
  2447. try
  2448. {
  2449. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2450. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2451. //添加分配人员
  2452. // 79 车/导游地接
  2453. // 80 签证
  2454. // 81 邀请/公务活动
  2455. var setdataids = new List<int>() { 79, 81 };
  2456. foreach (var groupModule in groupModuleOperators)
  2457. {
  2458. if (setdataids.Contains(groupModule.CTableId))
  2459. {
  2460. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2461. }
  2462. }
  2463. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2464. //消息通知成功 更改团组step、记录日志
  2465. if (res)
  2466. {
  2467. var groupStep = 0; //0-新建 1-企微消息通知
  2468. //更改团组step
  2469. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2470. .SetColumns(x => new Grp_DelegationInfo()
  2471. {
  2472. Step = 2
  2473. })
  2474. .Where(x => x.Id == diid && x.IsDel == 0)
  2475. .ExecuteCommandAsync();
  2476. if (updStatus > 0) groupStep = 2;
  2477. string groupStepLabel = groupStep switch
  2478. {
  2479. 1 => "新建",
  2480. 2 => "企微消息通知(报批)",
  2481. _ => "未设置"
  2482. };
  2483. //记录日志
  2484. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2485. .Where(x => x.Id == diid && x.IsDel == 0)
  2486. .Select(x => x.TeamName)
  2487. .First() ?? "-";
  2488. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2489. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2490. .Select(x => x.CnName)
  2491. .First() ?? "-";
  2492. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2493. //设置 签证流程初始值
  2494. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2495. }
  2496. }
  2497. catch (Exception ex)
  2498. {
  2499. return Ok(JsonView(false, ex.Message));
  2500. }
  2501. return Ok(jw);
  2502. }
  2503. #endregion
  2504. #region 团组&签证
  2505. #region 团组&签证 New
  2506. /// <summary>
  2507. /// 团组&签证 New
  2508. /// DeepSeek API:测试API连通性
  2509. /// </summary>
  2510. /// <param name="file">请求dto</param>
  2511. /// <returns></returns>
  2512. [HttpPost]
  2513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2514. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2515. {
  2516. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2517. }
  2518. /// <summary>
  2519. /// 团组&签证 New
  2520. /// DeepSeek API:检查可用端点
  2521. /// </summary>
  2522. /// <param name="file">请求dto</param>
  2523. /// <returns></returns>
  2524. [HttpPost]
  2525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2526. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2527. {
  2528. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2529. }
  2530. /// <summary>
  2531. /// 团组&签证 New
  2532. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2533. /// </summary>
  2534. /// <param name="file">请求dto</param>
  2535. /// <returns></returns>
  2536. [HttpPost]
  2537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2538. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2539. {
  2540. //文件验证
  2541. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2542. //var visaFiles = new VisaUploadFileTypeView();
  2543. var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2544. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2545. //服务器存储文件
  2546. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2547. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2548. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2549. using (var stream = new FileStream(filePath, FileMode.Create))
  2550. {
  2551. await visaFile.CopyToAsync(stream);
  2552. }
  2553. //日志记录-上传文件
  2554. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2555. IFormFile localFile = null;
  2556. //获取项目中的cs文件
  2557. try
  2558. {
  2559. _logger.LogInformation("读取并上传项目文件请求");
  2560. // 1. 读取项目文件
  2561. var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2562. if (readResponse.SuccessCount == 0)
  2563. {
  2564. return Ok(JsonView(false, "读取项目文件失败"));
  2565. }
  2566. localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2567. }
  2568. catch (Exception ex)
  2569. {
  2570. _logger.LogError(ex, "读取项目文件失败");
  2571. return Ok(JsonView(false, "读取项目文件失败"));
  2572. }
  2573. if (localFile == null)
  2574. {
  2575. return Ok(JsonView(false, "读取项目文件失败"));
  2576. }
  2577. var fileReq = new DeepSeekFileUploadRequest()
  2578. {
  2579. Files = new List<IFormFile> { localFile, visaFile },
  2580. };
  2581. var filesResult = new List<FileUploadResult>();
  2582. #region 上传文件到DeepSeekAPI
  2583. try
  2584. {
  2585. _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2586. filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2587. // 需要等待处理完成
  2588. if (fileReq.WaitForProcessing)
  2589. {
  2590. foreach (var result in filesResult)
  2591. {
  2592. if (result.Success)
  2593. {
  2594. try
  2595. {
  2596. var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2597. result.Status = processedFile.Status;
  2598. }
  2599. catch (Exception ex)
  2600. {
  2601. _logger.LogError(ex, "DeepSeek API文件上传失败");
  2602. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2603. }
  2604. }
  2605. }
  2606. }
  2607. }
  2608. catch (Exception ex)
  2609. {
  2610. _logger.LogError(ex, "DeepSeek API文件上传失败");
  2611. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2612. }
  2613. #endregion
  2614. if (filesResult == null || filesResult.Count < 1)
  2615. {
  2616. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2617. }
  2618. //
  2619. try
  2620. {
  2621. var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2622. _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2623. string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2624. var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  2625. return Ok(response);
  2626. }
  2627. catch (Exception ex)
  2628. {
  2629. _logger.LogError(ex, "使用文件聊天失败");
  2630. return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2631. }
  2632. //加载文件OpCarTouristGuideGroundContent
  2633. ////kimi AI 识别文档返回json结果
  2634. //int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2635. //var KiMiApi = new KiMiApiClient();
  2636. //var files = new List<IFormFile>() { file };
  2637. //var seedConter = await KiMiApi.UploadFilesAsync(files);
  2638. //if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2639. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2640. //var messages = new List<SeedMessages>
  2641. //{
  2642. // new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2643. // new() { Role = KimiRole.user, Content = seedMessage }
  2644. //};
  2645. //messages.InsertRange(1, seedConter);
  2646. string jsonString = string.Empty;
  2647. //bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2648. //while (!isJson)
  2649. //{
  2650. // kimiAI_API_Index++;
  2651. // var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2652. // var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2653. // jsonString += kimiApiResult_JObject["content"].ToString();
  2654. // string startStr = "```json", endStr = "```";
  2655. // // 判断并清除开头部分
  2656. // if (jsonString.StartsWith(startStr))
  2657. // {
  2658. // jsonString = jsonString.Replace(startStr, "");
  2659. // }
  2660. // // 判断并清除结尾部分
  2661. // if (jsonString.EndsWith(endStr))
  2662. // {
  2663. // jsonString = jsonString.Replace(endStr, "");
  2664. // }
  2665. // //验证json格式是否正确
  2666. // try
  2667. // {
  2668. // JsonDocument.Parse(jsonString);
  2669. // isJson = true; // 如果解析成功,则是json格式
  2670. // }
  2671. // catch (Exception)
  2672. // {
  2673. // //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2674. // messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2675. // }
  2676. //}
  2677. //var clientInfo = new Crm_DeleClient(); //客户资料表
  2678. //var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2679. //var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2680. //var clientCert = new Crm_CustomerCert(); //客户证件表
  2681. //var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2682. ////按照表格类型分别进行参数处理
  2683. //switch (fileTypeId)
  2684. //{
  2685. // //澳新签证个人申请表
  2686. // case 1:
  2687. // _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2688. // VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2689. // break;
  2690. // default:
  2691. // break;
  2692. //}
  2693. return Ok(JsonView(true, jsonString));
  2694. }
  2695. private int GetSuccessCount(List<FileUploadResult> results)
  2696. {
  2697. var count = 0;
  2698. foreach (var result in results)
  2699. {
  2700. if (result.Success) count++;
  2701. }
  2702. return count;
  2703. }
  2704. #endregion
  2705. /// <summary>
  2706. /// 根据团组Id获取签证客户信息List
  2707. /// </summary>
  2708. /// <param name="dto">请求dto</param>
  2709. /// <returns></returns>
  2710. [HttpPost]
  2711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2712. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2713. {
  2714. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2715. if (groupData.Code != 0)
  2716. {
  2717. return Ok(JsonView(false, groupData.Msg));
  2718. }
  2719. return Ok(JsonView(groupData.Data));
  2720. }
  2721. /// <summary>
  2722. /// IOS获取团组签证拍照上传进度01(团组列表)
  2723. /// </summary>
  2724. /// <param name="dto">请求dto</param>
  2725. /// <returns></returns>
  2726. [HttpPost]
  2727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2728. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2729. {
  2730. if (dto == null)
  2731. {
  2732. return Ok(JsonView(false, "参数为空"));
  2733. }
  2734. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2735. return Ok(JsonView(visaList));
  2736. }
  2737. /// <summary>
  2738. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2739. /// </summary>
  2740. /// <returns></returns>
  2741. [HttpPost]
  2742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2743. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2744. {
  2745. if (dto == null)
  2746. {
  2747. return Ok(JsonView(false, "请求错误:"));
  2748. }
  2749. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2750. return Ok(JsonView(list));
  2751. }
  2752. /// <summary>
  2753. /// IOS获取团组签证拍照上传进度03(相册)
  2754. /// </summary>
  2755. /// <returns></returns>
  2756. [HttpPost]
  2757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2758. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2759. {
  2760. if (dto == null)
  2761. {
  2762. return Ok(JsonView(false, "请求错误:"));
  2763. }
  2764. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2765. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2766. list.ForEach(s => s.url = url);
  2767. return Ok(JsonView(list));
  2768. }
  2769. /// <summary>
  2770. /// IOS获取团组签证拍照上传进度04(图片上传)
  2771. /// </summary>
  2772. /// <param name="dto"></param>
  2773. /// <returns></returns>
  2774. [HttpPost]
  2775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2776. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2777. {
  2778. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2779. //if (!string.IsNullOrEmpty(result))
  2780. //{
  2781. //}
  2782. //else {
  2783. // return Ok(JsonView(false, "上传失败"));
  2784. //}
  2785. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2786. int sucNum = 0;
  2787. try
  2788. {
  2789. foreach (var item in dto.base64DataList)
  2790. {
  2791. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2792. string result = DecodeBase64ToImage(item, imageName);
  2793. if (!string.IsNullOrEmpty(result))
  2794. {
  2795. var pic = new Grp_VisaProgressCustomerPicture
  2796. {
  2797. CreateUserId = dto.CreateUserId,
  2798. PicName = imageName,
  2799. PicPath = result,
  2800. VisaProgressCustomerId = dto.visaProgressCustomerId
  2801. };
  2802. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2803. if (insertResult > 0)
  2804. {
  2805. sucNum++;
  2806. }
  2807. }
  2808. }
  2809. }
  2810. catch (Exception ex)
  2811. {
  2812. return Ok(JsonView(false, ex.Message));
  2813. }
  2814. string msg = string.Format(@"成功上传{0}张", sucNum);
  2815. return Ok(JsonView(true, msg));
  2816. }
  2817. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2818. {
  2819. string filename = "";//声明一个string类型的相对路径
  2820. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2821. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2822. try//会有异常抛出,try,catch一下
  2823. {
  2824. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2825. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2826. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2827. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2828. //文件名称
  2829. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2830. //上传的文件的路径
  2831. string filePath = "";
  2832. if (!Directory.Exists(fileDir))
  2833. {
  2834. Directory.CreateDirectory(fileDir);
  2835. }
  2836. //上传的文件的路径
  2837. filePath = fileDir + filename;
  2838. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2839. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2840. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2841. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2842. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2843. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2844. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2845. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2846. bitmap.Dispose();
  2847. }
  2848. catch (Exception e)
  2849. {
  2850. string massage = e.Message;
  2851. Logs("IOS图片上传Error:" + massage);
  2852. //filename = e.Message;
  2853. }
  2854. return filename;//返回相对路径
  2855. }
  2856. /// <summary>
  2857. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2858. /// </summary>
  2859. /// <param name="dto"></param>
  2860. /// <returns></returns>
  2861. [HttpPost]
  2862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2863. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2864. {
  2865. if (dto == null)
  2866. {
  2867. return Ok(JsonView(false, "请求错误:"));
  2868. }
  2869. string msg = "参数错误";
  2870. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2871. {
  2872. try
  2873. {
  2874. //_delegationVisaRep.BeginTran();
  2875. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2876. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2877. .Where(s => s.Id == dto.visaProgressCustomerId)
  2878. .ExecuteCommandAsync();
  2879. if (updCount > 0 && dto.publishCode == 1)
  2880. {
  2881. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2882. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2883. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2884. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2885. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2886. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2887. if (groupData == null)
  2888. {
  2889. _delegationVisaRep.RollbackTran();
  2890. }
  2891. string title = string.Format(@"[签证进度更新]");
  2892. string content = string.Format(@"测试文本");
  2893. bool rst = await _message.AddMsg(new MessageDto()
  2894. {
  2895. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2896. IssuerId = dto.publisher,
  2897. Title = title,
  2898. Content = content,
  2899. ReleaseTime = DateTime.Now,
  2900. UIdList = new List<int> {
  2901. 234
  2902. }
  2903. });
  2904. if (rst)
  2905. {
  2906. return Ok(JsonView(true, "发送通知成功"));
  2907. }
  2908. }
  2909. //_delegationVisaRep.CommitTran();
  2910. }
  2911. catch (Exception)
  2912. {
  2913. //_delegationVisaRep.RollbackTran();
  2914. }
  2915. }
  2916. return Ok(JsonView(true, msg));
  2917. }
  2918. #endregion
  2919. #region 团组任务分配
  2920. /// <summary>
  2921. /// 团组任务分配初始化
  2922. /// </summary>
  2923. /// <returns></returns>
  2924. [HttpPost]
  2925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2926. public async Task<IActionResult> GetTaskAssignmen()
  2927. {
  2928. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2929. if (groupData.Code != 0)
  2930. {
  2931. return Ok(JsonView(false, groupData.Msg));
  2932. }
  2933. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2934. }
  2935. /// <summary>
  2936. /// 团组任务分配查询
  2937. /// </summary>
  2938. /// <param name="dto"></param>
  2939. /// <returns></returns>
  2940. [HttpPost]
  2941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2942. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2943. {
  2944. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2945. if (groupData.Code != 0)
  2946. {
  2947. return Ok(JsonView(false, groupData.Msg));
  2948. }
  2949. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2950. }
  2951. /// <summary>
  2952. /// 团组任务分配操作
  2953. /// </summary>
  2954. /// <param name="dto"></param>
  2955. /// <returns></returns>
  2956. [HttpPost]
  2957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2958. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2959. {
  2960. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2961. if (groupData.Code != 0)
  2962. {
  2963. return Ok(JsonView(false, groupData.Msg));
  2964. }
  2965. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2966. }
  2967. /// <summary>
  2968. /// 团组任务分配
  2969. /// 批量分配
  2970. /// 查询团组
  2971. /// </summary>
  2972. /// <param name="dto"></param>
  2973. /// <returns></returns>
  2974. [HttpPost]
  2975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2976. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2977. {
  2978. //参数验证
  2979. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2980. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2981. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2982. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2983. }
  2984. /// <summary>
  2985. /// 团组任务分配
  2986. /// 批量分配
  2987. /// </summary>
  2988. /// <param name="dto"></param>
  2989. /// <returns></returns>
  2990. [HttpPost]
  2991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2992. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2993. {
  2994. //参数验证
  2995. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2996. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2997. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2998. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2999. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  3000. }
  3001. #endregion
  3002. #region 团组费用审核
  3003. /// <summary>
  3004. /// 费用审核
  3005. /// 团组列表 Page
  3006. /// </summary>
  3007. /// <param name="_dto">团组列表请求dto</param>
  3008. /// <returns></returns>
  3009. [HttpPost]
  3010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3011. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  3012. {
  3013. #region 参数验证
  3014. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3015. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3016. #region 页面操作权限验证
  3017. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3018. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3019. #endregion
  3020. #endregion
  3021. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  3022. {
  3023. string sqlWhere = string.Empty;
  3024. if (_dto.IsSure == 0) //未完成
  3025. {
  3026. sqlWhere += string.Format(@" And IsSure = 0");
  3027. }
  3028. else if (_dto.IsSure == 1) //已完成
  3029. {
  3030. sqlWhere += string.Format(@" And IsSure = 1");
  3031. }
  3032. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  3033. {
  3034. string tj = _dto.SearchCriteria;
  3035. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  3036. tj, tj, tj, tj, tj);
  3037. }
  3038. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3039. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  3040. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3041. From (
  3042. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  3043. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  3044. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  3045. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3046. From Grp_DelegationInfo gdi
  3047. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3048. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3049. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3050. Where gdi.IsDel = 0 {0}
  3051. ) temp ", sqlWhere);
  3052. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3053. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  3054. var _view = new
  3055. {
  3056. PageFuncAuth = pageFunAuthView,
  3057. Data = _DelegationList
  3058. };
  3059. return Ok(JsonView(true, "查询成功!", _view, total));
  3060. }
  3061. else
  3062. {
  3063. return Ok(JsonView(false, "查询失败"));
  3064. }
  3065. }
  3066. /// <summary>
  3067. /// 获取团组费用审核
  3068. /// </summary>
  3069. /// <param name="_dto"></param>
  3070. /// <returns></returns>
  3071. [HttpPost]
  3072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3073. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  3074. {
  3075. try
  3076. {
  3077. #region 参数验证
  3078. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3079. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3080. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  3081. #region 页面操作权限验证
  3082. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3083. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3084. #endregion
  3085. #endregion
  3086. var _view = new Grp_CreditCardPaymentView();
  3087. var clientNameList = GetSimplClientList(_dto.DiId);
  3088. #region 费用清单
  3089. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  3090. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  3091. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  3092. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  3093. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  3094. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  3095. /*
  3096. * 76://酒店预订
  3097. */
  3098. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3099. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3100. /*
  3101. * 79://车/导游地接
  3102. */
  3103. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3104. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3105. /*
  3106. * 80: //签证
  3107. */
  3108. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3109. /*
  3110. *81: //邀请/公务活动
  3111. */
  3112. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3113. /*
  3114. * 82: //团组客户保险
  3115. */
  3116. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3117. /*
  3118. * Lable = 85 机票预订
  3119. */
  3120. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3121. /*
  3122. * 85 机票预定
  3123. */
  3124. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3125. /*
  3126. * 98 其他款项
  3127. */
  3128. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3129. /*
  3130. * 285:收款退还
  3131. */
  3132. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3133. /*
  3134. * 1015: //超支费用
  3135. */
  3136. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3137. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  3138. /*
  3139. * 币种信息
  3140. */
  3141. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  3142. /*
  3143. * 车/导游地接 费用类型
  3144. */
  3145. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  3146. /*
  3147. * 车/导游地接 费用类型
  3148. */
  3149. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  3150. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  3151. /*
  3152. * 用户信息
  3153. */
  3154. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  3155. /*
  3156. * 费用模块
  3157. */
  3158. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  3159. string priceModule = string.Empty;
  3160. if (sdPriceName != null)
  3161. {
  3162. priceModule = sdPriceName.Name;
  3163. }
  3164. /*
  3165. * 成本信息
  3166. */
  3167. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  3168. decimal _groupRate = 0.0000M;
  3169. string _groupCurrencyCode = "-";
  3170. if (groupCost != null)
  3171. {
  3172. _groupRate = groupCost.Rate;
  3173. if (int.TryParse(groupCost.Currency, out int _currency))
  3174. {
  3175. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  3176. }
  3177. else _groupCurrencyCode = groupCost.Currency;
  3178. }
  3179. string costContentSql = $"Select * From Grp_GroupCost";
  3180. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  3181. //处理日期为空的天数
  3182. for (int i = 0; i < groupCostDetails.Count; i++)
  3183. if (i != 0)
  3184. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  3185. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  3186. /*
  3187. * 处理详情数据
  3188. */
  3189. foreach (var entity in entityList)
  3190. {
  3191. var _detail = new Grp_CreditCardPaymentDetailView
  3192. {
  3193. Id = entity.Id,
  3194. PriceName = priceModule,
  3195. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  3196. };
  3197. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3198. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3199. //处理金额
  3200. if (entity.CTable == 1015)
  3201. {
  3202. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3203. if (czInfo != null)
  3204. {
  3205. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3206. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3207. }
  3208. }
  3209. /*
  3210. * 应付款金额
  3211. */
  3212. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3213. string PaymentCurrency_WaitPay = "Unknown";
  3214. string hotelCurrncyCode = "Unknown";
  3215. string hotelCurrncyName = "Unknown";
  3216. if (sdPaymentCurrency_WaitPay != null)
  3217. {
  3218. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3219. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3220. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3221. if (hotelCurrncyCode.Equals("CNY"))
  3222. {
  3223. entity.DayRate = 1.0000M;
  3224. }
  3225. }
  3226. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3227. /*
  3228. * 此次付款金额
  3229. */
  3230. decimal CurrPayStr = 0.00M,
  3231. OriginalCurrPay = 0.00M;
  3232. if (entity.PayPercentage == 0)
  3233. {
  3234. if (entity.PayThenMoney != 0)
  3235. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3236. }
  3237. else
  3238. {
  3239. if (entity.PayMoney != 0)
  3240. {
  3241. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3242. }
  3243. }
  3244. //if (_dto.Label == 79)
  3245. //{
  3246. // string original = string.Empty;
  3247. // if (hotelCurrncyCode.Equals("CNY"))
  3248. // {
  3249. // OriginalCurrPay = CurrPayStr;
  3250. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3251. // }
  3252. // else
  3253. // {
  3254. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3255. // //760 EUR(7600.00 CNY)
  3256. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3257. // }
  3258. //}
  3259. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3260. string original = string.Empty;
  3261. if (hotelCurrncyCode.Equals("CNY"))
  3262. {
  3263. OriginalCurrPay = CurrPayStr;
  3264. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3265. }
  3266. else
  3267. {
  3268. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3269. //760 EUR(7600.00 CNY)
  3270. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3271. }
  3272. /*
  3273. * 剩余尾款
  3274. */
  3275. decimal BalanceStr = 0;
  3276. if (CurrPayStr != 0)
  3277. {
  3278. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3279. BalanceStr = 0;
  3280. else
  3281. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3282. }
  3283. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3284. /*
  3285. * Bus名称
  3286. */
  3287. _detail.BusName = "待增加";
  3288. /*
  3289. *费用所属
  3290. */
  3291. switch (entity.CTable)
  3292. {
  3293. case 76://酒店预订
  3294. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3295. if (hotelReservations != null)
  3296. {
  3297. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3298. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3299. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3300. string roomFeeStr = "", roomFeestr1 = "";
  3301. //是否比较房型价格
  3302. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3303. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3304. roomFeeStr += $"<br/>";
  3305. var roomTotal = 0.00M;
  3306. if (hotelReservations.SingleRoomPrice > 0)
  3307. {
  3308. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3309. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3310. //__isSingle = true;
  3311. roomTotal += fee;
  3312. }
  3313. if (hotelReservations.DoubleRoomPrice > 0)
  3314. {
  3315. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3316. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3317. // __isDouble = true;
  3318. roomTotal += fee;
  3319. }
  3320. if (hotelReservations.SuiteRoomPrice > 0)
  3321. {
  3322. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3323. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3324. //__isSuite = true;
  3325. roomTotal += fee;
  3326. }
  3327. if (hotelReservations.OtherRoomPrice > 0)
  3328. {
  3329. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3330. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3331. //__isOther = true;
  3332. roomTotal += fee;
  3333. }
  3334. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3335. else roomFeeStr += " 0.00 * 0";
  3336. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3337. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3338. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3339. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3340. /*
  3341. * 费用类型
  3342. * 1:房费
  3343. * 2:早餐
  3344. * 3:地税
  3345. * 4:城市税
  3346. * </summary>
  3347. */
  3348. //地税
  3349. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3350. if (governmentRentData != null)
  3351. {
  3352. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3353. governmentRentFee = governmentRentData.Price;
  3354. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3355. if (governmentRentCurrData != null)
  3356. {
  3357. governmentRentCode = governmentRentCurrData.Name;
  3358. governmentRentName = $"({governmentRentCurrData.Remark})";
  3359. }
  3360. }
  3361. //城市税
  3362. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3363. if (cityTaxData != null)
  3364. {
  3365. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3366. cityTaxFee = cityTaxData.Price;
  3367. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3368. if (cityTaxCurrData != null)
  3369. {
  3370. cityTaxCode = cityTaxCurrData.Name;
  3371. cityTaxName = $"({cityTaxCurrData.Remark})";
  3372. }
  3373. }
  3374. //酒店早餐
  3375. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3376. if (breakfastData != null)
  3377. {
  3378. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3379. breakfastFee = breakfastData.Price;
  3380. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3381. if (breakfastCurrData != null)
  3382. {
  3383. breakfastCode = breakfastCurrData.Name;
  3384. breakfastName = $"({breakfastCurrData.Remark})";
  3385. }
  3386. }
  3387. //房间费用
  3388. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3389. if (roomData != null)
  3390. {
  3391. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3392. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3393. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3394. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3395. roomFee = roomData.Price;
  3396. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3397. if (roomCurrData != null)
  3398. {
  3399. roomCode = roomCurrData.Name;
  3400. roomName = $"({roomCurrData.Remark})";
  3401. }
  3402. }
  3403. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3404. string hotelCostStr = "";
  3405. decimal hotelCsotTotal = 0.00M;
  3406. if (groupCost != null)
  3407. {
  3408. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3409. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3410. }
  3411. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3412. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3413. string hotelCost_day = "";
  3414. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3415. foreach (var item in hotelCostDetails1)
  3416. {
  3417. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3418. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3419. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3420. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3421. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3422. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3423. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3424. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3425. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3426. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3427. hotelCost_day += @$"<br/>";
  3428. }
  3429. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3430. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3431. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3432. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3433. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3434. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3435. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3436. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3437. $"房间说明: {hotelReservations.Remark} <br/>" +
  3438. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3439. $"{hotelBreakfastStr}" +
  3440. $"{hotelGovernmentRentStr}" +
  3441. $"{hotelCityTaxStr}";
  3442. _detail.PriceNameContent = hotelReservations.HotelName;
  3443. }
  3444. break;
  3445. case 79://车/导游地接
  3446. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3447. if (touristGuideGroundReservations != null)
  3448. {
  3449. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3450. {
  3451. _detail.BusName = touristGuideGroundReservations.BusName;
  3452. }
  3453. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3454. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3455. //if (isInt)
  3456. //{
  3457. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3458. // if (cityInfo != null)
  3459. // {
  3460. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3461. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3462. // if (carFeeItem != null)
  3463. // {
  3464. // nameContent += $@"({carFeeItem.Name})";
  3465. // }
  3466. // _detail.PriceNameContent = nameContent;
  3467. // }
  3468. //}
  3469. //else
  3470. //{
  3471. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3472. //}
  3473. var touristGuideGroundReservationsContents =
  3474. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3475. var opContent_sb = new StringBuilder();
  3476. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3477. opContent_sb.AppendLine(contetTitle);
  3478. foreach (var item in touristGuideGroundReservationsContents)
  3479. {
  3480. string typeName = "Unknown";
  3481. string carCurrencyCode = "Unknown";
  3482. string carCurrencyName = "Unknown";
  3483. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3484. if (carTypeData != null) typeName = carTypeData.Name;
  3485. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3486. if (currencyData != null)
  3487. {
  3488. carCurrencyCode = currencyData.Name;
  3489. carCurrencyName = currencyData.Remark;
  3490. }
  3491. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3492. bool IsCurrencyAgreement = false;
  3493. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3494. string opCostStr = string.Empty;
  3495. decimal opCostTypePrice = 0.00M;
  3496. #region 处理成本各项费用
  3497. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3498. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3499. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3500. costOPFeeCNY = 0.00M, //团组成本 op费用
  3501. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3502. if (opCost.Count > 0)
  3503. {
  3504. switch (item.SId)
  3505. {
  3506. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3507. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3508. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3509. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3510. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3511. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3512. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3513. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3514. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3515. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3516. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3517. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3518. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3519. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3520. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3521. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3522. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3523. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3524. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3525. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3526. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3527. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3528. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3529. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3530. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3531. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3532. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3533. }
  3534. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3535. costOPFeeCNY = opCostTypePrice * _groupRate;
  3536. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3537. }
  3538. #endregion
  3539. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3540. aduitOPFeeCNY = item.Price * entity.DayRate;
  3541. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3542. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3543. $"{opTypeStr} {opCostStr}<br/>" +
  3544. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3545. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3546. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3547. {
  3548. if (IsCurrencyAgreement)
  3549. {
  3550. if (item.Price > opCostTypePrice)
  3551. {
  3552. opContent_sb.Append("<span style='color:red;'>");
  3553. opContent_sb.Append(opContent);
  3554. opContent_sb.Append("</span>");
  3555. opContent_sb.AppendLine();
  3556. }
  3557. else
  3558. {
  3559. opContent_sb.Append(opContent);
  3560. opContent_sb.AppendLine();
  3561. }
  3562. }
  3563. else
  3564. {
  3565. //验证是否超成本 按付款比例计算
  3566. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3567. {
  3568. opContent_sb.Append("<span style='color:red;'>");
  3569. opContent_sb.Append(opContent);
  3570. opContent_sb.Append("</span>");
  3571. opContent_sb.AppendLine();
  3572. }
  3573. else
  3574. {
  3575. opContent_sb.Append(opContent);
  3576. opContent_sb.AppendLine();
  3577. }
  3578. }
  3579. }
  3580. else
  3581. {
  3582. opContent_sb.Append(opContent);
  3583. opContent_sb.AppendLine();
  3584. }
  3585. }
  3586. _detail.PriceMsgContent = opContent_sb.ToString();
  3587. }
  3588. break;
  3589. case 80: //签证
  3590. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3591. if (visaInfo != null)
  3592. {
  3593. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3594. _detail.PriceNameContent = visaInfo.VisaDescription;
  3595. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3596. }
  3597. break;
  3598. case 81: //邀请/公务活动
  3599. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3600. if (_ioa != null)
  3601. {
  3602. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3603. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3604. sendCurrName = "Unknown", //快递费用币种 Name
  3605. sendCurrCode = "Unknown", //快递费用币种 Code
  3606. eventsCurrName = "Unknown", //公务活动费币种 Name
  3607. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3608. translateCurrName = "Unknown", //公务翻译费 Name
  3609. translateCurrCode = "Unknown"; //公务翻译费 Code
  3610. #region 处理费用币种
  3611. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3612. if (inviteCurrData != null)
  3613. {
  3614. inviteCurrName = inviteCurrData.Remark;
  3615. inviteCurrCode = inviteCurrData.Name;
  3616. }
  3617. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3618. if (sendCurrData != null)
  3619. {
  3620. sendCurrName = sendCurrData.Remark;
  3621. sendCurrCode = sendCurrData.Name;
  3622. }
  3623. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3624. if (eventsCurrData != null)
  3625. {
  3626. eventsCurrName = eventsCurrData.Remark;
  3627. eventsCurrCode = eventsCurrData.Name;
  3628. }
  3629. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3630. if (translateCurrData != null)
  3631. {
  3632. translateCurrName = translateCurrData.Remark;
  3633. translateCurrCode = translateCurrData.Name;
  3634. }
  3635. #endregion
  3636. _detail.PriceNameContent = _ioa.InviterArea;
  3637. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  3638. List<string> priceExpNames = new List<string>();
  3639. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  3640. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  3641. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  3642. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  3643. if (priceExpNames != null && priceExpNames.Count > 0)
  3644. {
  3645. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  3646. }
  3647. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3648. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3649. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3650. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3651. $@"备注:" + _ioa.Remark + "<br/>";
  3652. }
  3653. break;
  3654. case 82: //团组客户保险
  3655. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3656. if (customers != null)
  3657. {
  3658. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3659. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3660. }
  3661. break;
  3662. case 85: //机票预订
  3663. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3664. if (jpRes != null)
  3665. {
  3666. string FlightsDescription = jpRes.FlightsDescription;
  3667. string PriceDescription = jpRes.PriceDescription;
  3668. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3669. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3670. }
  3671. break;
  3672. case 98://其他款项
  3673. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3674. if (gdpRes != null)
  3675. {
  3676. //var urlBase = $"http://132.232.92.186:24/Office/GrpFile/http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  3677. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  3678. //{
  3679. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  3680. //}
  3681. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3682. _detail.PriceNameContent = gdpRes.PriceName;
  3683. }
  3684. break;
  3685. case 285://收款退还
  3686. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3687. if (refundAndOtherMoney != null)
  3688. {
  3689. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3690. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3691. }
  3692. break;
  3693. case 751://酒店早餐
  3694. break;
  3695. case 1015://超支费用
  3696. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3697. if (groupExtraCost != null)
  3698. {
  3699. _detail.PriceNameContent = groupExtraCost.PriceName;
  3700. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3701. }
  3702. break;
  3703. default:
  3704. break;
  3705. }
  3706. /*
  3707. * 申请人
  3708. */
  3709. string operatorName = " - ";
  3710. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3711. if (_opUser != null)
  3712. {
  3713. operatorName = _opUser.CnName;
  3714. }
  3715. _detail.OperatorName = operatorName;
  3716. /*
  3717. * 审核人
  3718. */
  3719. string auditOperatorName = " - ";
  3720. if (entity.IsAuditGM != 0)
  3721. {
  3722. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3723. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3724. else
  3725. {
  3726. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3727. if (_adUser != null)
  3728. {
  3729. auditOperatorName = _adUser.CnName;
  3730. }
  3731. }
  3732. }
  3733. _detail.AuditOperatorName = auditOperatorName;
  3734. /*
  3735. * 超预算比例
  3736. */
  3737. string overBudgetStr = "";
  3738. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3739. else if (entity.ExceedBudget == 0)
  3740. {
  3741. if (entity.CTable == 76 || entity.CTable == 79)
  3742. {
  3743. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3744. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3745. }
  3746. else
  3747. {
  3748. overBudgetStr = "未超预算";
  3749. }
  3750. }
  3751. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3752. _detail.OverBudget = overBudgetStr;
  3753. decimal auditFee = 0.00M; //已审核金额 人名币
  3754. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3755. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3756. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3757. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3758. {
  3759. auditedFeeOriginal = entity.PayMoney;
  3760. auditFee = CurrPayStr;
  3761. }
  3762. else if (entity.IsAuditGM == 0)
  3763. {
  3764. unAuditFeeCNY = CurrPayStr;
  3765. unAuditFeeOriginal = OriginalCurrPay;
  3766. OriginalCurrPay = 0.00M;
  3767. }
  3768. /*
  3769. * 费用总计
  3770. */
  3771. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3772. {
  3773. CurrencyId = entity.PaymentCurrency,
  3774. CurrencyName = PaymentCurrency_WaitPay,
  3775. AmountPayable = entity.PayMoney,
  3776. ThisPayment = OriginalCurrPay,
  3777. BalancePayment = BalanceStr,
  3778. AuditedFunds = auditFee,
  3779. AuditedFundsOriginal = auditedFeeOriginal,
  3780. UnAuditFundsCNY = unAuditFeeCNY,
  3781. UnAuditFundsOriginal = unAuditFeeOriginal
  3782. });
  3783. _detail.IsAuditGM = entity.IsAuditGM;
  3784. detailList.Add(_detail);
  3785. }
  3786. #endregion
  3787. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3788. /*
  3789. * 下方描述处理
  3790. */
  3791. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3792. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3793. if (ccpCurrencyPrice != null)
  3794. {
  3795. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3796. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3797. }
  3798. else
  3799. {
  3800. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3801. }
  3802. string amountPayableStr = string.Format(@"应付款总金额: ");
  3803. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3804. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3805. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3806. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3807. foreach (var item in nonDuplicat)
  3808. {
  3809. var currencyName = item.CurrencyName;
  3810. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3811. if (strs.Count > 0)
  3812. {
  3813. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3814. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3815. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3816. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3817. //单独处理此次付款金额
  3818. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3819. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3820. //单独处理已审核费用
  3821. //if (item.CurrencyId == 836) //人民币
  3822. //{
  3823. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3824. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3825. //}
  3826. //else
  3827. //{
  3828. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3829. //}
  3830. if (currencyName.Equals("CNY"))
  3831. {
  3832. //已审核费用
  3833. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3834. //未审核费用
  3835. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3836. }
  3837. else
  3838. {
  3839. //已审核费用
  3840. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  3841. //未审核费用
  3842. unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
  3843. }
  3844. }
  3845. }
  3846. _view.TotalStr1 = amountPayableStr[..^1];
  3847. _view.TotalStr2 = thisPaymentStr[..^1];
  3848. _view.TotalStr3 = balancePaymentStr[..^1];
  3849. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3850. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3851. var _view1 = new
  3852. {
  3853. PageFuncAuth = pageFunAuthView,
  3854. Data = _view
  3855. };
  3856. return Ok(JsonView(_view1));
  3857. }
  3858. catch (Exception ex)
  3859. {
  3860. return Ok(JsonView(false, ex.Message));
  3861. }
  3862. }
  3863. /// <summary>
  3864. /// 费用审核
  3865. /// 修改团组费用审核状态
  3866. /// </summary>
  3867. /// <param name="_dto">参数Json字符串</param>
  3868. /// <returns></returns>
  3869. [HttpPost]
  3870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3871. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3872. {
  3873. #region 参数验证
  3874. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3875. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3876. #endregion
  3877. #region 页面操作权限验证
  3878. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3879. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3880. #endregion
  3881. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3882. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3883. DateTime dtNow = DateTime.Now;
  3884. _groupRepository.BeginTran();
  3885. int rst = 0;
  3886. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3887. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3888. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3889. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3890. var msgDatas = new List<dynamic>();
  3891. var dic_ccp_user = new Dictionary<int, int>() { };
  3892. foreach (var item in idList)
  3893. {
  3894. int CreditId = int.Parse(item);
  3895. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3896. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3897. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3898. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3899. .Where(s => s.Id == CreditId)
  3900. .ExecuteCommandAsync();
  3901. if (result < 1)
  3902. {
  3903. rst = -1;
  3904. _groupRepository.RollbackTran();
  3905. return Ok(JsonView(false, "操作失败并回滚!"));
  3906. }
  3907. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3908. if (creditData != null)
  3909. {
  3910. #region 应用通知配置
  3911. try
  3912. {
  3913. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3914. }
  3915. catch (Exception ex)
  3916. {
  3917. }
  3918. #endregion
  3919. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3920. string groupNameStr = string.Empty;
  3921. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3922. if (groupData != null) groupNameStr = groupData.TeamName;
  3923. string creditTypeStr = string.Empty;
  3924. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3925. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3926. string creditCurrency = string.Empty;
  3927. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3928. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3929. if (creditCurrency.Equals("CNY"))
  3930. {
  3931. creditData.DayRate = 1.0000M;
  3932. }
  3933. if (creditData.PayPercentage == 0.00M)
  3934. {
  3935. creditData.PayPercentage = 100M;
  3936. }
  3937. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3938. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3939. string msgContent = "";
  3940. if (creditCurrency.Equals("CNY"))
  3941. {
  3942. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3943. }
  3944. else
  3945. {
  3946. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3947. }
  3948. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3949. }
  3950. }
  3951. if (rst == 0)
  3952. {
  3953. _groupRepository.CommitTran();
  3954. foreach (var item in msgDatas)
  3955. {
  3956. //发送消息
  3957. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3958. }
  3959. #region 应用推送
  3960. try
  3961. {
  3962. foreach (var ccpId in dic_ccp_user.Keys)
  3963. {
  3964. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3965. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3966. }
  3967. }
  3968. catch (Exception)
  3969. {
  3970. }
  3971. #endregion
  3972. return Ok(JsonView(true, "操作成功!"));
  3973. }
  3974. return Ok(JsonView(false, "操作失败!"));
  3975. }
  3976. /// <summary>
  3977. /// 费用审核
  3978. /// 其他款项 文件下载
  3979. /// </summary>
  3980. /// <param name="id">其他款项 主键编号</param>
  3981. /// <returns></returns>
  3982. [HttpGet("{id}")]
  3983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3984. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  3985. {
  3986. //网站域名
  3987. const string baseUrl = "http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  3988. var otherInfo = await _decreasePaymentsRep._sqlSugar
  3989. .Queryable<Grp_DecreasePayments>()
  3990. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  3991. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  3992. .Select((x, y) => new
  3993. {
  3994. x.Id,
  3995. x.FilePath
  3996. })
  3997. .FirstAsync();
  3998. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  3999. {
  4000. var url = $"{baseUrl}{otherInfo.FilePath}";
  4001. return Ok(JsonView(true, "操作成功!", url));
  4002. }
  4003. return Ok(JsonView(false, "暂无附件"));
  4004. }
  4005. #endregion
  4006. #region 机票费用录入
  4007. /// <summary>
  4008. /// 机票录入当前登录人可操作团组
  4009. /// </summary>
  4010. /// <param name="dto"></param>
  4011. /// <returns></returns>
  4012. [HttpPost]
  4013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4014. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  4015. {
  4016. try
  4017. {
  4018. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  4019. if (groupData.Code != 0)
  4020. {
  4021. return Ok(JsonView(false, groupData.Msg));
  4022. }
  4023. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4024. }
  4025. catch (Exception ex)
  4026. {
  4027. return Ok(JsonView(false, ex.Message));
  4028. }
  4029. }
  4030. /// <summary>
  4031. /// 机票费用录入列表
  4032. /// </summary>
  4033. /// <param name="dto"></param>
  4034. /// <returns></returns>
  4035. [HttpPost]
  4036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4037. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  4038. {
  4039. try
  4040. {
  4041. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  4042. if (groupData.Code != 0)
  4043. {
  4044. return Ok(JsonView(false, groupData.Msg));
  4045. }
  4046. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4047. }
  4048. catch (Exception ex)
  4049. {
  4050. return Ok(JsonView(false, ex.Message));
  4051. throw;
  4052. }
  4053. }
  4054. /// <summary>
  4055. /// 根据id查询费用录入信息
  4056. /// </summary>
  4057. /// <param name="dto"></param>
  4058. /// <returns></returns>
  4059. [HttpPost]
  4060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4061. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  4062. {
  4063. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  4064. if (groupData.Code != 0)
  4065. {
  4066. return Ok(JsonView(false, groupData.Msg));
  4067. }
  4068. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4069. }
  4070. /// <summary>
  4071. /// 机票费用录入操作(Status:1.新增,2.修改)
  4072. /// </summary>
  4073. /// <param name="dto"></param>
  4074. /// <returns></returns>
  4075. [HttpPost]
  4076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4077. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  4078. {
  4079. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  4080. if (groupData.Code != 0)
  4081. {
  4082. return Ok(JsonView(false, groupData.Msg));
  4083. }
  4084. #region 应用推送
  4085. try
  4086. {
  4087. var diId = dto.AirTicketResOpData.DiId;
  4088. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4089. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4090. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4091. //自动审核
  4092. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4093. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4094. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4095. $"GroupId:{diId};airId:{dataId};",
  4096. status,
  4097. auditMsg);
  4098. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4099. //2024-10-21 新增LZ UID
  4100. var userIds = new List<int>() { 21 };
  4101. string title = $"系统通知";
  4102. string content = "";
  4103. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4104. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4105. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4106. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4107. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4108. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4109. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4110. }
  4111. catch (Exception ex)
  4112. {
  4113. }
  4114. #endregion
  4115. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4116. }
  4117. /// <summary>
  4118. /// 机票费用自动审核 AI识别方式
  4119. /// </summary>
  4120. /// <returns></returns>
  4121. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4122. {
  4123. var ecoTypeIds = new List<int>() {
  4124. 459, //超经舱
  4125. 460, //经济舱
  4126. 1430, //公务舱(实际经济舱)
  4127. 1432, //头等舱(实际经济舱)
  4128. };
  4129. var bizTypeIds = new List<int>() {
  4130. 457, //头等舱
  4131. 458, //公务舱
  4132. 1431, //头等舱(实际公务舱)
  4133. };
  4134. var auditFeeTypeIds = new List<int>() { };
  4135. auditFeeTypeIds.AddRange(ecoTypeIds);
  4136. auditFeeTypeIds.AddRange(bizTypeIds);
  4137. int currModule = 85;
  4138. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4139. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4140. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4141. .Select((x, y) => new
  4142. {
  4143. x.Id,
  4144. CcpId = y.Id,
  4145. x.FlightsDate,
  4146. x.PrePrice,
  4147. x.CType,
  4148. x.ClientNum,
  4149. x.DIId
  4150. })
  4151. .FirstAsync();
  4152. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4153. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4154. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4155. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4156. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4157. var groupCostContents = await _sqlSugar
  4158. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4159. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4160. .ToListAsync();
  4161. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4162. //处理 成本详细信息日期为空 填装费用信息
  4163. var airFeeLabel = new StringBuilder();
  4164. airFeeLabel.AppendLine("费用成本:");
  4165. for (int i = 0; i < groupCostContents.Count; i++)
  4166. {
  4167. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4168. {
  4169. int index = i - 1;
  4170. if (index >= 0)
  4171. {
  4172. groupCostContents[i].Date = groupCostContents[index].Date;
  4173. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4174. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4175. }
  4176. }
  4177. else
  4178. {
  4179. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4180. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4181. }
  4182. var item = groupCostContents[i];
  4183. airFeeLabel.AppendLine($"{item.Date}");
  4184. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4185. }
  4186. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4187. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4188. //访问Kimi AI 返回价格结果
  4189. var msgs = new List<SeedMessages>()
  4190. {
  4191. new ()
  4192. {
  4193. Role = KimiRole.user,
  4194. Content = airFeeLabel.ToString()
  4195. }
  4196. };
  4197. var client = new KiMiApiClient();
  4198. var kimiApiResult = await client.SeedMessage(msgs);
  4199. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  4200. string clients = kimiApiResult_JObject["content"].ToString();
  4201. decimal ecoPri_kimiAI = 0.00M,
  4202. bizPri_kimiAI = 0.00M;
  4203. //单个价格: 经济舱价格
  4204. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  4205. //价格文本包含/:/前经济舱价格 /后公务舱价格
  4206. if (clients.Contains('/'))
  4207. {
  4208. var priArray = clients.Split('/');
  4209. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4210. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4211. }
  4212. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4213. var isAutoAudit = false;
  4214. //价格验证处理
  4215. //经济舱
  4216. if (ecoTypeIds.Contains(airInfo.CType))
  4217. {
  4218. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4219. }
  4220. //公务舱
  4221. else if (bizTypeIds.Contains(airInfo.CType))
  4222. {
  4223. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4224. }
  4225. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4226. //是否执行自动审核
  4227. if (isAutoAudit)
  4228. {
  4229. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4230. .SetColumns(x => x.IsAuditGM == 3)
  4231. .SetColumns(x => x.AuditGMOperate == 4)
  4232. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4233. .Where(x => x.Id == airInfo.CcpId)
  4234. .ExecuteCommandAsync();
  4235. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4236. }
  4237. return (false, "当前费用超过成本费用,不可自动审核!");
  4238. }
  4239. /// <summary>
  4240. /// 机票费用录入
  4241. /// 自动审核测试 - AI 识别
  4242. /// </summary>
  4243. /// <param name="groupId"></param>
  4244. /// <param name="Id"></param>
  4245. /// <returns></returns>
  4246. [HttpPost]
  4247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4248. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4249. {
  4250. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4251. return Ok(JsonView(status, msg));
  4252. }
  4253. /// <summary>
  4254. /// 根据舱位类型查询接团客户名单信息
  4255. /// </summary>
  4256. /// <param name="dto"></param>
  4257. /// <returns></returns>
  4258. [HttpPost]
  4259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4260. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4261. {
  4262. try
  4263. {
  4264. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4265. if (crm_Groups.Count != 0)
  4266. {
  4267. var Customer = new List<dynamic>();
  4268. foreach (var item in crm_Groups)
  4269. {
  4270. var data = new
  4271. {
  4272. item.Id,
  4273. item.Pinyin,
  4274. Name = item.LastName + item.FirstName
  4275. };
  4276. Customer.Add(data);
  4277. }
  4278. return Ok(JsonView(true, "查询成功!", Customer));
  4279. }
  4280. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4281. }
  4282. catch (Exception ex)
  4283. {
  4284. return Ok(JsonView(false, "程序错误!"));
  4285. throw;
  4286. }
  4287. }
  4288. /// <summary>
  4289. /// 根据团号获取客户信息
  4290. /// </summary>
  4291. /// <param name="dto"></param>
  4292. /// <returns></returns>
  4293. [HttpPost]
  4294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4295. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4296. {
  4297. var jw = JsonView(false);
  4298. if (dto.DIID < 1)
  4299. {
  4300. jw.Msg += "请输入正确的diid";
  4301. return Ok(jw);
  4302. }
  4303. var arr = GetSimplClientList(dto.DIID);
  4304. jw = JsonView(true, "获取成功!", arr);
  4305. return Ok(jw);
  4306. }
  4307. private List<SimplClientInfo> GetSimplClientList(int diId)
  4308. {
  4309. string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", diId);
  4310. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4311. foreach (var item in arr)
  4312. {
  4313. EncryptionProcessor.DecryptProperties(item);
  4314. }
  4315. return arr;
  4316. }
  4317. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4318. {
  4319. string result = origin;
  4320. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4321. {
  4322. string[] temparr = origin.Split(',');
  4323. string fistrStr = temparr[0];
  4324. int count = temparr.Length;
  4325. bool success = int.TryParse(fistrStr, out int tempId);
  4326. if (success)
  4327. {
  4328. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4329. if (tempInfo != null)
  4330. {
  4331. if (count > 1)
  4332. {
  4333. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4334. }
  4335. else
  4336. {
  4337. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4338. }
  4339. }
  4340. }
  4341. }
  4342. return result;
  4343. }
  4344. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4345. {
  4346. string result = origin;
  4347. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4348. {
  4349. string[] temparr = origin.Split(',');
  4350. result = "";
  4351. foreach (var item in temparr)
  4352. {
  4353. bool success = int.TryParse(item, out int tempId);
  4354. if (success)
  4355. {
  4356. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4357. if (tempInfo != null)
  4358. {
  4359. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4360. }
  4361. }
  4362. }
  4363. }
  4364. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4365. return result;
  4366. }
  4367. /// <summary>
  4368. /// 机票费用录入,删除
  4369. /// </summary>
  4370. /// <param name="dto"></param>
  4371. /// <returns></returns>
  4372. [HttpPost]
  4373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4374. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4375. {
  4376. try
  4377. {
  4378. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4379. if (res)
  4380. {
  4381. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4382. {
  4383. IsDel = 1,
  4384. DeleteUserId = dto.DeleteUserId,
  4385. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4386. }).ExecuteCommandAsync();
  4387. return Ok(JsonView(true, "删除成功!"));
  4388. }
  4389. return Ok(JsonView(false, "删除失败!"));
  4390. }
  4391. catch (Exception ex)
  4392. {
  4393. return Ok(JsonView(false, "程序错误!"));
  4394. throw;
  4395. }
  4396. }
  4397. /// <summary>
  4398. /// 导出机票录入报表
  4399. /// </summary>
  4400. /// <param name="dto"></param>
  4401. /// <returns></returns>
  4402. [HttpPost]
  4403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4404. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4405. {
  4406. try
  4407. {
  4408. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4409. if (groupData.Code != 0)
  4410. {
  4411. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4412. }
  4413. else
  4414. {
  4415. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4416. if (AirTicketReservations.Count != 0)
  4417. {
  4418. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4419. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4420. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4421. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4422. var designer = new WorkbookDesigner
  4423. {
  4424. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4425. };
  4426. decimal countCost = 0;
  4427. foreach (var item in AirTicketReservations)
  4428. {
  4429. #region 处理客人姓名
  4430. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4431. item.ClientName = clientNames;
  4432. #endregion
  4433. if (item.BankType == "其他")
  4434. {
  4435. item.BankNo = "--";
  4436. }
  4437. else
  4438. {
  4439. if (!string.IsNullOrEmpty(item.BankType))
  4440. {
  4441. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  4442. }
  4443. }
  4444. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4445. item.Price = System.Decimal.Round(item.Price, 2);
  4446. countCost += Convert.ToDecimal(item.Price);
  4447. }
  4448. designer.SetDataSource("Export", AirTicketReservations);
  4449. designer.SetDataSource("ExportDiCode", diCode);
  4450. designer.SetDataSource("ExportDiName", diName);
  4451. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4452. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4453. designer.Process();
  4454. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4455. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4456. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4457. return Ok(JsonView(true, "成功", url = rst));
  4458. }
  4459. else
  4460. {
  4461. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4462. }
  4463. }
  4464. }
  4465. catch (Exception ex)
  4466. {
  4467. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4468. throw;
  4469. }
  4470. }
  4471. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  4472. /// <summary>
  4473. /// 行程单导出
  4474. /// </summary>
  4475. /// <param name="dto"></param>
  4476. /// <returns></returns>
  4477. [HttpPost]
  4478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4479. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4480. {
  4481. try
  4482. {
  4483. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4484. if (groupData.Code != 0)
  4485. {
  4486. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4487. }
  4488. else
  4489. {
  4490. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4491. if (dto.Language == "CN")
  4492. {
  4493. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4494. var builder = new DocumentBuilder(doc);
  4495. int tableIndex = 0;//表格索引
  4496. //得到文档中的第一个表格
  4497. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4498. foreach (var item in _AirTicketReservations)
  4499. {
  4500. #region 处理固定数据
  4501. string[] FlightsCode = item.FlightsCode.Split('/');
  4502. if (FlightsCode.Length != 0)
  4503. {
  4504. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4505. if (_AirCompany != null)
  4506. {
  4507. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4508. }
  4509. else
  4510. {
  4511. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4512. }
  4513. }
  4514. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4515. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4516. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4517. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4518. string name = "";
  4519. foreach (string clientName in nameArray)
  4520. {
  4521. if (!name.Contains(clientName))
  4522. {
  4523. name += clientName + ",";
  4524. }
  4525. }
  4526. if (!string.IsNullOrWhiteSpace(name))
  4527. {
  4528. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4529. }
  4530. else
  4531. {
  4532. table.Range.Bookmarks["ClientName"].Text = "--";
  4533. }
  4534. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4535. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4536. table.Range.Bookmarks["JointTicket"].Text = "--";
  4537. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4538. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4539. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4540. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4541. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4542. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4543. #endregion
  4544. #region 循环数据处理
  4545. var airs = new List<AirInfo>();
  4546. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4547. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4548. for (int i = 0; i < FlightsCode.Length; i++)
  4549. {
  4550. var air = new AirInfo();
  4551. string[] tempstr = DayArray[i]
  4552. .Replace("\r\n", string.Empty)
  4553. .Replace("\\r\\n", string.Empty)
  4554. .TrimStart().TrimEnd()
  4555. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4556. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4557. string starCity = "";
  4558. if (star_Three != null)
  4559. {
  4560. starCity = star_Three.AirPort;
  4561. }
  4562. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4563. string EndCity = "";
  4564. if (End_Three != null)
  4565. {
  4566. EndCity = End_Three.AirPort;
  4567. }
  4568. air.Destination = starCity + "/" + EndCity;
  4569. air.Flight = FlightsCode[i];
  4570. air.SeatingClass = item.CTypeName;
  4571. string dateTime = tempstr[2];
  4572. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4573. air.FlightDate = DateTemp;
  4574. air.DepartureTime = tempstr[5];
  4575. air.LandingTime = tempstr[6];
  4576. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4577. air.TicketStatus = "--";
  4578. air.Luggage = "--";
  4579. air.DepartureTerminal = "--";
  4580. air.LandingTerminal = "--";
  4581. airs.Add(air);
  4582. }
  4583. int row = 13;
  4584. for (int i = 0; i < airs.Count; i++)
  4585. {
  4586. if (airs.Count > 2)
  4587. {
  4588. for (int j = 0; j < airs.Count - 2; j++)
  4589. {
  4590. var CopyRow = table.Rows[12].Clone(true);
  4591. table.Rows.Add(CopyRow);
  4592. }
  4593. }
  4594. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4595. int index = 0;
  4596. foreach (PropertyInfo property in properties)
  4597. {
  4598. string value = property.GetValue(airs[i]).ToString();
  4599. Cell ishcel0 = table.Rows[row].Cells[index];
  4600. var p = new Paragraph(doc);
  4601. string s = value;
  4602. p.AppendChild(new Run(doc, s));
  4603. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4604. ishcel0.AppendChild(p);
  4605. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4606. index++;
  4607. }
  4608. row++;
  4609. }
  4610. #endregion
  4611. var lastParagraph = new Paragraph(doc);
  4612. //第一个表格末尾加段落
  4613. table.ParentNode.InsertAfter(lastParagraph, table);
  4614. //复制第一个表格
  4615. Table cloneTable = (Table)table.Clone(true);
  4616. //在文档末尾段落后面加入复制的表格
  4617. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4618. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4619. {
  4620. int rownewsIndex = 13;
  4621. for (int i = 0; i < 2; i++)
  4622. {
  4623. var CopyRow = table.Rows[12].Clone(true);
  4624. table.Rows.RemoveAt(13);
  4625. table.Rows.Add(CopyRow);
  4626. rownewsIndex++;
  4627. }
  4628. }
  4629. else
  4630. {
  4631. table.Rows.RemoveAt(12);
  4632. }
  4633. cloneTable.Rows.RemoveAt(12);
  4634. }
  4635. if (_AirTicketReservations.Count != 0)
  4636. {
  4637. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4638. if (FlightsCode.Length != 0)
  4639. {
  4640. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4641. if (_AirCompany != null)
  4642. {
  4643. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4644. }
  4645. else
  4646. {
  4647. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4648. }
  4649. }
  4650. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4651. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4652. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4653. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4654. string name = "";
  4655. foreach (string clientName in nameArray)
  4656. {
  4657. if (!name.Contains(clientName))
  4658. {
  4659. name += clientName + ",";
  4660. }
  4661. }
  4662. if (!string.IsNullOrWhiteSpace(name))
  4663. {
  4664. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4665. }
  4666. else
  4667. {
  4668. table.Range.Bookmarks["ClientName"].Text = "--";
  4669. }
  4670. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4671. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4672. table.Range.Bookmarks["JointTicket"].Text = "--";
  4673. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4674. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4675. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4676. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4677. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4678. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4679. }
  4680. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4681. //保存合并后的文档
  4682. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4683. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4684. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4685. return Ok(JsonView(true, "成功!", rst));
  4686. }
  4687. else
  4688. {
  4689. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4690. var builder = new DocumentBuilder(doc);
  4691. int tableIndex = 0;//表格索引
  4692. //得到文档中的第一个表格
  4693. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4694. var texts = new List<string>();
  4695. foreach (var item in _AirTicketReservations)
  4696. {
  4697. string[] FlightsCode = item.FlightsCode.Split('/');
  4698. if (FlightsCode.Length != 0)
  4699. {
  4700. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4701. if (_AirCompany != null)
  4702. {
  4703. if (!transDic.ContainsKey(_AirCompany.CnName))
  4704. {
  4705. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4706. }
  4707. }
  4708. else
  4709. {
  4710. if (!transDic.ContainsKey("--"))
  4711. {
  4712. transDic.Add("--", "--");
  4713. }
  4714. }
  4715. }
  4716. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4717. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4718. string name = "";
  4719. foreach (string clientName in nameArray)
  4720. {
  4721. name += clientName + ",";
  4722. }
  4723. if (!texts.Contains(name))
  4724. {
  4725. texts.Add(name);
  4726. }
  4727. var airs = new List<AirInfo>();
  4728. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4729. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4730. for (int i = 0; i < FlightsCode.Length; i++)
  4731. {
  4732. var air = new AirInfo();
  4733. string[] tempstr = DayArray[i]
  4734. .Replace("\r\n", string.Empty)
  4735. .Replace("\\r\\n", string.Empty)
  4736. .TrimStart().TrimEnd()
  4737. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4738. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4739. if (star_Three != null)
  4740. {
  4741. if (!transDic.ContainsKey(star_Three.AirPort))
  4742. {
  4743. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4744. }
  4745. }
  4746. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4747. if (End_Three != null)
  4748. {
  4749. if (!transDic.ContainsKey(End_Three.AirPort))
  4750. {
  4751. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4752. }
  4753. }
  4754. if (!texts.Contains(item.CTypeName))
  4755. {
  4756. texts.Add(item.CTypeName);
  4757. }
  4758. }
  4759. }
  4760. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4761. if (transData.Count > 0)
  4762. {
  4763. foreach (TranslateResult item in transData)
  4764. {
  4765. if (!transDic.ContainsKey(item.Query))
  4766. {
  4767. transDic.Add(item.Query, item.Translation);
  4768. }
  4769. }
  4770. }
  4771. foreach (var item in _AirTicketReservations)
  4772. {
  4773. #region 处理固定数据
  4774. string[] FlightsCode = item.FlightsCode.Split('/');
  4775. if (FlightsCode.Length != 0)
  4776. {
  4777. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4778. if (_AirCompany != null)
  4779. {
  4780. string str = "--";
  4781. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4782. if (!string.IsNullOrEmpty(translateResult))
  4783. {
  4784. str = translateResult;
  4785. str = _airTicketResRep.Processing(str);
  4786. }
  4787. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4788. }
  4789. else
  4790. {
  4791. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4792. }
  4793. }
  4794. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4795. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4796. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4797. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4798. string names = "";
  4799. foreach (string clientName in nameArray)
  4800. {
  4801. names += clientName + ",";
  4802. }
  4803. if (!string.IsNullOrWhiteSpace(names))
  4804. {
  4805. string str = "--";
  4806. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4807. if (!string.IsNullOrEmpty(translateResult))
  4808. {
  4809. str = translateResult;
  4810. str = _airTicketResRep.Processing(str);
  4811. }
  4812. table.Range.Bookmarks["ClientName"].Text = str;
  4813. }
  4814. else
  4815. {
  4816. table.Range.Bookmarks["ClientName"].Text = "--";
  4817. }
  4818. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4819. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4820. table.Range.Bookmarks["JointTicket"].Text = "--";
  4821. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4822. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4823. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4824. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4825. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4826. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4827. #endregion
  4828. #region 循环数据处理
  4829. var airs = new List<AirInfo>();
  4830. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4831. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4832. for (int i = 0; i < FlightsCode.Length; i++)
  4833. {
  4834. var air = new AirInfo();
  4835. string[] tempstr = DayArray[i]
  4836. .Replace("\r\n", string.Empty)
  4837. .Replace("\\r\\n", string.Empty)
  4838. .TrimStart().TrimEnd()
  4839. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4840. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4841. string starCity = "";
  4842. if (star_Three != null)
  4843. {
  4844. string str2 = "--";
  4845. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4846. if (!string.IsNullOrEmpty(translateResult2))
  4847. {
  4848. str2 = translateResult2;
  4849. str2 = _airTicketResRep.Processing(str2);
  4850. }
  4851. starCity = str2;
  4852. }
  4853. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4854. string EndCity = "";
  4855. if (End_Three != null)
  4856. {
  4857. string str1 = "--";
  4858. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4859. if (!string.IsNullOrEmpty(translateResult1))
  4860. {
  4861. str1 = translateResult1;
  4862. str1 = _airTicketResRep.Processing(str1);
  4863. }
  4864. EndCity = str1;
  4865. }
  4866. air.Destination = starCity + "/" + EndCity;
  4867. air.Flight = FlightsCode[i];
  4868. string str = "--";
  4869. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4870. if (!string.IsNullOrEmpty(translateResult))
  4871. {
  4872. str = translateResult;
  4873. str = _airTicketResRep.Processing(str);
  4874. }
  4875. air.SeatingClass = str;
  4876. string dateTime = tempstr[2];
  4877. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4878. air.FlightDate = DateTemp;
  4879. air.DepartureTime = tempstr[5];
  4880. air.LandingTime = tempstr[6];
  4881. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4882. air.TicketStatus = "--";
  4883. air.Luggage = "--";
  4884. air.DepartureTerminal = "--";
  4885. air.LandingTerminal = "--";
  4886. airs.Add(air);
  4887. }
  4888. int row = 13;
  4889. for (int i = 0; i < airs.Count; i++)
  4890. {
  4891. if (airs.Count > 2)
  4892. {
  4893. for (int j = 0; j < airs.Count - 2; j++)
  4894. {
  4895. var CopyRow = table.Rows[12].Clone(true);
  4896. table.Rows.Add(CopyRow);
  4897. }
  4898. }
  4899. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4900. int index = 0;
  4901. foreach (PropertyInfo property in properties)
  4902. {
  4903. string value = property.GetValue(airs[i]).ToString();
  4904. Cell ishcel0 = table.Rows[row].Cells[index];
  4905. var p = new Paragraph(doc);
  4906. string s = value;
  4907. p.AppendChild(new Run(doc, s));
  4908. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4909. ishcel0.AppendChild(p);
  4910. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4911. //ishcel0.CellFormat.VerticalAlignment=
  4912. index++;
  4913. }
  4914. row++;
  4915. }
  4916. #endregion
  4917. var lastParagraph = new Paragraph(doc);
  4918. //第一个表格末尾加段落
  4919. table.ParentNode.InsertAfter(lastParagraph, table);
  4920. //复制第一个表格
  4921. Table cloneTable = (Table)table.Clone(true);
  4922. //在文档末尾段落后面加入复制的表格
  4923. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4924. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4925. {
  4926. int rownewsIndex = 13;
  4927. for (int i = 0; i < 2; i++)
  4928. {
  4929. var CopyRow = table.Rows[12].Clone(true);
  4930. table.Rows.RemoveAt(13);
  4931. table.Rows.Add(CopyRow);
  4932. rownewsIndex++;
  4933. }
  4934. }
  4935. else
  4936. {
  4937. table.Rows.RemoveAt(12);
  4938. }
  4939. cloneTable.Rows.RemoveAt(12);
  4940. }
  4941. if (_AirTicketReservations.Count != 0)
  4942. {
  4943. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4944. if (FlightsCode.Length != 0)
  4945. {
  4946. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4947. if (_AirCompany != null)
  4948. {
  4949. string str = "--";
  4950. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4951. if (!string.IsNullOrEmpty(translateResult))
  4952. {
  4953. str = translateResult;
  4954. str = _airTicketResRep.Processing(str);
  4955. }
  4956. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4957. }
  4958. else
  4959. {
  4960. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4961. }
  4962. }
  4963. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4964. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4965. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4966. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4967. string names = "";
  4968. foreach (string clientName in nameArray)
  4969. {
  4970. names += clientName + ",";
  4971. }
  4972. if (!string.IsNullOrWhiteSpace(names))
  4973. {
  4974. string str = "--";
  4975. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4976. if (!string.IsNullOrEmpty(translateResult))
  4977. {
  4978. str = translateResult;
  4979. str = _airTicketResRep.Processing(str);
  4980. }
  4981. table.Range.Bookmarks["ClientName"].Text = str;
  4982. }
  4983. else
  4984. {
  4985. table.Range.Bookmarks["ClientName"].Text = "--";
  4986. }
  4987. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4988. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4989. table.Range.Bookmarks["JointTicket"].Text = "--";
  4990. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4991. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4992. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4993. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4994. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4995. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4996. }
  4997. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4998. //保存合并后的文档
  4999. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  5000. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5001. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5002. return Ok(JsonView(true, "成功!", rst));
  5003. }
  5004. }
  5005. }
  5006. catch (Exception ex)
  5007. {
  5008. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  5009. throw;
  5010. }
  5011. }
  5012. #endregion
  5013. #region 团组增减款项 --> 其他款项
  5014. /// <summary>
  5015. /// 团组增减款项下拉框绑定
  5016. /// </summary>
  5017. /// <param name="dto"></param>
  5018. /// <returns></returns>
  5019. [HttpPost]
  5020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5021. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  5022. {
  5023. #region 参数验证
  5024. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5025. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  5026. #endregion
  5027. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  5028. }
  5029. /// <summary>
  5030. /// 根据团组Id查询团组增减款项
  5031. /// </summary>
  5032. /// <param name="dto"></param>
  5033. /// <returns></returns>
  5034. [HttpPost]
  5035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5036. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  5037. {
  5038. #region 参数验证
  5039. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5040. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5041. #endregion
  5042. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  5043. }
  5044. /// <summary>
  5045. /// 团组增减款项操作(Status:1.新增,2.修改)
  5046. /// </summary>
  5047. /// <param name="dto"></param>
  5048. /// <returns></returns>
  5049. [HttpPost]
  5050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5051. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  5052. {
  5053. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  5054. if (groupData.Code != 200)
  5055. {
  5056. return Ok(JsonView(false, groupData.Msg));
  5057. }
  5058. #region 应用推送
  5059. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  5060. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5061. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5062. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  5063. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  5064. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  5065. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  5066. if (recheck)
  5067. {
  5068. //自动审核
  5069. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  5070. }
  5071. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5072. //2024-10-21 新增LZ UID
  5073. var userIds = new List<int>() { 21 };
  5074. string title = $"系统通知";
  5075. string content = "";
  5076. var diId = dto.DiId;
  5077. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5078. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5079. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5080. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5081. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5082. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  5083. #endregion
  5084. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5085. }
  5086. /// <summary>
  5087. /// 团组增减款项操作 删除
  5088. /// </summary>
  5089. /// <param name="dto"></param>
  5090. /// <returns></returns>
  5091. [HttpPost]
  5092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5093. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5094. {
  5095. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5096. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5097. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5098. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5099. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5100. }
  5101. /// <summary>
  5102. /// 根据团组增减款项Id查询
  5103. /// </summary>
  5104. /// <param name="dto"></param>
  5105. /// <returns></returns>
  5106. [HttpPost]
  5107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5108. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5109. {
  5110. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5111. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5112. }
  5113. /// <summary>
  5114. /// 查询供应商名称
  5115. /// </summary>
  5116. /// <param name="dto"></param>
  5117. /// <returns></returns>
  5118. [HttpPost]
  5119. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5120. {
  5121. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5122. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5123. ?? new List<Grp_DecreasePayments>();
  5124. dbResult = dbResult.Distinct(new
  5125. ProductComparer()).ToList();
  5126. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5127. {
  5128. x.Id,
  5129. x.SupplierAddress,
  5130. x.SupplierArea,
  5131. x.SupplierContact,
  5132. x.SupplierContactNumber,
  5133. x.SupplierEmail,
  5134. x.SupplierName,
  5135. x.SupplierSocialAccount,
  5136. x.SupplierTypeId,
  5137. }).ToList());
  5138. return Ok(jw);
  5139. }
  5140. /// <summary>
  5141. /// 团组增减款项 OTA匹配
  5142. /// </summary>
  5143. /// <param name="file"></param>
  5144. /// <returns></returns>
  5145. [HttpPost]
  5146. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5147. {
  5148. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5149. string fileName = file.FileName;
  5150. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5151. {
  5152. return Ok(JsonView(false, "请上传Excel文件!"));
  5153. }
  5154. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5155. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5156. if (!Directory.Exists(path))
  5157. {
  5158. Directory.CreateDirectory(path);
  5159. }
  5160. var filePath = @$"{path}/{fileName}";
  5161. //保存文件
  5162. using (FileStream fs = System.IO.File.Create(filePath))
  5163. {
  5164. file.CopyTo(fs);
  5165. fs.Flush();
  5166. }
  5167. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5168. //读取ExcelFile
  5169. DataTable dt = ConvertExcelToDataTable(filePath);
  5170. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5171. dt.TableName = "TB";
  5172. //修改table列名
  5173. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5174. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5175. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5176. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5177. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5178. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5179. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5180. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5181. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5182. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5183. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5184. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5185. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5186. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5187. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5188. var otaOrderNos = new List<string>();
  5189. foreach (DataRow item in dt.Rows)
  5190. {
  5191. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5192. }
  5193. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5194. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  5195. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  5196. .Select((dp, di) => new
  5197. {
  5198. dp.PriceName,
  5199. dp.OTAOrderNo,
  5200. dp.FeeTotal,
  5201. di.TeamName,
  5202. })
  5203. .ToListAsync();
  5204. foreach (DataRow item in dt.Rows)
  5205. {
  5206. var otaOrderNo = item["OTAOrderNo"].ToString();
  5207. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5208. if (oaData == null) continue;
  5209. item["GroupName"] = oaData.TeamName;
  5210. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5211. }
  5212. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5213. var pairs = new Dictionary<string, object>();
  5214. var datas = new List<DataTable>
  5215. {
  5216. dt
  5217. };
  5218. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5219. return Ok(JsonView(true, "操作成功", new { url }));
  5220. }
  5221. #region
  5222. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5223. {
  5224. // 创建Workbook对象
  5225. var workbook = new Workbook(excelFilePath);
  5226. // 获取第一个工作表
  5227. var worksheet = workbook.Worksheets[0];
  5228. // 将工作表转换为DataTable
  5229. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5230. return dataTable;
  5231. }
  5232. #endregion
  5233. /// <summary>
  5234. /// 世运会数据
  5235. /// </summary>
  5236. /// <returns></returns>
  5237. [HttpGet]
  5238. public IActionResult WorldGamesData()
  5239. {
  5240. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5241. var groupMenu = setData.GroupBy(x => x.T0);
  5242. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5243. foreach (var item in groupMenu)
  5244. {
  5245. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5246. {
  5247. Data = new SetDataView
  5248. {
  5249. Name = item.Key
  5250. },
  5251. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5252. });
  5253. }
  5254. return Ok(JsonView(true, "success", resultArr));
  5255. }
  5256. #endregion
  5257. #region 文件上传、删除
  5258. /// <summary>
  5259. /// region 文件上传 可以带参数
  5260. /// </summary>
  5261. /// <param name="file"></param>
  5262. /// <returns></returns>
  5263. [HttpPost]
  5264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5265. public async Task<IActionResult> UploadProject(IFormFile file)
  5266. {
  5267. //var TypeName = Request.Headers["TypeName"].ToString();
  5268. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5269. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5270. ////文件名称
  5271. //string projectFileName = file.FileName;
  5272. ////上传的文件的路径
  5273. //string filePath = $"{fileDir}/{projectFileName}";
  5274. //if (TypeName == "A")//A代表团组增减款项
  5275. //{
  5276. // filePath = fileDir + $@"\团组增减款项相关文件";
  5277. // if (!Directory.Exists(filePath))
  5278. // {
  5279. // Directory.CreateDirectory(filePath);
  5280. // }
  5281. // //上传的文件的路径
  5282. // filePath += $@"\{projectFileName}";
  5283. //}
  5284. //else if (TypeName == "B")//B代表商邀相关文件
  5285. //{
  5286. // //上传的文件的路径
  5287. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5288. // if (!Directory.Exists(filePath))
  5289. // {
  5290. // Directory.CreateDirectory(filePath);
  5291. // }
  5292. // //上传的文件的路径
  5293. // filePath = $@"\{projectFileName}";
  5294. //}
  5295. //try
  5296. //{
  5297. // using (FileStream fs = System.IO.File.Create(filePath))
  5298. // {
  5299. // file.CopyTo(fs);
  5300. // fs.Flush();
  5301. // }
  5302. //}
  5303. //catch (Exception ex)
  5304. //{
  5305. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5306. //}
  5307. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5308. try
  5309. {
  5310. var TypeName = Request.Headers["TypeName"].ToString();
  5311. if (file != null)
  5312. {
  5313. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5314. //文件名称
  5315. string projectFileName = file.FileName;
  5316. //上传的文件的路径
  5317. string filePath = $"{fileDir}/{projectFileName}";
  5318. if (TypeName == "A")//A代表团组增减款项
  5319. {
  5320. if (!Directory.Exists(fileDir))
  5321. {
  5322. Directory.CreateDirectory(fileDir);
  5323. }
  5324. //上传的文件的路径
  5325. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5326. }
  5327. else if (TypeName == "B")//B代表商邀相关文件
  5328. {
  5329. if (!Directory.Exists(fileDir))
  5330. {
  5331. Directory.CreateDirectory(fileDir);
  5332. }
  5333. //上传的文件的路径
  5334. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5335. }
  5336. using (FileStream fs = System.IO.File.Create(filePath))
  5337. {
  5338. file.CopyTo(fs);
  5339. fs.Flush();
  5340. }
  5341. return Ok(JsonView(true, "上传成功!", projectFileName));
  5342. }
  5343. else
  5344. {
  5345. return Ok(JsonView(false, "上传失败!"));
  5346. }
  5347. }
  5348. catch (Exception ex)
  5349. {
  5350. return Ok(JsonView(false, ex.Message));
  5351. }
  5352. }
  5353. /// <summary>
  5354. /// 删除指定文件
  5355. /// </summary>
  5356. /// <param name="dto"></param>
  5357. /// <returns></returns>
  5358. [HttpPost]
  5359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5360. public async Task<IActionResult> DelFile(DelFileDto dto)
  5361. {
  5362. try
  5363. {
  5364. var TypeName = Request.Headers["TypeName"].ToString();
  5365. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5366. string filePath = "";
  5367. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5368. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5369. int id = 0;
  5370. if (TypeName == "A")
  5371. {
  5372. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5373. // 删除该文件
  5374. System.IO.File.Delete(filePath);
  5375. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5376. .Where(a => a.Id == dto.Id)
  5377. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5378. .ExecuteCommandAsync();
  5379. }
  5380. else if (TypeName == "B")
  5381. {
  5382. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5383. // 删除该文件
  5384. System.IO.File.Delete(filePath);
  5385. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5386. if (info != null)
  5387. {
  5388. string[] files = Array.Empty<string>();
  5389. if (!string.IsNullOrEmpty(info.Attachment))
  5390. {
  5391. try
  5392. {
  5393. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5394. }
  5395. catch (Exception)
  5396. {
  5397. files = new List<string>() { info.Attachment }.ToArray();
  5398. }
  5399. }
  5400. if (files.Length > 0)
  5401. {
  5402. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5403. string filePath2 = string.Empty;
  5404. if (files1.Length > 0)
  5405. {
  5406. filePath2 = JsonConvert.SerializeObject(files1);
  5407. }
  5408. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5409. .Where(a => a.Id == dto.Id)
  5410. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5411. .ExecuteCommandAsync();
  5412. }
  5413. }
  5414. }
  5415. if (id != 0)
  5416. {
  5417. return Ok(JsonView(true, "成功!"));
  5418. }
  5419. else
  5420. {
  5421. return Ok(JsonView(false, "失败!"));
  5422. }
  5423. }
  5424. catch (Exception ex)
  5425. {
  5426. return Ok(JsonView(false, "程序错误!"));
  5427. throw;
  5428. }
  5429. }
  5430. /// <summary>
  5431. /// 文件上传多个文件 可以带参数
  5432. /// </summary>
  5433. /// <param name="files"></param>
  5434. /// <returns></returns>
  5435. [HttpPost]
  5436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5437. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5438. {
  5439. try
  5440. {
  5441. var TypeName = Request.Headers["TypeName"].ToString();
  5442. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5443. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5444. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5445. var filePahts = new List<string>();
  5446. foreach (var file in files)
  5447. {
  5448. //文件名称
  5449. string projectFileName = file.FileName;
  5450. //上传的文件的路径
  5451. string filePath = $"{fileDir}/{projectFileName}";
  5452. if (TypeName == "A")//A代表团组增减款项
  5453. {
  5454. if (!Directory.Exists(fileDir))
  5455. {
  5456. Directory.CreateDirectory(fileDir);
  5457. }
  5458. //上传的文件的路径
  5459. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5460. }
  5461. else if (TypeName == "B")//B代表商邀相关文件
  5462. {
  5463. if (!Directory.Exists(fileDir))
  5464. {
  5465. Directory.CreateDirectory(fileDir);
  5466. }
  5467. //上传的文件的路径
  5468. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5469. }
  5470. using (FileStream fs = System.IO.File.Create(filePath))
  5471. {
  5472. file.CopyTo(fs);
  5473. fs.Flush();
  5474. }
  5475. filePahts.Add(projectFileName);
  5476. }
  5477. return Ok(JsonView(true, "上传成功!", filePahts));
  5478. }
  5479. catch (Exception ex)
  5480. {
  5481. return Ok(JsonView(false, ex.Message));
  5482. }
  5483. }
  5484. #endregion
  5485. #region 商邀费用录入
  5486. /// <summary>
  5487. /// 根据团组Id查询商邀费用列表
  5488. /// </summary>
  5489. /// <param name="dto"></param>
  5490. /// <returns></returns>
  5491. [HttpPost]
  5492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5493. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5494. {
  5495. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5496. if (groupData.Code != 0)
  5497. {
  5498. return Ok(JsonView(false, groupData.Msg));
  5499. }
  5500. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5501. }
  5502. /// <summary>
  5503. /// 商邀费用列表
  5504. /// 下载文件
  5505. /// </summary>
  5506. /// <param name="id"></param>
  5507. /// <returns></returns>
  5508. [HttpGet("{id}")]
  5509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5510. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5511. {
  5512. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5513. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5514. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5515. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5516. var filePaths = new List<string>();
  5517. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5518. try
  5519. {
  5520. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5521. }
  5522. catch (Exception ex)
  5523. {
  5524. filePaths.Add(info.Attachment);
  5525. }
  5526. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5527. for (int i = 0; i < filePaths.Count; i++)
  5528. {
  5529. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5530. }
  5531. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5532. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5533. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5534. {
  5535. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5536. {
  5537. foreach (string filePath in filePaths)
  5538. {
  5539. if (System.IO.File.Exists(filePath))
  5540. {
  5541. // 获取文件名
  5542. string fileName = Path.GetFileName(filePath);
  5543. // 将文件添加到ZIP归档中
  5544. zipArchive.CreateEntryFromFile(filePath, fileName);
  5545. }
  5546. }
  5547. }
  5548. }
  5549. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5550. }
  5551. /// <summary>
  5552. /// 商邀费用 Info Page 基础数据源
  5553. /// </summary>
  5554. /// <returns></returns>
  5555. [HttpPost]
  5556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5557. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5558. {
  5559. try
  5560. {
  5561. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5562. if (groupData.Code != 0)
  5563. {
  5564. return Ok(JsonView(false, groupData.Msg));
  5565. }
  5566. return Ok(JsonView(true, "操作成功", groupData.Data));
  5567. }
  5568. catch (Exception ex)
  5569. {
  5570. return Ok(JsonView(false, ex.Message));
  5571. throw;
  5572. }
  5573. }
  5574. /// <summary>
  5575. /// 根据商邀费用ID查询C表和商邀费用数据
  5576. /// </summary>
  5577. /// <param name="dto"></param>
  5578. /// <returns></returns>
  5579. [HttpPost]
  5580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5581. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5582. {
  5583. try
  5584. {
  5585. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5586. if (groupData.Code != 0)
  5587. {
  5588. return Ok(JsonView(false, groupData.Msg));
  5589. }
  5590. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5591. }
  5592. catch (Exception ex)
  5593. {
  5594. return Ok(JsonView(false, ex.Message));
  5595. throw;
  5596. }
  5597. }
  5598. /// <summary>
  5599. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5600. /// </summary>
  5601. /// <param name="dto"></param>
  5602. /// <returns></returns>
  5603. [HttpPost]
  5604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5605. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5606. {
  5607. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5608. if (groupData.Code != 0)
  5609. {
  5610. return Ok(JsonView(false, groupData.Msg));
  5611. }
  5612. #region 应用推送
  5613. try
  5614. {
  5615. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5616. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5617. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5618. //2024-10-21 新增LZ UID
  5619. var userIds = new List<int>() { 21 };
  5620. string title = $"系统通知";
  5621. string content = "";
  5622. var diId = dto.DiId;
  5623. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5624. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5625. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5626. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5627. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5628. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5629. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5630. }
  5631. catch (Exception ex)
  5632. {
  5633. }
  5634. #endregion
  5635. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5636. }
  5637. /// <summary>
  5638. /// 商邀删除
  5639. /// </summary>
  5640. /// <param name="dto"></param>
  5641. /// <returns></returns>
  5642. [HttpPost]
  5643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5644. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5645. {
  5646. try
  5647. {
  5648. _sqlSugar.BeginTran();
  5649. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5650. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5651. {
  5652. IsDel = 1,
  5653. DeleteUserId = dto.DeleteUserId,
  5654. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5655. })
  5656. .Where(it => it.Id == dto.Id)
  5657. .ExecuteCommand();
  5658. if (res1 > 0)
  5659. {
  5660. int _diId = 0;
  5661. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5662. if (_ioaInfo != null)
  5663. {
  5664. _diId = _ioaInfo.DiId;
  5665. }
  5666. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5667. .SetColumns(a => new Grp_CreditCardPayment()
  5668. {
  5669. IsDel = 1,
  5670. DeleteUserId = dto.DeleteUserId,
  5671. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5672. })
  5673. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5674. .ExecuteCommand();
  5675. if (res2 > 0)
  5676. {
  5677. _sqlSugar.CommitTran();
  5678. return Ok(JsonView(true, "删除成功!"));
  5679. }
  5680. }
  5681. _sqlSugar.RollbackTran();
  5682. return Ok(JsonView(false, "删除失败"));
  5683. }
  5684. catch (Exception ex)
  5685. {
  5686. _sqlSugar.RollbackTran();
  5687. return Ok(JsonView(false, ex.Message));
  5688. }
  5689. }
  5690. #endregion
  5691. #region 票据上传
  5692. /// <summary>
  5693. /// 团组模块文件上传
  5694. /// </summary>
  5695. /// <param name="dto"></param>
  5696. /// <returns></returns>
  5697. [HttpPost]
  5698. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5699. {
  5700. var jw = JsonView(false);
  5701. long M = 1024 * 1024;
  5702. if (dto.Files == null || dto.Files.Count == 0)
  5703. {
  5704. jw.Msg = "无文件信息!";
  5705. return Ok(jw);
  5706. }
  5707. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5708. {
  5709. jw.Msg = "文件大小超过20M!";
  5710. return Ok(jw);
  5711. }
  5712. //var nameSp = dto.File.FileName.Split(".");
  5713. //if (nameSp.Length < 2)
  5714. //{
  5715. // jw.Msg = "拓展名称有误!";
  5716. // return Ok(jw);
  5717. //}
  5718. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5719. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5720. //{
  5721. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5722. // return Ok(jw);
  5723. //}
  5724. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5725. if (Ctable == null)
  5726. {
  5727. jw.Msg = "Ctable指向有误!";
  5728. return Ok(jw);
  5729. }
  5730. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5731. if (groupInfo == null)
  5732. {
  5733. jw.Msg = "团组信息不存在!";
  5734. return Ok(jw);
  5735. }
  5736. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5737. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5738. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5739. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5740. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5741. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5742. try
  5743. {
  5744. if (!Directory.Exists(fileBase))
  5745. {
  5746. Directory.CreateDirectory(fileBase);
  5747. }
  5748. var saveArr = new List<Grp_GroupModelFile>();
  5749. foreach (var fileStream in dto.Files)
  5750. {
  5751. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5752. var file = new Grp_GroupModelFile()
  5753. {
  5754. Cid = dto.Cid,
  5755. CreateTime = DateTime.Now,
  5756. CreateUserId = dto.Userid,
  5757. Ctable = dto.Ctable,
  5758. Diid = dto.Diid,
  5759. IsDel = 0,
  5760. FilePath = saveFilePath,
  5761. FileName = fileStream.FileName
  5762. };
  5763. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5764. {
  5765. fileStream.CopyTo(fs);
  5766. fs.Flush();
  5767. }
  5768. saveArr.Add(file);
  5769. }
  5770. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5771. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5772. jw = JsonView(true, "保存成功!", new
  5773. {
  5774. count = addResult,
  5775. filesName = saveArr.Select(x => x.FileName)
  5776. });
  5777. }
  5778. catch (Exception ex)
  5779. {
  5780. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5781. {
  5782. count = 0,
  5783. filesName = Array.Empty<string>(),
  5784. });
  5785. }
  5786. return Ok(jw);
  5787. }
  5788. /// <summary>
  5789. /// 查询各模块已保存文件
  5790. /// </summary>
  5791. /// <param name="dto"></param>
  5792. /// <returns></returns>
  5793. [HttpPost]
  5794. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5795. {
  5796. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5797. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5798. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5799. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5800. {
  5801. expression = Expressionable.Create<Grp_GroupModelFile>()
  5802. .And(x => visaIds.Contains(x.CreateUserId));
  5803. }
  5804. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5805. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5806. .Where(expression.ToExpression())
  5807. .ToList();
  5808. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5809. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5810. {
  5811. x.FileName,
  5812. x.Id,
  5813. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5814. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5815. })));
  5816. }
  5817. /// <summary>
  5818. /// 下载该团组下的所有文件
  5819. /// </summary>
  5820. /// <param name="dto"></param>
  5821. /// <returns></returns>
  5822. [HttpPost]
  5823. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5824. {
  5825. var jw = JsonView(false);
  5826. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5827. if (groupInfo == null)
  5828. {
  5829. jw.Msg = "团组信息不存在!";
  5830. return Ok(jw);
  5831. }
  5832. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5833. var isModule = Convert.ToBoolean(dto.isModule);
  5834. var Zips = new Dictionary<string, Stream>();
  5835. var io = new IOOperatorHelper();
  5836. if (isModule)
  5837. {
  5838. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5839. foreach (var moduleArr in moduleGroup)
  5840. {
  5841. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5842. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5843. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5844. var chiZips = new Dictionary<string, Stream>();
  5845. foreach (var item in moduleArr)
  5846. {
  5847. if (System.IO.File.Exists(item.FilePath))
  5848. {
  5849. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5850. {
  5851. byte[] bytes = new byte[fileStream.Length];
  5852. fileStream.Read(bytes, 0, bytes.Length);
  5853. fileStream.Close();
  5854. Stream stream = new MemoryStream(bytes);
  5855. chiZips.Add(item.FileName, stream);
  5856. }
  5857. }
  5858. }
  5859. if (chiZips.Count > 0)
  5860. {
  5861. var byts = io.ConvertZipStream(chiZips);
  5862. Stream stream = new MemoryStream(byts);
  5863. Zips.Add(key.Name + "_.zip", stream);
  5864. }
  5865. }
  5866. }
  5867. else
  5868. {
  5869. foreach (var item in dbQuery)
  5870. {
  5871. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5872. {
  5873. byte[] bytes = new byte[fileStream.Length];
  5874. fileStream.Read(bytes, 0, bytes.Length);
  5875. fileStream.Close();
  5876. var stream = new MemoryStream(bytes);
  5877. while (Zips.ContainsKey(item.FileName))
  5878. {
  5879. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5880. }
  5881. Zips.Add(item.FileName, stream);
  5882. }
  5883. }
  5884. }
  5885. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5886. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5887. if (Zips.Count > 0)
  5888. {
  5889. var byts = io.ConvertZipStream(Zips);
  5890. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5891. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5892. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5893. }
  5894. else
  5895. {
  5896. jw.Msg = "暂无生成文件!";
  5897. }
  5898. return Ok(jw);
  5899. }
  5900. /// <summary>
  5901. /// 下载该团组下此模块的所有文件
  5902. /// </summary>
  5903. /// <param name="dto"></param>
  5904. /// <returns></returns>
  5905. [HttpPost]
  5906. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5907. {
  5908. var jw = JsonView(false);
  5909. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5910. if (groupInfo == null)
  5911. {
  5912. jw.Msg = "团组信息不存在!";
  5913. return Ok(jw);
  5914. }
  5915. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5916. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5917. && x.IsDel == 0);
  5918. if (key == null)
  5919. {
  5920. jw.Msg = "Ctable指向错误!";
  5921. return Ok(jw);
  5922. }
  5923. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5924. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5925. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5926. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5927. var io = new IOOperatorHelper();
  5928. var Zips = new Dictionary<string, Stream>();
  5929. foreach (var item in dbQuery)
  5930. {
  5931. if (System.IO.File.Exists(item.FilePath))
  5932. {
  5933. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5934. {
  5935. byte[] bytes = new byte[fileStream.Length];
  5936. fileStream.Read(bytes, 0, bytes.Length);
  5937. fileStream.Close();
  5938. var stream = new MemoryStream(bytes);
  5939. while (Zips.ContainsKey(item.FileName))
  5940. {
  5941. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5942. }
  5943. Zips.Add(item.FileName, stream);
  5944. }
  5945. }
  5946. }
  5947. if (Zips.Count > 0)
  5948. {
  5949. var byts = io.ConvertZipStream(Zips);
  5950. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5951. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5952. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5953. }
  5954. else
  5955. {
  5956. jw.Msg = "暂无生成文件!";
  5957. }
  5958. return Ok(jw);
  5959. }
  5960. /// <summary>
  5961. /// 删除该团组下的指定文件
  5962. /// </summary>
  5963. /// <param name="dto"></param>
  5964. /// <returns></returns>
  5965. [HttpPost]
  5966. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5967. {
  5968. var jw = JsonView(false);
  5969. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5970. if (sing == null)
  5971. {
  5972. jw.Msg = "暂无";
  5973. return Ok(jw);
  5974. }
  5975. if (System.IO.File.Exists(sing.FilePath))
  5976. {
  5977. try
  5978. {
  5979. System.IO.File.Delete(sing.FilePath);
  5980. }
  5981. catch (Exception ex)
  5982. {
  5983. jw.Msg = "删除失败!" + ex.Message;
  5984. return Ok(jw);
  5985. }
  5986. }
  5987. sing.IsDel = 1;
  5988. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5989. sing.DeleteUserId = dto.UserId;
  5990. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5991. jw = JsonView(true, "删除成功!");
  5992. return Ok(jw);
  5993. }
  5994. #endregion
  5995. #region 共享文件上传
  5996. /// <summary>
  5997. /// 共享文件数据初始化
  5998. /// </summary>
  5999. /// <returns></returns>
  6000. [HttpGet]
  6001. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  6002. {
  6003. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  6004. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  6005. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  6006. .Select(x => x.Id)
  6007. .ToList()
  6008. .Contains(userid);
  6009. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  6010. .Where(x => x.STid == 111 && x.IsDel == 0)
  6011. .Select(x => new
  6012. {
  6013. x.Name,
  6014. x.Id,
  6015. }).ToList();
  6016. if (isMarketingDepartment)
  6017. {
  6018. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  6019. }
  6020. if (portType == 1)
  6021. {
  6022. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  6023. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  6024. .Where(x => x.IsDel == 0)
  6025. .OrderByDescending(x => x.VisitDate)
  6026. .Select(x => new
  6027. {
  6028. x.TeamName,
  6029. x.Id,
  6030. x.CityId,
  6031. })
  6032. .ToList()
  6033. .Select(x =>
  6034. {
  6035. var provinceId = x.CityId;
  6036. var isDefualtVal = true;
  6037. if (provinceId > 0)
  6038. {
  6039. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  6040. if (parentId != null)
  6041. {
  6042. isDefualtVal = false;
  6043. provinceId = (int)parentId;
  6044. }
  6045. }
  6046. if (isDefualtVal)
  6047. {
  6048. provinceId = 122; //默认四川
  6049. }
  6050. return new
  6051. {
  6052. x.TeamName,
  6053. x.Id,
  6054. provinceId,
  6055. };
  6056. })
  6057. .ToList();
  6058. return Ok(JsonView(true, "SUCCESS!", new
  6059. {
  6060. dropDownType,
  6061. dropDownGroupList,
  6062. isMarketingDepartment
  6063. }));
  6064. }
  6065. else if (portType == 2 || portType == 3)
  6066. {
  6067. return Ok(JsonView(true, "SUCCESS!", new
  6068. {
  6069. dropDownType,
  6070. isMarketingDepartment
  6071. }));
  6072. }
  6073. else
  6074. {
  6075. return Ok(JsonView(false, "portType有误!"));
  6076. }
  6077. }
  6078. /// <summary>
  6079. /// 共享文件上传
  6080. /// </summary>
  6081. /// <param name="dto"></param>
  6082. /// <returns></returns>
  6083. [HttpPost]
  6084. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  6085. {
  6086. var isGroup = new List<int> { 1412 };
  6087. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  6088. {
  6089. return Ok(JsonView(false, "该文件需要关联团组!"));
  6090. }
  6091. if (dto.Files == null || dto.Files.Count == 0)
  6092. {
  6093. return Ok(JsonView(false, "无文件信息!"));
  6094. }
  6095. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6096. {
  6097. return Ok(JsonView(false, "文件大小超过20M!"));
  6098. }
  6099. if (dto.Userid < 1)
  6100. {
  6101. return Ok(JsonView(false, "请传入有效的Userid!"));
  6102. }
  6103. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6104. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6105. .Select((u, j) => new
  6106. {
  6107. u.CnName,
  6108. UserId = u.Id,
  6109. j.JobName,
  6110. })
  6111. .First();
  6112. if (jobInfo == null)
  6113. {
  6114. return Ok(JsonView(false, "请传入有效的Userid!"));
  6115. }
  6116. var commonFileExtensions = new List<string>
  6117. {
  6118. // 文本文件
  6119. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6120. // 图片文件
  6121. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6122. // 视频文件
  6123. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6124. // 音频文件
  6125. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6126. // 压缩文件
  6127. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6128. // 数据文件
  6129. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6130. };
  6131. try
  6132. {
  6133. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6134. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6135. commonFileExtensions.AddRange(settingExtend);
  6136. }
  6137. catch (Exception)
  6138. { }
  6139. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6140. if (setdata == null)
  6141. {
  6142. return Ok(JsonView(false, "请传入有效的FileType!"));
  6143. }
  6144. var insertList = new List<Grp_GroupShareFile>();
  6145. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6146. if (!Directory.Exists(winPath))
  6147. {
  6148. Directory.CreateDirectory(winPath);
  6149. }
  6150. foreach (var item in dto.Files)
  6151. {
  6152. var houzui = Path.GetExtension(item.FileName);
  6153. if (!commonFileExtensions.Contains(houzui))
  6154. {
  6155. return Ok(JsonView(false, "未知后缀名称!"));
  6156. }
  6157. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6158. var saveFilePath = winPath + fileName;
  6159. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6160. {
  6161. item.CopyTo(fs);
  6162. fs.Flush();
  6163. }
  6164. var fileDetail = new Grp_GroupShareFile()
  6165. {
  6166. CreateUserId = dto.Userid,
  6167. CreateTime = DateTime.Now,
  6168. UploadJob = jobInfo.JobName,
  6169. FileName = fileName,
  6170. FileType = dto.FileType,
  6171. Diid = dto.Diid,
  6172. FilePath = winPath + fileName,
  6173. };
  6174. insertList.Add(fileDetail);
  6175. }
  6176. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6177. return Ok(JsonView(true, "保存成功!"));
  6178. }
  6179. /// <summary>
  6180. /// 查询共享文件列表
  6181. /// </summary>
  6182. /// <param name="dto"></param>
  6183. /// <returns></returns>
  6184. [HttpPost]
  6185. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6186. {
  6187. var isGroup = new List<int> { 1412 };
  6188. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6189. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6190. .And(x => x.Diid == dto.Diid)
  6191. .And(x => x.FileType == dto.FileType)
  6192. .And(x => x.IsDel == 0)
  6193. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6194. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  6195. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  6196. int totalCount = 0;
  6197. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  6198. .Where(queryExpression.ToExpression())
  6199. .OrderBy(x => x.UploadJob)
  6200. .Select(x => new
  6201. {
  6202. x.Id,
  6203. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  6204. x.FileName,
  6205. x.FileType,
  6206. x.CreateTime,
  6207. })
  6208. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6209. return Ok(JsonView(true, "SUCCESS!", new
  6210. {
  6211. FileList = dbQuery,
  6212. dto.PageSize,
  6213. dto.PageIndex,
  6214. totalCount
  6215. }));
  6216. }
  6217. /// <summary>
  6218. /// 删除共享文件模块下的指定文件
  6219. /// </summary>
  6220. /// <param name="dto"></param>
  6221. /// <returns></returns>
  6222. [HttpPost]
  6223. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6224. {
  6225. var jw = JsonView(false);
  6226. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6227. if (sing == null)
  6228. {
  6229. jw.Msg = "暂无文件信息!";
  6230. return Ok(jw);
  6231. }
  6232. if (sing.CreateUserId != dto.UserId)
  6233. {
  6234. jw.Msg = "只能删除自己上传的文件!";
  6235. return Ok(jw);
  6236. }
  6237. if (System.IO.File.Exists(sing.FilePath))
  6238. {
  6239. try
  6240. {
  6241. System.IO.File.Delete(sing.FilePath);
  6242. }
  6243. catch (Exception ex)
  6244. {
  6245. jw.Msg = "删除失败!" + ex.Message;
  6246. return Ok(jw);
  6247. }
  6248. }
  6249. sing.IsDel = 1;
  6250. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6251. sing.DeleteUserId = dto.UserId;
  6252. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6253. jw = JsonView(true, "删除成功!");
  6254. return Ok(jw);
  6255. }
  6256. #endregion
  6257. #region 团组英文资料
  6258. /// <summary>
  6259. /// 查询团组英文所有资料
  6260. /// </summary>
  6261. /// <param name="dto"></param>
  6262. /// <returns></returns>
  6263. [HttpPost]
  6264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6265. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6266. {
  6267. try
  6268. {
  6269. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6270. if (groupData.Code != 0)
  6271. {
  6272. return Ok(JsonView(false, groupData.Msg));
  6273. }
  6274. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6275. }
  6276. catch (Exception ex)
  6277. {
  6278. return Ok(JsonView(false, ex.Message));
  6279. throw;
  6280. }
  6281. }
  6282. /// <summary>
  6283. /// 团组英文资料操作(Status:1.新增,2.修改)
  6284. /// </summary>
  6285. /// <param name="dto"></param>
  6286. /// <returns></returns>
  6287. [HttpPost]
  6288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6289. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6290. {
  6291. try
  6292. {
  6293. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6294. if (groupData.Code != 0)
  6295. {
  6296. return Ok(JsonView(false, groupData.Msg));
  6297. }
  6298. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6299. }
  6300. catch (Exception ex)
  6301. {
  6302. return Ok(JsonView(false, ex.Message));
  6303. throw;
  6304. }
  6305. }
  6306. /// <summary>
  6307. /// 团组英文资料Id查询数据
  6308. /// </summary>
  6309. /// <param name="dto"></param>
  6310. /// <returns></returns>
  6311. [HttpPost]
  6312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6313. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6314. {
  6315. try
  6316. {
  6317. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6318. if (_DelegationEnData != null)
  6319. {
  6320. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6321. }
  6322. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6323. }
  6324. catch (Exception ex)
  6325. {
  6326. return Ok(JsonView(false, "程序错误!"));
  6327. throw;
  6328. }
  6329. }
  6330. /// <summary>
  6331. /// 团组英文资料删除
  6332. /// </summary>
  6333. /// <param name="dto"></param>
  6334. /// <returns></returns>
  6335. [HttpPost]
  6336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6337. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6338. {
  6339. try
  6340. {
  6341. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6342. if (!res)
  6343. {
  6344. return Ok(JsonView(false, "删除失败"));
  6345. }
  6346. return Ok(JsonView(true, "删除成功!"));
  6347. }
  6348. catch (Exception ex)
  6349. {
  6350. return Ok(JsonView(false, ex.Message));
  6351. throw;
  6352. }
  6353. }
  6354. #endregion
  6355. #region 导出邀请函
  6356. /// <summary>
  6357. /// 导出邀请函页面初始化
  6358. /// </summary>
  6359. /// <param name="dto"></param>
  6360. /// <returns></returns>
  6361. [HttpPost]
  6362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6363. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6364. {
  6365. try
  6366. {
  6367. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6368. var crm_Deles = new List<Crm_DeleClient>();
  6369. if (dto.DiId == 0)
  6370. {
  6371. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6372. }
  6373. else
  6374. {
  6375. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6376. }
  6377. return Ok(JsonView(true, "查询成功!", new
  6378. {
  6379. deleClient = crm_Deles,
  6380. delegations = grp_Delegations
  6381. }));
  6382. }
  6383. catch (Exception ex)
  6384. {
  6385. return Ok(JsonView(false, "程序错误!"));
  6386. throw;
  6387. }
  6388. }
  6389. /// <summary>
  6390. /// 导出邀请函
  6391. /// </summary>
  6392. /// <param name="dto"></param>
  6393. /// <returns></returns>
  6394. [HttpPost]
  6395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6396. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6397. {
  6398. #region 参数验证
  6399. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6400. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6401. #endregion
  6402. try
  6403. {
  6404. var transDic = new Dictionary<string, string>();
  6405. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6406. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6407. From Grp_TourClientList tcl
  6408. Left Join
  6409. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6410. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6411. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6412. From Crm_DeleClient dc
  6413. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6414. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6415. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6416. Where dc.IsDel = 0) temp
  6417. On temp.DcId =tcl.ClientId
  6418. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6419. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6420. var texts = new List<string>();
  6421. if (datas.Count != 0)
  6422. {
  6423. foreach (TourClientListDetailsView item in datas)
  6424. {
  6425. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6426. {
  6427. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6428. }
  6429. else
  6430. {
  6431. string name = item.LastName + item.FirstName;
  6432. texts.Add(name);
  6433. }
  6434. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6435. {
  6436. if (!transDic.ContainsKey(item.Job))
  6437. {
  6438. texts.Add(item.Job);
  6439. }
  6440. }
  6441. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6442. {
  6443. texts.Add(item.CompanyFullName);
  6444. }
  6445. }
  6446. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6447. if (transData.Count > 0)
  6448. {
  6449. foreach (TranslateResult item in transData)
  6450. {
  6451. if (!transDic.ContainsKey(item.Query))
  6452. {
  6453. transDic.Add(item.Query, item.Translation);
  6454. }
  6455. }
  6456. }
  6457. var list = new List<GuestList>();
  6458. foreach (var dele in datas)
  6459. {
  6460. var guestList = new GuestList();
  6461. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6462. {
  6463. guestList.Name = dele.Pinyin;
  6464. }
  6465. else
  6466. {
  6467. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6468. guestList.Name = Name;
  6469. }
  6470. if (dele.Sex == 0)
  6471. {
  6472. guestList.Sex = "Male";
  6473. }
  6474. else if (dele.Sex == 1)
  6475. {
  6476. guestList.Sex = "Female";
  6477. }
  6478. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6479. if (!string.IsNullOrEmpty(dele.Job))
  6480. {
  6481. guestList.Job = dele.Job;
  6482. }
  6483. list.Add(guestList);
  6484. }
  6485. //载入模板
  6486. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6487. var builder = new DocumentBuilder(doc);
  6488. //获取word里所有表格
  6489. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6490. //获取所填表格的序数
  6491. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6492. var rowStart = tableOne.Rows[0]; //获取第1行
  6493. //循环赋值
  6494. for (int i = 0; i < list.Count; i++)
  6495. {
  6496. builder.MoveToCell(0, i + 1, 0, 0);
  6497. builder.Write(list[i].Name.ToString());
  6498. builder.MoveToCell(0, i + 1, 1, 0);
  6499. builder.Write(list[i].Sex.ToString());
  6500. builder.MoveToCell(0, i + 1, 2, 0);
  6501. builder.Write(list[i].DOB.ToString());
  6502. builder.MoveToCell(0, i + 1, 3, 0);
  6503. builder.Write(list[i].Job.ToString());
  6504. }
  6505. //删除多余行
  6506. while (tableOne.Rows.Count > list.Count + 1)
  6507. {
  6508. tableOne.Rows.RemoveAt(list.Count + 1);
  6509. }
  6510. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6511. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6512. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6513. doc.Save(filePath);
  6514. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6515. return Ok(JsonView(true, "操作成功!", Url));
  6516. }
  6517. else
  6518. {
  6519. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6520. }
  6521. }
  6522. catch (Exception ex)
  6523. {
  6524. return Ok(JsonView(false, ex.Message));
  6525. throw;
  6526. }
  6527. }
  6528. #endregion
  6529. #region 团组经理模块 出入境费用
  6530. /// <summary>
  6531. /// 团组模块 - 出入境费用 - 省份基础数据源
  6532. /// </summary>
  6533. /// <returns></returns>
  6534. [HttpGet]
  6535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6536. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6537. {
  6538. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6539. }
  6540. /// <summary>
  6541. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6542. /// </summary>
  6543. /// <param name="dto"></param>
  6544. /// <returns></returns>
  6545. [HttpPost]
  6546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6547. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6548. {
  6549. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6550. var groupNamFirst = groupNameData.FirstOrDefault();
  6551. //SetDataInfoView
  6552. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6553. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6554. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6555. //验证城市归属并给默认值
  6556. int provinceId = 122;
  6557. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6558. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6559. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6560. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6561. return Ok(JsonView(true, "查询成功!", new
  6562. {
  6563. GroupNameData = groupNameData,
  6564. CurrencyData = _CurrencyData,
  6565. WordTypeData = wordTypeData,
  6566. ExcelTypeData = excelTypeData,
  6567. CurrencyInit = _currencyInfos,
  6568. ViewPermissionData = viewPermissionData
  6569. }));
  6570. }
  6571. /// <summary>
  6572. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6573. /// </summary>
  6574. /// <returns></returns>
  6575. [HttpGet("{provinceId}")]
  6576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6577. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6578. {
  6579. //验证城市归属并给默认值
  6580. if (provinceId < 1) provinceId = 122;
  6581. /*
  6582. * 122 四川
  6583. * 108 贵州
  6584. * 103 重庆
  6585. * 132 云南
  6586. */
  6587. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6588. return Ok(JsonView(true, "查询成功!", new
  6589. {
  6590. WordTypeData = wordTypeData,
  6591. ExcelTypeData = excelTypeData,
  6592. }));
  6593. }
  6594. /// <summary>
  6595. /// 团组模块 - 出入境费用
  6596. /// 实时汇率 tips
  6597. /// 签证费用 tips
  6598. /// 机票费用 tips
  6599. /// </summary>
  6600. /// <returns></returns>
  6601. [HttpPost]
  6602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6603. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6604. {
  6605. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6606. //默认币种显示
  6607. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6608. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6609. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6610. return Ok(JsonView(true, "查询成功!", new
  6611. {
  6612. //GroupNameData = groupNameData.Data,
  6613. visaData = visaData.Data,
  6614. airData,
  6615. reteInfos
  6616. }));
  6617. }
  6618. /// <summary>
  6619. /// 团组模块 - 出入境费用 - Info
  6620. /// </summary>
  6621. /// <param name="dto"></param>
  6622. /// <returns></returns>
  6623. [HttpPost]
  6624. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6626. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6627. {
  6628. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6629. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6630. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6631. }
  6632. /// <summary>
  6633. /// 团组模块 - 出入境费用 - 设置view权限
  6634. /// </summary>
  6635. /// <returns></returns>
  6636. [HttpPost]
  6637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6638. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6639. {
  6640. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6641. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6642. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6643. var permissions = new List<Grp_EnterExitCostPermission>();
  6644. foreach (var userId in dto.UserIds)
  6645. {
  6646. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6647. }
  6648. if (permissions.Any())
  6649. {
  6650. _sqlSugar.BeginTran();
  6651. try
  6652. {
  6653. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6654. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6655. if (result < 1)
  6656. {
  6657. _sqlSugar.RollbackTran();
  6658. return Ok(JsonView(false));
  6659. }
  6660. }
  6661. catch (Exception ex)
  6662. {
  6663. _sqlSugar.RollbackTran();
  6664. return Ok(JsonView(false, ex.Message));
  6665. }
  6666. _sqlSugar.CommitTran();
  6667. return Ok(JsonView(true));
  6668. }
  6669. return Ok(JsonView(false));
  6670. }
  6671. /// <summary>
  6672. /// 团组模块 - 出入境费用 - Add And Update
  6673. /// </summary>
  6674. /// <returns></returns>
  6675. [HttpPost]
  6676. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6678. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6679. {
  6680. try
  6681. {
  6682. var rateRecords = new List<RateRecordInfo>();
  6683. #region 汇率保存前存储
  6684. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  6685. if (info != null)
  6686. {
  6687. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  6688. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  6689. {
  6690. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  6691. {
  6692. CurrencyCode = x.CurrencyCode,
  6693. CurrencyName = x.CurrencyName,
  6694. UpdatePreRate = x.Rate,
  6695. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  6696. }).ToList();
  6697. }
  6698. else
  6699. {
  6700. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6701. {
  6702. CurrencyCode = x.CurrencyCode,
  6703. CurrencyName = x.CurrencyName,
  6704. UpdatePreRate = 0.00M,
  6705. UpdateBreRate = x.Rate
  6706. }).ToList();
  6707. }
  6708. }
  6709. else
  6710. {
  6711. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6712. {
  6713. CurrencyCode = x.CurrencyCode,
  6714. CurrencyName = x.CurrencyName,
  6715. UpdatePreRate = 0.00M,
  6716. UpdateBreRate = x.Rate
  6717. }).ToList();
  6718. }
  6719. #endregion
  6720. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6721. if (dto.DayOtherPriceData.Any())
  6722. {
  6723. var inserList = dto.DayOtherPriceData
  6724. .Where(x => x.Id == 0)
  6725. .Select(x => new Grp_DayOtherPrice
  6726. {
  6727. Cost = x.Cost,
  6728. Id = x.Id,
  6729. CreateTime = DateTime.Now,
  6730. CreateUserId = dto.UserId,
  6731. Currency = x.Currency,
  6732. Diid = x.DiId,
  6733. Index = x.Index,
  6734. IsDel = 0,
  6735. SetDataId = x.SetDataId,
  6736. SubTotal = x.SubTotal,
  6737. Remark = x.Remark
  6738. })
  6739. .ToList();
  6740. var updateList = dto.DayOtherPriceData
  6741. .Where(x => x.Id != 0)
  6742. .Select(x => new Grp_DayOtherPrice
  6743. {
  6744. Cost = x.Cost,
  6745. Id = x.Id,
  6746. CreateTime = DateTime.Now,
  6747. CreateUserId = dto.UserId,
  6748. Currency = x.Currency,
  6749. Diid = x.DiId,
  6750. Index = x.Index,
  6751. IsDel = 0,
  6752. SetDataId = x.SetDataId,
  6753. SubTotal = x.SubTotal,
  6754. Remark = x.Remark
  6755. })
  6756. .ToList();
  6757. //添加
  6758. _sqlSugar.BeginTran();
  6759. if (inserList.Any())
  6760. {
  6761. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6762. }
  6763. if (updateList.Any())
  6764. {
  6765. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6766. }
  6767. _sqlSugar.CommitTran();
  6768. }
  6769. if (data.Code != 0)
  6770. {
  6771. return Ok(JsonView(false, data.Msg));
  6772. }
  6773. //生成默认文件pdf并且通知人员
  6774. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6775. {
  6776. DiId = dto.DiId,
  6777. ExportType = 1,
  6778. SubTypeId = 1005
  6779. }, "pdf");
  6780. //发送通知
  6781. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6782. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6783. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6784. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6785. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6786. //汇率信息记录
  6787. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6788. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  6789. //汇率验证、反推
  6790. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  6791. if (isSendMsg)
  6792. {
  6793. //消息推送
  6794. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  6795. }
  6796. #region //日志汇率记录
  6797. //按照已使用币种记录
  6798. if (checkCurrencys != null && checkCurrencys.Count > 0)
  6799. {
  6800. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  6801. //汇率记录中加入实时汇率
  6802. if (liveRates != null && liveRates.Count > 0)
  6803. {
  6804. foreach (var item in rateRecords)
  6805. {
  6806. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  6807. }
  6808. }
  6809. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  6810. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  6811. var logContent = new StringBuilder();
  6812. foreach (var item in rateRecords)
  6813. {
  6814. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  6815. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  6816. logContent.AppendLine(msg);
  6817. }
  6818. _eec_textLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】\r\n{logContent}", teamName, dto.DiId, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logContent.ToString());
  6819. }
  6820. #endregion
  6821. return Ok(JsonView(true, data.Msg, data.Data));
  6822. }
  6823. catch (Exception ex)
  6824. {
  6825. return Ok(JsonView(false, ex.Message));
  6826. }
  6827. }
  6828. /// <summary>
  6829. /// 团组模块 - 出入境费用 - Confirm 费用
  6830. /// </summary>
  6831. /// <returns></returns>
  6832. [HttpPost]
  6833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6834. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6835. {
  6836. //TODO:测试完毕需把对应的用户ID更改
  6837. //1、数据表添加字段
  6838. //2、更改字段接口()
  6839. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6840. //3、确认成功 给财务发送消息
  6841. if (_view.Code == 200)
  6842. {
  6843. if (dto.Type == 1)
  6844. {
  6845. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6846. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6847. }
  6848. }
  6849. return Ok(_view);
  6850. }
  6851. /// <summary>
  6852. /// 团组模块 - 出入境费用 - File download
  6853. /// </summary>
  6854. /// <param name="dto"></param>
  6855. /// <returns></returns>
  6856. [HttpPost]
  6857. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6859. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6860. {
  6861. try
  6862. {
  6863. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6864. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6865. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6866. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6867. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6868. 3 团组成员名单 1 团组成员名单", ""));
  6869. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6870. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6871. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6872. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6873. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6874. //数据源
  6875. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6876. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6877. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6878. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6879. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6880. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6881. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6882. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6883. .Select((x, a, b) => new
  6884. {
  6885. x.Index,
  6886. itemName = a.Name,
  6887. CurrencyStr = b.Name,
  6888. x.Cost,
  6889. x.SubTotal,
  6890. x.Remark
  6891. })
  6892. .OrderBy((x) => x.Index)
  6893. .ToList(); //其他款项费用
  6894. var peiceItemCurrencys = new List<string>();
  6895. if (_DayAndCosts.Any())
  6896. {
  6897. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6898. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6899. }
  6900. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6901. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6902. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6903. {
  6904. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6905. }
  6906. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6907. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6908. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6909. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6910. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6911. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6912. .Select((tcl, dc, cc) => new ClientInfo
  6913. {
  6914. LastName = dc.LastName,
  6915. FirstName = dc.FirstName,
  6916. Sex = dc.Sex,
  6917. Birthday = dc.BirthDay,
  6918. Company = cc.CompanyFullName,
  6919. Job = dc.Job
  6920. })
  6921. .ToList();
  6922. foreach (var item in DeleClientList)
  6923. {
  6924. EncryptionProcessor.DecryptProperties(item);
  6925. }
  6926. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6927. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6928. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6929. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6930. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6931. if (dto.ExportType == 1) //明细表
  6932. {
  6933. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6934. {
  6935. //获取模板
  6936. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6937. //载入模板
  6938. var doc = new Document(tempPath);
  6939. var builder = new DocumentBuilder(doc);
  6940. var dic = new Dictionary<string, string>();
  6941. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6942. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6943. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6944. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6945. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6946. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6947. //境内费用(其他费用)
  6948. if (_EnterExitCosts.ChoiceOne == 1)
  6949. {
  6950. string row1_1 = "";
  6951. if (_EnterExitCosts.Visa > 0)
  6952. {
  6953. //insidePayTotal += _EnterExitCosts.Visa;
  6954. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  6955. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6956. //{
  6957. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6958. //}
  6959. }
  6960. string row1_2 = "";
  6961. if (_EnterExitCosts.YiMiao > 0)
  6962. {
  6963. //insidePayTotal += _EnterExitCosts.YiMiao;
  6964. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  6965. }
  6966. if (_EnterExitCosts.HeSuan > 0)
  6967. {
  6968. //insidePayTotal += _EnterExitCosts.HeSuan;
  6969. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  6970. }
  6971. if (_EnterExitCosts.Service > 0)
  6972. {
  6973. //insidePayTotal += _EnterExitCosts.Service;
  6974. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  6975. }
  6976. string row1_3 = "";
  6977. if (_EnterExitCosts.Safe > 0)
  6978. {
  6979. //insidePayTotal += _EnterExitCosts.Safe;
  6980. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  6981. }
  6982. if (_EnterExitCosts.Ticket > 0)
  6983. {
  6984. //insidePayTotal += _EnterExitCosts.Ticket;
  6985. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  6986. }
  6987. string row1 = "";
  6988. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6989. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6990. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6991. row1 += $"备注:{_EnterExitCosts.Remark}";
  6992. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6993. dic.Add("Row1Str", row1);
  6994. }
  6995. string airTotalStr = string.Empty,
  6996. airPriceStr = string.Empty;
  6997. //经济舱
  6998. if (_EnterExitCosts.SumJJC == 1)
  6999. {
  7000. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  7001. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  7002. }
  7003. //公务舱
  7004. if (_EnterExitCosts.SumGWC == 1)
  7005. {
  7006. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  7007. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  7008. }
  7009. //头等舱
  7010. if (_EnterExitCosts.SumTDC == 1)
  7011. {
  7012. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  7013. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  7014. }
  7015. //汇率描述
  7016. string rateStr = "";
  7017. if (peiceItemCurrencyInfos.Any())
  7018. {
  7019. rateStr = "\r\n汇率描述:";
  7020. foreach (var item in peiceItemCurrencyInfos)
  7021. {
  7022. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  7023. }
  7024. }
  7025. string twoItemRemark = "备注:";
  7026. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7027. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7028. dic.Add("AirTotalStr", airTotalStr);
  7029. dic.Add("AirPriceStr", airPriceStr);
  7030. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7031. dic.Add("TwoItemRemark", twoItemRemark);
  7032. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7033. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7034. int table1Row = 0,
  7035. table2Row = 0,
  7036. table3Row = 0,
  7037. table4Row = 0,
  7038. table5Row = 0;
  7039. //住宿费
  7040. if (_EnterExitCosts.ChoiceThree == 1)
  7041. {
  7042. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7043. table1Row = dac1.Count;
  7044. #region 填充word表格内容
  7045. for (int i = 0; i < dac1.Count; i++)
  7046. {
  7047. Grp_DayAndCost dac = dac1[i];
  7048. if (dac == null) continue;
  7049. builder.MoveToCell(0, i, 0, 0);
  7050. builder.Write("第" + dac.Days.ToString() + "晚:");
  7051. builder.MoveToCell(0, i, 1, 0);
  7052. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7053. //builder.Write(dac.Place == null ? "" : dac.Place);
  7054. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7055. builder.MoveToCell(0, i, 2, 0);
  7056. builder.Write("费用标准:");
  7057. string curr = "";
  7058. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7059. if (currData != null)
  7060. {
  7061. curr = currData.Name;
  7062. }
  7063. builder.MoveToCell(0, i, 3, 0);
  7064. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7065. builder.MoveToCell(0, i, 4, 0);
  7066. builder.Write("费用小计:");
  7067. builder.MoveToCell(0, i, 5, 0);
  7068. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7069. }
  7070. #endregion
  7071. }
  7072. else dic.Add("SubZS", "0.00");
  7073. //删除多余行
  7074. while (table1.Rows.Count > table1Row)
  7075. {
  7076. table1.Rows.RemoveAt(table1Row);
  7077. }
  7078. //伙食费
  7079. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7080. if (_EnterExitCosts.ChoiceFour == 1)
  7081. {
  7082. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7083. table2Row = dac2.Count;
  7084. #region 填充word表格内容
  7085. for (int i = 0; i < dac2.Count; i++)
  7086. {
  7087. Grp_DayAndCost dac = dac2[i];
  7088. if (dac == null) continue;
  7089. builder.MoveToCell(1, i, 0, 0);
  7090. builder.Write("第" + dac.Days.ToString() + "天:");
  7091. builder.MoveToCell(1, i, 1, 0);
  7092. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7093. builder.MoveToCell(1, i, 2, 0);
  7094. builder.Write("费用标准:");
  7095. string curr = "";
  7096. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7097. if (currData != null)
  7098. {
  7099. curr = currData.Name;
  7100. }
  7101. builder.MoveToCell(1, i, 3, 0);
  7102. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7103. builder.MoveToCell(1, i, 4, 0);
  7104. builder.Write("费用小计:");
  7105. builder.MoveToCell(1, i, 5, 0);
  7106. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7107. }
  7108. #endregion
  7109. }
  7110. else dic.Add("SubHS", "0.00");
  7111. //删除多余行
  7112. while (table2.Rows.Count > table2Row)
  7113. {
  7114. table2.Rows.RemoveAt(table2Row);
  7115. }
  7116. //公杂费
  7117. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7118. if (_EnterExitCosts.ChoiceFive == 1)
  7119. {
  7120. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7121. table3Row = dac3.Count;
  7122. #region 填充word表格内容
  7123. for (int i = 0; i < dac3.Count; i++)
  7124. {
  7125. Grp_DayAndCost dac = dac3[i];
  7126. if (dac == null) continue;
  7127. builder.MoveToCell(2, i, 0, 0);
  7128. builder.Write("第" + dac.Days.ToString() + "天:");
  7129. builder.MoveToCell(2, i, 1, 0);
  7130. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7131. builder.MoveToCell(2, i, 2, 0);
  7132. builder.Write("费用标准:");
  7133. string curr = "";
  7134. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7135. if (currData != null)
  7136. {
  7137. curr = currData.Name;
  7138. }
  7139. builder.MoveToCell(2, i, 3, 0);
  7140. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7141. builder.MoveToCell(2, i, 4, 0);
  7142. builder.Write("费用小计:");
  7143. builder.MoveToCell(2, i, 5, 0);
  7144. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7145. }
  7146. //删除多余行
  7147. while (table3.Rows.Count > table3Row)
  7148. {
  7149. table3.Rows.RemoveAt(table3Row);
  7150. }
  7151. #endregion
  7152. }
  7153. else dic.Add("SubGZF", "0.00");
  7154. //删除多余行
  7155. while (table3.Rows.Count > table3Row)
  7156. {
  7157. table3.Rows.RemoveAt(table3Row);
  7158. }
  7159. //培训费
  7160. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7161. if (_EnterExitCosts.ChoiceSix == 1)
  7162. {
  7163. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7164. dic.Add("SubPX", pxStr);
  7165. table4Row = dac4.Count;
  7166. #region 填充word表格内容
  7167. for (int i = 0; i < dac4.Count; i++)
  7168. {
  7169. Grp_DayAndCost dac = dac4[i];
  7170. if (dac == null) continue;
  7171. builder.MoveToCell(3, i, 0, 0);
  7172. builder.Write("第" + dac.Days.ToString() + "天:");
  7173. builder.MoveToCell(3, i, 1, 0);
  7174. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7175. builder.MoveToCell(3, i, 2, 0);
  7176. builder.Write("费用标准:");
  7177. string curr = "";
  7178. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7179. if (currData != null)
  7180. {
  7181. curr = currData.Name;
  7182. }
  7183. builder.MoveToCell(3, i, 3, 0);
  7184. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7185. builder.MoveToCell(3, i, 4, 0);
  7186. builder.Write("费用小计:");
  7187. builder.MoveToCell(3, i, 5, 0);
  7188. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7189. }
  7190. #endregion
  7191. }
  7192. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7193. //删除多余行
  7194. while (table4.Rows.Count > table4Row)
  7195. {
  7196. table4.Rows.RemoveAt(table4Row);
  7197. }
  7198. //其他费用
  7199. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7200. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7201. {
  7202. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  7203. dic.Add("titleQi", qtStr);
  7204. table5Row = dac5.Count;
  7205. #region 填充word表格内容
  7206. for (int i = 0; i < dac5.Count; i++)
  7207. {
  7208. var dac = dac5[i];
  7209. if (dac == null) continue;
  7210. builder.MoveToCell(4, i, 0, 0);
  7211. builder.Write("第" + dac.Index.ToString() + "项:");
  7212. builder.MoveToCell(4, i, 1, 0);
  7213. builder.Write(dac.itemName);
  7214. builder.MoveToCell(4, i, 2, 0);
  7215. builder.Write("费用标准:");
  7216. builder.MoveToCell(4, i, 3, 0);
  7217. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7218. builder.MoveToCell(4, i, 4, 0);
  7219. builder.Write("费用小计:");
  7220. builder.MoveToCell(4, i, 5, 0);
  7221. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7222. builder.MoveToCell(4, i, 6, 0);
  7223. builder.Write("备注:");
  7224. builder.MoveToCell(4, i, 7, 0);
  7225. builder.Write(dac.Remark);
  7226. }
  7227. #endregion
  7228. }
  7229. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7230. //删除多余行
  7231. while (table5.Rows.Count > table5Row)
  7232. {
  7233. table5.Rows.RemoveAt(table5Row);
  7234. }
  7235. //加上其他费用
  7236. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7237. decimal subJJC = 0.00M,
  7238. subGWC = 0.00M,
  7239. subTDC = 0.00M;
  7240. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7241. string totalLabel = string.Format("全部费用总计:");
  7242. //经济舱
  7243. if (_EnterExitCosts.SumJJC == 1)
  7244. {
  7245. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7246. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7247. }
  7248. //公务舱
  7249. if (_EnterExitCosts.SumGWC == 1)
  7250. {
  7251. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7252. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7253. }
  7254. //头等舱
  7255. if (_EnterExitCosts.SumTDC == 1)
  7256. {
  7257. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7258. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7259. }
  7260. //TotalLabel
  7261. dic.Add("TotalLabel", totalLabel);
  7262. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7263. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7264. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7265. #region 填充word模板书签内容
  7266. foreach (var key in dic.Keys)
  7267. {
  7268. Bookmark bookmark = doc.Range.Bookmarks[key];
  7269. if (bookmark != null)
  7270. {
  7271. builder.MoveToBookmark(key);
  7272. builder.Write(dic[key]);
  7273. }
  7274. }
  7275. #endregion
  7276. #region 设置页眉
  7277. string userLabel = string.Empty;
  7278. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7279. if (currUserInfo != null)
  7280. {
  7281. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7282. if (userInfo != null)
  7283. {
  7284. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7285. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7286. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7287. }
  7288. }
  7289. //设置页脚
  7290. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7291. #endregion
  7292. //文件名
  7293. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  7294. AsposeHelper.removewatermark_v2180();
  7295. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7296. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7297. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7298. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7299. }
  7300. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7301. {
  7302. //获取模板
  7303. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7304. //载入模板
  7305. var doc = new Document(tempPath);
  7306. var builder = new DocumentBuilder(doc);
  7307. var dic = new Dictionary<string, string>();
  7308. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7309. {
  7310. var list = new List<string>();
  7311. try
  7312. {
  7313. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7314. foreach (var item in spilitArr)
  7315. {
  7316. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7317. var depCode = spDotandEmpty[2].Substring(0, 3);
  7318. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7319. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7320. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7321. list.Add(depName);
  7322. list.Add(arrName);
  7323. }
  7324. list = list.Distinct().ToList();
  7325. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7326. }
  7327. catch (Exception)
  7328. {
  7329. dic.Add("ReturnCode", "行程录入不正确!");
  7330. }
  7331. }
  7332. else
  7333. {
  7334. dic.Add("ReturnCode", "未录入行程!");
  7335. }
  7336. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7337. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7338. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7339. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7340. {
  7341. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7342. dic.Add("Day", sp.Days.ToString());
  7343. }
  7344. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7345. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7346. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7347. //dic.Add("Names", Names);
  7348. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7349. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7350. decimal dac1totalPrice = 0.00M;
  7351. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7352. foreach (var dac in dac1)
  7353. {
  7354. if (dac.SubTotal == 0.00M)
  7355. {
  7356. continue;
  7357. }
  7358. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7359. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7360. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7361. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7362. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7363. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7364. builder.Write(currency);//币种
  7365. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7366. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7367. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7368. builder.Write("");//人数
  7369. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7370. builder.Write("");//天数
  7371. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7372. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7373. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7374. decimal rate = 0.00M;
  7375. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7376. builder.Write(rate.ToString("#0.0000"));//汇率
  7377. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7378. decimal rbmPrice = dac.SubTotal;
  7379. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7380. accommodationStartIndex++;
  7381. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7382. }
  7383. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7384. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7385. {
  7386. table1.Rows.RemoveAt(i - 1);
  7387. foodandotherStartIndex--;
  7388. }
  7389. if (dac2.Count == dac3.Count)//国家 币种 金额
  7390. {
  7391. for (int i = 0; i < dac2.Count; i++)
  7392. {
  7393. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7394. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7395. }
  7396. }
  7397. decimal dac2totalPrice = 0.00M;
  7398. foreach (var dac in dac2)
  7399. {
  7400. if (dac.SubTotal == 0)
  7401. {
  7402. continue;
  7403. }
  7404. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7405. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7406. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7407. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7408. builder.Write(currency);//币种
  7409. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7410. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7411. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7412. builder.Write("");//人数
  7413. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7414. builder.Write("");//天数
  7415. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7416. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7417. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7418. decimal rate = 0.00M;
  7419. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7420. builder.Write(rate.ToString("#0.0000"));//汇率
  7421. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7422. decimal rbmPrice = dac.SubTotal;
  7423. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7424. foodandotherStartIndex++;
  7425. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7426. }
  7427. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7428. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7429. {
  7430. table1.Rows.RemoveAt(i - 1);
  7431. }
  7432. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7433. string otherFeeStr = "";
  7434. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7435. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7436. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7437. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7438. foreach (var otherInfo in dac5)
  7439. {
  7440. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7441. }
  7442. #endregion
  7443. if (otherFeeStr.Length > 0)
  7444. {
  7445. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7446. otherFeeStr = $"({otherFeeStr})";
  7447. dic.Add("OtherFeeStr", otherFeeStr);
  7448. }
  7449. //总计
  7450. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7451. //国际旅费
  7452. string outsideAir = string.Empty;
  7453. string allPriceAir = string.Empty;
  7454. if (_EnterExitCosts.SumJJC == 1)
  7455. {
  7456. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7457. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7458. }
  7459. if (_EnterExitCosts.SumGWC == 1)
  7460. {
  7461. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7462. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7463. }
  7464. if (_EnterExitCosts.SumTDC == 1)
  7465. {
  7466. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7467. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7468. }
  7469. dic.Add("InTravelPrice", $"({outsideAir})");
  7470. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7471. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7472. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7473. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7474. foreach (var key in dic.Keys)
  7475. {
  7476. builder.MoveToBookmark(key);
  7477. builder.Write(dic[key]);
  7478. }
  7479. //模板文件名
  7480. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7481. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7482. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7483. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7484. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7485. }
  7486. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7487. {
  7488. //获取模板
  7489. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7490. //载入模板
  7491. var designer = new WorkbookDesigner
  7492. {
  7493. Workbook = new Workbook(tempPath)
  7494. };
  7495. var dic = new Dictionary<string, string>();
  7496. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7497. {
  7498. var list = new List<string>();
  7499. try
  7500. {
  7501. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7502. foreach (var item in spilitArr)
  7503. {
  7504. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7505. var depCode = spDotandEmpty[2].Substring(0, 3);
  7506. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7507. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7508. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7509. list.Add(depName);
  7510. list.Add(arrName);
  7511. }
  7512. list = list.Distinct().ToList();
  7513. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7514. }
  7515. catch (Exception)
  7516. {
  7517. dic.Add("ReturnCode", "行程录入不正确!");
  7518. }
  7519. }
  7520. else
  7521. {
  7522. dic.Add("ReturnCode", "未录入行程!");
  7523. }
  7524. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7525. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7526. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7527. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7528. {
  7529. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7530. dic.Add("Day", sp.Days.ToString());
  7531. }
  7532. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7533. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7534. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7535. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7536. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7537. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7538. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7539. designer.SetDataSource("Name", Names);
  7540. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7541. designer.SetDataSource("Day", dic["Day"] + "天");
  7542. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7543. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7544. int startIndex = 10;
  7545. const int startIndexcopy = 10;
  7546. if (dac2.Count == dac3.Count)//国家 币种 金额
  7547. {
  7548. for (int i = 0; i < dac2.Count; i++)
  7549. {
  7550. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7551. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7552. }
  7553. }
  7554. var dtdac1 = new DataTable();
  7555. var place = new List<string>();
  7556. dtdac1.Columns.AddRange(new DataColumn[] {
  7557. new(){ ColumnName = "city"},
  7558. new(){ ColumnName = "curr"},
  7559. new(){ ColumnName = "criterion"},
  7560. new(){ ColumnName = "number",DataType = typeof(int)},
  7561. new(){ ColumnName = "day",DataType = typeof(int)},
  7562. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7563. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7564. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7565. });
  7566. var dtdac2 = new DataTable();
  7567. dtdac2.Columns.AddRange(new DataColumn[] {
  7568. new(){ ColumnName = "city"},
  7569. new(){ ColumnName = "curr"},
  7570. new(){ ColumnName = "criterion"},
  7571. new(){ ColumnName = "number",DataType = typeof(int)},
  7572. new(){ ColumnName = "day",DataType = typeof(int)},
  7573. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7574. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7575. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7576. });
  7577. dtdac1.TableName = "tb1";
  7578. dtdac2.TableName = "tb2";
  7579. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7580. foreach (var item in dac1)
  7581. {
  7582. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7583. if (place.Contains(item.Place))
  7584. {
  7585. continue;
  7586. }
  7587. DataRow row = dtdac1.NewRow();
  7588. row["city"] = item.Place;
  7589. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7590. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7591. row["curr"] = currency;
  7592. row["rate"] = rate.ToString("#0.0000");
  7593. row["criterion"] = item.Cost.ToString("#0.00");
  7594. row["number"] = 1;
  7595. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7596. //row["costRMB"] = rbmPrice;
  7597. dtdac1.Rows.Add(row);
  7598. place.Add(item.Place);
  7599. }
  7600. place = new List<string>();
  7601. foreach (var item in dac2)
  7602. {
  7603. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7604. if (place.Contains(item.Place))
  7605. {
  7606. continue;
  7607. }
  7608. DataRow row = dtdac2.NewRow();
  7609. row["city"] = item.Place;
  7610. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7611. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7612. row["curr"] = currency;
  7613. row["rate"] = rate.ToString("#0.0000");
  7614. row["criterion"] = item.Cost.ToString("#0.00");
  7615. row["number"] = 1;
  7616. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7617. //row["cost"] = item.SubTotal;
  7618. //row["costRMB"] = rbmPrice;
  7619. dtdac2.Rows.Add(row);
  7620. place.Add(item.Place);
  7621. //dac2totalPrice += rbmPrice;
  7622. }
  7623. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7624. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7625. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7626. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7627. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7628. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7629. string cell4Str1 = string.Empty;
  7630. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7631. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7632. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7633. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7634. string cellStr = $" 5.其他费用(";
  7635. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7636. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7637. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7638. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7639. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7640. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7641. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7642. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7643. foreach (var otherInfo in dac5)
  7644. {
  7645. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7646. }
  7647. #endregion
  7648. if (cellStr.Length > 8)
  7649. {
  7650. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7651. }
  7652. cellStr += ")";
  7653. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7654. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7655. decimal pxFee = dac4.Sum(it => it.Cost);
  7656. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7657. string celllastStr1 = "";
  7658. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7659. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7660. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7661. celllastStr1 += $",国际旅费 元";
  7662. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7663. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7664. designer.SetDataSource("cell4Str", cell4Str);
  7665. designer.SetDataSource("cellStr", cellStr);
  7666. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7667. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7668. designer.SetDataSource("celllastStr", celllastStr);
  7669. Workbook wb = designer.Workbook;
  7670. var sheet = wb.Worksheets[0];
  7671. //绑定datatable数据集
  7672. designer.SetDataSource(dtdac1);
  7673. designer.SetDataSource(dtdac2);
  7674. designer.Process();
  7675. var rowStart = dtdac1.Rows.Count;
  7676. while (rowStart > 0)
  7677. {
  7678. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7679. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7680. startIndex++;
  7681. rowStart--;
  7682. }
  7683. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7684. startIndex += 1; //总计行
  7685. rowStart = dtdac2.Rows.Count;
  7686. while (rowStart > 0)
  7687. {
  7688. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7689. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7690. startIndex++;
  7691. rowStart--;
  7692. }
  7693. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7694. wb.CalculateFormula(true);
  7695. //模板文件名
  7696. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7697. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7698. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7699. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7700. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7701. }
  7702. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7703. {
  7704. //获取模板
  7705. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7706. //载入模板
  7707. var doc = new Document(tempPath);
  7708. var builder = new DocumentBuilder(doc);
  7709. var dic = new Dictionary<string, string>
  7710. {
  7711. { "GroupName", _DelegationInfo.TeamName },
  7712. { "ClientUnit", _DelegationInfo.ClientUnit }
  7713. };
  7714. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7715. string missionLeaderJob = "";//负责人job
  7716. //int groupNumber = 0; //团人数
  7717. if (DeleClientList.Count > 0)
  7718. {
  7719. missionLeader = DeleClientList[0]?.Name ?? "";
  7720. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7721. }
  7722. dic.Add("MissionLeader", missionLeader); //团负责人
  7723. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7724. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7725. #region MyRegion
  7726. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7727. //{
  7728. // List<string> list = new List<string>();
  7729. // try
  7730. // {
  7731. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7732. // foreach (var item in spilitArr)
  7733. // {
  7734. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7735. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7736. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7737. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7738. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7739. // list.Add(depName);
  7740. // list.Add(arrName);
  7741. // }
  7742. // list = list.Distinct().ToList();
  7743. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7744. // }
  7745. // catch (Exception)
  7746. // {
  7747. // dic.Add("ReturnCode", "行程录入不正确!");
  7748. // }
  7749. //}
  7750. //else
  7751. //{
  7752. // dic.Add("ReturnCode", "未录入行程!");
  7753. //}
  7754. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7755. dic.Add("ReturnCode", string.Join("、", countrys));
  7756. #endregion
  7757. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7758. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7759. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7760. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7761. //{
  7762. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7763. // dic.Add("Day", sp.Days.ToString());
  7764. //}
  7765. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7766. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7767. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7768. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7769. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7770. //培训人员名单
  7771. int cultivateRowIndex = 7;
  7772. foreach (var item in DeleClientList)
  7773. {
  7774. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7775. builder.Write(item.Name);
  7776. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7777. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7778. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7779. string birthDay = "";
  7780. if (item.Birthday != null)
  7781. {
  7782. DateTime dt = Convert.ToDateTime(item.Birthday);
  7783. birthDay = $"{dt.Year}.{dt.Month}";
  7784. }
  7785. builder.Write(birthDay);
  7786. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7787. builder.Write(item.Company);
  7788. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7789. builder.Write(item.Job);
  7790. cultivateRowIndex++;
  7791. }
  7792. //删除多余行
  7793. //cultivateRowIndex -= 2;
  7794. int delRows = 10 + 7 - cultivateRowIndex;
  7795. if (delRows > 0)
  7796. {
  7797. for (int i = 0; i < delRows; i++)
  7798. {
  7799. table1.Rows.RemoveAt(cultivateRowIndex);
  7800. //cultivateRowIndex++;
  7801. }
  7802. }
  7803. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7804. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7805. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7806. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7807. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7808. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7809. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7810. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7811. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7812. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7813. //其他费用
  7814. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7815. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7816. //其他费用合计
  7817. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7818. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7819. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7820. //公务舱合计
  7821. //国际旅费
  7822. //string outsideJJ = "";
  7823. //string allPriceJJ = "";
  7824. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7825. {
  7826. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7827. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7828. }
  7829. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7830. {
  7831. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7832. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7833. }
  7834. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7835. {
  7836. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7837. dic.Add("AirFeeTotal", airFeeTotalStr);
  7838. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7839. dic.Add("FeeTotal", feeTotalStr);
  7840. }
  7841. foreach (var key in dic.Keys)
  7842. {
  7843. builder.MoveToBookmark(key);
  7844. builder.Write(dic[key]);
  7845. }
  7846. //模板文件名
  7847. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7848. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7849. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7850. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7851. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7852. }
  7853. }
  7854. else if (dto.ExportType == 2) //表格
  7855. {
  7856. //利用键值对存放数据
  7857. Dictionary<string, string> dic = new Dictionary<string, string>();
  7858. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7859. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7860. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7861. dic.Add("Day", sp.Days.ToString());
  7862. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7863. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7864. {
  7865. //获取模板
  7866. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7867. //载入模板
  7868. var doc = new Document(tempPath);
  7869. var builder = new DocumentBuilder(doc);
  7870. dic.Add("TeamName", _DelegationInfo.TeamName);
  7871. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7872. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7873. string missionLeaderName = "",
  7874. missionLeaderJob = "";
  7875. if (DeleClientList.Count > 0)
  7876. {
  7877. missionLeaderName = DeleClientList[0].Name;
  7878. missionLeaderJob = DeleClientList[0].Job;
  7879. }
  7880. dic.Add("MissionLeaderName", missionLeaderName);
  7881. dic.Add("MissionLeaderJob", missionLeaderJob);
  7882. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7883. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7884. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7885. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7886. int rowCount = 10;//总人数行
  7887. int startRowIndex = 7; //起始行
  7888. for (int i = 0; i < DeleClientList.Count; i++)
  7889. {
  7890. builder.MoveToCell(0, startRowIndex, 0, 0);
  7891. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7892. builder.MoveToCell(0, startRowIndex, 1, 0);
  7893. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7894. builder.Write(sex);//性别
  7895. builder.MoveToCell(0, startRowIndex, 2, 0);
  7896. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7897. builder.MoveToCell(0, startRowIndex, 3, 0);
  7898. builder.Write(DeleClientList[i].Company);//工作单位
  7899. builder.MoveToCell(0, startRowIndex, 4, 0);
  7900. builder.Write(DeleClientList[i].Job);//职务及级别
  7901. builder.MoveToCell(0, startRowIndex, 5, 0);
  7902. builder.Write("");//人员属性
  7903. builder.MoveToCell(0, startRowIndex, 6, 0);
  7904. builder.Write("");//上次出国时间
  7905. startRowIndex++;
  7906. }
  7907. int nullRow = rowCount - DeleClientList.Count;//空行
  7908. for (int i = 0; i < nullRow; i++)
  7909. {
  7910. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7911. }
  7912. foreach (var key in dic.Keys)
  7913. {
  7914. builder.MoveToBookmark(key);
  7915. builder.Write(dic[key]);
  7916. }
  7917. //模板文件名
  7918. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7919. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7920. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7921. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7922. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7923. }
  7924. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7925. {
  7926. //获取模板
  7927. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7928. //载入模板
  7929. var doc = new Document(tempPath);
  7930. var builder = new DocumentBuilder(doc);
  7931. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7932. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7933. dic.Add("Names", Names);
  7934. int accommodationRows = 12;
  7935. //int foodandotherRows = 12;
  7936. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7937. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7938. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7939. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7940. int accommodationStartIndex = 6;
  7941. decimal dac1totalPrice = 0.00M;
  7942. foreach (var dac in dac1)
  7943. {
  7944. if (dac.SubTotal == 0)
  7945. {
  7946. continue;
  7947. }
  7948. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7949. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7950. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7951. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7952. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7953. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7954. builder.Write(currency);//币种
  7955. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7956. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7957. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7958. builder.Write("");//人数
  7959. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7960. builder.Write("");//天数
  7961. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7962. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7963. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7964. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7965. builder.Write(rate.ToString("#0.0000"));//汇率
  7966. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7967. decimal rbmPrice = rate * dac.SubTotal;
  7968. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7969. accommodationStartIndex++;
  7970. dac1totalPrice += rbmPrice;
  7971. }
  7972. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7973. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7974. builder.Write("小计");
  7975. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7976. builder.Write(dac1totalPrice.ToString("#0.00"));
  7977. accommodationStartIndex++;
  7978. int nullRow = accommodationRows - dac1.Count;
  7979. //删除空行
  7980. //if (nullRow > 0)
  7981. //{
  7982. // int rowIndex = accommodationStartIndex;
  7983. // for (int i = 0; i < nullRow; i++)
  7984. // {
  7985. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7986. // row.Remove();
  7987. // rowIndex++;
  7988. // }
  7989. //}
  7990. if (dac2.Count == dac3.Count)//国家 币种 金额
  7991. {
  7992. for (int i = 0; i < dac2.Count; i++)
  7993. {
  7994. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7995. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7996. }
  7997. }
  7998. int foodandotherStartIndex = 19;//
  7999. decimal dac2totalPrice = 0.00M;
  8000. foreach (var dac in dac2)
  8001. {
  8002. if (dac.SubTotal == 0)
  8003. {
  8004. continue;
  8005. }
  8006. //foodandotherStartIndex = 12;
  8007. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8008. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8009. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8010. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8011. builder.Write(currency);//币种
  8012. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8013. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8014. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8015. builder.Write("");//人数
  8016. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8017. builder.Write("");//天数
  8018. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8019. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8020. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8021. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8022. builder.Write(rate.ToString("#0.0000"));//汇率
  8023. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8024. decimal rbmPrice = rate * dac.SubTotal;
  8025. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8026. foodandotherStartIndex++;
  8027. dac2totalPrice += rbmPrice;
  8028. }
  8029. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8030. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8031. //删除空行
  8032. //if (dac2.Count < foodandotherRows)
  8033. //{
  8034. // while (table2.Rows.Count > dac2.Count)
  8035. // {
  8036. // table2.Rows.RemoveAt(dac2.Count);
  8037. // }
  8038. //}
  8039. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8040. string otherFeeStr = "";
  8041. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8042. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8043. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8044. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8045. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8046. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8047. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8048. foreach (var otherInfo in dac5)
  8049. {
  8050. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8051. }
  8052. #endregion
  8053. if (otherFeeStr.Length > 0)
  8054. {
  8055. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8056. otherFeeStr = $"({otherFeeStr})";
  8057. dic.Add("OtherFeeStr", otherFeeStr);
  8058. }
  8059. foreach (var key in dic.Keys)
  8060. {
  8061. builder.MoveToBookmark(key);
  8062. builder.Write(dic[key]);
  8063. }
  8064. //模板文件名
  8065. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8066. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8067. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8068. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8069. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8070. }
  8071. }
  8072. else if (dto.ExportType == 3)
  8073. {
  8074. if (dto.SubTypeId == 1) //团组成员名单
  8075. {
  8076. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  8077. //获取模板
  8078. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  8079. //载入模板
  8080. var doc = new Document(tempPath);
  8081. var builder = new DocumentBuilder(doc);
  8082. //获取word里所有表格
  8083. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8084. //获取所填表格的序数
  8085. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8086. var rowStart = tableOne.Rows[0]; //获取第1行
  8087. //循环赋值
  8088. for (int i = 0; i < DeleClientList.Count; i++)
  8089. {
  8090. builder.MoveToCell(0, i + 1, 0, 0);
  8091. builder.Write(DeleClientList[i].Name);
  8092. builder.MoveToCell(0, i + 1, 1, 0);
  8093. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8094. builder.Write(sex);
  8095. builder.MoveToCell(0, i + 1, 2, 0);
  8096. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8097. builder.MoveToCell(0, i + 1, 3, 0);
  8098. builder.Write(DeleClientList[i].Company);
  8099. builder.MoveToCell(0, i + 1, 4, 0);
  8100. builder.Write(DeleClientList[i].Job);
  8101. }
  8102. //删除多余行
  8103. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8104. {
  8105. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8106. }
  8107. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8108. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8109. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8110. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8111. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8112. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8113. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8114. }
  8115. }
  8116. return Ok(JsonView(400, "操作失败!", ""));
  8117. }
  8118. catch (Exception ex)
  8119. {
  8120. return Ok(JsonView(400, ex.Message, ""));
  8121. }
  8122. }
  8123. /// <summary>
  8124. /// 获取三公费用标准city
  8125. /// </summary>
  8126. /// <param name="placeData"></param>
  8127. /// <param name="nationalTravelFeeId"></param>
  8128. /// <returns></returns>
  8129. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8130. {
  8131. string _city = string.Empty;
  8132. if (placeData.Count < 1) return _city;
  8133. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8134. if (data == null) return _city;
  8135. string country = data.Country;
  8136. string city = data.City;
  8137. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8138. else _city = city;
  8139. return _city;
  8140. }
  8141. ///// <summary>
  8142. ///// 团组模块 - 出入境费用 - 明细表导出
  8143. ///// </summary>
  8144. ///// <returns></returns>
  8145. //[HttpPost]
  8146. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8147. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8148. //{
  8149. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8150. // if (data.Code != 0)
  8151. // {
  8152. // return Ok(JsonView(false, data.Msg));
  8153. // }
  8154. // return Ok(JsonView(true, data.Msg, data.Data));
  8155. //}
  8156. /// <summary>
  8157. /// 团组模块 - 出入境费用 - 一键清空
  8158. /// </summary>
  8159. /// <returns></returns>
  8160. [HttpPost]
  8161. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8163. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8164. {
  8165. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8166. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8167. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8168. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8169. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8170. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8171. .SetColumns(x => new Grp_DayOtherPrice
  8172. {
  8173. IsDel = 1,
  8174. DeleteUserId = dto.UserId,
  8175. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8176. })
  8177. .ExecuteCommandAsync();
  8178. if (_view.Code == 0)
  8179. {
  8180. return Ok(JsonView(true, "操作成功"));
  8181. }
  8182. return Ok(JsonView(false, "操作失败"));
  8183. }
  8184. /// <summary>
  8185. /// 团组模块 - 出入境费用 - 子项删除
  8186. /// </summary>
  8187. /// <returns></returns>
  8188. [HttpPost]
  8189. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8191. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8192. {
  8193. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8194. if (data.Code != 0)
  8195. {
  8196. return Ok(JsonView(false, data.Msg));
  8197. }
  8198. return Ok(JsonView(true, "操作成功!", data.Data));
  8199. }
  8200. /// <summary>
  8201. /// 删除三公其他费用
  8202. /// </summary>
  8203. /// <param name="dto"></param>
  8204. /// <returns></returns>
  8205. [HttpPost]
  8206. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8207. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8208. {
  8209. var jw = JsonView(false, "删除失败!");
  8210. var data = new Grp_DayOtherPrice()
  8211. {
  8212. Id = dto.Id,
  8213. IsDel = 1,
  8214. DeleteUserId = dto.DeleteUserId,
  8215. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8216. };
  8217. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8218. if (del > 0)
  8219. {
  8220. jw.Code = 200;
  8221. jw.Msg = "删除成功!";
  8222. }
  8223. return Ok(jw);
  8224. }
  8225. /// <summary>
  8226. /// 团组模块 - 出入境国家费用标准 List
  8227. /// </summary>
  8228. /// <returns></returns>
  8229. [HttpPost]
  8230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8231. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8232. {
  8233. int provinceId = dto.ProvinceId;
  8234. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8235. var nftData = await _sqlSugar
  8236. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8237. JoinType.Left, ntf.Currency == sd1.Id,
  8238. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8239. JoinType.Left, ntf.ProvinceId == c.Id
  8240. ))
  8241. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8242. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8243. {
  8244. Id = ntf.Id,
  8245. ProvinceId = ntf.ProvinceId,
  8246. ProvinceName = c.Name_CN,
  8247. Continent = ntf.Continent,
  8248. Country = ntf.Country,
  8249. City = ntf.City,
  8250. Currency = ntf.Currency,
  8251. CurrencyCode = sd1.Name,
  8252. CurrencyName = sd1.Remark,
  8253. RoomCost = ntf.RoomCost,
  8254. FoodCost = ntf.FoodCost,
  8255. PublicCost = ntf.PublicCost,
  8256. LastUpdateUserId = ntf.LastUpdateUserId,
  8257. LastUpdateUserName = u.CnName,
  8258. LastUpdateTime = ntf.LastUpdateTime
  8259. })
  8260. .ToListAsync();
  8261. return Ok(JsonView(true, "查询成功!", nftData));
  8262. }
  8263. /// <summary>
  8264. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8265. /// </summary>
  8266. /// <returns></returns>
  8267. [HttpPost]
  8268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8269. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8270. {
  8271. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8272. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8273. List<string> countryData = new List<string>();
  8274. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8275. countryData = countryData.Distinct().ToList();
  8276. List<dynamic> dataSource = new List<dynamic>();
  8277. foreach (var item in countryData)
  8278. {
  8279. var cityData1 = new List<string>();
  8280. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8281. var countryData2 = new
  8282. {
  8283. CountryName = item,
  8284. CityData = cityData1
  8285. };
  8286. if (!dataSource.Contains(countryData2))
  8287. {
  8288. dataSource.Add(countryData2);
  8289. }
  8290. }
  8291. return Ok(JsonView(true, "查询成功!", dataSource));
  8292. }
  8293. /// <summary>
  8294. /// 团组模块 - 出入境国家费用标准 Page List
  8295. /// </summary>
  8296. /// <returns></returns>
  8297. [HttpPost]
  8298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8299. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8300. {
  8301. int portId = dto.PortType,
  8302. pageIndex = dto.PageIndex,
  8303. pageSize = dto.PageSize;
  8304. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8305. if (pageIndex == 0) pageIndex = 1;
  8306. if (pageSize == 0) pageSize = 10;
  8307. RefAsync<int> total = 0;
  8308. var nationalTravelFeeData = await _sqlSugar
  8309. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8310. JoinType.Left, ntf.Currency == sd1.Id,
  8311. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8312. JoinType.Left, ntf.ProvinceId == sd2.Id
  8313. ))
  8314. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8315. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8316. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8317. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8318. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8319. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8320. {
  8321. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8322. Id = ntf.Id,
  8323. ProvinceId = ntf.ProvinceId,
  8324. ProvinceName = sd2.Name_CN,
  8325. Continent = ntf.Continent,
  8326. Country = ntf.Country,
  8327. City = ntf.City,
  8328. Currency = ntf.Currency,
  8329. CurrencyCode = sd1.Name,
  8330. CurrencyName = sd1.Remark,
  8331. RoomCost = ntf.RoomCost,
  8332. FoodCost = ntf.FoodCost,
  8333. PublicCost = ntf.PublicCost,
  8334. LastUpdateUserId = ntf.LastUpdateUserId,
  8335. LastUpdateUserName = u.CnName,
  8336. LastUpdateTime = ntf.LastUpdateTime,
  8337. Remark = ntf.Remark
  8338. })
  8339. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8340. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8341. }
  8342. /// <summary>
  8343. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8344. /// </summary>
  8345. /// <returns></returns>
  8346. [HttpPost]
  8347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8348. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8349. {
  8350. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8351. int portId = dto.PortType;
  8352. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8353. string whereSql = string.Empty;
  8354. if (!string.IsNullOrEmpty(dto.Country))
  8355. {
  8356. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8357. }
  8358. if (!string.IsNullOrEmpty(dto.City))
  8359. {
  8360. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8361. }
  8362. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8363. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8364. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8365. From Grp_NationalTravelFee gntf
  8366. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8367. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8368. Where gntf.Isdel = 0 {0} ", whereSql);
  8369. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8370. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8371. }
  8372. /// <summary>
  8373. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8374. /// </summary>
  8375. /// <returns></returns>
  8376. [HttpPost]
  8377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8378. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8379. {
  8380. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8381. }
  8382. /// <summary>
  8383. /// 团组模块 - 出入境国家费用标准 - Del
  8384. /// </summary>
  8385. /// <returns></returns>
  8386. [HttpPost]
  8387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8388. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8389. {
  8390. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8391. {
  8392. Id = dto.Id,
  8393. DeleteUserId = dto.DeleteUserId,
  8394. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8395. IsDel = 1
  8396. };
  8397. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8398. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8399. .WhereColumns(it => new { it.Id })
  8400. .ExecuteCommandAsync();
  8401. if (delStatus <= 0)
  8402. {
  8403. return Ok(JsonView(false, "删除失败!"));
  8404. }
  8405. return Ok(JsonView(true, "操作成功!"));
  8406. }
  8407. /// <summary>
  8408. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8409. /// 注:Get 请求Headers 加 Token
  8410. /// </summary>
  8411. /// <param name="groupId"></param>
  8412. /// <returns></returns>
  8413. [HttpGet("{groupId}")]
  8414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8415. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8416. {
  8417. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8418. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8419. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8420. data.ForEach(x =>
  8421. {
  8422. x.CreateUserId = _currUserInfo.UserId;
  8423. });
  8424. if (data.Any())
  8425. {
  8426. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8427. if (add > 0)
  8428. {
  8429. return Ok(JsonView(true, "操作成功!"));
  8430. }
  8431. }
  8432. return Ok(JsonView(false, "未操作!"));
  8433. }
  8434. #endregion
  8435. #region 团组经理模块 出入境费用-草稿
  8436. /// <summary>
  8437. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8438. /// </summary>
  8439. /// <returns></returns>
  8440. [HttpGet]
  8441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8442. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8443. {
  8444. var provData = await _groupRepository.ProvinceBasicSource();
  8445. return Ok(JsonView(true, "查询成功!", provData));
  8446. }
  8447. /// <summary>
  8448. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8449. /// </summary>
  8450. /// <returns></returns>
  8451. [HttpGet("{provinceId}")]
  8452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8453. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8454. {
  8455. //验证城市归属并给默认值
  8456. if (provinceId < 1) provinceId = 122;
  8457. /*
  8458. * 122 四川
  8459. * 108 贵州
  8460. * 103 重庆
  8461. * 132 云南
  8462. */
  8463. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8464. return Ok(JsonView(true, "查询成功!", new
  8465. {
  8466. WordTypeData = wordTypeData,
  8467. ExcelTypeData = excelTypeData,
  8468. }));
  8469. }
  8470. /// <summary>
  8471. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8472. /// </summary>
  8473. /// <returns></returns>
  8474. [HttpPost]
  8475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8476. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8477. {
  8478. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8479. .Where(x => x.IsDel == 0)
  8480. .OrderByDescending(x => x.CreateTime)
  8481. .Select(x => new { x.Id, x.DraftName })
  8482. .ToListAsync();
  8483. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8484. //SetDataInfoView
  8485. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8486. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8487. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8488. int provinceId = dto.ProvinceId;
  8489. if (provinceId < 1) provinceId = 122;
  8490. /*
  8491. * 122 四川
  8492. * 108 贵州
  8493. * 103 重庆
  8494. * 132 云南
  8495. */
  8496. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8497. //默认币种显示
  8498. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8499. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8500. return Ok(JsonView(true, "查询成功!", new
  8501. {
  8502. DraftNameDatas = draftNameDatas,
  8503. CurrencyData = _CurrencyData,
  8504. WordTypeData = wordTypeData,
  8505. ExcelTypeData = excelTypeData,
  8506. CurrencyInit = _currencyInfos,
  8507. ViewPermissionData = viewPermissionData
  8508. }));
  8509. }
  8510. /// <summary>
  8511. /// 团组模块 - 出入境费用-草稿
  8512. /// 实时汇率 tips
  8513. /// 机票费用 tips
  8514. /// </summary>
  8515. /// <returns></returns>
  8516. [HttpPost]
  8517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8518. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8519. {
  8520. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8521. return Ok(JsonView(true, "查询成功!", new
  8522. {
  8523. //GroupNameData = groupNameData.Data,
  8524. //visaData = visaData.Data,
  8525. //airData = airData.Data,
  8526. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8527. }));
  8528. }
  8529. /// <summary>
  8530. /// 团组模块 - 出入境费用-草稿
  8531. /// 签证费用 tips
  8532. /// </summary>
  8533. /// <returns></returns>
  8534. [HttpPost]
  8535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8536. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8537. {
  8538. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8539. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8540. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8541. .Select(x => x.NationalTravelFeeId)
  8542. .Distinct()
  8543. .ToListAsync();
  8544. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8545. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8546. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8547. .Select(x => x.Country)
  8548. .Distinct()
  8549. .ToArrayAsync();
  8550. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8551. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8552. return Ok(JsonView(true, "查询成功!", new
  8553. {
  8554. totalAmt,
  8555. remark
  8556. }));
  8557. }
  8558. /// <summary>
  8559. /// 团组模块 - 出入境费用-草稿 - Info
  8560. /// </summary>
  8561. /// <returns></returns>
  8562. [HttpPost]
  8563. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8565. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8566. {
  8567. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8568. }
  8569. /// <summary>
  8570. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8571. /// </summary>
  8572. /// <returns></returns>
  8573. [HttpPost]
  8574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8575. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8576. {
  8577. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8578. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8579. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8580. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8581. foreach (var userId in dto.UserIds)
  8582. {
  8583. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8584. }
  8585. if (permissions.Any())
  8586. {
  8587. _sqlSugar.BeginTran();
  8588. try
  8589. {
  8590. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8591. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8592. if (result < 1)
  8593. {
  8594. _sqlSugar.RollbackTran();
  8595. return Ok(JsonView(false));
  8596. }
  8597. }
  8598. catch (Exception ex)
  8599. {
  8600. _sqlSugar.RollbackTran();
  8601. return Ok(JsonView(false, ex.Message));
  8602. }
  8603. _sqlSugar.CommitTran();
  8604. return Ok(JsonView(true));
  8605. }
  8606. return Ok(JsonView(false));
  8607. }
  8608. /// <summary>
  8609. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8610. /// </summary>
  8611. /// <returns></returns>
  8612. [HttpPost]
  8613. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8615. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8616. {
  8617. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8618. if (data.Code != 0)
  8619. {
  8620. return Ok(JsonView(false, data.Msg));
  8621. }
  8622. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8623. //汇率信息记录
  8624. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8625. return Ok(JsonView(true, data.Msg, data.Data));
  8626. }
  8627. /// <summary>
  8628. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8629. /// </summary>
  8630. /// <param name="dto"></param>
  8631. /// <returns></returns>
  8632. [HttpPost]
  8633. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8635. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8636. {
  8637. try
  8638. {
  8639. var id = dto.Id;
  8640. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8641. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8642. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8643. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8644. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8645. 3 团组成员名单 1 团组成员名单", ""));
  8646. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8647. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8648. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8649. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8650. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8651. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8652. //数据源
  8653. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8654. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8655. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8656. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8657. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8658. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8659. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8660. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8661. .Select((x, a, b) => new
  8662. {
  8663. x.Index,
  8664. itemName = a.Name,
  8665. CurrencyStr = b.Name,
  8666. x.Cost,
  8667. x.SubTotal,
  8668. x.Remark
  8669. })
  8670. .OrderBy((x) => x.Index)
  8671. .ToList(); //其他款项费用
  8672. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8673. var peiceItemCurrencys = new List<string>();
  8674. if (_DayAndCosts.Any())
  8675. {
  8676. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8677. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8678. }
  8679. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8680. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8681. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8682. {
  8683. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8684. }
  8685. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8686. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8687. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8688. if (dto.ExportType == 1) //明细表
  8689. {
  8690. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8691. {
  8692. //获取模板
  8693. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8694. //载入模板
  8695. Document doc = new Document(tempPath);
  8696. DocumentBuilder builder = new DocumentBuilder(doc);
  8697. //利用键值对存放数据
  8698. Dictionary<string, string> dic = new Dictionary<string, string>();
  8699. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8700. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8701. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8702. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8703. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8704. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8705. //境内费用(其他费用)
  8706. if (_EnterExitCosts.ChoiceOne == 1)
  8707. {
  8708. string row1_1 = "";
  8709. if (_EnterExitCosts.Visa > 0)
  8710. {
  8711. //insidePayTotal += _EnterExitCosts.Visa;
  8712. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8713. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8714. //{
  8715. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8716. //}
  8717. }
  8718. string row1_2 = "";
  8719. if (_EnterExitCosts.YiMiao > 0)
  8720. {
  8721. //insidePayTotal += _EnterExitCosts.YiMiao;
  8722. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8723. }
  8724. if (_EnterExitCosts.HeSuan > 0)
  8725. {
  8726. //insidePayTotal += _EnterExitCosts.HeSuan;
  8727. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8728. }
  8729. if (_EnterExitCosts.Service > 0)
  8730. {
  8731. //insidePayTotal += _EnterExitCosts.Service;
  8732. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8733. }
  8734. string row1_3 = "";
  8735. if (_EnterExitCosts.Safe > 0)
  8736. {
  8737. //insidePayTotal += _EnterExitCosts.Safe;
  8738. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8739. }
  8740. if (_EnterExitCosts.Ticket > 0)
  8741. {
  8742. //insidePayTotal += _EnterExitCosts.Ticket;
  8743. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8744. }
  8745. string row1 = "";
  8746. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8747. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8748. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8749. row1 += $"备注:{_EnterExitCosts.Remark}";
  8750. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8751. dic.Add("Row1Str", row1);
  8752. }
  8753. string airTotalStr = string.Empty,
  8754. airPriceStr = string.Empty;
  8755. //经济舱
  8756. if (_EnterExitCosts.SumJJC == 1)
  8757. {
  8758. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8759. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8760. }
  8761. //公务舱
  8762. if (_EnterExitCosts.SumGWC == 1)
  8763. {
  8764. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8765. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8766. }
  8767. //头等舱
  8768. if (_EnterExitCosts.SumTDC == 1)
  8769. {
  8770. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8771. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8772. }
  8773. //汇率描述
  8774. string rateStr = "";
  8775. if (peiceItemCurrencyInfos.Any())
  8776. {
  8777. rateStr = "\r\n汇率描述:";
  8778. foreach (var item in peiceItemCurrencyInfos)
  8779. {
  8780. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8781. }
  8782. }
  8783. string twoItemRemark = "备注:";
  8784. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8785. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8786. dic.Add("AirTotalStr", airTotalStr);
  8787. dic.Add("AirPriceStr", airPriceStr);
  8788. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8789. dic.Add("TwoItemRemark", twoItemRemark);
  8790. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8791. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8792. int table1Row = 0,
  8793. table2Row = 0,
  8794. table3Row = 0,
  8795. table4Row = 0,
  8796. table5Row = 0;
  8797. //住宿费
  8798. if (_EnterExitCosts.ChoiceThree == 1)
  8799. {
  8800. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8801. table1Row = dac1.Count;
  8802. #region 填充word表格内容
  8803. for (int i = 0; i < dac1.Count; i++)
  8804. {
  8805. var dac = dac1[i];
  8806. if (dac == null) continue;
  8807. builder.MoveToCell(0, i, 0, 0);
  8808. builder.Write("第" + dac.Days.ToString() + "晚:");
  8809. builder.MoveToCell(0, i, 1, 0);
  8810. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8811. //builder.Write(dac.Place == null ? "" : dac.Place);
  8812. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8813. builder.MoveToCell(0, i, 2, 0);
  8814. builder.Write("费用标准:");
  8815. string curr = "";
  8816. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8817. if (currData != null)
  8818. {
  8819. curr = currData.Name;
  8820. }
  8821. builder.MoveToCell(0, i, 3, 0);
  8822. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8823. builder.MoveToCell(0, i, 4, 0);
  8824. builder.Write("费用小计:");
  8825. builder.MoveToCell(0, i, 5, 0);
  8826. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8827. }
  8828. #endregion
  8829. }
  8830. else dic.Add("SubZS", "0.00");
  8831. //删除多余行
  8832. while (table1.Rows.Count > table1Row)
  8833. {
  8834. table1.Rows.RemoveAt(table1Row);
  8835. }
  8836. //伙食费
  8837. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8838. if (_EnterExitCosts.ChoiceFour == 1)
  8839. {
  8840. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8841. table2Row = dac2.Count;
  8842. #region 填充word表格内容
  8843. for (int i = 0; i < dac2.Count; i++)
  8844. {
  8845. var dac = dac2[i];
  8846. if (dac == null) continue;
  8847. builder.MoveToCell(1, i, 0, 0);
  8848. builder.Write("第" + dac.Days.ToString() + "天:");
  8849. builder.MoveToCell(1, i, 1, 0);
  8850. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8851. builder.MoveToCell(1, i, 2, 0);
  8852. builder.Write("费用标准:");
  8853. string curr = "";
  8854. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8855. if (currData != null)
  8856. {
  8857. curr = currData.Name;
  8858. }
  8859. builder.MoveToCell(1, i, 3, 0);
  8860. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8861. builder.MoveToCell(1, i, 4, 0);
  8862. builder.Write("费用小计:");
  8863. builder.MoveToCell(1, i, 5, 0);
  8864. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8865. }
  8866. #endregion
  8867. }
  8868. else dic.Add("SubHS", "0.00");
  8869. //删除多余行
  8870. while (table2.Rows.Count > table2Row)
  8871. {
  8872. table2.Rows.RemoveAt(table2Row);
  8873. }
  8874. //公杂费
  8875. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8876. if (_EnterExitCosts.ChoiceFive == 1)
  8877. {
  8878. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8879. table3Row = dac3.Count;
  8880. #region 填充word表格内容
  8881. for (int i = 0; i < dac3.Count; i++)
  8882. {
  8883. var dac = dac3[i];
  8884. if (dac == null) continue;
  8885. builder.MoveToCell(2, i, 0, 0);
  8886. builder.Write("第" + dac.Days.ToString() + "天:");
  8887. builder.MoveToCell(2, i, 1, 0);
  8888. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8889. builder.MoveToCell(2, i, 2, 0);
  8890. builder.Write("费用标准:");
  8891. string curr = "";
  8892. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8893. if (currData != null)
  8894. {
  8895. curr = currData.Name;
  8896. }
  8897. builder.MoveToCell(2, i, 3, 0);
  8898. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8899. builder.MoveToCell(2, i, 4, 0);
  8900. builder.Write("费用小计:");
  8901. builder.MoveToCell(2, i, 5, 0);
  8902. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8903. }
  8904. //删除多余行
  8905. while (table3.Rows.Count > table3Row)
  8906. {
  8907. table3.Rows.RemoveAt(table3Row);
  8908. }
  8909. #endregion
  8910. }
  8911. else dic.Add("SubGZF", "0.00");
  8912. //删除多余行
  8913. while (table3.Rows.Count > table3Row)
  8914. {
  8915. table3.Rows.RemoveAt(table3Row);
  8916. }
  8917. //培训费
  8918. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8919. if (_EnterExitCosts.ChoiceSix == 1)
  8920. {
  8921. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8922. dic.Add("SubPX", pxStr);
  8923. table4Row = dac4.Count;
  8924. #region 填充word表格内容
  8925. for (int i = 0; i < dac4.Count; i++)
  8926. {
  8927. var dac = dac4[i];
  8928. if (dac == null) continue;
  8929. builder.MoveToCell(3, i, 0, 0);
  8930. builder.Write("第" + dac.Days.ToString() + "天:");
  8931. builder.MoveToCell(3, i, 1, 0);
  8932. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8933. builder.MoveToCell(3, i, 2, 0);
  8934. builder.Write("费用标准:");
  8935. string curr = "";
  8936. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8937. if (currData != null)
  8938. {
  8939. curr = currData.Name;
  8940. }
  8941. builder.MoveToCell(3, i, 3, 0);
  8942. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8943. builder.MoveToCell(3, i, 4, 0);
  8944. builder.Write("费用小计:");
  8945. builder.MoveToCell(3, i, 5, 0);
  8946. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8947. }
  8948. #endregion
  8949. }
  8950. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8951. //删除多余行
  8952. while (table4.Rows.Count > table4Row)
  8953. {
  8954. table4.Rows.RemoveAt(table4Row);
  8955. }
  8956. //其他费用
  8957. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8958. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8959. {
  8960. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8961. dic.Add("titleQi", qtStr);
  8962. table5Row = dac5.Count;
  8963. #region 填充word表格内容
  8964. for (int i = 0; i < dac5.Count; i++)
  8965. {
  8966. var dac = dac5[i];
  8967. if (dac == null) continue;
  8968. builder.MoveToCell(4, i, 0, 0);
  8969. builder.Write("第" + dac.Index.ToString() + "项:");
  8970. builder.MoveToCell(4, i, 1, 0);
  8971. builder.Write(dac.itemName);
  8972. builder.MoveToCell(4, i, 2, 0);
  8973. builder.Write("费用标准:");
  8974. builder.MoveToCell(4, i, 3, 0);
  8975. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8976. builder.MoveToCell(4, i, 4, 0);
  8977. builder.Write("费用小计:");
  8978. builder.MoveToCell(4, i, 5, 0);
  8979. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8980. builder.MoveToCell(4, i, 6, 0);
  8981. builder.Write("备注:");
  8982. builder.MoveToCell(4, i, 7, 0);
  8983. builder.Write(dac.Remark);
  8984. }
  8985. #endregion
  8986. }
  8987. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8988. //删除多余行
  8989. while (table5.Rows.Count > table5Row)
  8990. {
  8991. table5.Rows.RemoveAt(table5Row);
  8992. }
  8993. //加上其他费用
  8994. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8995. decimal subJJC = 0.00M,
  8996. subGWC = 0.00M,
  8997. subTDC = 0.00M;
  8998. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8999. string totalLabel = string.Format("全部费用总计:");
  9000. //经济舱
  9001. if (_EnterExitCosts.SumJJC == 1)
  9002. {
  9003. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  9004. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  9005. }
  9006. //公务舱
  9007. if (_EnterExitCosts.SumGWC == 1)
  9008. {
  9009. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  9010. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  9011. }
  9012. //头等舱
  9013. if (_EnterExitCosts.SumTDC == 1)
  9014. {
  9015. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9016. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  9017. }
  9018. //TotalLabel
  9019. dic.Add("TotalLabel", totalLabel);
  9020. #region 填充word模板书签内容
  9021. foreach (var key in dic.Keys)
  9022. {
  9023. Bookmark bookmark = doc.Range.Bookmarks[key];
  9024. if (bookmark != null)
  9025. {
  9026. builder.MoveToBookmark(key);
  9027. builder.Write(dic[key]);
  9028. }
  9029. }
  9030. #endregion
  9031. //文件名
  9032. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  9033. strFileName = CommonFun.ValidFileName(strFileName);
  9034. AsposeHelper.removewatermark_v2180();
  9035. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9036. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9037. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9038. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9039. }
  9040. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  9041. {
  9042. //获取模板
  9043. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  9044. //载入模板
  9045. Document doc = new Document(tempPath);
  9046. DocumentBuilder builder = new DocumentBuilder(doc);
  9047. Dictionary<string, string> dic = new Dictionary<string, string>();
  9048. string returnCodeLabel = string.Empty;
  9049. if (nationalTravelFeeData.Any())
  9050. {
  9051. List<string> list = new List<string>();
  9052. foreach (var item in nationalTravelFeeData)
  9053. {
  9054. list.Add($"{item.Country}({item.City})");
  9055. }
  9056. list = list.Distinct().ToList();
  9057. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9058. }
  9059. var countryLabel = string.Empty;
  9060. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9061. if (countryData.Any())
  9062. {
  9063. countryLabel = string.Join("、", countryData);
  9064. }
  9065. dic.Add("ReturnCodeAir", returnCodeLabel);
  9066. dic.Add("VisitStartDate", "-");
  9067. dic.Add("VisitEndDate", "-");
  9068. dic.Add("Day", "-");
  9069. dic.Add("VisitCountry", countryLabel);
  9070. dic.Add("ClientUnit", "-");
  9071. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  9072. //dic.Add("Names", Names);
  9073. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9074. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9075. decimal dac1totalPrice = 0.00M;
  9076. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  9077. foreach (var dac in dac1)
  9078. {
  9079. if (dac.SubTotal == 0.00M)
  9080. {
  9081. continue;
  9082. }
  9083. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  9084. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  9085. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  9086. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9087. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  9088. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9089. builder.Write(currency);//币种
  9090. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  9091. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9092. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9093. builder.Write("");//人数
  9094. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9095. builder.Write("");//天数
  9096. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9097. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9098. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9099. decimal rate = 0.00M;
  9100. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9101. builder.Write(rate.ToString("#0.0000"));//汇率
  9102. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9103. decimal rbmPrice = dac.SubTotal;
  9104. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9105. accommodationStartIndex++;
  9106. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9107. }
  9108. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9109. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9110. {
  9111. table1.Rows.RemoveAt(i - 1);
  9112. foodandotherStartIndex--;
  9113. }
  9114. if (dac2.Count == dac3.Count)//国家 币种 金额
  9115. {
  9116. for (int i = 0; i < dac2.Count; i++)
  9117. {
  9118. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9119. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9120. }
  9121. }
  9122. decimal dac2totalPrice = 0.00M;
  9123. foreach (var dac in dac2)
  9124. {
  9125. if (dac.SubTotal == 0)
  9126. {
  9127. continue;
  9128. }
  9129. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9130. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9131. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9132. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9133. builder.Write(currency);//币种
  9134. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9135. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9136. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9137. builder.Write("");//人数
  9138. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9139. builder.Write("");//天数
  9140. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9141. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9142. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9143. decimal rate = 0.00M;
  9144. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9145. builder.Write(rate.ToString("#0.0000"));//汇率
  9146. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9147. decimal rbmPrice = dac.SubTotal;
  9148. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9149. foodandotherStartIndex++;
  9150. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9151. }
  9152. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9153. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9154. {
  9155. table1.Rows.RemoveAt(i - 1);
  9156. }
  9157. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9158. string otherFeeStr = "";
  9159. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9160. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9161. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9162. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9163. foreach (var otherInfo in dac5)
  9164. {
  9165. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9166. }
  9167. #endregion
  9168. if (otherFeeStr.Length > 0)
  9169. {
  9170. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9171. otherFeeStr = $"({otherFeeStr})";
  9172. dic.Add("OtherFeeStr", otherFeeStr);
  9173. }
  9174. //总计
  9175. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9176. //国际旅费
  9177. string outsideAir = string.Empty;
  9178. string allPriceAir = string.Empty;
  9179. if (_EnterExitCosts.SumJJC == 1)
  9180. {
  9181. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9182. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9183. }
  9184. if (_EnterExitCosts.SumGWC == 1)
  9185. {
  9186. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9187. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9188. }
  9189. if (_EnterExitCosts.SumTDC == 1)
  9190. {
  9191. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9192. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9193. }
  9194. dic.Add("InTravelPrice", $"({outsideAir})");
  9195. dic.Add("FinalSumPrice", $"({allPriceAir})");
  9196. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  9197. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  9198. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  9199. foreach (var key in dic.Keys)
  9200. {
  9201. builder.MoveToBookmark(key);
  9202. builder.Write(dic[key]);
  9203. }
  9204. //模板文件名
  9205. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9206. strFileName = CommonFun.ValidFileName(strFileName);
  9207. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9208. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9209. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9210. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9211. }
  9212. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9213. {
  9214. //获取模板
  9215. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9216. //载入模板
  9217. WorkbookDesigner designer = new WorkbookDesigner();
  9218. designer.Workbook = new Workbook(tempPath);
  9219. Dictionary<string, string> dic = new Dictionary<string, string>();
  9220. string returnCodeLabel = string.Empty;
  9221. if (nationalTravelFeeData.Any())
  9222. {
  9223. List<string> list = new List<string>();
  9224. foreach (var item in nationalTravelFeeData)
  9225. {
  9226. list.Add($"{item.Country}({item.City})");
  9227. }
  9228. list = list.Distinct().ToList();
  9229. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9230. }
  9231. var countryLabel = string.Empty;
  9232. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9233. if (countryData.Any())
  9234. {
  9235. countryLabel = string.Join("、", countryData);
  9236. }
  9237. dic.Add("ReturnCodeAir", returnCodeLabel);
  9238. dic.Add("VisitStartDate", "-");
  9239. dic.Add("VisitEndDate", "-");
  9240. dic.Add("Day", "0");
  9241. dic.Add("VisitCountry", countryLabel);
  9242. dic.Add("ClientUnit", "-");
  9243. designer.SetDataSource("ClientUnit", "-");
  9244. designer.SetDataSource("VisitCountry", countryLabel);
  9245. designer.SetDataSource("Group", "-");
  9246. designer.SetDataSource("ClientUnitTitle", "-");
  9247. designer.SetDataSource("Name", "-");
  9248. designer.SetDataSource("VisitStartDate", "-");
  9249. designer.SetDataSource("Day", "0");
  9250. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9251. designer.SetDataSource("ReturnCodeAir", "-");
  9252. int startIndex = 10;
  9253. const int startIndexcopy = 10;
  9254. if (dac2.Count == dac3.Count)//国家 币种 金额
  9255. {
  9256. for (int i = 0; i < dac2.Count; i++)
  9257. {
  9258. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9259. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9260. }
  9261. }
  9262. DataTable dtdac1 = new DataTable();
  9263. List<string> place = new List<string>();
  9264. dtdac1.Columns.AddRange(new DataColumn[] {
  9265. new DataColumn(){ ColumnName = "city"},
  9266. new DataColumn(){ ColumnName = "curr"},
  9267. new DataColumn(){ ColumnName = "criterion"},
  9268. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9269. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9270. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9271. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9272. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9273. });
  9274. DataTable dtdac2 = new DataTable();
  9275. dtdac2.Columns.AddRange(new DataColumn[] {
  9276. new DataColumn(){ ColumnName = "city"},
  9277. new DataColumn(){ ColumnName = "curr"},
  9278. new DataColumn(){ ColumnName = "criterion"},
  9279. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9280. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9281. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9282. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9283. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9284. });
  9285. dtdac1.TableName = "tb1";
  9286. dtdac2.TableName = "tb2";
  9287. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9288. foreach (var item in dac1)
  9289. {
  9290. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9291. if (place.Contains(item.Place))
  9292. {
  9293. continue;
  9294. }
  9295. DataRow row = dtdac1.NewRow();
  9296. row["city"] = item.Place;
  9297. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9298. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9299. row["curr"] = currency;
  9300. row["rate"] = rate.ToString("#0.0000");
  9301. row["criterion"] = item.Cost.ToString("#0.00");
  9302. row["number"] = 1;
  9303. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9304. //row["costRMB"] = rbmPrice;
  9305. dtdac1.Rows.Add(row);
  9306. place.Add(item.Place);
  9307. }
  9308. place = new List<string>();
  9309. foreach (var item in dac2)
  9310. {
  9311. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9312. if (place.Contains(item.Place))
  9313. {
  9314. continue;
  9315. }
  9316. DataRow row = dtdac2.NewRow();
  9317. row["city"] = item.Place;
  9318. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9319. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9320. row["curr"] = currency;
  9321. row["rate"] = rate.ToString("#0.0000");
  9322. row["criterion"] = item.Cost.ToString("#0.00");
  9323. row["number"] = 1;
  9324. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9325. //row["cost"] = item.SubTotal;
  9326. //row["costRMB"] = rbmPrice;
  9327. dtdac2.Rows.Add(row);
  9328. place.Add(item.Place);
  9329. //dac2totalPrice += rbmPrice;
  9330. }
  9331. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9332. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9333. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9334. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9335. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9336. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9337. string cell4Str1 = string.Empty;
  9338. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9339. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9340. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9341. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9342. string cellStr = $" 5.其他费用(";
  9343. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9344. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9345. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9346. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9347. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9348. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9349. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9350. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9351. foreach (var otherInfo in dac5)
  9352. {
  9353. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9354. }
  9355. #endregion
  9356. if (cellStr.Length > 8)
  9357. {
  9358. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9359. }
  9360. cellStr += ")";
  9361. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9362. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9363. decimal pxFee = dac4.Sum(it => it.Cost);
  9364. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9365. string celllastStr1 = "";
  9366. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9367. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9368. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9369. celllastStr1 += $",国际旅费 元";
  9370. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9371. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9372. designer.SetDataSource("cell4Str", cell4Str);
  9373. designer.SetDataSource("cellStr", cellStr);
  9374. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9375. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9376. designer.SetDataSource("celllastStr", celllastStr);
  9377. Workbook wb = designer.Workbook;
  9378. var sheet = wb.Worksheets[0];
  9379. //绑定datatable数据集
  9380. designer.SetDataSource(dtdac1);
  9381. designer.SetDataSource(dtdac2);
  9382. designer.Process();
  9383. var rowStart = dtdac1.Rows.Count;
  9384. while (rowStart > 0)
  9385. {
  9386. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9387. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9388. startIndex++;
  9389. rowStart--;
  9390. }
  9391. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9392. startIndex += 1; //总计行
  9393. rowStart = dtdac2.Rows.Count;
  9394. while (rowStart > 0)
  9395. {
  9396. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9397. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9398. startIndex++;
  9399. rowStart--;
  9400. }
  9401. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9402. wb.CalculateFormula(true);
  9403. //模板文件名
  9404. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9405. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9406. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9407. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9408. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9409. }
  9410. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9411. {
  9412. //获取模板
  9413. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9414. //载入模板
  9415. Document doc = new Document(tempPath);
  9416. DocumentBuilder builder = new DocumentBuilder(doc);
  9417. Dictionary<string, string> dic = new Dictionary<string, string>();
  9418. dic.Add("GroupName", "-");
  9419. dic.Add("ClientUnit", "-");
  9420. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9421. //string missionLeaderJob = "";//负责人job
  9422. //int groupNumber = 0; //团人数
  9423. dic.Add("MissionLeader", "-"); //团负责人
  9424. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9425. dic.Add("GroupNumber", "0"); //团人数
  9426. dic.Add("Day", "0");
  9427. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9428. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9429. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9430. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9431. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9432. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9433. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9434. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9435. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9436. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9437. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9438. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9439. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9440. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9441. //其他费用
  9442. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9443. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9444. //其他费用合计
  9445. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9446. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9447. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9448. //公务舱合计
  9449. //国际旅费
  9450. //string outsideJJ = "";
  9451. //string allPriceJJ = "";
  9452. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9453. {
  9454. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9455. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9456. }
  9457. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9458. {
  9459. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9460. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9461. }
  9462. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9463. {
  9464. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9465. dic.Add("AirFeeTotal", airFeeTotalStr);
  9466. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9467. dic.Add("FeeTotal", feeTotalStr);
  9468. }
  9469. foreach (var key in dic.Keys)
  9470. {
  9471. builder.MoveToBookmark(key);
  9472. builder.Write(dic[key]);
  9473. }
  9474. //模板文件名
  9475. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9476. strFileName = CommonFun.ValidFileName(strFileName);
  9477. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9478. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9479. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9480. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9481. }
  9482. }
  9483. else if (dto.ExportType == 2) //表格
  9484. {
  9485. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9486. }
  9487. else if (dto.ExportType == 3)
  9488. {
  9489. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9490. }
  9491. return Ok(JsonView(400, "只可导出明细表!", ""));
  9492. }
  9493. catch (Exception ex)
  9494. {
  9495. return Ok(JsonView(400, ex.Message, ""));
  9496. }
  9497. }
  9498. /// <summary>
  9499. /// 获取三公费用标准city
  9500. /// </summary>
  9501. /// <param name="placeData"></param>
  9502. /// <param name="nationalTravelFeeId"></param>
  9503. /// <returns></returns>
  9504. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9505. {
  9506. string _city = string.Empty;
  9507. if (!placeData.Any()) return _city;
  9508. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9509. if (data == null) return _city;
  9510. string country = data.Country;
  9511. string city = data.City;
  9512. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9513. else _city = city;
  9514. return _city;
  9515. }
  9516. /// <summary>
  9517. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9518. /// </summary>
  9519. /// <returns></returns>
  9520. [HttpPost]
  9521. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9523. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9524. {
  9525. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9526. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9527. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9528. if (_view.Code == 0)
  9529. {
  9530. return Ok(JsonView(true, "操作成功"));
  9531. }
  9532. return Ok(JsonView(false, "操作失败"));
  9533. }
  9534. /// <summary>
  9535. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9536. /// </summary>
  9537. /// <returns></returns>
  9538. [HttpPost]
  9539. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9541. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9542. {
  9543. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9544. if (data.Code != 0)
  9545. {
  9546. return Ok(JsonView(false, data.Msg));
  9547. }
  9548. return Ok(JsonView(true, "操作成功!", data.Data));
  9549. }
  9550. /// <summary>
  9551. /// 三公其他费用草稿 删除
  9552. /// </summary>
  9553. /// <param name="dto"></param>
  9554. /// <returns></returns>
  9555. [HttpPost]
  9556. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9557. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9558. {
  9559. var jw = JsonView(false, "删除失败!");
  9560. var data = new Grp_DayOtherPriceDraft()
  9561. {
  9562. Id = dto.Id,
  9563. IsDel = 1,
  9564. DeleteUserId = dto.DeleteUserId,
  9565. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9566. };
  9567. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9568. if (del > 0)
  9569. {
  9570. jw.Code = 200;
  9571. jw.Msg = "删除成功!";
  9572. }
  9573. return Ok(jw);
  9574. }
  9575. /// <summary>
  9576. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9577. /// </summary>
  9578. /// <returns></returns>
  9579. [HttpPost]
  9580. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9581. {
  9582. var jw = JsonView(false);
  9583. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9584. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9585. jw.Code = StatusCodes.Status200OK;
  9586. jw.Msg = "操作成功!";
  9587. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9588. return Ok(jw);
  9589. }
  9590. /// <summary>
  9591. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9592. /// </summary>
  9593. /// <param name="dto"></param>
  9594. /// <returns></returns>
  9595. [HttpPost]
  9596. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9597. {
  9598. int userId = dto.UserId,
  9599. portId = dto.PortType,
  9600. groupId = dto.GroupId,
  9601. draftId = dto.DraftId;
  9602. _portTypeData.Add(1);
  9603. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9604. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9605. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9606. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9607. _sqlSugar.BeginTran();
  9608. try
  9609. {
  9610. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9611. if (draftDatas == null)
  9612. {
  9613. _sqlSugar.RollbackTran();
  9614. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9615. }
  9616. //验证可覆盖已有数据 两边创建人需为同一人;
  9617. int draftCreateUserId = draftDatas.CreateUserId,
  9618. formalCreateUserId = 0;
  9619. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9620. if (formalData != null)
  9621. {
  9622. formalCreateUserId = formalData.CreateUserId;
  9623. if (draftCreateUserId != formalCreateUserId)
  9624. {
  9625. _sqlSugar.RollbackTran();
  9626. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9627. }
  9628. }
  9629. //默认添加查看、编辑权限(创建人、自己)
  9630. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9631. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9632. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9633. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9634. newExterData.DiId = groupId;
  9635. newExterData.CreateUserId = userId;
  9636. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9637. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9638. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9639. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9640. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9641. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9642. //数据如果存在执行删除
  9643. if (enterExitCostInfo != null)
  9644. {
  9645. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9646. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9647. .Where(x => x.Id == enterExitCostInfo.Id)
  9648. .ExecuteCommand();
  9649. _sqlSugar.Updateable<Grp_DayAndCost>()
  9650. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9651. .Where(x => x.DiId == groupId)
  9652. .ExecuteCommand();
  9653. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9654. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9655. .Where(x => x.Diid == groupId)
  9656. .ExecuteCommand();
  9657. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9658. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9659. .Where(x => x.GroupId == groupId)
  9660. .ExecuteCommand();
  9661. }
  9662. //执行insert
  9663. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9664. if (insertId < 1)
  9665. {
  9666. _sqlSugar.RollbackTran();
  9667. return Ok(JsonView(false, "草稿数据导入失败!"));
  9668. }
  9669. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9670. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9671. #region 默认添加权限
  9672. #endregion
  9673. _sqlSugar.CommitTran();
  9674. //执行操作之后
  9675. //生成默认文件pdf并且通知人员
  9676. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9677. {
  9678. DiId = groupId,
  9679. ExportType = 1,
  9680. SubTypeId = 1005
  9681. }, "pdf");
  9682. //发送通知
  9683. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9684. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9685. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9686. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9687. //汇率信息记录
  9688. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9689. return Ok(JsonView(true));
  9690. }
  9691. catch (Exception ex)
  9692. {
  9693. _sqlSugar.RollbackTran();
  9694. return Ok(JsonView(false, ex.Message));
  9695. }
  9696. }
  9697. #endregion
  9698. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9699. /// <summary>
  9700. /// 获取币种基础数据(含逻辑处理)
  9701. /// </summary>
  9702. /// <returns></returns>
  9703. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9704. {
  9705. return await GeneralMethod.EnterExitCostInitRate();
  9706. }
  9707. /// <summary>
  9708. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9709. /// </summary>
  9710. /// <returns></returns>
  9711. [HttpPost]
  9712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9713. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9714. {
  9715. //验证城市归属并给默认值
  9716. int provinceId = dto.ProvinceId;
  9717. if (provinceId < 1) provinceId = 122;
  9718. var dataSource = await _sqlSugar
  9719. .Queryable<Sys_SetData>()
  9720. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9721. .ToListAsync();
  9722. var fileTypes = new List<EecSetDataInfoView>();
  9723. //三公费用-Word明细类型
  9724. var wordTypeData = dataSource
  9725. .Where(it => it.STid == 72)
  9726. .Select(x => new EecSetDataInfoView
  9727. {
  9728. ParentId = 1,
  9729. Id = x.Id,
  9730. Name = x.Name
  9731. })
  9732. .ToArray();
  9733. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9734. var excelTypeData = dataSource
  9735. .Where(it => it.STid == 73)
  9736. .Select(x => new EecSetDataInfoView
  9737. {
  9738. ParentId = 2,
  9739. Id = x.Id,
  9740. Name = x.Name
  9741. })
  9742. .ToArray();
  9743. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9744. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9745. fileTypes.Add(groupNameList);
  9746. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9747. //默认币种显示
  9748. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9749. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9750. return Ok(JsonView(true, "查询成功!", new
  9751. {
  9752. FileTypeData = fileTypes,
  9753. CurrencyInit = _currencyInfos,
  9754. viewPermissionData = viewPermissionData
  9755. }));
  9756. }
  9757. /// <summary>
  9758. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9759. /// </summary>
  9760. /// <returns></returns>
  9761. [HttpPost]
  9762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9763. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9764. {
  9765. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9766. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9767. RefAsync<int> total = 0;
  9768. int diId = 0;
  9769. var status = int.TryParse(dto.GroupName, out diId);
  9770. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9771. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9772. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9773. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9774. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9775. .OrderByDescending(x => x.VisitStartDate)
  9776. .Select(x => new EnterExitCostMobileGroupView()
  9777. {
  9778. Id = x.Id,
  9779. GroupName = x.TeamName,
  9780. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9781. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9782. ProvinceId = x.CityId
  9783. })
  9784. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9785. //处理省份Id
  9786. if (data.Any())
  9787. {
  9788. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9789. if (provCityDatas.Any())
  9790. {
  9791. foreach (var item in data)
  9792. {
  9793. var provinceId = item.ProvinceId;
  9794. var isDefualtVal = true;
  9795. if (provinceId > 0)
  9796. {
  9797. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9798. if (parentId != null)
  9799. {
  9800. isDefualtVal = false;
  9801. item.ProvinceId = (int)parentId;
  9802. }
  9803. }
  9804. if (isDefualtVal)
  9805. {
  9806. item.ProvinceId = 122; //默认四川
  9807. }
  9808. }
  9809. }
  9810. }
  9811. //处理是否显示
  9812. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9813. {
  9814. foreach (var item in data)
  9815. {
  9816. item.IsView = true;
  9817. }
  9818. }
  9819. return Ok(JsonView(true, "查询成功!", data, total));
  9820. }
  9821. /// <summary>
  9822. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9823. /// </summary>
  9824. /// <returns></returns>
  9825. [HttpPost]
  9826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9827. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9828. {
  9829. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9830. RefAsync<int> total = 0;
  9831. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9832. .Where(x => x.IsDel == 0 && x.STid == 66)
  9833. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9834. .Select(x => new
  9835. {
  9836. id = x.Id,
  9837. name = x.Name,
  9838. remark = x.Remark,
  9839. })
  9840. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9841. return Ok(JsonView(true, "查询成功!", data, total));
  9842. }
  9843. /// <summary>
  9844. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9845. /// </summary>
  9846. /// <returns></returns>
  9847. [HttpPost]
  9848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9849. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9850. {
  9851. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9852. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9853. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9854. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9855. var groupOtherRateData = groupRateData.TeamRates;
  9856. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9857. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9858. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9859. groupOtherRateData = groupOtherRateData
  9860. .Select(x => new TeamRateDescAddCurrencyIdView
  9861. {
  9862. CurrencyId = x.CurrencyId,
  9863. CurrencyName = x.CurrencyName,
  9864. CurrencyCode = x.CurrencyCode,
  9865. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9866. }).ToList();
  9867. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9868. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9869. }
  9870. /// <summary>
  9871. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9872. /// </summary>
  9873. /// <returns></returns>
  9874. [HttpPost]
  9875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9876. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9877. {
  9878. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9879. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9880. var tipsData = new List<int>() { 1, 2, 3 };
  9881. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9882. if (dto.TipsType == 1)
  9883. {
  9884. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9885. }
  9886. else if (dto.TipsType == 2)
  9887. {
  9888. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9889. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9890. }
  9891. else if (dto.TipsType == 3)
  9892. {
  9893. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9894. return Ok(JsonView(true, "查询成功!", airData));
  9895. }
  9896. return Ok(JsonView(false));
  9897. }
  9898. /// <summary>
  9899. /// 团组模块 - 出入境国家费用标准-移动端 List
  9900. /// </summary>
  9901. /// <returns></returns>
  9902. [HttpPost]
  9903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9904. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9905. {
  9906. Stopwatch sw = new Stopwatch();
  9907. sw.Start();
  9908. int provinceId = dto.ProvinceId;
  9909. if (provinceId < 1) provinceId = 122; // 默认四川
  9910. RefAsync<int> total = 0;
  9911. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9912. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9913. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9914. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9915. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9916. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9917. .Select((ntf, sd, u, sd1) => new
  9918. {
  9919. Id = ntf.Id,
  9920. Area = $"{ntf.Country}-{ntf.City}",
  9921. Currency = ntf.Currency,
  9922. CurrencyCode = sd.Name,
  9923. CurrencyName = sd.Remark,
  9924. RoomCost = ntf.RoomCost,
  9925. FoodCost = ntf.FoodCost,
  9926. PublicCost = ntf.PublicCost,
  9927. TrainCost = ntf.TrainCost,
  9928. LastUpdateUserId = ntf.LastUpdateUserId,
  9929. LastUpdateUserName = u.CnName,
  9930. LastUpdateTime = ntf.LastUpdateTime
  9931. })
  9932. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9933. sw.Stop();
  9934. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9935. }
  9936. /// <summary>
  9937. /// 团组模块 - 出入境费用-移动端 - Info
  9938. /// </summary>
  9939. /// <returns></returns>
  9940. [HttpPost]
  9941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9942. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9943. {
  9944. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9945. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9946. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9947. return Ok(data);
  9948. }
  9949. /// <summary>
  9950. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9951. /// </summary>
  9952. /// <returns></returns>
  9953. [HttpPost]
  9954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9955. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9956. {
  9957. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9958. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9959. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9960. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9961. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9962. mobileInfo.DiId = dto.DiId;
  9963. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9964. if (eecInfo == null) return Ok(mobileInfo);
  9965. //验证查看权限
  9966. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9967. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9968. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9969. mobileInfo.IsAssignPerm = isSet;
  9970. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9971. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9972. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9973. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9974. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9975. {
  9976. SubId = dac.Id,
  9977. DiId = dac.DiId,
  9978. Type = dac.Type,
  9979. Days = dac.Days,
  9980. NationalTravelFeeId = dac.NationalTravelFeeId,
  9981. Arae = $"{ntf.Country}-{ntf.City}",
  9982. Cost = dac.Cost,
  9983. Currency = dac.Currency,
  9984. CurrencyName = sd.Name,
  9985. SubTotal = dac.SubTotal,
  9986. })
  9987. .ToList();
  9988. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9989. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9990. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9991. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9992. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9993. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9994. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9995. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9996. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9997. //其他款项
  9998. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9999. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10000. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10001. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10002. .OrderBy((dop, sd1, sd2) => dop.Index)
  10003. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10004. {
  10005. SubId = dop.Id,
  10006. DiId = dop.Diid,
  10007. Index = dop.Index,
  10008. SetDataId = dop.SetDataId,
  10009. SetDataName = sd1.Name,
  10010. Cost = dop.Cost,
  10011. Currency = dop.Currency,
  10012. CurrencyName = sd2.Remark,
  10013. SubTotal = dop.SubTotal,
  10014. Remark = dop.Remark,
  10015. })
  10016. .ToArray();
  10017. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10018. return Ok(mobileInfo);
  10019. }
  10020. /// <summary>
  10021. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  10022. /// </summary>
  10023. /// <returns></returns>
  10024. [HttpPost]
  10025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10026. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  10027. {
  10028. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10029. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10030. //验证查看权限
  10031. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  10032. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  10033. var userIds = await _sqlSugar
  10034. .Queryable<Grp_EnterExitCostPermission>()
  10035. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  10036. .Select(x => x.UserId)
  10037. .ToArrayAsync();
  10038. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  10039. var perUsersView = new List<dynamic>();
  10040. foreach (var item in perUsers)
  10041. {
  10042. bool isView1 = false;
  10043. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10044. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10045. }
  10046. return Ok(JsonView(perUsersView));
  10047. }
  10048. /// <summary>
  10049. /// 团组模块 - 出入境费用-移动端 - SubInfo
  10050. /// </summary>
  10051. /// <returns></returns>
  10052. [HttpPost]
  10053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10054. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  10055. {
  10056. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10057. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10058. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10059. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10060. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10061. //验证查看权限
  10062. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  10063. //if (!isView) return Ok(JsonView(false, msg));
  10064. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10065. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10066. var subType = dto.SubType;
  10067. if (subType == 1) //1:境内费用
  10068. {
  10069. var oneData = new ChoiceOneMobileSubInfoView()
  10070. {
  10071. Id = eecInfo.Id,
  10072. ChoiceOne = eecInfo.ChoiceOne,
  10073. ChoiceOneTotalCost = eecInfo.InsidePay,
  10074. Visa = eecInfo.Visa,
  10075. VisaRemark = eecInfo.VisaRemark,
  10076. YiMiao = eecInfo.YiMiao,
  10077. HeSuan = eecInfo.HeSuan,
  10078. Service = eecInfo.Service,
  10079. Ticket = eecInfo.Ticket,
  10080. Safe = eecInfo.Safe,
  10081. FirstItemRemark = eecInfo.FirstItemRemark
  10082. };
  10083. return Ok(JsonView(oneData));
  10084. }
  10085. else if (subType == 2) //2:国际旅费
  10086. {
  10087. var twoData = new ChoiceTwoMobileSubInfoView()
  10088. {
  10089. Id = eecInfo.Id,
  10090. ChoiceTwoJJ = eecInfo.SumJJC,
  10091. OutsideJJPay = eecInfo.OutsideJJPay,
  10092. ChoiceTwoGW = eecInfo.SumGWC,
  10093. OutsideGWPay = eecInfo.OutsideGWPay,
  10094. ChoiceTwoTD = eecInfo.SumTDC,
  10095. OutsideTDPay = eecInfo.OutsideTDPay,
  10096. AirJJ = eecInfo.AirJJ,
  10097. AirGW = eecInfo.AirGW,
  10098. AirTD = eecInfo.AirTD,
  10099. CityTranffic = eecInfo.CityTranffic,
  10100. TwoItemRemark = eecInfo.TwoItemRemark
  10101. };
  10102. return Ok(JsonView(twoData));
  10103. }
  10104. else if (subType == 3) //3:住宿费
  10105. {
  10106. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10107. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10108. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10109. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10110. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10111. {
  10112. SubId = dac.Id,
  10113. DiId = dac.DiId,
  10114. Type = dac.Type,
  10115. Days = dac.Days,
  10116. NationalTravelFeeId = dac.NationalTravelFeeId,
  10117. Arae = $"{ntf.Country}-{ntf.City}",
  10118. Cost = dac.Cost,
  10119. Currency = dac.Currency,
  10120. CurrencyName = sd.Name,
  10121. SubTotal = dac.SubTotal,
  10122. })
  10123. .ToArray();
  10124. var data = new ChoiceMobileSubInfo3To6View()
  10125. {
  10126. ParentId = eecInfo.Id,
  10127. Choice = eecInfo.ChoiceThree,
  10128. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10129. Details = dayAndCostDatas
  10130. };
  10131. return Ok(JsonView(data));
  10132. }
  10133. else if (subType == 4) //4:伙食费
  10134. {
  10135. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10136. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10137. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10138. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10139. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10140. {
  10141. SubId = dac.Id,
  10142. DiId = dac.DiId,
  10143. Type = dac.Type,
  10144. Days = dac.Days,
  10145. NationalTravelFeeId = dac.NationalTravelFeeId,
  10146. Arae = $"{ntf.Country}-{ntf.City}",
  10147. Cost = dac.Cost,
  10148. Currency = dac.Currency,
  10149. CurrencyName = sd.Name,
  10150. SubTotal = dac.SubTotal,
  10151. })
  10152. .ToArray();
  10153. var data = new ChoiceMobileSubInfo3To6View()
  10154. {
  10155. ParentId = eecInfo.Id,
  10156. Choice = eecInfo.ChoiceFour,
  10157. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10158. Details = dayAndCostDatas
  10159. };
  10160. return Ok(JsonView(data));
  10161. }
  10162. else if (subType == 5) //5:公杂费
  10163. {
  10164. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10165. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10166. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10167. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10168. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10169. {
  10170. SubId = dac.Id,
  10171. DiId = dac.DiId,
  10172. Type = dac.Type,
  10173. Days = dac.Days,
  10174. NationalTravelFeeId = dac.NationalTravelFeeId,
  10175. Arae = $"{ntf.Country}-{ntf.City}",
  10176. Cost = dac.Cost,
  10177. Currency = dac.Currency,
  10178. CurrencyName = sd.Name,
  10179. SubTotal = dac.SubTotal,
  10180. })
  10181. .ToArray();
  10182. var data = new ChoiceMobileSubInfo3To6View()
  10183. {
  10184. ParentId = eecInfo.Id,
  10185. Choice = eecInfo.ChoiceFive,
  10186. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10187. Details = dayAndCostDatas
  10188. };
  10189. return Ok(JsonView(data));
  10190. }
  10191. else if (subType == 6) //6:培训费
  10192. {
  10193. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10194. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10195. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10196. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  10197. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10198. {
  10199. SubId = dac.Id,
  10200. DiId = dac.DiId,
  10201. Type = dac.Type,
  10202. Days = dac.Days,
  10203. NationalTravelFeeId = dac.NationalTravelFeeId,
  10204. Arae = $"{ntf.Country}-{ntf.City}",
  10205. Cost = dac.Cost,
  10206. Currency = dac.Currency,
  10207. CurrencyName = sd.Name,
  10208. SubTotal = dac.SubTotal,
  10209. })
  10210. .ToArray();
  10211. var data = new ChoiceMobileSubInfo3To6View()
  10212. {
  10213. ParentId = eecInfo.Id,
  10214. Choice = eecInfo.ChoiceSix,
  10215. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10216. Details = dayAndCostDatas
  10217. };
  10218. return Ok(JsonView(data));
  10219. }
  10220. else if (subType == 7) //7:其他
  10221. {
  10222. //其他款项
  10223. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10224. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10225. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10226. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10227. .OrderBy((dop, sd1, sd2) => dop.Index)
  10228. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10229. {
  10230. SubId = dop.Id,
  10231. DiId = dop.Diid,
  10232. Index = dop.Index,
  10233. SetDataId = dop.SetDataId,
  10234. SetDataName = sd1.Name,
  10235. Cost = dop.Cost,
  10236. Currency = dop.Currency,
  10237. CurrencyName = sd2.Name,
  10238. SubTotal = dop.SubTotal,
  10239. Remark = dop.Remark,
  10240. })
  10241. .ToArray();
  10242. var data = new ChoiceSevenMobileSubInfoView()
  10243. {
  10244. ParentId = eecInfo.Id,
  10245. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10246. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10247. Details = otherData
  10248. };
  10249. return Ok(JsonView(data));
  10250. }
  10251. return Ok(JsonView(false));
  10252. }
  10253. #region op
  10254. ///// <summary>
  10255. ///// 移动端更新费用消息通知
  10256. ///// </summary>
  10257. ///// <param name="diid"></param>
  10258. ///// <param name="id"></param>
  10259. ///// <param name="currUserId"></param>
  10260. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10261. //{
  10262. // try
  10263. // {
  10264. // ////生成默认文件pdf并且通知人员
  10265. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10266. // //{
  10267. // // DiId = diid,
  10268. // // ExportType = 1,
  10269. // // SubTypeId = 1005
  10270. // //}, "pdf");
  10271. // ////发送通知
  10272. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10273. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10274. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10275. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10276. // ////汇率信息记录
  10277. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10278. // }
  10279. // catch (Exception ex)
  10280. // {
  10281. // //记录日志
  10282. // throw;
  10283. // }
  10284. //}
  10285. /// <summary>
  10286. /// 验证出入境费用数据是否存在
  10287. /// 不存在添加
  10288. /// </summary>
  10289. /// <param name="diId"></param>
  10290. /// <param name="currUserId"></param>
  10291. /// <returns></returns>
  10292. /// <exception cref="CustomException"></exception>
  10293. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10294. {
  10295. var parentId = 0;
  10296. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10297. if (info != null)
  10298. {
  10299. parentId = info.Id;
  10300. }
  10301. else
  10302. {
  10303. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10304. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10305. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10306. parentId = addId;
  10307. }
  10308. return parentId;
  10309. }
  10310. /// <summary>
  10311. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10312. /// </summary>
  10313. /// <returns></returns>
  10314. [HttpPost]
  10315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10316. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10317. {
  10318. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10319. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10320. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10321. //验证编辑权限
  10322. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10323. //if (!isEdit) return Ok(JsonView(false, msg));
  10324. var permissions = new List<Grp_EnterExitCostPermission>();
  10325. foreach (var userId in dto.UserIds)
  10326. {
  10327. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10328. }
  10329. if (permissions.Any())
  10330. {
  10331. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10332. {
  10333. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10334. }
  10335. _sqlSugar.BeginTran();
  10336. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10337. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10338. if (result < 1)
  10339. {
  10340. _sqlSugar.RollbackTran();
  10341. return Ok(JsonView(false));
  10342. }
  10343. _sqlSugar.CommitTran();
  10344. return Ok(JsonView(true));
  10345. }
  10346. return Ok(JsonView(false));
  10347. }
  10348. /// <summary>
  10349. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10350. /// </summary>
  10351. /// <returns></returns>
  10352. [HttpPost]
  10353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10354. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10355. {
  10356. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10357. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10358. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10359. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10360. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10361. int id = dto.Id;
  10362. if (id <= 0) //add
  10363. {
  10364. //int provinceId = dto.ProvinceId;
  10365. int groupId = dto.DiId;
  10366. //if (provinceId < 1) provinceId = 122;
  10367. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10368. info.LastUpdateUserId = dto.CurrUserId;
  10369. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10370. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10371. if (add < 1) return Ok(JsonView(false));
  10372. id = add;
  10373. }
  10374. else //update
  10375. {
  10376. ////验证编辑权限
  10377. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10378. //if (!isEdit) return Ok(JsonView(false, msg));
  10379. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  10380. {
  10381. CurrencyRemark = currencyStr,
  10382. LastUpdateUserId = dto.CurrUserId,
  10383. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10384. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10385. if (upd < 1) return Ok(JsonView(false));
  10386. }
  10387. #region 汇率变更时更改币种相关费用
  10388. var opDayCosts = new List<Grp_DayAndCost>();
  10389. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10390. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10391. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10392. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10393. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10394. .Select((dac, sd) => new
  10395. {
  10396. dac.Id,
  10397. dac.DiId,
  10398. CurrencyCode = sd.Name,
  10399. dac.Cost
  10400. })
  10401. .ToList();
  10402. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10403. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10404. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10405. .Select((dop, sd) => new
  10406. {
  10407. dop.Id,
  10408. dop.Diid,
  10409. CurrencyCode = sd.Name,
  10410. dop.Cost
  10411. })
  10412. .ToList();
  10413. if (dayCosts.Count > 0)
  10414. {
  10415. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10416. foreach (var dc in new_dayCosts)
  10417. {
  10418. var thisCurrency = dc.Key.ToUpper();
  10419. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10420. if (thisRate == 0.00M) continue;
  10421. foreach (var dcSub in dc)
  10422. {
  10423. opDayCosts.Add(new Grp_DayAndCost()
  10424. {
  10425. Id = dcSub.Id,
  10426. DiId = dcSub.DiId,
  10427. Cost = dcSub.Cost,
  10428. SubTotal = dcSub.Cost * thisRate,
  10429. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10430. });
  10431. }
  10432. }
  10433. if (opDayCosts.Count > 0)
  10434. {
  10435. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10436. }
  10437. }
  10438. if (dayOtherCosts.Count > 0)
  10439. {
  10440. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10441. foreach (var dc in new_dayOtherCosts)
  10442. {
  10443. var thisCurrency = dc.Key.ToUpper();
  10444. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10445. if (thisRate == 0.00M) continue;
  10446. foreach (var dcSub in dc)
  10447. {
  10448. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10449. {
  10450. Id = dcSub.Id,
  10451. Diid = dcSub.Diid,
  10452. Cost = dcSub.Cost,
  10453. SubTotal = dcSub.Cost * thisRate,
  10454. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10455. });
  10456. }
  10457. }
  10458. if (opDayOtherCosts.Count > 0)
  10459. {
  10460. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10461. }
  10462. }
  10463. #endregion
  10464. //消息通知
  10465. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10466. //汇率信息记录
  10467. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10468. return Ok(JsonView(new { parentId = id }));
  10469. }
  10470. /// <summary>
  10471. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10472. /// </summary>
  10473. /// <returns></returns>
  10474. [HttpPost]
  10475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10476. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10477. {
  10478. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10479. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10480. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10481. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10482. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10483. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  10484. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10485. int id = dto.Id;
  10486. if (id <= 0) //add
  10487. {
  10488. checkboxInfo.CreateUserId = dto.CurrUserId;
  10489. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10490. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10491. if (add < 1) return Ok(JsonView(false));
  10492. }
  10493. else //update
  10494. {
  10495. ////验证编辑权限
  10496. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10497. //if (!isEdit) return Ok(JsonView(false, msg));
  10498. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10499. .UpdateColumns(x => new
  10500. {
  10501. x.ChoiceOne,
  10502. x.ChoiceTwo,
  10503. x.SumJJC,
  10504. x.SumGWC,
  10505. x.SumTDC,
  10506. x.ChoiceThree,
  10507. x.ChoiceFour,
  10508. x.ChoiceFive,
  10509. x.ChoiceSix,
  10510. x.OtherExpenses_Checked
  10511. })
  10512. .Where(x => x.Id == id)
  10513. .ExecuteCommandAsync();
  10514. if (upd < 1) return Ok(JsonView(false));
  10515. }
  10516. return Ok(JsonView(new { parentId = id }));
  10517. }
  10518. /// <summary>
  10519. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10520. /// </summary>
  10521. /// <returns></returns>
  10522. [HttpPost]
  10523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10524. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10525. {
  10526. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10527. // if (provinceId < 1) provinceId = 122;
  10528. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10529. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10530. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10531. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10532. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10533. var checkboxInfo = new Grp_EnterExitCost()
  10534. {
  10535. Id = id,
  10536. //ProvinceId = provinceId,
  10537. DiId = diId,
  10538. CreateUserId = currUserId,
  10539. LastUpdateUserId = dto.CurrUserId,
  10540. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10541. };
  10542. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10543. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10544. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10545. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10546. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10547. if (id <= 0) //add
  10548. {
  10549. checkboxInfo.CreateUserId = dto.CurrUserId;
  10550. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10551. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10552. if (add < 1) return Ok(JsonView(false));
  10553. }
  10554. else //update
  10555. {
  10556. ////验证编辑权限
  10557. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10558. //if (!isEdit) return Ok(JsonView(false, msg));
  10559. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10560. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  10561. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  10562. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10563. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10564. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10565. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10566. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10567. .Where(x => x.Id == id)
  10568. .ExecuteCommandAsync();
  10569. if (upd < 1) return Ok(JsonView(false));
  10570. }
  10571. return Ok(JsonView(new { parentId = id }));
  10572. }
  10573. /// <summary>
  10574. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10575. /// </summary>
  10576. /// <returns></returns>
  10577. [HttpPost]
  10578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10579. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10580. {
  10581. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10582. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10583. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10584. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10585. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10586. info.FirstItemRemark = dto.FirstItemRemark;
  10587. info.LastUpdateUserId = dto.CurrUserId;
  10588. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10589. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10590. int id = dto.Id;
  10591. if (id <= 0) //add
  10592. {
  10593. info.CreateUserId = dto.CurrUserId;
  10594. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10595. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10596. if (add < 1) return Ok(JsonView(false));
  10597. id = add;
  10598. }
  10599. else //update
  10600. {
  10601. ////验证编辑权限
  10602. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10603. //if (!isEdit) return Ok(JsonView(false, msg));
  10604. var upd = await _sqlSugar.Updateable(info)
  10605. .UpdateColumns(x => new
  10606. {
  10607. x.ChoiceOne,
  10608. x.InsidePay,
  10609. x.VisaRemark,
  10610. x.Visa,
  10611. x.Service,
  10612. x.Safe,
  10613. x.Ticket,
  10614. x.HeSuan,
  10615. x.YiMiao,
  10616. x.FirstItemRemark,
  10617. x.LastUpdateUserId,
  10618. x.LastUpdateTime
  10619. })
  10620. .Where(x => x.Id == id)
  10621. .ExecuteCommandAsync();
  10622. if (upd < 1) return Ok(JsonView(false));
  10623. }
  10624. //消息通知
  10625. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10626. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10627. }
  10628. /// <summary>
  10629. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10630. /// </summary>
  10631. /// <returns></returns>
  10632. [HttpPost]
  10633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10634. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10635. {
  10636. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10637. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10638. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10639. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10640. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10641. info.DiId = dto.DiId;
  10642. //info.ProvinceId = dto.ProvinceId;
  10643. info.OutsideJJPay = dto.OutsideJJPay;
  10644. info.OutsideGWPay = dto.OutsideGWPay;
  10645. info.OutsideTDPay = dto.OutsideTDPay;
  10646. info.AirJJ = dto.AirJJ;
  10647. info.AirGW = dto.AirGW;
  10648. info.AirTD = dto.AirTD;
  10649. info.CityTranffic = dto.CityTranffic;
  10650. info.TwoItemRemark = dto.TwoItemRemark;
  10651. info.SumJJC = dto.ChoiceTwoJJ;
  10652. info.SumGWC = dto.ChoiceTwoGW;
  10653. info.SumTDC = dto.ChoiceTwoTD;
  10654. info.LastUpdateUserId = dto.CurrUserId;
  10655. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10656. int id = dto.Id;
  10657. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10658. if (id <= 0) //add i
  10659. {
  10660. info.CreateUserId = dto.CurrUserId;
  10661. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10662. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10663. if (addId <= 0) return Ok(JsonView(false));
  10664. id = addId;
  10665. }
  10666. else //update
  10667. {
  10668. ////验证编辑权限
  10669. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10670. //if (!isEdit) return Ok(JsonView(false, msg));
  10671. var upd = await _sqlSugar.Updateable(info)
  10672. .UpdateColumns(x => new
  10673. {
  10674. x.SumJJC,
  10675. x.OutsideJJPay,
  10676. x.SumGWC,
  10677. x.OutsideGWPay,
  10678. x.SumTDC,
  10679. x.OutsideTDPay,
  10680. x.AirJJ,
  10681. x.AirGW,
  10682. x.AirTD,
  10683. x.CityTranffic,
  10684. x.TwoItemRemark,
  10685. x.LastUpdateTime,
  10686. x.LastUpdateUserId
  10687. })
  10688. .Where(x => x.Id == id)
  10689. .ExecuteCommandAsync();
  10690. if (upd < 1) return Ok(JsonView(false));
  10691. }
  10692. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10693. gwcItemTotal = info.AirGW + info.CityTranffic;
  10694. tdcItemTotal = info.AirTD + info.CityTranffic;
  10695. //消息通知
  10696. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10697. return Ok(JsonView(new
  10698. {
  10699. parentId = id,
  10700. choiceTwoJJ = dto.ChoiceTwoJJ,
  10701. jjcItemTotal = jjcItemTotal,
  10702. choiceTwoGW = dto.ChoiceTwoGW,
  10703. gwcItemTotal = gwcItemTotal,
  10704. choiceTwoTD = dto.ChoiceTwoTD,
  10705. tdcItemTotal = tdcItemTotal
  10706. }));
  10707. }
  10708. /// <summary>
  10709. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10710. /// </summary>
  10711. /// <returns></returns>
  10712. [HttpPost]
  10713. [ApiExplorerSettings(IgnoreApi = true)]
  10714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10715. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10716. {
  10717. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10718. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10719. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10720. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10721. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10722. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10723. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10724. var infos = infos1.Select(x => new Grp_DayAndCost
  10725. {
  10726. Id = x.Id,
  10727. DiId = dto.DiId,
  10728. Type = dto.FeeType,
  10729. Days = x.Days,
  10730. NationalTravelFeeId = x.NationalTravelFeeId,
  10731. Cost = x.Cost,
  10732. Currency = x.Currency,
  10733. SubTotal = x.SubTotal,
  10734. CreateUserId = dto.CurrUserId
  10735. })
  10736. .ToList();
  10737. var adds = infos.Where(x => x.Id <= 0).ToList();
  10738. var upds = infos.Where(x => x.Id > 0).ToList();
  10739. if (adds.Count > 0)
  10740. {
  10741. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10742. if (add < 1) return Ok(JsonView(false));
  10743. }
  10744. if (upds.Count > 0)
  10745. {
  10746. var upd = await _sqlSugar.Updateable(adds)
  10747. .UpdateColumns(x => new
  10748. {
  10749. x.Days,
  10750. x.NationalTravelFeeId,
  10751. x.Cost,
  10752. x.Currency,
  10753. x.SubTotal
  10754. })
  10755. .WhereColumns(x => new { x.Id })
  10756. .ExecuteCommandAsync();
  10757. if (upd < 1) return Ok(JsonView(false));
  10758. }
  10759. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10760. //消息通知
  10761. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10762. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10763. return Ok(JsonView(new { itemTotal = itemTotal }));
  10764. }
  10765. /// <summary>
  10766. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10767. /// </summary>
  10768. /// <returns></returns>
  10769. [HttpPost]
  10770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10771. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10772. {
  10773. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10774. int subId = dto.SubId, feeType = dto.FeeType;
  10775. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10776. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10777. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10778. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10779. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10780. subInfo.Id = subId;
  10781. subInfo.DiId = dto.DiId;
  10782. if (feeType == 3) subInfo.Type = 1;
  10783. else if (feeType == 4) subInfo.Type = 2;
  10784. else if (feeType == 5) subInfo.Type = 3;
  10785. else if (feeType == 6) subInfo.Type = 4;
  10786. subInfo.CreateUserId = dto.CurrUserId;
  10787. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10788. if (parentId < 1) return Ok(JsonView(false));
  10789. //子表op
  10790. if (subId < 1)
  10791. {
  10792. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10793. if (subAdd < 1) return Ok(JsonView(false));
  10794. }
  10795. else
  10796. {
  10797. ////验证编辑权限
  10798. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10799. //if (!isEdit) return Ok(JsonView(false, msg));
  10800. var subUpd = await _sqlSugar.Updateable(subInfo)
  10801. .UpdateColumns(x => new
  10802. {
  10803. x.Days,
  10804. x.NationalTravelFeeId,
  10805. x.Cost,
  10806. x.Currency,
  10807. x.SubTotal
  10808. })
  10809. .WhereColumns(x => new { x.Id })
  10810. .ExecuteCommandAsync();
  10811. if (subUpd < 1) return Ok(JsonView(false));
  10812. }
  10813. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10814. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10815. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10816. }
  10817. /// <summary>
  10818. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10819. /// </summary>
  10820. /// <returns></returns>
  10821. [HttpPost]
  10822. [ApiExplorerSettings(IgnoreApi = true)]
  10823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10824. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10825. {
  10826. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10827. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10828. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10829. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10830. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10831. {
  10832. Id = x.Id,
  10833. Diid = dto.DiId,
  10834. SetDataId = x.SetDataId,
  10835. Index = x.Index,
  10836. Cost = x.Cost,
  10837. Currency = x.Currency,
  10838. SubTotal = x.SubTotal,
  10839. CreateUserId = dto.CurrUserId,
  10840. Remark = x.Remark
  10841. }).ToList();
  10842. var adds = infos.Where(x => x.Id <= 0).ToList();
  10843. var upds = infos.Where(x => x.Id > 0).ToList();
  10844. if (adds.Count > 0)
  10845. {
  10846. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10847. if (add < 1) return Ok(JsonView(false));
  10848. }
  10849. if (upds.Count > 0)
  10850. {
  10851. var upd = await _sqlSugar.Updateable(adds)
  10852. .UpdateColumns(x => new
  10853. {
  10854. x.Index,
  10855. x.SetDataId,
  10856. x.Cost,
  10857. x.Currency,
  10858. x.SubTotal,
  10859. x.Remark
  10860. })
  10861. .WhereColumns(x => new { x.Id })
  10862. .ExecuteCommandAsync();
  10863. if (upd < 1) return Ok(JsonView(false));
  10864. }
  10865. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10866. //消息通知
  10867. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10868. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10869. return Ok(JsonView(new { itemTotal = itemTotal }));
  10870. }
  10871. /// <summary>
  10872. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10873. /// </summary>
  10874. /// <returns></returns>
  10875. [HttpPost]
  10876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10877. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10878. {
  10879. int subId = dto.SubId;
  10880. int diId = dto.Diid;
  10881. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10882. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10883. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10884. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10885. subInfo.Id = subId;
  10886. subInfo.Diid = dto.Diid;
  10887. subInfo.CreateUserId = dto.CurrUserId;
  10888. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10889. if (parentId < 1) return Ok(JsonView(false));
  10890. #region 子表op
  10891. if (subId < 1)//add
  10892. {
  10893. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10894. if (subAdd < 1) return Ok(JsonView(false));
  10895. }
  10896. else //upd
  10897. {
  10898. ////验证编辑权限
  10899. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10900. //if (!isEdit) return Ok(JsonView(false, msg));
  10901. var subUpd = await _sqlSugar.Updateable(subInfo)
  10902. .UpdateColumns(x => new
  10903. {
  10904. x.Index,
  10905. x.SetDataId,
  10906. x.Cost,
  10907. x.Currency,
  10908. x.SubTotal,
  10909. x.Remark
  10910. })
  10911. .WhereColumns(x => new { x.Id })
  10912. .ExecuteCommandAsync();
  10913. if (subUpd < 1) return Ok(JsonView(false));
  10914. }
  10915. #endregion
  10916. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10917. //消息通知
  10918. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10919. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10920. }
  10921. /// <summary>
  10922. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10923. /// </summary>
  10924. /// <returns></returns>
  10925. [HttpPost]
  10926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10927. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10928. {
  10929. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10930. if (data.Code != 0)
  10931. {
  10932. return Ok(JsonView(false, data.Msg));
  10933. }
  10934. return Ok(JsonView(true, "操作成功!", data.Data));
  10935. }
  10936. /// <summary>
  10937. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10938. /// </summary>
  10939. /// <param name="dto"></param>
  10940. /// <returns></returns>
  10941. [HttpPost]
  10942. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10943. {
  10944. var data = new Grp_DayOtherPrice()
  10945. {
  10946. Id = dto.Id,
  10947. IsDel = 1,
  10948. DeleteUserId = dto.DeleteUserId,
  10949. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10950. };
  10951. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10952. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10953. return Ok(JsonView(false, "删除失败!"));
  10954. }
  10955. #endregion
  10956. #endregion
  10957. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10958. /// <summary>
  10959. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10960. /// </summary>
  10961. /// <returns></returns>
  10962. [HttpGet]
  10963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10964. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10965. {
  10966. var provData = await _groupRepository.ProvinceBasicSource();
  10967. return Ok(JsonView(true, "查询成功!", provData));
  10968. }
  10969. /// <summary>
  10970. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10971. /// </summary>
  10972. /// <returns></returns>
  10973. [HttpPost]
  10974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10975. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10976. {
  10977. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10978. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10979. RefAsync<int> total = 0;
  10980. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10981. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10982. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10983. .Select(x => new
  10984. {
  10985. Id = x.Id,
  10986. DraftName = x.DraftName,
  10987. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10988. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10989. .Any()
  10990. })
  10991. .OrderByDescending(x => x.Id)
  10992. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10993. return Ok(JsonView(true, "查询成功!", data, total));
  10994. }
  10995. /// <summary>
  10996. /// 出入境费用-草稿 移动端
  10997. /// 获取币种基础数据(含逻辑处理)
  10998. /// </summary>
  10999. /// <returns></returns>
  11000. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  11001. {
  11002. return await GeneralMethod.EnterExitCostInitRate();
  11003. }
  11004. /// <summary>
  11005. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  11006. /// </summary>
  11007. /// <returns></returns>
  11008. [HttpPost]
  11009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11010. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  11011. {
  11012. //验证城市归属并给默认值
  11013. int provinceId = dto.ProvinceId;
  11014. if (provinceId < 1) provinceId = 122;
  11015. var dataSource = await _sqlSugar
  11016. .Queryable<Sys_SetData>()
  11017. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  11018. .ToListAsync();
  11019. //三公费用-Word明细类型
  11020. var wordTypeData = dataSource.Where(it => it.STid == 72)
  11021. .Select(x => new SetDataInfoView
  11022. {
  11023. Id = x.Id,
  11024. Name = x.Name,
  11025. Remark = x.Remark
  11026. })
  11027. .ToList();
  11028. //三公费用-Excel明细类型
  11029. var excelTypeData = dataSource.Where(it => it.STid == 73)
  11030. .Select(x => new SetDataInfoView
  11031. {
  11032. Id = x.Id,
  11033. Name = x.Name,
  11034. Remark = x.Remark
  11035. })
  11036. .ToList();
  11037. //默认币种显示
  11038. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  11039. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  11040. return Ok(JsonView(true, "查询成功!", new
  11041. {
  11042. WordTypeData = wordTypeData,
  11043. ExcelTypeData = excelTypeData,
  11044. CurrencyInit = _currencyInfos,
  11045. viewPermissionData = viewPermissionData
  11046. }));
  11047. }
  11048. /// <summary>
  11049. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  11050. /// </summary>
  11051. /// <returns></returns>
  11052. [HttpPost]
  11053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11054. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  11055. {
  11056. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11057. RefAsync<int> total = 0;
  11058. int diId = 0;
  11059. var status = int.TryParse(dto.GroupName, out diId);
  11060. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  11061. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  11062. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  11063. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  11064. .OrderByDescending(x => x.VisitStartDate)
  11065. .Select(x => new
  11066. {
  11067. Id = x.Id,
  11068. GroupName = x.TeamName
  11069. })
  11070. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11071. return Ok(JsonView(true, "查询成功!", data, total));
  11072. }
  11073. /// <summary>
  11074. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  11075. /// </summary>
  11076. /// <returns></returns>
  11077. [HttpPost]
  11078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11079. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  11080. {
  11081. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11082. RefAsync<int> total = 0;
  11083. var data = await _sqlSugar.Queryable<Sys_SetData>()
  11084. .Where(x => x.IsDel == 0 && x.STid == 66)
  11085. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  11086. .Select(x => new
  11087. {
  11088. id = x.Id,
  11089. name = x.Name,
  11090. remark = x.Remark,
  11091. })
  11092. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11093. return Ok(JsonView(true, "查询成功!", data, total));
  11094. }
  11095. /// <summary>
  11096. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11097. /// </summary>
  11098. /// <returns></returns>
  11099. [HttpPost]
  11100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11101. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11102. {
  11103. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11104. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11105. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11106. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11107. var groupOtherRateData = groupRateData.TeamRates;
  11108. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11109. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11110. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11111. groupOtherRateData = groupOtherRateData
  11112. .Select(x => new TeamRateDescAddCurrencyIdView
  11113. {
  11114. CurrencyId = x.CurrencyId,
  11115. CurrencyName = x.CurrencyName,
  11116. CurrencyCode = x.CurrencyCode,
  11117. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11118. }).ToList();
  11119. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11120. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11121. }
  11122. /// <summary>
  11123. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11124. /// </summary>
  11125. /// <returns></returns>
  11126. [HttpPost]
  11127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11128. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11129. {
  11130. int portType = dto.PortType;
  11131. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11132. var tipsData = new List<int>() { 1, 2, 3 };
  11133. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11134. if (dto.TipsType == 1)
  11135. {
  11136. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11137. }
  11138. else if (dto.TipsType == 2)
  11139. {
  11140. if (portType == 2)
  11141. {
  11142. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11143. }
  11144. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11145. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11146. .Select(x => x.NationalTravelFeeId)
  11147. .Distinct()
  11148. .ToListAsync();
  11149. if (portType == 2)
  11150. {
  11151. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11152. }
  11153. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11154. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11155. .Select(x => x.Country)
  11156. .Distinct()
  11157. .ToArrayAsync();
  11158. if (portType == 2)
  11159. {
  11160. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11161. }
  11162. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11163. return Ok(JsonView(true, "查询成功!", new
  11164. {
  11165. totalAmt = totalAmt,
  11166. remark = remark
  11167. }));
  11168. }
  11169. else if (dto.TipsType == 3)
  11170. {
  11171. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11172. }
  11173. return Ok(JsonView(false));
  11174. }
  11175. /// <summary>
  11176. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11177. /// </summary>
  11178. /// <returns></returns>
  11179. [HttpPost]
  11180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11181. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11182. {
  11183. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11184. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11185. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11186. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11187. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11188. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11189. var info = new Grp_EnterExitCostDraft()
  11190. {
  11191. ProvinceId = dto.ProvinceId,
  11192. DraftName = dto.DraftName,
  11193. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  11194. CreateUserId = dto.CurrUserId
  11195. };
  11196. _sqlSugar.BeginTran();
  11197. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11198. if (draftId < 1)
  11199. {
  11200. _sqlSugar.RollbackTran();
  11201. return Ok(JsonView(false, "草稿创建失败!"));
  11202. }
  11203. //添加默认权限
  11204. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  11205. _sqlSugar.CommitTran();
  11206. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11207. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11208. mobileInfo.Id = draftId;
  11209. mobileInfo.DraftName = dto.DraftName;
  11210. mobileInfo.Currencys = rateInfos;
  11211. mobileInfo.IsAssignPerm = assignPerm;
  11212. return Ok(JsonView(mobileInfo));
  11213. }
  11214. /// <summary>
  11215. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11216. /// </summary>
  11217. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11218. /// <summary>
  11219. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11220. /// </summary>
  11221. /// <returns></returns>
  11222. [HttpPost]
  11223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11224. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11225. {
  11226. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11227. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11228. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11229. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11230. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11231. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11232. //验证查看编辑权限
  11233. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11234. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11235. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11236. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11237. mobileInfo.IsAssignPerm = assignPerm;
  11238. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11239. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11240. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11241. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11242. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11243. {
  11244. ParentId = dac.ParentId,
  11245. SubId = dac.Id,
  11246. Type = dac.Type,
  11247. Days = dac.Days,
  11248. NationalTravelFeeId = dac.NationalTravelFeeId,
  11249. Arae = $"{ntf.Country}-{ntf.City}",
  11250. Cost = dac.Cost,
  11251. Currency = dac.Currency,
  11252. CurrencyName = sd.Name,
  11253. SubTotal = dac.SubTotal,
  11254. })
  11255. .ToList();
  11256. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11257. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11258. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11259. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11260. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11261. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11262. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11263. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11264. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11265. //其他款项
  11266. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11267. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11268. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11269. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11270. .OrderBy((dop, sd1, sd2) => dop.Index)
  11271. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11272. {
  11273. ParentId = dop.ParentId,
  11274. SubId = dop.Id,
  11275. Index = dop.Index,
  11276. SetDataId = dop.SetDataId,
  11277. SetDataName = sd1.Name,
  11278. Cost = dop.Cost,
  11279. Currency = dop.Currency,
  11280. CurrencyName = sd2.Remark,
  11281. SubTotal = dop.SubTotal,
  11282. Remark = dop.Remark,
  11283. })
  11284. .ToArray();
  11285. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11286. return Ok(mobileInfo);
  11287. }
  11288. /// <summary>
  11289. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11290. /// </summary>
  11291. /// <returns></returns>
  11292. [HttpPost]
  11293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11294. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11295. {
  11296. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11297. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11298. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11299. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11300. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11301. //验证查看编辑权限
  11302. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11303. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11304. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11305. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11306. var subType = dto.SubType;
  11307. if (subType == 1) //1:境内费用
  11308. {
  11309. var oneData = new ChoiceOneMobileSubInfoView()
  11310. {
  11311. Id = eecInfo.Id,
  11312. ChoiceOne = eecInfo.ChoiceOne,
  11313. ChoiceOneTotalCost = eecInfo.InsidePay,
  11314. Visa = eecInfo.Visa,
  11315. VisaRemark = eecInfo.VisaRemark,
  11316. YiMiao = eecInfo.YiMiao,
  11317. HeSuan = eecInfo.HeSuan,
  11318. Service = eecInfo.Service,
  11319. Ticket = eecInfo.Ticket,
  11320. Safe = eecInfo.Safe,
  11321. FirstItemRemark = eecInfo.FirstItemRemark
  11322. };
  11323. return Ok(JsonView(oneData));
  11324. }
  11325. else if (subType == 2) //2:国际旅费
  11326. {
  11327. var twoData = new ChoiceTwoMobileSubInfoView()
  11328. {
  11329. Id = eecInfo.Id,
  11330. ChoiceTwoJJ = eecInfo.SumJJC,
  11331. OutsideJJPay = eecInfo.OutsideJJPay,
  11332. ChoiceTwoGW = eecInfo.SumGWC,
  11333. OutsideGWPay = eecInfo.OutsideGWPay,
  11334. ChoiceTwoTD = eecInfo.SumTDC,
  11335. OutsideTDPay = eecInfo.OutsideTDPay,
  11336. AirJJ = eecInfo.AirJJ,
  11337. AirGW = eecInfo.AirGW,
  11338. AirTD = eecInfo.AirTD,
  11339. CityTranffic = eecInfo.CityTranffic,
  11340. TwoItemRemark = eecInfo.TwoItemRemark
  11341. };
  11342. return Ok(JsonView(twoData));
  11343. }
  11344. else if (subType == 3) //3:住宿费
  11345. {
  11346. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11347. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11348. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11349. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11350. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11351. {
  11352. ParentId = dac.ParentId,
  11353. SubId = dac.Id,
  11354. Type = dac.Type,
  11355. Days = dac.Days,
  11356. NationalTravelFeeId = dac.NationalTravelFeeId,
  11357. Arae = $"{ntf.Country}-{ntf.City}",
  11358. Cost = dac.Cost,
  11359. Currency = dac.Currency,
  11360. CurrencyName = sd.Name,
  11361. SubTotal = dac.SubTotal,
  11362. })
  11363. .ToArray();
  11364. var data = new ChoiceDraftMobileSubInfo3To6View()
  11365. {
  11366. ParentId = eecInfo.Id,
  11367. Choice = eecInfo.ChoiceThree,
  11368. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11369. Details = dayAndCostDatas
  11370. };
  11371. return Ok(JsonView(data));
  11372. }
  11373. else if (subType == 4) //4:伙食费
  11374. {
  11375. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11376. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11377. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11378. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11379. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11380. {
  11381. ParentId = dac.ParentId,
  11382. SubId = dac.Id,
  11383. Type = dac.Type,
  11384. Days = dac.Days,
  11385. NationalTravelFeeId = dac.NationalTravelFeeId,
  11386. Arae = $"{ntf.Country}-{ntf.City}",
  11387. Cost = dac.Cost,
  11388. Currency = dac.Currency,
  11389. CurrencyName = sd.Name,
  11390. SubTotal = dac.SubTotal,
  11391. })
  11392. .ToArray();
  11393. var data = new ChoiceDraftMobileSubInfo3To6View()
  11394. {
  11395. ParentId = eecInfo.Id,
  11396. Choice = eecInfo.ChoiceFour,
  11397. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11398. Details = dayAndCostDatas
  11399. };
  11400. return Ok(JsonView(data));
  11401. }
  11402. else if (subType == 5) //5:公杂费
  11403. {
  11404. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11405. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11406. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11407. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11408. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11409. {
  11410. ParentId = dac.ParentId,
  11411. SubId = dac.Id,
  11412. Type = dac.Type,
  11413. Days = dac.Days,
  11414. NationalTravelFeeId = dac.NationalTravelFeeId,
  11415. Arae = $"{ntf.Country}-{ntf.City}",
  11416. Cost = dac.Cost,
  11417. Currency = dac.Currency,
  11418. CurrencyName = sd.Name,
  11419. SubTotal = dac.SubTotal,
  11420. })
  11421. .ToArray();
  11422. var data = new ChoiceDraftMobileSubInfo3To6View()
  11423. {
  11424. ParentId = eecInfo.Id,
  11425. Choice = eecInfo.ChoiceFive,
  11426. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11427. Details = dayAndCostDatas
  11428. };
  11429. return Ok(JsonView(data));
  11430. }
  11431. else if (subType == 6) //6:培训费
  11432. {
  11433. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11434. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11435. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11436. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11437. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11438. {
  11439. ParentId = dac.ParentId,
  11440. SubId = dac.Id,
  11441. Type = dac.Type,
  11442. Days = dac.Days,
  11443. NationalTravelFeeId = dac.NationalTravelFeeId,
  11444. Arae = $"{ntf.Country}-{ntf.City}",
  11445. Cost = dac.Cost,
  11446. Currency = dac.Currency,
  11447. CurrencyName = sd.Name,
  11448. SubTotal = dac.SubTotal,
  11449. })
  11450. .ToArray();
  11451. var data = new ChoiceDraftMobileSubInfo3To6View()
  11452. {
  11453. ParentId = eecInfo.Id,
  11454. Choice = eecInfo.ChoiceSix,
  11455. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11456. Details = dayAndCostDatas
  11457. };
  11458. return Ok(JsonView(data));
  11459. }
  11460. else if (subType == 7) //7:其他
  11461. {
  11462. //其他款项
  11463. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11464. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11465. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11466. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11467. .OrderBy((dop, sd1, sd2) => dop.Index)
  11468. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11469. {
  11470. ParentId = dop.ParentId,
  11471. SubId = dop.Id,
  11472. Index = dop.Index,
  11473. SetDataId = dop.SetDataId,
  11474. SetDataName = sd1.Name,
  11475. Cost = dop.Cost,
  11476. Currency = dop.Currency,
  11477. CurrencyName = sd2.Name,
  11478. SubTotal = dop.SubTotal,
  11479. Remark = dop.Remark,
  11480. })
  11481. .ToArray();
  11482. var data = new ChoiceSevenDraftMobileSubInfoView()
  11483. {
  11484. ParentId = eecInfo.Id,
  11485. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11486. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11487. Details = otherData
  11488. };
  11489. return Ok(JsonView(data));
  11490. }
  11491. return Ok(JsonView(false));
  11492. }
  11493. #region op
  11494. ///// <summary>
  11495. ///// 移动端更新费用消息通知
  11496. ///// </summary>
  11497. ///// <param name="draftId"></param>
  11498. ///// <param name="id"></param>
  11499. ///// <param name="currUserId"></param>
  11500. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11501. //{
  11502. // try
  11503. // {
  11504. // ////生成默认文件pdf并且通知人员
  11505. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11506. // //{
  11507. // // DiId = draftId,
  11508. // // ExportType = 1,
  11509. // // SubTypeId = 1005
  11510. // //}, "pdf");
  11511. // ////发送通知
  11512. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11513. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11514. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11515. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11516. // ////汇率信息记录
  11517. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11518. // }
  11519. // catch (Exception ex)
  11520. // {
  11521. // //记录日志
  11522. // throw;
  11523. // }
  11524. //}
  11525. /// <summary>
  11526. /// 验证出入境费用数据是否存在
  11527. /// 不存在添加
  11528. /// </summary>
  11529. /// <param name="draftId"></param>
  11530. /// <param name="currUserId"></param>
  11531. /// <returns></returns>
  11532. /// <exception cref="CustomException"></exception>
  11533. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11534. {
  11535. var parentId = 0;
  11536. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11537. if (info != null) parentId = info.Id;
  11538. else
  11539. {
  11540. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11541. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11542. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11543. parentId = addId;
  11544. }
  11545. return parentId;
  11546. }
  11547. /// <summary>
  11548. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11549. /// </summary>
  11550. /// <returns></returns>
  11551. [HttpPost]
  11552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11553. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11554. {
  11555. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11556. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11557. //验证查看权限
  11558. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11559. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11560. var userIds = await _sqlSugar
  11561. .Queryable<Grp_EnterExitCostDraftPermission>()
  11562. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11563. .Select(x => x.UserId)
  11564. .ToArrayAsync();
  11565. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11566. var perUsersView = new List<dynamic>();
  11567. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11568. var viewPermissionData = new List<PermissionViewUserview>();
  11569. if (feeBasePerm.Any())
  11570. {
  11571. foreach (var item in feeBasePerm)
  11572. {
  11573. if (item.Users.Any())
  11574. {
  11575. viewPermissionData.AddRange(item.Users);
  11576. }
  11577. }
  11578. }
  11579. foreach (var item in perUsers)
  11580. {
  11581. bool isView1 = false;
  11582. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11583. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11584. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11585. }
  11586. return Ok(JsonView(perUsersView));
  11587. }
  11588. /// <summary>
  11589. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11590. /// </summary>
  11591. /// <returns></returns>
  11592. [HttpPost]
  11593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11594. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11595. {
  11596. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11597. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11598. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11599. //验证查看编辑权限
  11600. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11601. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11602. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11603. foreach (var userId in dto.UserIds)
  11604. {
  11605. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11606. }
  11607. if (permissions.Any())
  11608. {
  11609. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11610. {
  11611. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11612. }
  11613. _sqlSugar.BeginTran();
  11614. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11615. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11616. if (result < 1)
  11617. {
  11618. _sqlSugar.RollbackTran();
  11619. return Ok(JsonView(false));
  11620. }
  11621. _sqlSugar.CommitTran();
  11622. return Ok(JsonView(true));
  11623. }
  11624. return Ok(JsonView(false));
  11625. }
  11626. /// <summary>
  11627. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11628. /// </summary>
  11629. /// <returns></returns>
  11630. [HttpPost]
  11631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11632. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11633. {
  11634. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11635. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11636. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11637. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11638. int id = dto.DraftId;
  11639. if (id <= 0) //add
  11640. {
  11641. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11642. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11643. if (add < 1) return Ok(JsonView(false));
  11644. id = add;
  11645. }
  11646. else //update
  11647. {
  11648. //验证查看编辑权限
  11649. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11650. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11651. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11652. if (upd < 1) return Ok(JsonView(false));
  11653. }
  11654. return Ok(JsonView(new { parentId = id }));
  11655. }
  11656. /// <summary>
  11657. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11658. /// </summary>
  11659. /// <returns></returns>
  11660. [HttpPost]
  11661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11662. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11663. {
  11664. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11665. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11666. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11667. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11668. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11669. int id = dto.DraftId;
  11670. if (id <= 0) //add
  11671. {
  11672. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11673. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11674. if (add < 1) return Ok(JsonView(false));
  11675. id = add;
  11676. }
  11677. else //update
  11678. {
  11679. //验证查看编辑权限
  11680. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11681. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11682. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11683. if (upd < 1) return Ok(JsonView(false));
  11684. }
  11685. #region 汇率变更时更改币种相关费用
  11686. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11687. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11688. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11689. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11690. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11691. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11692. .Select((dac, sd) => new
  11693. {
  11694. dac.Id,
  11695. dac.ParentId,
  11696. CurrencyCode = sd.Name,
  11697. dac.Cost
  11698. })
  11699. .ToList();
  11700. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11701. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11702. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11703. .Select((dop, sd) => new
  11704. {
  11705. dop.Id,
  11706. dop.ParentId,
  11707. CurrencyCode = sd.Name,
  11708. dop.Cost
  11709. })
  11710. .ToList();
  11711. if (dayCosts.Count > 0)
  11712. {
  11713. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11714. foreach (var dc in new_dayCosts)
  11715. {
  11716. var thisCurrency = dc.Key.ToUpper();
  11717. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11718. if (thisRate == 0.00M) continue;
  11719. foreach (var dcSub in dc)
  11720. {
  11721. opDayCosts.Add(new Grp_DayAndCostDraft()
  11722. {
  11723. Id = dcSub.Id,
  11724. ParentId = dcSub.ParentId,
  11725. Cost = dcSub.Cost,
  11726. SubTotal = dcSub.Cost * thisRate,
  11727. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11728. });
  11729. }
  11730. }
  11731. if (opDayCosts.Count > 0)
  11732. {
  11733. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11734. }
  11735. }
  11736. if (dayOtherCosts.Count > 0)
  11737. {
  11738. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11739. foreach (var dc in new_dayOtherCosts)
  11740. {
  11741. var thisCurrency = dc.Key.ToUpper();
  11742. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11743. if (thisRate == 0.00M) continue;
  11744. foreach (var dcSub in dc)
  11745. {
  11746. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11747. {
  11748. Id = dcSub.Id,
  11749. ParentId = dcSub.ParentId,
  11750. Cost = dcSub.Cost,
  11751. SubTotal = dcSub.Cost * thisRate,
  11752. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11753. });
  11754. }
  11755. }
  11756. if (opDayOtherCosts.Count > 0)
  11757. {
  11758. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11759. }
  11760. }
  11761. #endregion
  11762. ////消息通知
  11763. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11764. ////汇率信息记录
  11765. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11766. return Ok(JsonView(new { parentId = id }));
  11767. }
  11768. /// <summary>
  11769. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11770. /// </summary>
  11771. /// <returns></returns>
  11772. [HttpPost]
  11773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11774. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11775. {
  11776. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11777. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11778. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11779. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11780. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11781. int id = dto.DraftId;
  11782. if (id <= 0) //add
  11783. {
  11784. checkboxInfo.ProvinceId = dto.ProvinceId;
  11785. checkboxInfo.CreateUserId = dto.CurrUserId;
  11786. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11787. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11788. if (add < 1) return Ok(JsonView(false));
  11789. }
  11790. else //update
  11791. {
  11792. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11793. .UpdateColumns(x => new
  11794. {
  11795. x.ChoiceOne,
  11796. x.ChoiceTwo,
  11797. x.SumJJC,
  11798. x.SumGWC,
  11799. x.SumTDC,
  11800. x.ChoiceThree,
  11801. x.ChoiceFour,
  11802. x.ChoiceFive,
  11803. x.ChoiceSix,
  11804. x.OtherExpenses_Checked
  11805. })
  11806. .Where(x => x.Id == id)
  11807. .ExecuteCommandAsync();
  11808. if (upd < 1) return Ok(JsonView(false));
  11809. }
  11810. return Ok(JsonView(new { parentId = id }));
  11811. }
  11812. /// <summary>
  11813. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11814. /// </summary>
  11815. /// <returns></returns>
  11816. [HttpPost]
  11817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11818. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11819. {
  11820. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11821. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11822. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11823. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11824. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11825. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11826. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11827. var checkboxInfo = new Grp_EnterExitCostDraft()
  11828. {
  11829. Id = draftId,
  11830. ProvinceId = dto.ProvinceId,
  11831. CreateUserId = currUserId
  11832. };
  11833. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11834. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11835. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11836. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11837. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11838. if (draftId <= 0) //add
  11839. {
  11840. checkboxInfo.CreateUserId = dto.CurrUserId;
  11841. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11842. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11843. if (add < 1) return Ok(JsonView(false));
  11844. }
  11845. else //update
  11846. {
  11847. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11848. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11849. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11850. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11851. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11852. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11853. .Where(x => x.Id == draftId)
  11854. .ExecuteCommandAsync();
  11855. if (upd < 1) return Ok(JsonView(false));
  11856. }
  11857. return Ok(JsonView(new { parentId = draftId }));
  11858. }
  11859. /// <summary>
  11860. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11861. /// </summary>
  11862. /// <returns></returns>
  11863. [HttpPost]
  11864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11865. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11866. {
  11867. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11868. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11869. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11870. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11871. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11872. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11873. info.ProvinceId = dto.ProvinceId;
  11874. info.FirstItemRemark = dto.FirstItemRemark;
  11875. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11876. if (id <= 0) //add
  11877. {
  11878. info.CreateUserId = dto.CurrUserId;
  11879. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11880. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11881. if (add < 1) return Ok(JsonView(false));
  11882. id = add;
  11883. }
  11884. else //update
  11885. {
  11886. var upd = await _sqlSugar.Updateable(info)
  11887. .UpdateColumns(x => new
  11888. {
  11889. x.ChoiceOne,
  11890. x.InsidePay,
  11891. x.VisaRemark,
  11892. x.Visa,
  11893. x.Service,
  11894. x.Safe,
  11895. x.Ticket,
  11896. x.HeSuan,
  11897. x.YiMiao,
  11898. x.FirstItemRemark
  11899. })
  11900. .Where(x => x.Id == id)
  11901. .ExecuteCommandAsync();
  11902. if (upd < 1) return Ok(JsonView(false));
  11903. }
  11904. ////消息通知
  11905. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11906. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11907. }
  11908. /// <summary>
  11909. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11910. /// </summary>
  11911. /// <returns></returns>
  11912. [HttpPost]
  11913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11914. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11915. {
  11916. int id = dto.DraftId;
  11917. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11918. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11919. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11920. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11921. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11922. info.ProvinceId = dto.ProvinceId;
  11923. info.OutsideJJPay = dto.OutsideJJPay;
  11924. info.OutsideGWPay = dto.OutsideGWPay;
  11925. info.OutsideTDPay = dto.OutsideTDPay;
  11926. info.AirJJ = dto.AirJJ;
  11927. info.AirGW = dto.AirGW;
  11928. info.AirTD = dto.AirTD;
  11929. info.CityTranffic = dto.CityTranffic;
  11930. info.TwoItemRemark = dto.TwoItemRemark;
  11931. info.SumJJC = dto.ChoiceTwoJJ;
  11932. info.SumGWC = dto.ChoiceTwoGW;
  11933. info.SumTDC = dto.ChoiceTwoTD;
  11934. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11935. if (id <= 0) //add
  11936. {
  11937. info.CreateUserId = dto.CurrUserId;
  11938. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11939. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11940. if (addId <= 0) return Ok(JsonView(false));
  11941. id = addId;
  11942. }
  11943. else //update
  11944. {
  11945. var upd = await _sqlSugar.Updateable(info)
  11946. .UpdateColumns(x => new
  11947. {
  11948. x.SumJJC,
  11949. x.OutsideJJPay,
  11950. x.SumGWC,
  11951. x.OutsideGWPay,
  11952. x.SumTDC,
  11953. x.OutsideTDPay,
  11954. x.AirJJ,
  11955. x.AirGW,
  11956. x.AirTD,
  11957. x.CityTranffic,
  11958. x.TwoItemRemark
  11959. })
  11960. .Where(x => x.Id == id)
  11961. .ExecuteCommandAsync();
  11962. if (upd < 1) return Ok(JsonView(false));
  11963. }
  11964. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11965. gwcItemTotal = info.AirGW + info.CityTranffic;
  11966. tdcItemTotal = info.AirTD + info.CityTranffic;
  11967. ////消息通知
  11968. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11969. return Ok(JsonView(new
  11970. {
  11971. parentId = id,
  11972. choiceTwoJJ = dto.ChoiceTwoJJ,
  11973. jjcItemTotal = jjcItemTotal,
  11974. choiceTwoGW = dto.ChoiceTwoGW,
  11975. gwcItemTotal = gwcItemTotal,
  11976. choiceTwoTD = dto.ChoiceTwoTD,
  11977. tdcItemTotal = tdcItemTotal
  11978. }));
  11979. }
  11980. /// <summary>
  11981. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11982. /// </summary>
  11983. /// <returns></returns>
  11984. [HttpPost]
  11985. [ApiExplorerSettings(IgnoreApi = true)]
  11986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11987. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11988. {
  11989. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11990. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11991. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11992. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11993. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11994. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11995. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11996. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11997. {
  11998. Id = x.Id,
  11999. ParentId = dto.DraftId,
  12000. Type = dto.FeeType,
  12001. Days = x.Days,
  12002. NationalTravelFeeId = x.NationalTravelFeeId,
  12003. Cost = x.Cost,
  12004. Currency = x.Currency,
  12005. SubTotal = x.SubTotal,
  12006. CreateUserId = dto.CurrUserId
  12007. })
  12008. .ToList();
  12009. var adds = infos.Where(x => x.Id <= 0).ToList();
  12010. var upds = infos.Where(x => x.Id > 0).ToList();
  12011. if (adds.Count > 0)
  12012. {
  12013. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12014. if (add < 1) return Ok(JsonView(false));
  12015. }
  12016. if (upds.Count > 0)
  12017. {
  12018. var upd = await _sqlSugar.Updateable(adds)
  12019. .UpdateColumns(x => new
  12020. {
  12021. x.Days,
  12022. x.NationalTravelFeeId,
  12023. x.Cost,
  12024. x.Currency,
  12025. x.SubTotal
  12026. })
  12027. .WhereColumns(x => new { x.Id })
  12028. .ExecuteCommandAsync();
  12029. if (upd < 1) return Ok(JsonView(false));
  12030. }
  12031. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  12032. ////消息通知
  12033. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  12034. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12035. return Ok(JsonView(new { itemTotal = itemTotal }));
  12036. }
  12037. /// <summary>
  12038. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  12039. /// </summary>
  12040. /// <returns></returns>
  12041. [HttpPost]
  12042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12043. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  12044. {
  12045. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  12046. int subId = dto.SubId, feeType = dto.FeeType;
  12047. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12048. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12049. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12050. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12051. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  12052. subInfo.Id = subId;
  12053. subInfo.ParentId = dto.DraftId;
  12054. if (feeType == 3) subInfo.Type = 1;
  12055. else if (feeType == 4) subInfo.Type = 2;
  12056. else if (feeType == 5) subInfo.Type = 3;
  12057. else if (feeType == 6) subInfo.Type = 4;
  12058. subInfo.CreateUserId = dto.CurrUserId;
  12059. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  12060. if (parentId < 1) return Ok(JsonView(false));
  12061. //子表op
  12062. if (subId < 1)
  12063. {
  12064. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12065. if (subAdd < 1) return Ok(JsonView(false));
  12066. }
  12067. else
  12068. {
  12069. var subUpd = await _sqlSugar.Updateable(subInfo)
  12070. .UpdateColumns(x => new
  12071. {
  12072. x.Days,
  12073. x.NationalTravelFeeId,
  12074. x.Cost,
  12075. x.Currency,
  12076. x.SubTotal
  12077. })
  12078. .WhereColumns(x => new { x.Id })
  12079. .ExecuteCommandAsync();
  12080. if (subUpd < 1) return Ok(JsonView(false));
  12081. }
  12082. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  12083. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12084. }
  12085. /// <summary>
  12086. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  12087. /// </summary>
  12088. /// <returns></returns>
  12089. [HttpPost]
  12090. [ApiExplorerSettings(IgnoreApi = true)]
  12091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12092. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12093. {
  12094. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12095. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12096. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12097. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12098. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12099. {
  12100. Id = x.Id,
  12101. ParentId = dto.DraftId,
  12102. SetDataId = x.SetDataId,
  12103. Index = x.Index,
  12104. Cost = x.Cost,
  12105. Currency = x.Currency,
  12106. SubTotal = x.SubTotal,
  12107. CreateUserId = dto.CurrUserId,
  12108. Remark = x.Remark
  12109. }).ToList();
  12110. var adds = infos.Where(x => x.Id <= 0).ToList();
  12111. var upds = infos.Where(x => x.Id > 0).ToList();
  12112. if (adds.Count > 0)
  12113. {
  12114. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12115. if (add < 1) return Ok(JsonView(false));
  12116. }
  12117. if (upds.Count > 0)
  12118. {
  12119. var upd = await _sqlSugar.Updateable(adds)
  12120. .UpdateColumns(x => new
  12121. {
  12122. x.Index,
  12123. x.SetDataId,
  12124. x.Cost,
  12125. x.Currency,
  12126. x.SubTotal,
  12127. x.Remark
  12128. })
  12129. .WhereColumns(x => new { x.Id })
  12130. .ExecuteCommandAsync();
  12131. if (upd < 1) return Ok(JsonView(false));
  12132. }
  12133. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12134. //消息通知
  12135. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12136. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12137. return Ok(JsonView(new { itemTotal = itemTotal }));
  12138. }
  12139. /// <summary>
  12140. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12141. /// </summary>
  12142. /// <returns></returns>
  12143. [HttpPost]
  12144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12145. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12146. {
  12147. int subId = dto.SubId, id = dto.DraftId;
  12148. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12149. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12150. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12151. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12152. subInfo.Id = subId;
  12153. subInfo.ParentId = id;
  12154. subInfo.CreateUserId = dto.CurrUserId;
  12155. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12156. if (parentId < 1) return Ok(JsonView(false));
  12157. #region 子表op
  12158. if (subId < 1)//add
  12159. {
  12160. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12161. if (subAdd < 1) return Ok(JsonView(false));
  12162. }
  12163. else //upd
  12164. {
  12165. var subUpd = await _sqlSugar.Updateable(subInfo)
  12166. .UpdateColumns(x => new
  12167. {
  12168. x.Index,
  12169. x.SetDataId,
  12170. x.Cost,
  12171. x.Currency,
  12172. x.SubTotal,
  12173. x.Remark
  12174. })
  12175. .WhereColumns(x => new { x.Id })
  12176. .ExecuteCommandAsync();
  12177. if (subUpd < 1) return Ok(JsonView(false));
  12178. }
  12179. #endregion
  12180. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12181. ////消息通知
  12182. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12183. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12184. }
  12185. /// <summary>
  12186. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12187. /// </summary>
  12188. /// <returns></returns>
  12189. [HttpPost]
  12190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12191. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12192. {
  12193. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12194. if (data.Code != 0)
  12195. {
  12196. return Ok(JsonView(false, data.Msg));
  12197. }
  12198. return Ok(JsonView(true, "操作成功!", data.Data));
  12199. }
  12200. /// <summary>
  12201. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  12202. /// </summary>
  12203. /// <param name="dto"></param>
  12204. /// <returns></returns>
  12205. [HttpPost]
  12206. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12207. {
  12208. var data = new Grp_DayOtherPriceDraft()
  12209. {
  12210. Id = dto.Id,
  12211. IsDel = 1,
  12212. DeleteUserId = dto.DeleteUserId,
  12213. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12214. };
  12215. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12216. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12217. return Ok(JsonView(false, "删除失败!"));
  12218. }
  12219. #endregion
  12220. #endregion
  12221. #region 团组经理模块 出入境费用报价表
  12222. /// <summary>
  12223. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12224. /// </summary>
  12225. /// <returns></returns>
  12226. [HttpPost]
  12227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12228. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12229. {
  12230. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12231. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12232. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12233. initRates.Insert(0, cnyInfo);
  12234. liveRates.Insert(0, cnyInfo);
  12235. return Ok(JsonView(true, "查询成功!", new
  12236. {
  12237. InitRates = initRates,
  12238. LiveRates = liveRates
  12239. }));
  12240. }
  12241. /// <summary>
  12242. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12243. /// </summary>
  12244. /// <returns></returns>
  12245. [HttpPost]
  12246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12247. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12248. {
  12249. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12250. }
  12251. /// <summary>
  12252. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12253. /// </summary>
  12254. /// <returns></returns>
  12255. [HttpPost]
  12256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12257. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12258. {
  12259. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12260. }
  12261. /// <summary>
  12262. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12263. /// </summary>
  12264. /// <returns></returns>
  12265. [HttpPost]
  12266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12267. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12268. {
  12269. int groupId = dto.DiId,
  12270. currUserId = dto.CurrUserId;
  12271. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12272. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12273. //验证报价数据是否存在
  12274. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12275. if (isNull != null)
  12276. {
  12277. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12278. if (!info1.Rates.Any())
  12279. {
  12280. var rates = await GeneralMethod.EnterExitCostInitRate();
  12281. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12282. info1.Rates = rates.ToArray();
  12283. }
  12284. return Ok(JsonView(info1));
  12285. }
  12286. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12287. result.GroupId = groupId;
  12288. //处理报价名称
  12289. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12290. if (groupInfo != null)
  12291. {
  12292. var visitCountry = groupInfo.VisitCountry;
  12293. if (!string.IsNullOrEmpty(visitCountry))
  12294. {
  12295. string quoteName = string.Empty;
  12296. if (visitCountry.Contains("|"))
  12297. {
  12298. var countrys = visitCountry.Split("|");
  12299. quoteName = string.Join("、", countrys);
  12300. }
  12301. else quoteName = visitCountry;
  12302. quoteName += $"团组报价表";
  12303. result.Name = quoteName;
  12304. }
  12305. }
  12306. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12307. if (info.Code != StatusCodes.Status200OK)
  12308. {
  12309. if (!result.Rates.Any())
  12310. {
  12311. var rates = await GeneralMethod.EnterExitCostInitRate();
  12312. result.Rates = rates.ToArray();
  12313. }
  12314. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12315. }
  12316. var infoView = info.Data as EnterExitCostInfoView;
  12317. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12318. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12319. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12320. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12321. var eecRates = infoView.Currencys;
  12322. //默认添加人名币
  12323. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12324. {
  12325. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12326. }
  12327. //处理团组人数
  12328. int pplNum = 1;
  12329. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12330. var views = new List<QuoteSubItemInfo>();
  12331. #region 数据填充
  12332. var intTravelCosts = new List<QuoteSubItemInfo>();
  12333. #region 机票费用 1354
  12334. int intTravelIndex = 1;
  12335. if (infoView.SumJJC == 1)
  12336. {
  12337. intTravelCosts.Add(new QuoteSubItemInfo
  12338. {
  12339. ItemId = 1354,
  12340. Index = intTravelIndex,
  12341. FeeName = "经济舱",
  12342. UnitPrice = infoView.AirJJ,
  12343. Currency = "CNY",
  12344. Quantity = 1,
  12345. PplNum = 1,
  12346. TotalAmt = infoView.AirJJ,
  12347. Remark = "",
  12348. });
  12349. intTravelIndex++;
  12350. }
  12351. if (infoView.SumGWC == 1)
  12352. {
  12353. intTravelCosts.Add(new QuoteSubItemInfo
  12354. {
  12355. ItemId = 1354,
  12356. Index = intTravelIndex,
  12357. FeeName = "公务舱",
  12358. UnitPrice = infoView.AirGW,
  12359. Currency = "CNY",
  12360. Quantity = 1,
  12361. PplNum = 1,
  12362. TotalAmt = infoView.AirGW,
  12363. Remark = "",
  12364. });
  12365. intTravelIndex++;
  12366. }
  12367. if (infoView.SumTDC == 1)
  12368. {
  12369. intTravelCosts.Add(new QuoteSubItemInfo
  12370. {
  12371. ItemId = 1354,
  12372. Index = intTravelIndex,
  12373. FeeName = "头等舱",
  12374. UnitPrice = infoView.AirTD,
  12375. Currency = "CNY",
  12376. Quantity = 1,
  12377. PplNum = 1,
  12378. TotalAmt = infoView.AirTD,
  12379. Remark = "",
  12380. });
  12381. intTravelIndex++;
  12382. }
  12383. intTravelCosts.Add(new QuoteSubItemInfo
  12384. {
  12385. ItemId = 1354,
  12386. Index = intTravelIndex,
  12387. FeeName = "城市间交通费用",
  12388. UnitPrice = infoView.CityTranffic,
  12389. Currency = "CNY",
  12390. Quantity = 1,
  12391. PplNum = pplNum,
  12392. TotalAmt = infoView.CityTranffic * pplNum,
  12393. Remark = "",
  12394. });
  12395. views.AddRange(intTravelCosts);
  12396. #endregion
  12397. var accomCosts = new List<QuoteSubItemInfo>();
  12398. #region 住宿费 1355
  12399. if (infoView.QuarterageData.Any())
  12400. {
  12401. int accomIndex = 1;
  12402. int accomItemTypeId = 1355;
  12403. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12404. foreach (var item in groupData)
  12405. {
  12406. string feeName = string.Empty;
  12407. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12408. if (countryInfo != null)
  12409. {
  12410. feeName = countryInfo.Country;
  12411. var city = countryInfo.City;
  12412. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12413. {
  12414. feeName += $"-{city}";
  12415. }
  12416. }
  12417. var hotelInfo = item.FirstOrDefault();
  12418. if (hotelInfo == null) continue;
  12419. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12420. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12421. int quantity = item.ToList().Count;
  12422. accomCosts.Add(new QuoteSubItemInfo
  12423. {
  12424. ItemId = accomItemTypeId,
  12425. Index = accomIndex,
  12426. FeeName = feeName,
  12427. UnitPrice = hotelInfo.Cost,
  12428. Currency = thisCurrency,
  12429. Quantity = quantity,
  12430. PplNum = pplNum,
  12431. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12432. Remark = "",
  12433. });
  12434. accomIndex++;
  12435. }
  12436. views.AddRange(accomCosts);
  12437. }
  12438. #endregion
  12439. var mealCosts = new List<QuoteSubItemInfo>();
  12440. #region 餐饮费 1356
  12441. if (infoView.BoardWagesData.Any())
  12442. {
  12443. var mealIndex = 1;
  12444. int mealItemTypeId = 1356;
  12445. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12446. foreach (var item in groupData)
  12447. {
  12448. string feeName = string.Empty;
  12449. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12450. if (countryInfo != null)
  12451. {
  12452. feeName = countryInfo.Country;
  12453. var city = countryInfo.City;
  12454. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12455. {
  12456. feeName += $"-{city}";
  12457. }
  12458. }
  12459. var mealInfo = item.FirstOrDefault();
  12460. if (mealInfo == null) continue;
  12461. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12462. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12463. int quantity = item.ToList().Count;
  12464. mealCosts.Add(new QuoteSubItemInfo
  12465. {
  12466. ItemId = mealItemTypeId,
  12467. Index = mealIndex,
  12468. FeeName = feeName,
  12469. UnitPrice = mealInfo.Cost,
  12470. Currency = thisCurrency,
  12471. Quantity = quantity,
  12472. PplNum = pplNum,
  12473. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12474. Remark = "",
  12475. });
  12476. mealIndex++;
  12477. }
  12478. views.AddRange(mealCosts);
  12479. }
  12480. #endregion
  12481. var miscCosts = new List<QuoteSubItemInfo>();
  12482. #region 公杂费 1364
  12483. if (infoView.MiscellaneousFeeData.Any())
  12484. {
  12485. var miscIndex = 1;
  12486. int miscItemTypeId = 1364;
  12487. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12488. foreach (var item in groupData)
  12489. {
  12490. string feeName = string.Empty;
  12491. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12492. if (countryInfo != null)
  12493. {
  12494. feeName = countryInfo.Country;
  12495. var city = countryInfo.City;
  12496. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12497. {
  12498. feeName += $"-{city}";
  12499. }
  12500. }
  12501. var miscInfo = item.FirstOrDefault();
  12502. if (miscInfo == null) continue;
  12503. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12504. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12505. int quantity = item.ToList().Count;
  12506. miscCosts.Add(new QuoteSubItemInfo
  12507. {
  12508. ItemId = miscItemTypeId,
  12509. Index = miscIndex,
  12510. FeeName = feeName,
  12511. UnitPrice = miscInfo.Cost,
  12512. Currency = thisCurrency,
  12513. Quantity = quantity,
  12514. PplNum = pplNum,
  12515. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12516. Remark = "",
  12517. });
  12518. miscIndex++;
  12519. }
  12520. views.AddRange(miscCosts);
  12521. }
  12522. #endregion
  12523. #region 签证+保险 1362
  12524. int visaInsIndex = 1;
  12525. int visaInsItemTypeId = 1362;
  12526. if (infoView.Visa > 0)
  12527. {
  12528. views.Add(new QuoteSubItemInfo()
  12529. {
  12530. ItemId = visaInsItemTypeId,
  12531. Index = visaInsIndex,
  12532. FeeName = $"签证",
  12533. UnitPrice = infoView.Visa,
  12534. Currency = $"CNY",
  12535. Quantity = 1,
  12536. PplNum = pplNum,
  12537. TotalAmt = infoView.Visa * pplNum,
  12538. Remark = "",
  12539. });
  12540. visaInsIndex++;
  12541. }
  12542. if (infoView.Safe > 0)
  12543. {
  12544. views.Add(new QuoteSubItemInfo()
  12545. {
  12546. ItemId = visaInsItemTypeId,
  12547. Index = visaInsIndex,
  12548. FeeName = $"保险",
  12549. UnitPrice = infoView.Safe,
  12550. Currency = $"CNY",
  12551. Quantity = 1,
  12552. PplNum = pplNum,
  12553. TotalAmt = infoView.Safe * pplNum,
  12554. Remark = "",
  12555. });
  12556. }
  12557. #endregion
  12558. #region 服务费 1363
  12559. int serviceFeeIndex = 1;
  12560. int serviceFeeItemTypeId = 1363;
  12561. if (infoView.Service > 0)
  12562. {
  12563. views.Add(new QuoteSubItemInfo()
  12564. {
  12565. ItemId = serviceFeeItemTypeId,
  12566. Index = serviceFeeIndex,
  12567. FeeName = $"服务费",
  12568. UnitPrice = infoView.Service,
  12569. Currency = $"CNY",
  12570. Quantity = 1,
  12571. PplNum = pplNum,
  12572. TotalAmt = infoView.Service * pplNum,
  12573. Remark = "",
  12574. });
  12575. }
  12576. #endregion
  12577. #endregion
  12578. if (result.FeeItems.Any())
  12579. {
  12580. result.FeeItems.Select(x =>
  12581. {
  12582. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12583. if (feeInfos.Any()) x.Infos = feeInfos;
  12584. return x;
  12585. }
  12586. ).OrderBy(x => x.Index)
  12587. .ToList();
  12588. if (!result.Rates.Any())
  12589. {
  12590. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12591. else
  12592. {
  12593. var rates = await GeneralMethod.EnterExitCostInitRate();
  12594. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12595. result.Rates = rates.ToArray();
  12596. }
  12597. }
  12598. }
  12599. return Ok(JsonView(result));
  12600. }
  12601. /// <summary>
  12602. /// 团组模块 - 出入境费用报价表 - Info
  12603. /// </summary>
  12604. /// <returns></returns>
  12605. [HttpPost]
  12606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12607. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12608. {
  12609. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12610. if (!info.Rates.Any())
  12611. {
  12612. var rates = await GeneralMethod.EnterExitCostInitRate();
  12613. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12614. info.Rates = rates.ToArray();
  12615. }
  12616. return Ok(JsonView(info));
  12617. }
  12618. /// <summary>
  12619. /// 团组模块 - 出入境费用报价表 - OP
  12620. /// </summary>
  12621. /// <returns></returns>
  12622. [HttpPost]
  12623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12624. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12625. {
  12626. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12627. }
  12628. /// <summary>
  12629. /// 团组模块 - 出入境费用报价表 - 删除 项
  12630. /// </summary>
  12631. /// <returns></returns>
  12632. [HttpPost]
  12633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12634. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12635. {
  12636. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12637. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12638. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12639. }
  12640. /// <summary>
  12641. /// 团组模块 - 出入境费用报价表 - 导出
  12642. /// </summary>
  12643. /// <returns></returns>
  12644. [HttpPost]
  12645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12646. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12647. {
  12648. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12649. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12650. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12651. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12652. var rates = info.Rates;
  12653. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12654. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12655. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12656. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12657. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12658. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12659. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12660. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12661. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12662. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12663. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12664. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12665. //获取模板
  12666. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12667. var designer = new WorkbookDesigner();
  12668. designer.Workbook = new Workbook(tempPath);
  12669. designer.SetDataSource("QuoteName", info.Name);
  12670. designer.SetDataSource("CompanyTitle", "公司名称");
  12671. designer.SetDataSource("CompanyLabel", "");
  12672. #region 国际旅费
  12673. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12674. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12675. {
  12676. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12677. var label = new StringBuilder();
  12678. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12679. if (infos.Any())
  12680. {
  12681. label.Append(infos.Sum(x => x.PplNum));
  12682. label.Append("人全程机票:");
  12683. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12684. label.AppendLine("元");
  12685. }
  12686. foreach (var item in intTravelCosts.Infos)
  12687. {
  12688. label.Append(item.FeeName);
  12689. label.Append(":");
  12690. label.Append(item.UnitPrice.TruncDecimals(2));
  12691. label.Append("元/人*");
  12692. label.Append(item.PplNum);
  12693. label.AppendLine("人");
  12694. }
  12695. if (label.HasValue())
  12696. {
  12697. label.Append("\r\n以上小计:");
  12698. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12699. label.Append("元");
  12700. }
  12701. designer.SetDataSource("IntTravelLabel", label.ToString());
  12702. }
  12703. #endregion
  12704. #region 住宿费
  12705. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12706. if (accomCosts != null && accomCosts.Infos.Any())
  12707. {
  12708. string currencyName = string.Empty,
  12709. countryName = string.Empty;
  12710. decimal rate = 1.0000M;
  12711. var label = new StringBuilder();
  12712. label.AppendLine("全程五星酒店,每人1间房");
  12713. foreach (var item in accomCosts.Infos)
  12714. {
  12715. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12716. string name = string.Empty, thisCountryName = string.Empty;
  12717. if (item.FeeName.Contains('-'))
  12718. {
  12719. var feeName = item.FeeName.Split('-');
  12720. thisCountryName = feeName[0];
  12721. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12722. name = feeName[1];
  12723. }
  12724. else name = item.FeeName;
  12725. string thisFeeName = string.Empty;
  12726. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12727. else thisFeeName = $"\r\n{name}:";
  12728. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12729. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12730. rate = rateInfo?.Rate ?? 1.0000M;
  12731. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12732. label.AppendLine(subLabel);
  12733. }
  12734. if (label.HasValue())
  12735. {
  12736. //以上小计:52440元(美金汇率:7.5 )
  12737. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12738. label.AppendLine(subLabel);
  12739. }
  12740. designer.SetDataSource("AccomLabel", label.ToString());
  12741. }
  12742. #endregion
  12743. #region 餐饮费
  12744. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12745. if (mealCosts != null && mealCosts.Infos.Any())
  12746. {
  12747. string currencyName = string.Empty;
  12748. decimal rate = 1.0000M;
  12749. var label = new StringBuilder();
  12750. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12751. foreach (var item in mealCosts.Infos)
  12752. {
  12753. string name = string.Empty;
  12754. if (item.FeeName.Contains('-'))
  12755. {
  12756. var feeName = item.FeeName.Split('-');
  12757. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12758. }
  12759. else name = $"\r\n{item.FeeName}:";
  12760. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12761. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12762. rate = rateInfo?.Rate ?? 1.0000M;
  12763. label.Append(name);
  12764. label.Append(item.UnitPrice.TruncDecimals(2));
  12765. label.Append(currencyName);
  12766. label.Append("/天*");
  12767. label.Append(item.Quantity.ToString("#0"));
  12768. label.Append('*');
  12769. label.Append(item.PplNum);
  12770. label.Append("人\r\n");
  12771. }
  12772. if (label.HasValue())
  12773. {
  12774. label.Append("\r\n以上小计:");
  12775. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12776. label.Append("元\r\n(");
  12777. label.Append("汇率:");
  12778. label.Append(rate.TruncDecimals(4));
  12779. label.Append(')');
  12780. }
  12781. designer.SetDataSource("MealLabel", label.ToString());
  12782. }
  12783. #endregion
  12784. #region 车辆安排
  12785. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12786. if (vehArranges != null && vehArranges.Infos.Any())
  12787. {
  12788. string currencyName = string.Empty;
  12789. //decimal rate = 1.0000M;
  12790. var label = new StringBuilder();
  12791. foreach (var item in vehArranges.Infos)
  12792. {
  12793. label.AppendLine();
  12794. label.AppendLine();
  12795. label.Append(item.FeeName);
  12796. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12797. }
  12798. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12799. }
  12800. #endregion
  12801. #region 邀请函发放对象
  12802. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12803. designer.SetDataSource("InviteToContent", "");
  12804. #endregion
  12805. #region 邀请函费
  12806. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12807. var is_label = new StringBuilder();
  12808. if (inviteCosts != null && inviteCosts.Infos.Any())
  12809. {
  12810. string currencyName = string.Empty;
  12811. decimal rate = 1.0000M;
  12812. foreach (var item in inviteCosts.Infos)
  12813. {
  12814. //乌兹别克斯坦:2000美金
  12815. currencyName = item.Currency;
  12816. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12817. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12818. is_label.AppendLine(label);
  12819. }
  12820. if (is_label.HasValue())
  12821. {
  12822. //以上小计:28500元(美金汇率:7.5)
  12823. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12824. is_label.AppendLine(label);
  12825. }
  12826. }
  12827. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12828. #endregion
  12829. #region 邀请函发放时间
  12830. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12831. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12832. #endregion
  12833. #region 公务活动(含翻译)
  12834. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12835. var oa_label = new StringBuilder();
  12836. if (officialActs != null && officialActs.Infos.Any())
  12837. {
  12838. string currencyName = string.Empty;
  12839. decimal rate = 1.0000M;
  12840. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12841. foreach (var item in officialActs.Infos)
  12842. {
  12843. //乌兹别克斯坦:1000美金/场
  12844. currencyName = item.Currency;
  12845. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12846. string label_remark = string.Empty;
  12847. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12848. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12849. }
  12850. label_content += "*总费用中未含超出公务活动价格";
  12851. //8场公务活动(以上小计:60000元)
  12852. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12853. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12854. oa_label.AppendLine(label_title);
  12855. oa_label.AppendLine(label_content);
  12856. }
  12857. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12858. #endregion
  12859. #region 签证+保险
  12860. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12861. var vi_label = new StringBuilder();
  12862. if (visaIns != null && visaIns.Infos.Any())
  12863. {
  12864. foreach (var item in visaIns.Infos)
  12865. {
  12866. //签证:500元/人
  12867. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12868. vi_label.AppendLine(label);
  12869. }
  12870. if (vi_label.HasValue())
  12871. {
  12872. //以上小计:6000元
  12873. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12874. vi_label.AppendLine(label);
  12875. }
  12876. }
  12877. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12878. #endregion
  12879. #region 服务费
  12880. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12881. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12882. #endregion
  12883. #region 公杂费
  12884. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12885. var pm_label = new StringBuilder();
  12886. if (pubMiscs != null && pubMiscs.Infos.Any())
  12887. {
  12888. string currencyName = string.Empty,
  12889. countryName = string.Empty;
  12890. decimal rate = 1.0000M;
  12891. foreach (var item in pubMiscs.Infos)
  12892. {
  12893. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12894. string name = string.Empty, thisCountryName = string.Empty;
  12895. if (item.FeeName.Contains('-'))
  12896. {
  12897. var feeName = item.FeeName.Split('-');
  12898. thisCountryName = feeName[0];
  12899. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12900. name = feeName[1];
  12901. }
  12902. else name = item.FeeName;
  12903. string thisFeeName = string.Empty;
  12904. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12905. else thisFeeName = $"\r\n{name}:";
  12906. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12907. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12908. rate = rateInfo?.Rate ?? 1.0000M;
  12909. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12910. pm_label.AppendLine(label);
  12911. }
  12912. if (pm_label.HasValue())
  12913. {
  12914. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12915. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12916. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12917. pm_label.AppendLine(string.Format("部分发放成员"));
  12918. }
  12919. }
  12920. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12921. #endregion
  12922. #region 税费
  12923. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12924. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12925. #endregion
  12926. #region 合计(单位:元)
  12927. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12928. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12929. #endregion
  12930. #region 汇率 Remark
  12931. var rate_label = new StringBuilder();
  12932. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12933. foreach (var item in rateGroups)
  12934. {
  12935. //美元汇率按\r\n1:7.5
  12936. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12937. rate_label.AppendLine(label);
  12938. }
  12939. designer.SetDataSource("RateLabel", rate_label.ToString());
  12940. #endregion
  12941. designer.Process();
  12942. //文件名
  12943. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12944. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12945. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12946. return Ok(JsonView(true, "成功", url));
  12947. }
  12948. #endregion
  12949. #region 签证费用录入
  12950. /// <summary>
  12951. /// 根据diid查询签证费用列表
  12952. /// </summary>
  12953. /// <param name="dto"></param>
  12954. /// <returns></returns>
  12955. [HttpPost]
  12956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12957. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12958. {
  12959. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12960. if (groupData.Code != 0)
  12961. {
  12962. return Ok(JsonView(false, groupData.Msg));
  12963. }
  12964. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12965. }
  12966. /// <summary>
  12967. /// 根据签证费用Id查询单条数据及c表数据
  12968. /// </summary>
  12969. /// <param name="dto"></param>
  12970. /// <returns></returns>
  12971. [HttpPost]
  12972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12973. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12974. {
  12975. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12976. if (groupData.Code != 0)
  12977. {
  12978. return Ok(JsonView(false, groupData.Msg));
  12979. }
  12980. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12981. }
  12982. /// <summary>
  12983. /// 签证费用删除
  12984. /// </summary>
  12985. /// <param name="dto"></param>
  12986. /// <returns></returns>
  12987. [HttpPost]
  12988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12989. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12990. {
  12991. _sqlSugar.BeginTran();
  12992. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12993. if (!res)
  12994. {
  12995. _sqlSugar.RollbackTran();
  12996. return Ok(JsonView(false, "删除失败"));
  12997. }
  12998. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12999. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  13000. .SetColumns(a => new Grp_CreditCardPayment()
  13001. {
  13002. IsDel = 1,
  13003. DeleteUserId = dto.DeleteUserId,
  13004. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13005. })
  13006. .ExecuteCommand();
  13007. if (resSub < 1)
  13008. {
  13009. _sqlSugar.RollbackTran();
  13010. return Ok(JsonView(false, "删除失败"));
  13011. }
  13012. _sqlSugar.CommitTran();
  13013. return Ok(JsonView(true, "删除成功!"));
  13014. }
  13015. /// <summary>
  13016. /// 签证费用录入下拉框初始化
  13017. /// </summary>
  13018. /// <returns></returns>
  13019. [HttpPost]
  13020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13021. public async Task<IActionResult> VisaPriceAddSelect()
  13022. {
  13023. //支付方式
  13024. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  13025. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  13026. //币种
  13027. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  13028. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  13029. //乘客类型
  13030. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  13031. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  13032. //卡类型
  13033. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  13034. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  13035. //代办费类型
  13036. var agencyFeeTypeData = new List<dynamic>() {
  13037. new { id = 0 , Text = "未选择" },
  13038. new { id = 1 , Text = "小公务" },
  13039. new { id = 2 , Text = "大公务" },
  13040. };
  13041. //签证费用标准国家Data
  13042. var visaSql = string.Format(@"select
  13043. id,
  13044. case
  13045. when FeeType = 0 then Country+'(因公)'
  13046. when FeeType = 1 then Country+'(因私)'
  13047. else Country+'(未设置)'
  13048. end as 'country'
  13049. from Res_VisaFeeStandard where isdel = 0");
  13050. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  13051. var data = new
  13052. {
  13053. Payment = _Payment,
  13054. CurrencyList = _CurrencyList,
  13055. PassengerType = _PassengerType,
  13056. BankCard = _BankCard,
  13057. AgencyFeeType = agencyFeeTypeData,
  13058. CountryFeeData = visaCountryFeeData
  13059. };
  13060. return Ok(JsonView(true, "查询成功!", data));
  13061. }
  13062. /// <summary>
  13063. /// 签证费用录入操作(Status:1.新增,2.修改)
  13064. /// </summary>
  13065. /// <param name="dto"></param>
  13066. /// <returns></returns>
  13067. [HttpPost]
  13068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13069. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  13070. {
  13071. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  13072. if (groupData.Code != 0)
  13073. {
  13074. return Ok(JsonView(false, groupData.Msg));
  13075. }
  13076. #region 应用推送
  13077. try
  13078. {
  13079. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13080. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13081. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13082. //2024-10-21 新增LZ UID
  13083. var userIds = new List<int>() { 21 };
  13084. string title = $"系统通知";
  13085. string content = "";
  13086. var diId = dto.DiId;
  13087. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13088. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13089. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13090. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13091. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13092. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  13093. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13094. }
  13095. catch (Exception ex)
  13096. {
  13097. }
  13098. #endregion
  13099. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13100. }
  13101. #endregion
  13102. #region 签证提成录入
  13103. /// <summary>
  13104. /// 签证提成录入
  13105. /// 基础数据
  13106. /// </summary>
  13107. /// <returns></returns>
  13108. [HttpGet]
  13109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13110. public async Task<IActionResult> VisaCommissionInit()
  13111. {
  13112. return Ok(await _visaCommissionRep.Init());
  13113. }
  13114. /// <summary>
  13115. /// 签证提成录入
  13116. /// Item
  13117. /// </summary>
  13118. /// <param name="_dto"></param>
  13119. /// <returns></returns>
  13120. [HttpPost]
  13121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13122. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13123. {
  13124. var validator = new VisaCommissionItemDtoValidator();
  13125. var validatorRes = await validator.ValidateAsync(_dto);
  13126. if (!validatorRes.IsValid)
  13127. {
  13128. var sb = new StringBuilder();
  13129. foreach (var item in validatorRes.Errors)
  13130. {
  13131. sb.AppendLine(item.ErrorMessage);
  13132. }
  13133. return Ok(JsonView(false, sb.ToString()));
  13134. }
  13135. return Ok(await _visaCommissionRep.Item(_dto));
  13136. }
  13137. /// <summary>
  13138. /// 签证提成录入
  13139. /// Save
  13140. /// </summary>
  13141. /// <param name="_dto"></param>
  13142. /// <returns></returns>
  13143. [HttpPost]
  13144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13145. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13146. {
  13147. //参数验证
  13148. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13149. foreach (var item in _dto.Items)
  13150. {
  13151. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13152. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13153. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13154. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13155. }
  13156. return Ok(await _visaCommissionRep.Save(_dto));
  13157. }
  13158. /// <summary>
  13159. /// 签证提成录入
  13160. /// Create
  13161. /// </summary>
  13162. /// <param name="_dto"></param>
  13163. /// <returns></returns>
  13164. [HttpPost]
  13165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13166. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13167. {
  13168. var validator = new VisaCommissionCreateDtoValidator();
  13169. var validatorRes = await validator.ValidateAsync(_dto);
  13170. if (!validatorRes.IsValid)
  13171. {
  13172. var sb = new StringBuilder();
  13173. foreach (var item in validatorRes.Errors)
  13174. {
  13175. sb.AppendLine(item.ErrorMessage);
  13176. }
  13177. return Ok(JsonView(false, sb.ToString()));
  13178. }
  13179. return Ok(await _visaCommissionRep.Create(_dto));
  13180. }
  13181. /// <summary>
  13182. /// 签证提成录入
  13183. /// Put(编辑)
  13184. /// </summary>
  13185. /// <param name="id"></param>
  13186. /// <param name="_dto"></param>
  13187. /// <returns></returns>
  13188. [HttpPut]
  13189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13190. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13191. {
  13192. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13193. var validator = new VisaCommissionCreateDtoValidator();
  13194. var validatorRes = await validator.ValidateAsync(_dto);
  13195. if (!validatorRes.IsValid)
  13196. {
  13197. var sb = new StringBuilder();
  13198. foreach (var item in validatorRes.Errors)
  13199. {
  13200. sb.AppendLine(item.ErrorMessage);
  13201. }
  13202. return Ok(JsonView(false, sb.ToString()));
  13203. }
  13204. return Ok(await _visaCommissionRep.Edit(id, _dto));
  13205. }
  13206. /// <summary>
  13207. /// 签证提成录入
  13208. /// Del
  13209. /// </summary>
  13210. /// <param name="id"></param>
  13211. /// <param name="currUserId"></param>
  13212. /// <returns></returns>
  13213. [HttpPost]
  13214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13215. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13216. {
  13217. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13218. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13219. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13220. }
  13221. #endregion
  13222. #region op费用录入
  13223. /// <summary>
  13224. /// 根据diid查询op费用列表
  13225. /// </summary>
  13226. /// <param name="dto"></param>
  13227. /// <returns></returns>
  13228. [HttpPost]
  13229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13230. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13231. {
  13232. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13233. if (groupData.Code != 0)
  13234. {
  13235. return Ok(JsonView(false, groupData.Msg));
  13236. }
  13237. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13238. }
  13239. /// <summary>
  13240. /// 根据op费用Id查询单条数据及c表数据
  13241. /// </summary>
  13242. /// <param name="dto"></param>
  13243. /// <returns></returns>
  13244. [HttpPost]
  13245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13246. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13247. {
  13248. try
  13249. {
  13250. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13251. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13252. var data = new
  13253. {
  13254. CarTouristGuideGround = _groupData,
  13255. CreditCardPayment = _creditCardPayment
  13256. };
  13257. return Ok(JsonView(true, "查询成功!", data));
  13258. }
  13259. catch (Exception ex)
  13260. {
  13261. return Ok(JsonView(false, "程序错误!"));
  13262. }
  13263. }
  13264. /// <summary>
  13265. /// op费用删除
  13266. /// </summary>
  13267. /// <param name="dto"></param>
  13268. /// <returns></returns>
  13269. [HttpPost]
  13270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13271. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13272. {
  13273. try
  13274. {
  13275. _sqlSugar.BeginTran();
  13276. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13277. if (!res)
  13278. {
  13279. return Ok(JsonView(false, "删除失败"));
  13280. }
  13281. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13282. {
  13283. IsDel = 1,
  13284. DeleteUserId = dto.DeleteUserId,
  13285. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13286. }).ExecuteCommandAsync();
  13287. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13288. {
  13289. IsDel = 1,
  13290. DeleteUserId = dto.DeleteUserId,
  13291. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13292. }).ExecuteCommandAsync();
  13293. #region 删除超支相关数据
  13294. //删除导入的超支数据
  13295. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13296. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13297. {
  13298. IsDel = 1,
  13299. DeleteUserId = dto.DeleteUserId,
  13300. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13301. }).ExecuteCommand();
  13302. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13303. {
  13304. IsDel = 1,
  13305. DeleteUserId = dto.DeleteUserId,
  13306. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13307. }).ExecuteCommand();
  13308. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13309. {
  13310. IsDel = 1,
  13311. DeleteUserId = dto.DeleteUserId,
  13312. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13313. }).ExecuteCommand();
  13314. #endregion
  13315. _sqlSugar.CommitTran();
  13316. return Ok(JsonView(true, "删除成功!"));
  13317. }
  13318. catch (Exception ex)
  13319. {
  13320. _sqlSugar.RollbackTran();
  13321. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13322. }
  13323. }
  13324. /// <summary>
  13325. /// op费用录入操作(Status:1.新增,2.修改)
  13326. /// </summary>
  13327. /// <param name="dto"></param>
  13328. /// <returns></returns>
  13329. [HttpPost]
  13330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13331. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13332. {
  13333. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13334. if (groupData.Code != 0)
  13335. {
  13336. return Ok(JsonView(false, groupData.Msg));
  13337. }
  13338. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13339. }
  13340. /// <summary>
  13341. /// 填写费用详细页面初始化绑定
  13342. /// </summary>
  13343. /// <param name="dto"></param>
  13344. /// <returns></returns>
  13345. [HttpPost]
  13346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13347. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13348. {
  13349. try
  13350. {
  13351. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13352. if (groupData.Code != 0)
  13353. {
  13354. return Ok(JsonView(false, groupData.Msg));
  13355. }
  13356. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13357. }
  13358. catch (Exception ex)
  13359. {
  13360. return Ok(JsonView(false, ex.Message));
  13361. }
  13362. }
  13363. /// <summary>
  13364. /// 根据op费用Id查询详细数据
  13365. /// </summary>
  13366. /// <param name="dto"></param>
  13367. /// <returns></returns>
  13368. [HttpPost]
  13369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13370. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13371. {
  13372. try
  13373. {
  13374. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13375. if (groupData.Code != 0)
  13376. {
  13377. return Ok(JsonView(false, groupData.Msg));
  13378. }
  13379. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13380. }
  13381. catch (Exception ex)
  13382. {
  13383. return Ok(JsonView(false, ex.Message));
  13384. }
  13385. }
  13386. /// <summary>
  13387. /// OP费用录入填写详情
  13388. /// </summary>
  13389. /// <param name="dto"></param>
  13390. /// <returns></returns>
  13391. [HttpPost]
  13392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13393. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13394. {
  13395. try
  13396. {
  13397. #region 参数校验
  13398. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13399. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13400. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13401. #endregion
  13402. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13403. if (groupData.Code != 0)
  13404. {
  13405. return Ok(JsonView(false, groupData.Msg));
  13406. }
  13407. //自动审核
  13408. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13409. #region 尾款自动审核
  13410. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13411. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  13412. if (opinfos.PriceType == 1062)
  13413. {
  13414. var isAuto = false;
  13415. //找对应的首付款
  13416. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13417. .InnerJoin<Grp_CreditCardPayment>((x, a) => a.IsDel == 0 && a.CTable == 79 && a.CId == x.Id && a.DIId == x.DiId && (a.IsAuditGM == 1 || a.IsAuditGM == 3))
  13418. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  13419. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  13420. x.PriceType == 1061 && x.DiId == dto.DiId);
  13421. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  13422. {
  13423. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  13424. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  13425. //合计中排除城市税
  13426. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  13427. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  13428. .Sum(x => x.Price * x.Count);
  13429. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  13430. if (balance >= opinfos.ServiceQuotedPrice)
  13431. {
  13432. isAuto = true;
  13433. }
  13434. }
  13435. if (isAuto)
  13436. {
  13437. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13438. .SetColumns(a => new Grp_CreditCardPayment
  13439. {
  13440. IsAuditGM = 3, //自动审核通过
  13441. AuditGMOperate = 4,
  13442. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13443. })
  13444. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  13445. .ExecuteCommand();
  13446. }
  13447. }
  13448. #endregion
  13449. #region 应用推送
  13450. try
  13451. {
  13452. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13453. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13454. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13455. //2024-10-21 新增LZ UID
  13456. var userIds = new List<int>() { 21 };
  13457. string title = $"系统通知";
  13458. var diId = dto.DiId;
  13459. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13460. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13461. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13462. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13463. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13464. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13465. }
  13466. catch (Exception ex)
  13467. {
  13468. }
  13469. #endregion
  13470. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13471. }
  13472. catch (Exception ex)
  13473. {
  13474. return Ok(JsonView(false, ex.Message));
  13475. }
  13476. }
  13477. /// <summary>
  13478. /// 获取三公详细所有城市
  13479. /// </summary>
  13480. /// <returns></returns>
  13481. [HttpGet]
  13482. public IActionResult OpCarCityResult()
  13483. {
  13484. var jw = JsonView(false);
  13485. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13486. {
  13487. x.Id,
  13488. x.Country,
  13489. x.City,
  13490. }).ToList();
  13491. if (data.Count > 0)
  13492. {
  13493. jw = JsonView(true, "获取成功!", data);
  13494. }
  13495. else
  13496. {
  13497. jw.Msg = "城市数据为空!";
  13498. jw.Data = Array.Empty<string>();
  13499. }
  13500. return Ok(jw);
  13501. }
  13502. /// <summary>
  13503. /// 导出地接费用明细
  13504. /// </summary>
  13505. /// <param name="dto"></param>
  13506. /// <returns></returns>
  13507. [HttpPost]
  13508. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13509. {
  13510. var jw = JsonView(false);
  13511. if (dto.Diid < 1)
  13512. {
  13513. jw.Msg = "请输入正确的diid!";
  13514. return Ok(jw);
  13515. }
  13516. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13517. if (group == null)
  13518. {
  13519. jw.Msg = "未找到团组信息!";
  13520. return Ok(jw);
  13521. }
  13522. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13523. if (localGuideArr.Count == 0)
  13524. {
  13525. jw.Msg = "该团组暂无地接信息!";
  13526. return Ok(jw);
  13527. }
  13528. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13529. var overspendSoure = new Dictionary<int, int>
  13530. {
  13531. { 91, 982 }, //车
  13532. { 92 , 1059} ,//导游
  13533. { 994 , 1073}, //翻译
  13534. { 988 , 1074 }, //早餐
  13535. { 93 , 1075 }, //午餐
  13536. { 989 , 1076 }, //晚餐
  13537. };
  13538. var Zips = new Dictionary<string, Stream>();
  13539. foreach (var groupArr in localGroup)
  13540. {
  13541. var keyValue = groupArr.Key;
  13542. if (int.TryParse(keyValue, out int cityid))
  13543. {
  13544. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13545. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13546. }
  13547. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13548. foreach (var item in groupArr)
  13549. {
  13550. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13551. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13552. new Grp_CarTouristGuideGroundReservationsContentExtend
  13553. {
  13554. Count = a.Count,
  13555. CreateTime = a.CreateTime,
  13556. CreateUserId = a.CreateUserId,
  13557. CTGGRId = a.CTGGRId,
  13558. Currency = a.Currency,
  13559. DatePrice = a.DatePrice,
  13560. DeleteTime = a.DeleteTime,
  13561. DeleteUserId = a.DeleteUserId,
  13562. DiId = a.DiId,
  13563. Id = a.Id,
  13564. IsDel = a.IsDel,
  13565. Price = a.Price,
  13566. PriceContent = a.PriceContent,
  13567. Remark = a.Remark,
  13568. SId = a.SId,
  13569. SidName = b.Name,
  13570. Units = a.Units,
  13571. }
  13572. ).ToList();
  13573. if (content.Count > 0)
  13574. {
  13575. contentArr.Add(content);
  13576. }
  13577. }
  13578. //open excel
  13579. //set excel
  13580. //save excel
  13581. try
  13582. {
  13583. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13584. IWorkbook workbook;
  13585. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13586. {
  13587. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13588. }
  13589. else
  13590. {
  13591. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13592. }
  13593. ISheet sheet = workbook.GetSheetAt(0);
  13594. var rowStartIndex = 2;
  13595. var clounmCount = 10;
  13596. var initStyleRow = sheet.GetRow(2);
  13597. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13598. //var overspendArrDetail =
  13599. var existsId = new List<CarCompare>();
  13600. var lastElem = arr.Last();
  13601. var thisSid = -1;
  13602. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13603. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13604. {
  13605. Name = "未知币种!",
  13606. Remark = "未知币种!",
  13607. };
  13608. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13609. Action cloneRowFn = () =>
  13610. {
  13611. rowStartIndex++;
  13612. var cloneRow = sheet.CreateRow(rowStartIndex);
  13613. // 复制样式
  13614. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13615. {
  13616. ICell sourceCell = initStyleRow.GetCell(i);
  13617. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13618. // 确保单元格存在样式
  13619. if (sourceCell.CellStyle != null)
  13620. {
  13621. targetCell.CellStyle = sourceCell.CellStyle;
  13622. }
  13623. }
  13624. };
  13625. var mergeRow = () =>
  13626. {
  13627. for (int i = 2; i < sheet.LastRowNum; i++)
  13628. {
  13629. var row = sheet.GetRow(i);
  13630. var cellFirst = row.GetCell(0);
  13631. var thisIndex = i + 1;
  13632. while (thisIndex < sheet.LastRowNum)
  13633. {
  13634. var nextRow = sheet.GetRow(thisIndex);
  13635. var nextCellFirst = nextRow.GetCell(0);
  13636. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13637. {
  13638. thisIndex++;
  13639. }
  13640. else
  13641. {
  13642. break;
  13643. }
  13644. }
  13645. thisIndex--;
  13646. if (thisIndex != i)
  13647. {
  13648. //合并row
  13649. var cellRangeAddress = new CellRangeAddress(
  13650. i, // 起始行索引(0-based)
  13651. thisIndex, // 结束行索引(0-based)
  13652. 0, // 起始列索引(0-based)
  13653. 0 // 结束列索引(0-based)
  13654. );
  13655. sheet.AddMergedRegion(cellRangeAddress);
  13656. i = thisIndex;
  13657. }
  13658. }
  13659. };
  13660. var chaoshiNumber = 0;
  13661. var totalNumber = 0.00M;
  13662. string lastStr = "";
  13663. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13664. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13665. {
  13666. b.IsAuditGM,
  13667. x.Id,
  13668. x.Area,
  13669. b.PayPercentage,
  13670. b.PayMoney,
  13671. }).ToList();
  13672. string yesPayment = "", noPayment = "";
  13673. foreach (var item in queryCarArrByCityAndDiid)
  13674. {
  13675. if (item.IsAuditGM == 1)
  13676. {
  13677. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13678. }
  13679. else
  13680. {
  13681. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13682. }
  13683. }
  13684. lastStr = yesPayment + noPayment;
  13685. foreach (var item in arr)
  13686. {
  13687. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13688. {
  13689. if (thisSid != item.SId)
  13690. {
  13691. if (thisSid == -1)
  13692. {
  13693. thisSid = item.SId;
  13694. }
  13695. else
  13696. {
  13697. //合并小计行
  13698. //创建合并区域的实例
  13699. var cellRangeAddress = new CellRangeAddress(
  13700. rowStartIndex, // 起始行索引(0-based)
  13701. rowStartIndex, // 结束行索引(0-based)
  13702. 0, // 起始列索引(0-based)
  13703. 3 // 结束列索引(0-based)
  13704. );
  13705. sheet.AddMergedRegion(cellRangeAddress);
  13706. var CellStyle = workbook.CreateCellStyle();
  13707. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13708. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13709. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13710. for (int i = 0; i <= clounmCount; i++)
  13711. {
  13712. if (i > 6)
  13713. {
  13714. var CellStyle1 = workbook.CreateCellStyle();
  13715. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13716. IFont Font = workbook.CreateFont(); // 创建字体
  13717. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13718. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13719. CellStyle1.SetFont(Font);
  13720. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13721. }
  13722. else
  13723. {
  13724. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13725. }
  13726. }
  13727. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13728. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13729. //超时合计
  13730. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13731. //超时数
  13732. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13733. //超时合计费用
  13734. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13735. thisSid = item.SId;
  13736. cloneRowFn();
  13737. chaoshiNumber = 0;
  13738. totalNumber = 0;
  13739. }
  13740. }
  13741. IRow row = sheet.GetRow(rowStartIndex);
  13742. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13743. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13744. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13745. if (isOpenOverspendSoure)
  13746. {
  13747. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13748. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13749. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13750. }
  13751. for (int i = 0; i <= clounmCount; i++)
  13752. {
  13753. var cell = row.GetCell(i);
  13754. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13755. if (cell == null)
  13756. {
  13757. cell = row.CreateCell(i);
  13758. }
  13759. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13760. fontRed.CloneStyleFrom(cell.CellStyle);
  13761. IFont Font = workbook.CreateFont(); // 创建字体
  13762. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13763. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13764. fontRed.SetFont(Font);
  13765. byte[] rgb = new byte[3] { 255, 242, 204 };
  13766. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13767. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13768. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13769. if (workbook is XSSFWorkbook)
  13770. {
  13771. BackgroundColor255_242_204.FillForegroundColor = 0;
  13772. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13773. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13774. }
  13775. else
  13776. {
  13777. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13778. }
  13779. if (i == 1 || i > 6)
  13780. {
  13781. if (i > 6)
  13782. {
  13783. fontRed.FillForegroundColor = 0;
  13784. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13785. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13786. }
  13787. cell.CellStyle = fontRed;
  13788. }
  13789. if (i > 2 && i < 7)
  13790. {
  13791. cell.CellStyle = BackgroundColor255_242_204;
  13792. }
  13793. cell.SetCellValue(setCellValue); //写入单元格
  13794. }
  13795. if (overspendSoure.ContainsKey(thisSid))
  13796. {
  13797. var overspendId = overspendSoure[thisSid];
  13798. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13799. }
  13800. cloneRowFn();
  13801. existsId.Add(new CarCompare
  13802. {
  13803. DataPrice = item.DatePrice.ObjToDate(),
  13804. Sid = item.SId
  13805. });
  13806. }
  13807. if (item.Equals(lastElem))
  13808. {
  13809. //合并小计行
  13810. //创建合并区域的实例
  13811. var cellRangeAddress = new CellRangeAddress(
  13812. rowStartIndex, // 起始行索引(0-based)
  13813. rowStartIndex, // 结束行索引(0-based)
  13814. 0, // 起始列索引(0-based)
  13815. 3 // 结束列索引(0-based)
  13816. );
  13817. sheet.AddMergedRegion(cellRangeAddress);
  13818. var CellStyle = workbook.CreateCellStyle();
  13819. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13820. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13821. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13822. for (int i = 0; i <= clounmCount; i++)
  13823. {
  13824. if (i > 6)
  13825. {
  13826. var CellStyle1 = workbook.CreateCellStyle();
  13827. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13828. IFont Font = workbook.CreateFont(); // 创建字体
  13829. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13830. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13831. CellStyle1.SetFont(Font);
  13832. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13833. }
  13834. else
  13835. {
  13836. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13837. }
  13838. }
  13839. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13840. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13841. //超时合计
  13842. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13843. //超时数
  13844. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13845. //超时合计费用
  13846. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13847. cloneRowFn();
  13848. // 创建合并区域的实例
  13849. cellRangeAddress = new CellRangeAddress(
  13850. rowStartIndex, // 起始行索引(0-based)
  13851. rowStartIndex, // 结束行索引(0-based)
  13852. 0, // 起始列索引(0-based)
  13853. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13854. );
  13855. // 添加合并区域
  13856. sheet.AddMergedRegion(cellRangeAddress);
  13857. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13858. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13859. }
  13860. }
  13861. mergeRow();
  13862. // 保存修改后的Excel文件到新文件
  13863. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13864. // new FileStream(newFilePath, FileMode.CreateNew)
  13865. using (var stream = new MemoryStream())
  13866. {
  13867. workbook.Write(stream, true);
  13868. stream.Flush();
  13869. stream.Seek(0, SeekOrigin.Begin);
  13870. var memoryStream = new MemoryStream();
  13871. stream.CopyTo(memoryStream);
  13872. memoryStream.Seek(0, SeekOrigin.Begin);
  13873. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13874. }
  13875. workbook.Close();
  13876. workbook.Dispose();
  13877. }
  13878. catch (Exception ex)
  13879. {
  13880. jw.Msg = "出现异常!" + ex.Message;
  13881. return Ok(jw);
  13882. }
  13883. }
  13884. if (Zips.Count > 0)
  13885. {
  13886. var io = new IOOperatorHelper();
  13887. var byts = io.ConvertZipStream(Zips);
  13888. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13889. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13890. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13891. }
  13892. else
  13893. {
  13894. jw.Msg = "暂无生成文件!";
  13895. }
  13896. return Ok(jw);
  13897. }
  13898. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13899. {
  13900. string outStr = string.Empty;
  13901. switch (i)
  13902. {
  13903. case 0:
  13904. outStr = arr[0].SidName;
  13905. break;
  13906. case 1:
  13907. outStr = arr[0].DataPriceStr;
  13908. break;
  13909. case 2:
  13910. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13911. break;
  13912. case 4:
  13913. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13914. break;
  13915. case 7:
  13916. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13917. {
  13918. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13919. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13920. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13921. }
  13922. break;
  13923. case 8:
  13924. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13925. {
  13926. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13927. }
  13928. break;
  13929. case 9:
  13930. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13931. {
  13932. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13933. }
  13934. break;
  13935. case 10:
  13936. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13937. {
  13938. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13939. }
  13940. break;
  13941. }
  13942. return outStr;
  13943. }
  13944. #region OP行程单
  13945. /// <summary>
  13946. /// OP行程单初始化
  13947. /// </summary>
  13948. /// <param name="dto"></param>
  13949. /// <returns></returns>
  13950. [HttpPost]
  13951. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13952. {
  13953. var jw = JsonView(false);
  13954. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13955. var group = groupList.First();
  13956. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13957. if (group == null)
  13958. {
  13959. jw.Msg = "暂无团组!";
  13960. return Ok(jw);
  13961. }
  13962. group = groupList.Find(x => x.Id == diid);
  13963. if (group == null)
  13964. {
  13965. jw.Msg = "请输入正确的团组ID!";
  13966. return Ok(jw);
  13967. }
  13968. string city = string.Empty;
  13969. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13970. if (blackCode.Count > 0)
  13971. {
  13972. var black = blackCode.First();
  13973. black.BlackCode = black.BlackCode ?? "";
  13974. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13975. if (blackSp.Length > 0)
  13976. {
  13977. try
  13978. {
  13979. var cityArrCode = new List<string>(20);
  13980. foreach (var item in blackSp)
  13981. {
  13982. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13983. var IndexSelect = itemSp[2];
  13984. var cityArrCodeLength = cityArrCode.Count - 1;
  13985. var startCity = IndexSelect.Substring(0, 3);
  13986. if (cityArrCodeLength > 0)
  13987. {
  13988. var arrEndCity = cityArrCode[cityArrCodeLength];
  13989. if (arrEndCity != startCity)
  13990. {
  13991. cityArrCode.Add(startCity.ToUpper());
  13992. }
  13993. }
  13994. else
  13995. {
  13996. cityArrCode.Add(startCity.ToUpper());
  13997. }
  13998. var endCity = IndexSelect.Substring(3, 3);
  13999. cityArrCode.Add(endCity.ToUpper());
  14000. }
  14001. var cityThree = string.Empty;
  14002. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  14003. cityThree = cityThree.TrimEnd(',');
  14004. if (string.IsNullOrWhiteSpace(cityThree))
  14005. {
  14006. throw new
  14007. Exception("error");
  14008. }
  14009. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  14010. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  14011. foreach (var item in cityArrCode)
  14012. {
  14013. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  14014. if (find != null)
  14015. {
  14016. city += find.City + "/";
  14017. }
  14018. else
  14019. {
  14020. city += item + "三字码未收入/";
  14021. }
  14022. }
  14023. city = city.TrimEnd('/');
  14024. }
  14025. catch (Exception e)
  14026. {
  14027. city = "黑屏代码格式不正确!";
  14028. }
  14029. }
  14030. }
  14031. else
  14032. {
  14033. city = "未录入黑屏代码";
  14034. }
  14035. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  14036. {
  14037. Date = x.Date,
  14038. Days = x.Days,
  14039. Diffgroup = x.Diffgroup,
  14040. Diid = x.Diid,
  14041. Traffic_First = x.Traffic_First,
  14042. Traffic_Second = x.Traffic_Second,
  14043. Trip = x.Trip,
  14044. WeekDay = x.WeekDay,
  14045. Id = x.Id
  14046. }).ToList();
  14047. jw.Data = new
  14048. {
  14049. groupList = groupList.Select(x => new
  14050. {
  14051. x.Id,
  14052. x.TeamName,
  14053. x.TourCode
  14054. }).ToList(),
  14055. groupInfo = new
  14056. {
  14057. group.VisitDays,
  14058. group.TourCode,
  14059. group.VisitPNumber,
  14060. group.TeamName,
  14061. city
  14062. },
  14063. OpTravelList
  14064. };
  14065. jw.Code = 200;
  14066. jw.Msg = "操作成功!";
  14067. return Ok(jw);
  14068. }
  14069. /// <summary>
  14070. /// 删除团组行程单
  14071. /// </summary>
  14072. /// <returns></returns>
  14073. [HttpPost]
  14074. public IActionResult DelTravel(DelOpTravelDto dto)
  14075. {
  14076. var jw = JsonView(false);
  14077. if (dto.UserId <= 0 || dto.Diid <= 0)
  14078. {
  14079. jw.Msg = "请输入正确的参数!";
  14080. return Ok(jw);
  14081. }
  14082. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  14083. .SetColumns(x => new Grp_TravelList
  14084. {
  14085. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  14086. DeleteUserId = dto.UserId,
  14087. IsDel = 1,
  14088. }).ExecuteCommand();
  14089. jw = JsonView(true);
  14090. return Ok(jw);
  14091. }
  14092. /// <summary>
  14093. /// 行程单保存
  14094. /// </summary>
  14095. /// <returns></returns>
  14096. [HttpPost]
  14097. public IActionResult TravelSave(TravelSaveDto dto)
  14098. {
  14099. var jw = JsonView(false);
  14100. if (dto.Arr.Count > 0)
  14101. {
  14102. try
  14103. {
  14104. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14105. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14106. .ToList();
  14107. _sqlSugar.BeginTran();
  14108. foreach (var item in dto.Arr)
  14109. {
  14110. if (item.Id == 0)
  14111. {
  14112. throw new Exception("请传入正确的Id");
  14113. }
  14114. //比较上一次的差异
  14115. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14116. if (findTravel != null)
  14117. {
  14118. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14119. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14120. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14121. }
  14122. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14123. .SetColumns(x => new Grp_TravelList
  14124. {
  14125. Trip = item.Trip
  14126. }).ExecuteCommand();
  14127. }
  14128. _sqlSugar.CommitTran();
  14129. jw = JsonView(true);
  14130. }
  14131. catch (Exception ex)
  14132. {
  14133. _sqlSugar.RollbackTran();
  14134. jw.Msg = "程序异常!" + ex.Message;
  14135. }
  14136. }
  14137. else
  14138. {
  14139. jw.Msg = "请传入正确的参数!";
  14140. }
  14141. return Ok(jw);
  14142. }
  14143. private static string CheckStr(string original, string changed)
  14144. {
  14145. // 创建diff_match_patch对象
  14146. var dmp = new diff_match_patch();
  14147. // 计算差异
  14148. List<Diff> diffs = dmp.diff_main(original, changed);
  14149. // 清理和合并差异
  14150. dmp.diff_cleanupSemantic(diffs);
  14151. // 使用StringBuilder构建最终的字符串
  14152. var finalString = new StringBuilder();
  14153. // 输出差异结果,并构建变动后的字符串
  14154. foreach (Diff diff in diffs)
  14155. {
  14156. switch (diff.operation)
  14157. {
  14158. case Operation.EQUAL:
  14159. // 相等的部分,直接添加到最终字符串
  14160. finalString.Append(diff.text);
  14161. break;
  14162. case Operation.INSERT:
  14163. // 插入的部分,添加标记并添加到最终字符串
  14164. finalString.Append("[++]" + diff.text + "[++]");
  14165. break;
  14166. case Operation.DELETE:
  14167. // 删除的部分,不添加到最终字符串
  14168. //finalString.Append("[++]" + diff.text + "[++]");
  14169. break;
  14170. }
  14171. }
  14172. // 输出变动后的字符串
  14173. return finalString.ToString();
  14174. }
  14175. private class tagContent
  14176. {
  14177. public DateTime Date { get; set; }
  14178. public string StartTag { get; set; }
  14179. public string EndTag { get; set; }
  14180. public string Content { get; set; }
  14181. public static int tagLength { get { return 3; } }
  14182. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14183. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14184. public bool IsFinally { get; set; }
  14185. }
  14186. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14187. {
  14188. var results = new List<string>();
  14189. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14190. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14191. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14192. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14193. string[] strValueArr = new string[1];
  14194. foreach (System.Text.RegularExpressions.Match match in matches)
  14195. {
  14196. var strValue = match.Groups[1].Value;
  14197. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  14198. }
  14199. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  14200. return results;
  14201. }
  14202. /// <summary>
  14203. /// 导出行程单
  14204. /// </summary>
  14205. /// <param name="dto"></param>
  14206. /// <returns></returns>
  14207. [HttpPost]
  14208. public IActionResult ExportTravel(ExportTravelDto dto)
  14209. {
  14210. var jw = JsonView(false);
  14211. jw.Data = "";
  14212. int diid = 0;
  14213. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  14214. if (Find == null)
  14215. {
  14216. jw.Msg = "请选择正确的团组!";
  14217. return Ok(jw);
  14218. }
  14219. else
  14220. {
  14221. diid = Find.Id;
  14222. }
  14223. //数据源
  14224. var _travelList = new List<Grp_TravelList>();
  14225. DataTable dtBlack = null;
  14226. try
  14227. {
  14228. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14229. }
  14230. catch (Exception)
  14231. {
  14232. jw.Msg = "机票黑屏代码有误!";
  14233. return Ok(jw);
  14234. }
  14235. string CityStr = string.Empty;
  14236. if (dtBlack.Rows.Count == 0)
  14237. {
  14238. jw.Msg = "机票黑屏代码有误!";
  14239. return Ok(jw);
  14240. }
  14241. else
  14242. {
  14243. foreach (DataRow row in dtBlack.Rows)
  14244. {
  14245. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14246. {
  14247. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14248. return Ok(jw);
  14249. }
  14250. }
  14251. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14252. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14253. }
  14254. // 指定的文字
  14255. var targetTextDic = new Dictionary<string, List<string>>();
  14256. //创建数据源Table
  14257. var dtSource = new DataTable();
  14258. dtSource.Columns.Add("Days", typeof(string));
  14259. dtSource.Columns.Add("Date", typeof(string));
  14260. dtSource.Columns.Add("Week", typeof(string));
  14261. dtSource.Columns.Add("Traffic", typeof(string));
  14262. dtSource.Columns.Add("Trip", typeof(string));
  14263. //获取数据,放到datatable
  14264. foreach (var item in _travelList)
  14265. {
  14266. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14267. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14268. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14269. .Replace("[++]", string.Empty);
  14270. DataRow dr = dtSource.NewRow();
  14271. dr["Days"] = item.Days;
  14272. dr["Date"] = item.Date;
  14273. dr["Week"] = item.WeekDay;
  14274. dr["Traffic"] = item.Traffic_First
  14275. + "\r\n"
  14276. + item.Traffic_Second;
  14277. dr["Trip"] = item.Trip;
  14278. dtSource.Rows.Add(dr);
  14279. }
  14280. var dic = new Dictionary<string, string>
  14281. {
  14282. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14283. { "City", CityStr },
  14284. { "Days", Find.VisitDays.ToString() },
  14285. { "DeleCode", Find.TourCode },
  14286. { "Pnum", Find.VisitPNumber.ToString() }
  14287. };
  14288. //模板路径
  14289. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14290. //载入模板
  14291. Document doc = null;
  14292. DocumentBuilder builder = null;
  14293. try
  14294. {
  14295. //载入模板
  14296. doc = new Document(tempPath);
  14297. builder = new DocumentBuilder(doc);
  14298. }
  14299. catch (Exception)
  14300. {
  14301. jw.Msg = "模板位置不存在!";
  14302. return Ok(jw);
  14303. }
  14304. foreach (var key in dic.Keys)
  14305. {
  14306. Bookmark bookmark = doc.Range.Bookmarks[key];
  14307. if (bookmark != null)
  14308. {
  14309. builder.MoveToBookmark(key);
  14310. builder.Write(dic[key]);
  14311. }
  14312. }
  14313. //获取word里所有表格
  14314. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14315. //获取所填表格的序数
  14316. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14317. try
  14318. {
  14319. //循环赋值
  14320. for (int i = 0; i < dtSource.Rows.Count; i++)
  14321. {
  14322. builder.MoveToCell(0, i + 1, 0, 0);
  14323. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14324. builder.MoveToCell(0, i + 1, 1, 0);
  14325. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14326. builder.MoveToCell(0, i + 1, 2, 0);
  14327. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14328. var trip = dtSource.Rows[i]["Trip"].ToString();
  14329. builder.MoveToCell(0, i + 1, 3, 0);
  14330. builder.Write(trip);
  14331. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14332. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14333. // 获取特定索引的段落
  14334. Paragraph paragraph = (Paragraph)paragraphs[0];
  14335. Run run = paragraph.Runs[0];
  14336. Aspose.Words.Font font = run.Font;
  14337. font.Name = "黑体";
  14338. //设置双休红色
  14339. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14340. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14341. paragraph = (Paragraph)paragraphs[1];
  14342. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14343. {
  14344. run = paragraph.Runs[0];
  14345. font = run.Font;
  14346. font.Color = Color.Red;
  14347. }
  14348. }
  14349. }
  14350. catch (Exception ex)
  14351. {
  14352. }
  14353. //删除多余行
  14354. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14355. {
  14356. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14357. }
  14358. var targetTextList = new List<string>();
  14359. // 遍历文档中的表格
  14360. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14361. {
  14362. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14363. {
  14364. var cellIndex = 0;
  14365. foreach (Cell cell in row.Cells)
  14366. {
  14367. if (cellIndex == 1 && row.Cells.Count == 4)
  14368. {
  14369. foreach (var target in targetTextDic.Keys)
  14370. {
  14371. if (cell.GetText().Contains(target))
  14372. {
  14373. targetTextList = targetTextDic[target];
  14374. break;
  14375. }
  14376. }
  14377. }
  14378. // 遍历单元格中的所有段落
  14379. foreach (Paragraph paragraph in cell.Paragraphs)
  14380. {
  14381. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14382. var runs = new List<Run>();
  14383. foreach (Run run in paragraph.Runs)
  14384. {
  14385. runs.Add(run);
  14386. }
  14387. foreach (Run run in runs)
  14388. {
  14389. foreach (var targetText in targetTextList)
  14390. {
  14391. // 检查文字是否包含指定文字
  14392. if (run.Text.Contains(targetText))
  14393. {
  14394. // 将包含的部分设置为红色
  14395. HighlightText(run, targetText, Color.Red);
  14396. }
  14397. }
  14398. }
  14399. }
  14400. cellIndex++;
  14401. }
  14402. }
  14403. }
  14404. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14405. if (!Directory.Exists(savePath))
  14406. {
  14407. try
  14408. {
  14409. Directory.CreateDirectory(savePath);
  14410. }
  14411. catch
  14412. {
  14413. }
  14414. }
  14415. string path = savePath + Find.TeamName + "出访日程";
  14416. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14417. try
  14418. {
  14419. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14420. string postfix = ".docx";
  14421. if (dto.IsPDF == 1)
  14422. {
  14423. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14424. postfix = ".pdf";
  14425. }
  14426. doc.Save(path + postfix, saveFormat);
  14427. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14428. }
  14429. catch (Exception)
  14430. {
  14431. jw = JsonView(false);
  14432. }
  14433. return Ok(jw);
  14434. }
  14435. /// <summary>
  14436. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14437. /// </summary>
  14438. /// <param name="num"></param>
  14439. /// <returns></returns>
  14440. static string GetNum(string num)
  14441. {
  14442. string str = "";
  14443. switch (num)
  14444. {
  14445. case "1":
  14446. str = "一";
  14447. break;
  14448. case "2":
  14449. str = "二";
  14450. break;
  14451. case "3":
  14452. str = "三";
  14453. break;
  14454. case "4":
  14455. str = "四";
  14456. break;
  14457. case "5":
  14458. str = "五";
  14459. break;
  14460. case "6":
  14461. str = "六";
  14462. break;
  14463. case "7":
  14464. str = "七";
  14465. break;
  14466. case "8":
  14467. str = "八";
  14468. break;
  14469. case "9":
  14470. str = "九";
  14471. break;
  14472. case "10":
  14473. str = "十";
  14474. break;
  14475. case "11":
  14476. str = "十一";
  14477. break;
  14478. case "12":
  14479. str = "十二";
  14480. break;
  14481. case "一":
  14482. str = "1";
  14483. break;
  14484. case "二":
  14485. str = "2";
  14486. break;
  14487. case "三":
  14488. str = "3";
  14489. break;
  14490. case "四":
  14491. str = "4";
  14492. break;
  14493. case "五":
  14494. str = "5";
  14495. break;
  14496. case "六":
  14497. str = "6";
  14498. break;
  14499. case "七":
  14500. str = "7";
  14501. break;
  14502. case "八":
  14503. str = "8";
  14504. break;
  14505. case "九":
  14506. str = "9";
  14507. break;
  14508. case "十":
  14509. str = "10";
  14510. break;
  14511. case "十一":
  14512. str = "11";
  14513. break;
  14514. case "十二":
  14515. str = "12";
  14516. break;
  14517. }
  14518. return str;
  14519. }
  14520. /// <summary>
  14521. /// 高亮包含指定文字的部分
  14522. /// </summary>
  14523. /// <param name="run"></param>
  14524. /// <param name="targetText"></param>
  14525. /// <param name="color"></param>
  14526. static void HighlightText(Run run, string targetText, Color color)
  14527. {
  14528. string text = run.Text;
  14529. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14530. if (startIndex >= 0)
  14531. {
  14532. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14533. // 前部分
  14534. if (startIndex > 0)
  14535. {
  14536. Run beforeRun = (Run)run.Clone(true);
  14537. beforeRun.Text = text.Substring(0, startIndex);
  14538. parentParagraph.InsertBefore(beforeRun, run);
  14539. }
  14540. // 匹配部分
  14541. Run matchRun = (Run)run.Clone(true);
  14542. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14543. matchRun.Font.Color = color;
  14544. parentParagraph.InsertBefore(matchRun, run);
  14545. // 后部分
  14546. if (startIndex + targetText.Length < text.Length)
  14547. {
  14548. Run afterRun = (Run)run.Clone(true);
  14549. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14550. parentParagraph.InsertBefore(afterRun, run);
  14551. }
  14552. // 删除原始Run
  14553. run.Remove();
  14554. }
  14555. }
  14556. #endregion
  14557. #endregion
  14558. #region 团组成本
  14559. /// <summary>
  14560. /// 团组成本数据初始化
  14561. /// </summary>
  14562. /// <param name="dto"></param>
  14563. /// <returns></returns>
  14564. [HttpPost]
  14565. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14566. {
  14567. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14568. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14569. WHEN COUNT(*) >= 0 THEN 'True'
  14570. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14571. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14572. ").ToList(); //团组列表
  14573. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14574. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14575. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14576. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14577. if (groupinfoValue != null)
  14578. {
  14579. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14580. var spArr = new string[1] { countryArr };
  14581. if (countryArr.Contains("|"))
  14582. {
  14583. spArr = countryArr.Split("|");
  14584. }
  14585. else if (countryArr.Contains("、"))
  14586. {
  14587. spArr = countryArr.Split("、");
  14588. }
  14589. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14590. {
  14591. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14592. if (dbQueryCountry != null)
  14593. {
  14594. visaCountryInfoArr.Add(dbQueryCountry);
  14595. }
  14596. }
  14597. }
  14598. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14599. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14600. #region 屏蔽黑屏代码生成
  14601. //var create = _GroupCostRepository.
  14602. // CreateGroupCostByBlackCode(dto.Diid);
  14603. //if (groupCost.Count == 0 && create.Code == 0)
  14604. //{
  14605. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14606. //}
  14607. #endregion
  14608. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14609. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14610. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14611. groupCostMap = groupCostMap.Select(x =>
  14612. {
  14613. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14614. {
  14615. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14616. }
  14617. return x;
  14618. }).ToList();
  14619. //GroupCostParameter.Add(new
  14620. // Grp_GroupCostParameter());
  14621. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14622. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14623. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14624. return Ok(JsonView(new
  14625. {
  14626. groupList,
  14627. groupInfo,
  14628. groupChecks,
  14629. groupCost = groupCostMap,
  14630. hotelNumber,
  14631. GroupCostParameter = GroupCostParameterMap,
  14632. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14633. {
  14634. x.VisaCountry,
  14635. x.VisaPrice,
  14636. x.Id,
  14637. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14638. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14639. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14640. x.VisaTime, // 一般签证时间
  14641. x.PettyBusinessAgencyFee, //小公务代办费
  14642. x.GrandBusinessAgencyFee //大公务代办费
  14643. }).ToList(),
  14644. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14645. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14646. hotelIsTrue,
  14647. groupModuleOperators
  14648. }));
  14649. }
  14650. /// <summary>
  14651. /// 团组成本信息保存
  14652. /// </summary>
  14653. /// <param name="dto"></param>
  14654. /// <returns></returns>
  14655. [HttpPost]
  14656. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14657. {
  14658. if (dto.Diid <= 0 || dto.Userid <= 0)
  14659. {
  14660. return Ok(JsonView(false));
  14661. }
  14662. JsonView jw = null;
  14663. bool isTrue = false;
  14664. #region 复制团组成本
  14665. //if (dto.Diid == 2581)
  14666. //{
  14667. // dto.Diid = 2599;
  14668. // dto.CheckBoxs.ForEach(x =>
  14669. // {
  14670. // x.Diid = 2599;
  14671. // });
  14672. // dto.GroupCosts.ForEach(x =>
  14673. // {
  14674. // x.Diid = 2599;
  14675. // });
  14676. // dto.CostTypeHotelNumbers.ForEach(x =>
  14677. // {
  14678. // x.Diid = 2599;
  14679. // });
  14680. // dto.GroupCostParameters.ForEach(x =>
  14681. // {
  14682. // x.DiId = 2599;
  14683. // });
  14684. //}
  14685. #endregion
  14686. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14687. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14688. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14689. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14690. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14691. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14692. try
  14693. {
  14694. _sqlSugar.BeginTran();
  14695. isTrue = await _GroupCostRepository.
  14696. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14697. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14698. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14699. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14700. _sqlSugar.CommitTran();
  14701. jw = JsonView(true, "保存成功!", isTrue);
  14702. }
  14703. catch (Exception)
  14704. {
  14705. _sqlSugar.RollbackTran();
  14706. jw = JsonView(false);
  14707. }
  14708. return Ok(jw);
  14709. }
  14710. /// <summary>
  14711. /// 复制团组成本信息
  14712. /// </summary>
  14713. /// <param name="dto"></param>
  14714. /// <returns></returns>
  14715. [HttpPost]
  14716. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14717. {
  14718. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14719. {
  14720. return Ok(JsonView(false, "参数有误!"));
  14721. }
  14722. #region 复制团组成本
  14723. dto.Diid = dto.ToGroupId;
  14724. dto.CheckBoxs.ForEach(x =>
  14725. {
  14726. x.Diid = dto.ToGroupId;
  14727. });
  14728. dto.GroupCosts.ForEach(x =>
  14729. {
  14730. x.Diid = dto.ToGroupId;
  14731. });
  14732. dto.CostTypeHotelNumbers.ForEach(x =>
  14733. {
  14734. x.Diid = dto.ToGroupId;
  14735. });
  14736. dto.GroupCostParameters.ForEach(x =>
  14737. {
  14738. x.DiId = dto.ToGroupId;
  14739. });
  14740. #endregion
  14741. JsonView jw = null;
  14742. bool isTrue = false;
  14743. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14744. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14745. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14746. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14747. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14748. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14749. try
  14750. {
  14751. _sqlSugar.BeginTran();
  14752. isTrue = await _GroupCostRepository.
  14753. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14754. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14755. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14756. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14757. _sqlSugar.CommitTran();
  14758. jw = JsonView(true, "保存成功!", isTrue);
  14759. }
  14760. catch (Exception)
  14761. {
  14762. _sqlSugar.RollbackTran();
  14763. jw = JsonView(false);
  14764. }
  14765. return Ok(jw);
  14766. }
  14767. /// <summary>
  14768. /// 司兼导数据
  14769. /// </summary>
  14770. /// <param name="dto"></param>
  14771. /// <returns></returns>
  14772. [HttpPost]
  14773. public IActionResult GetCarGuides(CarGuidesDto dto)
  14774. {
  14775. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14776. return Ok(JsonView(true, "获取成功!", Data));
  14777. }
  14778. /// <summary>
  14779. /// 导游数据
  14780. /// </summary>
  14781. /// <param name="dto"></param>
  14782. /// <returns></returns>
  14783. [HttpPost]
  14784. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14785. {
  14786. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14787. // SELECT*,ROW_NUMBER() OVER (ORDER BY Id) AS RowNumber FROM Grp_GuidesInfo where (city like '%{dto.City}%' or country like '%{dto.City}%' ) and isdel = 0 ) as b
  14788. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14789. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14790. return Ok(JsonView(true, "获取成功!", Data));
  14791. }
  14792. /// <summary>
  14793. /// 成本车数据
  14794. /// </summary>
  14795. /// <param name="dto"></param>
  14796. /// <returns></returns>
  14797. [HttpPost]
  14798. public IActionResult GetCarInfo(CarGuidesDto dto)
  14799. {
  14800. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14801. return Ok(JsonView(true, "获取成功!", Data));
  14802. }
  14803. /// <summary>
  14804. /// 景点数据
  14805. /// </summary>
  14806. /// <param name="dto"></param>
  14807. /// <returns></returns>
  14808. [HttpPost]
  14809. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14810. {
  14811. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14812. return Ok(JsonView(true, "获取成功!", Data));
  14813. }
  14814. /// <summary>
  14815. /// 成本通知
  14816. /// </summary>
  14817. /// <param name="dto"></param>
  14818. /// <returns></returns>
  14819. [HttpPost]
  14820. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14821. {
  14822. if (dto.Diid < 0)
  14823. {
  14824. return Ok(JsonView(false));
  14825. }
  14826. JsonView jw;
  14827. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14828. if (GroupCostParameter != null)
  14829. {
  14830. int IsShare = 0;
  14831. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14832. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14833. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14834. string msg = string.Empty;
  14835. if (isTrue)
  14836. {
  14837. if (IsShare == 0)
  14838. {
  14839. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14840. }
  14841. else
  14842. {
  14843. #region 企微通知对应岗位用户
  14844. try
  14845. {
  14846. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14847. }
  14848. catch (Exception)
  14849. {
  14850. }
  14851. #endregion
  14852. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14853. }
  14854. jw = JsonView(isTrue, msg, new { IsShare });
  14855. }
  14856. else
  14857. {
  14858. msg = "修改失败!";
  14859. jw = JsonView(isTrue, msg);
  14860. }
  14861. }
  14862. else
  14863. {
  14864. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14865. }
  14866. return Ok(jw);
  14867. }
  14868. /// <summary>
  14869. /// 导出报价单
  14870. /// </summary>
  14871. /// <param name="dto"></param>
  14872. /// <returns></returns>
  14873. [HttpPost]
  14874. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14875. {
  14876. if (dto.Diid == 0)
  14877. {
  14878. return Ok(JsonView(false, "请传递团组id"));
  14879. }
  14880. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14881. if (deleInfo.Code != 0)
  14882. {
  14883. return Ok(JsonView(false, "团组信息查询失败!"));
  14884. }
  14885. var di = deleInfo.Data as DelegationInfoWebView;
  14886. if (di != null)
  14887. {
  14888. di.TeamName = di.TeamName.Replace("|", "、");
  14889. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14890. //文件名
  14891. string strFileName = di.TeamName + "-收款账单.doc";
  14892. //获取模板
  14893. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14894. //载入模板
  14895. Document doc = new Document(tmppath);
  14896. decimal TotalPrice = 0.00M;
  14897. string itemStr = string.Empty;
  14898. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14899. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14900. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14901. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14902. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14903. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14904. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14905. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14906. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14907. foreach (var cost in groupCostType)
  14908. {
  14909. var List = cost.ToList();
  14910. if (cost.Key == "A")
  14911. {
  14912. foreach (var ListItem in List)
  14913. {
  14914. if (ListItem.number > 0)
  14915. {
  14916. if (ListItem.code.Contains("TBR"))
  14917. {
  14918. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14919. }
  14920. else
  14921. {
  14922. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14923. }
  14924. TotalPrice += (ListItem.number * ListItem.price);
  14925. }
  14926. }
  14927. }
  14928. else
  14929. {
  14930. itemStr = itemStr.Insert(0, "A段\r\n");
  14931. itemStr += "B段\r\n";
  14932. foreach (var ListItem in List)
  14933. {
  14934. if (ListItem.number > 0)
  14935. {
  14936. if (ListItem.code.Contains("TBR"))
  14937. {
  14938. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14939. }
  14940. else
  14941. {
  14942. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14943. }
  14944. TotalPrice += (ListItem.number * ListItem.price);
  14945. }
  14946. }
  14947. }
  14948. }
  14949. #region 替换Word模板书签内容
  14950. Dictionary<string, string> marks = new Dictionary<string, string>();
  14951. marks.Add("To", di.ClientUnit);//付款方
  14952. marks.Add("ToTel", di.TellPhone);//付款方电话
  14953. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14954. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14955. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14956. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14957. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14958. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14959. marks.Add("PayItemContent", itemStr);//详细信息
  14960. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14961. #endregion
  14962. ////注
  14963. //if (doc.Range.Bookmarks["Attention"] != null)
  14964. //{
  14965. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14966. // mark.Text = frList[0].Attention;
  14967. //}
  14968. foreach (var item in marks.Keys)
  14969. {
  14970. if (doc.Range.Bookmarks[item] != null)
  14971. {
  14972. Bookmark mark = doc.Range.Bookmarks[item];
  14973. mark.Text = marks[item];
  14974. }
  14975. }
  14976. byte[] bytes = null;
  14977. using (MemoryStream stream = new MemoryStream())
  14978. {
  14979. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14980. bytes = stream.ToArray();
  14981. }
  14982. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14983. return Ok(JsonView(true, "", new
  14984. {
  14985. Data = bytes,
  14986. strFileName,
  14987. }));
  14988. }
  14989. else
  14990. {
  14991. return Ok(JsonView(false, "团组信息不存在!"));
  14992. }
  14993. }
  14994. /// <summary>
  14995. /// 导出团组成本
  14996. /// </summary>
  14997. /// <param name="dto"></param>
  14998. /// <returns></returns>
  14999. [HttpPost]
  15000. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  15001. {
  15002. var jw = JsonView(false);
  15003. if (dto.Diid == 0)
  15004. {
  15005. return Ok(JsonView(false, "请传递团组id"));
  15006. }
  15007. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15008. if (deleInfo.Code != 0)
  15009. {
  15010. return Ok(JsonView(false, "团组信息查询失败!"));
  15011. }
  15012. var di = deleInfo.Data as DelegationInfoWebView;
  15013. if (di == null)
  15014. {
  15015. return Ok(JsonView(false, "团组信息查询失败!"));
  15016. }
  15017. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  15018. WorkbookDesigner designer = new WorkbookDesigner();
  15019. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  15020. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  15021. List<int> hideColumnList = new List<int>();
  15022. var ColumnSetting = new[]
  15023. {
  15024. new { tag = "VF", Index = 4, P = "CarCost" },
  15025. new { tag = "VN", Index = 5, P = "CarNumber" },
  15026. new { tag = "VRD", Index = 6, P = "CarTiming" },
  15027. new { tag = "T/G S", Index = 7, P = "TGS" },
  15028. new { tag = "TGWH", Index = 8, P = "TGWH" },
  15029. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  15030. new { tag = "T/G M", Index = 10, P = "TGM" },
  15031. new { tag = "T/G A", Index = 11, P = "TGA" },
  15032. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  15033. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  15034. new { tag = "C/F S", Index = 14, P = "CFS" },
  15035. new { tag = "C/F M", Index = 15, P = "CFM" },
  15036. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  15037. new { tag = "B", Index = 17, P = "B" },
  15038. new { tag = "L", Index = 18, P = "L" },
  15039. new { tag = "D", Index = 19, P = "D" },
  15040. new { tag = "TBR", Index = 20, P = "TBR" },
  15041. new { tag = "SGR", Index = 21, P = "SGR" },
  15042. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  15043. new { tag = "Suite", Index = 23, P = "Suite" },
  15044. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  15045. new { tag = "T/V", Index = 25, P = "TV" },
  15046. new { tag = "1/L", Index = 26, P = "iL" },
  15047. new { tag = "I/F", Index = 27, P = "IF" },
  15048. new { tag = "EF", Index = 28, P = "EF" },
  15049. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  15050. new { tag = "TE", Index = 30, P = "TE" },
  15051. new { tag = "T/G T", Index = 31, P = "TGTips" },
  15052. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  15053. new { tag = "P/C", Index = 33, P = "PC" },
  15054. new { tag = "T/L F", Index = 34, P = "TLF" },
  15055. new { tag = "E/C T", Index = 35, P = "ECT" }
  15056. };
  15057. Func<string, bool> isEmpty = (str) =>
  15058. {
  15059. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  15060. {
  15061. return true;
  15062. }
  15063. if (string.IsNullOrWhiteSpace(str))
  15064. {
  15065. return true;
  15066. }
  15067. return false;
  15068. };
  15069. for (int i = 0; i < List_GC.Count; i++)
  15070. {
  15071. GroupCost_Excel gc = new GroupCost_Excel();
  15072. gc.Id = List_GC[i].Id;
  15073. gc.Diid = List_GC[i].Diid.ToString();
  15074. gc.DAY = List_GC[i].DAY;
  15075. string week = "";
  15076. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  15077. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  15078. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  15079. gc.ITIN = List_GC[i].ITIN;
  15080. gc.CarType = List_GC[i].CarType;
  15081. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  15082. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  15083. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  15084. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  15085. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  15086. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  15087. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  15088. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  15089. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  15090. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  15091. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  15092. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  15093. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  15094. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  15095. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  15096. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  15097. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  15098. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  15099. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  15100. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15101. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15102. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15103. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15104. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15105. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15106. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15107. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15108. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15109. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15110. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15111. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15112. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15113. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15114. gc.EFR = List_GC[i].EFR;
  15115. List_GC1.Add(gc);
  15116. }
  15117. if (List_GC1.Count > 0)
  15118. {
  15119. var p = List_GC1[0];
  15120. var prs = p.GetType().GetProperties();
  15121. foreach (var item in prs)
  15122. {
  15123. var tp = item.PropertyType;
  15124. if (tp == typeof(int))
  15125. {
  15126. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15127. if (val == 0)
  15128. {
  15129. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15130. if (columnSetting != null)
  15131. {
  15132. hideColumnList.Add(columnSetting.Index);
  15133. }
  15134. }
  15135. }
  15136. if (tp == typeof(decimal))
  15137. {
  15138. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15139. if (val == 0)
  15140. {
  15141. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15142. if (columnSetting != null)
  15143. {
  15144. hideColumnList.Add(columnSetting.Index);
  15145. }
  15146. }
  15147. }
  15148. if (tp == typeof(string))
  15149. {
  15150. var val = List_GC1.Sum(x =>
  15151. {
  15152. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15153. if (decimal.TryParse(str, out decimal str_De))
  15154. {
  15155. return str_De;
  15156. }
  15157. else
  15158. {
  15159. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  15160. }
  15161. });
  15162. if (val == 0)
  15163. {
  15164. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15165. if (columnSetting != null)
  15166. {
  15167. hideColumnList.Add(columnSetting.Index);
  15168. }
  15169. }
  15170. }
  15171. }
  15172. }
  15173. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  15174. dt.TableName = "TB";
  15175. //报表标题等不用dt的值
  15176. designer.SetDataSource("TeamName", dto.title.TeamName);
  15177. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  15178. designer.SetDataSource("Tax", dto.title.Tax);
  15179. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  15180. designer.SetDataSource("Currency", dto.title.Currency);
  15181. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  15182. designer.SetDataSource("Rate", dto.title.Rate);
  15183. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  15184. var Aparams = hotels.Find(x => x.Type == "Default");
  15185. if (Aparams == null)
  15186. {
  15187. return Ok(jw);
  15188. }
  15189. //酒店数量
  15190. var txtSGRNumber = Aparams.SGR.ToString();
  15191. var txtTBRNumber = Aparams.TBR.ToString();
  15192. var txtJSESNumber = Aparams.JSES.ToString();
  15193. var txtSUITENumbe = Aparams.SUITE.ToString();
  15194. if (dto.costType == "B")
  15195. {
  15196. Aparams = hotels.Find(x => x.Type == "A");
  15197. var Bparams = hotels.Find(x => x.Type == "B");
  15198. if (Aparams == null || Bparams == null)
  15199. {
  15200. return Ok(jw);
  15201. }
  15202. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  15203. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  15204. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  15205. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  15206. }
  15207. designer.SetDataSource("SGRNumber", txtSGRNumber);
  15208. designer.SetDataSource("TBRNumber", txtTBRNumber);
  15209. designer.SetDataSource("JSESNumber", txtJSESNumber);
  15210. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  15211. var ws = designer.Workbook.Worksheets[1];
  15212. int Row = List_GC.Count;
  15213. int startIndex = 0;
  15214. int HideRows = 0;
  15215. Row = 0;
  15216. List<int> hideRowsList = new List<int>();
  15217. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  15218. #region A段left数据
  15219. var left = dto.leftInfo.Find(x => x.Type == "A");
  15220. if (left == null)
  15221. {
  15222. return Ok(jw);
  15223. }
  15224. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15225. if (leftBindData != null)
  15226. {
  15227. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15228. designer.SetDataSource("VisaRS", leftBindData.rs);
  15229. designer.SetDataSource("VisaXS", leftBindData.xs);
  15230. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15231. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15232. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15233. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15234. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15235. }
  15236. else
  15237. {
  15238. hideRowsList.Add(Row + startIndex + HideRows);
  15239. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15240. }
  15241. HideRows += 2;
  15242. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  15243. if (leftBindData != null)
  15244. {
  15245. designer.SetDataSource("BXDRCB", leftBindData.cb);
  15246. designer.SetDataSource("BXRS", leftBindData.rs);
  15247. designer.SetDataSource("BXXS", leftBindData.xs);
  15248. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15249. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15250. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15251. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15252. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15253. }
  15254. else
  15255. {
  15256. hideRowsList.Add(Row + startIndex + HideRows);
  15257. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15258. }
  15259. HideRows += 2;
  15260. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15261. if (leftBindData != null)
  15262. {
  15263. designer.SetDataSource("HSDRCB", leftBindData.cb);
  15264. designer.SetDataSource("HSRS", leftBindData.rs);
  15265. designer.SetDataSource("HSXS", leftBindData.xs);
  15266. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15267. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15268. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15269. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15270. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15271. }
  15272. else
  15273. {
  15274. hideRowsList.Add(Row + startIndex + HideRows);
  15275. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15276. }
  15277. HideRows += 2;
  15278. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15279. if (leftBindData != null)
  15280. {
  15281. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  15282. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15283. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15284. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15285. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15286. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15287. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15288. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15289. }
  15290. else
  15291. {
  15292. hideRowsList.Add(Row + startIndex + HideRows);
  15293. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15294. }
  15295. HideRows += 2;
  15296. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15297. if (leftBindData != null)
  15298. {
  15299. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  15300. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15301. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15302. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15303. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15304. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15305. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15306. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15307. }
  15308. else
  15309. {
  15310. hideRowsList.Add(Row + startIndex + HideRows);
  15311. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15312. }
  15313. HideRows += 2;
  15314. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15315. if (leftBindData != null)
  15316. {
  15317. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15318. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15319. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15320. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15321. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15322. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15323. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15324. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15325. }
  15326. else
  15327. {
  15328. hideRowsList.Add(Row + startIndex + HideRows);
  15329. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15330. }
  15331. HideRows += 2;
  15332. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15333. if (leftBindData != null)
  15334. {
  15335. ////TBR
  15336. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15337. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15338. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15339. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15340. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15341. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15342. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15343. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15344. }
  15345. else
  15346. {
  15347. hideRowsList.Add(Row + startIndex + HideRows);
  15348. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15349. }
  15350. HideRows += 2;
  15351. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15352. if (leftBindData != null)
  15353. {
  15354. ////SGR
  15355. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  15356. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  15357. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  15358. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15359. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15360. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15361. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15362. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15363. }
  15364. else
  15365. {
  15366. hideRowsList.Add(Row + startIndex + HideRows);
  15367. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15368. }
  15369. HideRows += 2;
  15370. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15371. if (leftBindData != null)
  15372. {
  15373. ////JS/ES
  15374. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15375. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15376. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15377. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15378. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15379. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15380. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15381. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15382. }
  15383. else
  15384. {
  15385. hideRowsList.Add(Row + startIndex + HideRows);
  15386. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15387. }
  15388. HideRows += 2;
  15389. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15390. if (leftBindData != null)
  15391. {
  15392. ////SUITE
  15393. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15394. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15395. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15396. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15397. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15398. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15399. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15400. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15401. }
  15402. else
  15403. {
  15404. hideRowsList.Add(Row + startIndex + HideRows);
  15405. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15406. }
  15407. HideRows += 2;
  15408. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15409. if (leftBindData != null)
  15410. {
  15411. designer.SetDataSource("DJDRCB", leftBindData.cb);
  15412. designer.SetDataSource("DJRS", leftBindData.rs);
  15413. designer.SetDataSource("DJXS", leftBindData.xs);
  15414. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15415. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15416. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15417. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15418. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15419. }
  15420. else
  15421. {
  15422. hideRowsList.Add(Row + startIndex + HideRows);
  15423. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15424. }
  15425. HideRows += 2;
  15426. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15427. if (leftBindData != null)
  15428. {
  15429. designer.SetDataSource("HCPCB", leftBindData.cb);
  15430. designer.SetDataSource("HCPRS", leftBindData.rs);
  15431. designer.SetDataSource("HCPXS", leftBindData.xs);
  15432. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15433. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15434. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15435. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15436. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15437. }
  15438. else
  15439. {
  15440. hideRowsList.Add(Row + startIndex + HideRows);
  15441. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15442. }
  15443. HideRows += 2;
  15444. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15445. if (leftBindData != null)
  15446. {
  15447. designer.SetDataSource("CPCB", leftBindData.cb);
  15448. designer.SetDataSource("CPRS", leftBindData.rs);
  15449. designer.SetDataSource("CPXS", leftBindData.xs);
  15450. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15451. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15452. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15453. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15454. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15455. }
  15456. else
  15457. {
  15458. hideRowsList.Add(Row + startIndex + HideRows);
  15459. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15460. }
  15461. HideRows += 2;
  15462. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15463. if (leftBindData != null)
  15464. {
  15465. designer.SetDataSource("GWDRCD", leftBindData.cb);
  15466. designer.SetDataSource("GWRS", leftBindData.rs);
  15467. designer.SetDataSource("GWXS", leftBindData.xs);
  15468. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15469. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15470. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15471. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15472. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15473. }
  15474. else
  15475. {
  15476. hideRowsList.Add(Row + startIndex + HideRows);
  15477. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15478. }
  15479. HideRows += 2;
  15480. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15481. if (leftBindData != null)
  15482. {
  15483. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15484. designer.SetDataSource("LYJRS", leftBindData.rs);
  15485. designer.SetDataSource("LYJXS", leftBindData.xs);
  15486. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15487. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15488. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15489. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15490. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15491. }
  15492. else
  15493. {
  15494. hideRowsList.Add(Row + startIndex + HideRows);
  15495. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15496. }
  15497. #endregion
  15498. #region A段Right信息
  15499. var right = dto.rightInfo.Find(x => x.Type == "A");
  15500. if (right == null)
  15501. {
  15502. return Ok(jw);
  15503. }
  15504. HideRows += 4;
  15505. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15506. if (rightBindData != null)
  15507. {
  15508. //经济舱 + 双人间 TBR
  15509. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15510. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15511. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15512. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15513. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15514. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15515. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15516. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15517. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15518. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15519. }
  15520. else
  15521. {
  15522. hideRowsList.Add(Row + startIndex + HideRows);
  15523. }
  15524. HideRows += 2;
  15525. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15526. if (rightBindData != null)
  15527. {
  15528. //经济舱 + 单人间 SGR
  15529. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15530. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15531. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15532. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15533. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15534. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15535. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15536. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15537. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15538. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15539. }
  15540. else
  15541. {
  15542. hideRowsList.Add(Row + startIndex + HideRows);
  15543. }
  15544. HideRows += 2;
  15545. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15546. if (rightBindData != null)
  15547. {
  15548. //公务舱 + 单人间 SGR
  15549. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15550. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15551. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15552. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15553. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15554. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15555. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15556. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15557. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15558. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15559. }
  15560. else
  15561. {
  15562. hideRowsList.Add(Row + startIndex + HideRows);
  15563. }
  15564. HideRows += 2;
  15565. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15566. if (rightBindData != null)
  15567. {
  15568. //公务舱 + 小套房 JSES
  15569. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15570. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15571. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15572. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15573. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15574. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15575. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15576. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15577. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15578. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15579. }
  15580. else
  15581. {
  15582. hideRowsList.Add(Row + startIndex + HideRows);
  15583. }
  15584. HideRows += 2;
  15585. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15586. if (rightBindData != null)
  15587. {
  15588. //公务舱 + 小套房 JSES
  15589. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15590. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15591. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15592. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15593. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15594. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15595. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15596. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15597. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15598. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15599. }
  15600. else
  15601. {
  15602. hideRowsList.Add(Row + startIndex + HideRows);
  15603. }
  15604. HideRows += 2;
  15605. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15606. if (rightBindData != null)
  15607. {
  15608. //经济舱 + 大套房
  15609. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15610. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15611. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15612. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15613. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15614. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15615. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15616. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15617. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15618. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15619. }
  15620. else
  15621. {
  15622. hideRowsList.Add(Row + startIndex + HideRows);
  15623. }
  15624. HideRows += 2;
  15625. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15626. if (rightBindData != null)
  15627. {
  15628. //头等舱 + 小套房 JSES
  15629. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15630. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15631. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15632. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15633. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15634. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15635. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15636. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15637. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15638. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15639. }
  15640. else
  15641. {
  15642. hideRowsList.Add(Row + startIndex + HideRows);
  15643. }
  15644. HideRows += 2;
  15645. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15646. if (rightBindData != null)
  15647. {
  15648. //头等舱 + 大套房
  15649. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15650. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15651. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15652. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15653. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15654. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15655. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15656. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15657. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15658. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15659. }
  15660. else
  15661. {
  15662. hideRowsList.Add(Row + startIndex + HideRows);
  15663. }
  15664. #endregion
  15665. #region B段标题清空
  15666. designer.SetDataSource("CostBDRCB", "");
  15667. designer.SetDataSource("CostBRS", "");
  15668. designer.SetDataSource("CostBXS", "");
  15669. designer.SetDataSource("CostBZCB", "");
  15670. designer.SetDataSource("CostBDRBJ", "");
  15671. designer.SetDataSource("CostBZBJ", "");
  15672. designer.SetDataSource("CostBDRLR", "");
  15673. designer.SetDataSource("CostBZLR", "");
  15674. designer.SetDataSource("CostBDRCBOM", "");
  15675. designer.SetDataSource("CostBRSOM", "");
  15676. designer.SetDataSource("CostBZCBOM", "");
  15677. designer.SetDataSource("CostBDRBJOM", "");
  15678. designer.SetDataSource("CostBZBJOM", "");
  15679. designer.SetDataSource("CostBDRLROM", "");
  15680. designer.SetDataSource("CostBZLROM", "");
  15681. #endregion
  15682. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15683. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15684. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15685. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15686. designer.SetDataSource("DJName", "地接(CNY)");
  15687. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15688. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15689. designer.SetDataSource("GWName", "公务(CNY)");
  15690. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15691. designer.SetDataSource("LYJName", "零用金(CNY)");
  15692. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15693. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15694. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15695. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15696. designer.SetDataSource("BXName", "保险(CNY)");
  15697. designer.SetDataSource("VisaName", "签证(CNY)");
  15698. #region B段基本数据
  15699. if (dto.costType == "B")
  15700. {
  15701. left = dto.leftInfo.Find(x => x.Type == "B");
  15702. if (left == null)
  15703. {
  15704. return Ok(jw);
  15705. }
  15706. #region B段left数据
  15707. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15708. if (leftBindData != null)
  15709. {
  15710. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15711. designer.SetDataSource("BHSRS", leftBindData.rs);
  15712. designer.SetDataSource("BHSXS", leftBindData.xs);
  15713. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15714. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15715. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15716. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15717. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15718. }
  15719. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15720. if (leftBindData != null)
  15721. {
  15722. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15723. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15724. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15725. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15726. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15727. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15728. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15729. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15730. }
  15731. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15732. if (leftBindData != null)
  15733. {
  15734. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15735. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15736. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15737. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15738. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15739. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15740. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15741. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15742. }
  15743. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15744. if (leftBindData != null)
  15745. {
  15746. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15747. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15748. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15749. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15750. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15751. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15752. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15753. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15754. }
  15755. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15756. if (leftBindData != null)
  15757. {
  15758. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15759. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15760. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15761. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15762. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15763. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15764. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15765. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15766. }
  15767. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15768. if (leftBindData != null)
  15769. {
  15770. designer.SetDataSource("BCPCB", leftBindData.cb);
  15771. designer.SetDataSource("BCPRS", leftBindData.rs);
  15772. designer.SetDataSource("BCPXS", leftBindData.xs);
  15773. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15774. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15775. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15776. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15777. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15778. }
  15779. //TBR
  15780. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15781. if (leftBindData != null)
  15782. {
  15783. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15784. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15785. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15786. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15787. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15788. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15789. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15790. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15791. }
  15792. //SGR
  15793. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15794. if (leftBindData != null)
  15795. {
  15796. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15797. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15798. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15799. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15800. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15801. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15802. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15803. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15804. }
  15805. //JS/ES
  15806. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15807. if (leftBindData != null)
  15808. {
  15809. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15810. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15811. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15812. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15813. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15814. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15815. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15816. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15817. }
  15818. //SUITE
  15819. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15820. if (leftBindData != null)
  15821. {
  15822. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15823. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15824. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15825. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15826. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15827. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15828. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15829. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15830. }
  15831. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15832. if (leftBindData != null)
  15833. {
  15834. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15835. designer.SetDataSource("BDJRS", leftBindData.rs);
  15836. designer.SetDataSource("BDJXS", leftBindData.xs);
  15837. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15838. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15839. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15840. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15841. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15842. }
  15843. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15844. if (leftBindData != null)
  15845. {
  15846. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15847. designer.SetDataSource("BGWRS", leftBindData.rs);
  15848. designer.SetDataSource("BGWXS", leftBindData.xs);
  15849. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15850. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15851. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15852. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15853. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15854. }
  15855. #region 优化方案
  15856. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15857. //excelBind.Add("零用金", new {
  15858. //cb="",
  15859. //rs="",
  15860. //xs ="",
  15861. //zcb = "",
  15862. //});
  15863. #endregion
  15864. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15865. if (leftBindData != null)
  15866. {
  15867. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15868. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15869. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15870. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15871. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15872. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15873. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15874. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15875. }
  15876. #endregion
  15877. #region B段Right信息
  15878. right = dto.rightInfo.Find(x => x.Type == "B");
  15879. if (right == null)
  15880. {
  15881. return Ok(jw);
  15882. }
  15883. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15884. if (rightBindData != null)
  15885. {
  15886. //经济舱 + 双人间 TBR
  15887. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15888. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15889. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15890. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15891. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15892. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15893. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15894. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15895. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15896. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15897. }
  15898. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15899. if (rightBindData != null)
  15900. {
  15901. //经济舱 + 单人间 SGR
  15902. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15903. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15904. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15905. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15906. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15907. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15908. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15909. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15910. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15911. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15912. }
  15913. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15914. if (rightBindData != null)
  15915. {
  15916. //公务舱 + 单人间 SGR
  15917. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15918. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15919. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15920. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15921. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15922. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15923. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15924. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15925. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15926. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15927. }
  15928. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15929. if (rightBindData != null)
  15930. {
  15931. //公务舱 + 小套房 JSES
  15932. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15933. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15934. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15935. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15936. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15937. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15938. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15939. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15940. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15941. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15942. }
  15943. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15944. if (rightBindData != null)
  15945. {
  15946. //公务舱 + 小套房 JSES
  15947. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15948. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15949. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15950. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15951. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15952. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15953. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15954. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15955. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15956. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15957. }
  15958. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15959. if (rightBindData != null)
  15960. {
  15961. //经济舱 + 大套房
  15962. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15963. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15964. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15965. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15966. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15967. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15968. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15969. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15970. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15971. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15972. }
  15973. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15974. if (rightBindData != null)
  15975. {
  15976. //头等舱 + 小套房 JSES
  15977. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15978. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15979. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15980. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15981. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15982. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15983. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15984. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15985. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15986. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15987. }
  15988. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15989. if (rightBindData != null)
  15990. {
  15991. //头等舱 + 大套房
  15992. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15993. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15994. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15995. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15996. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15997. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15998. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15999. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16000. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16001. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16002. }
  16003. #endregion
  16004. #region 标题
  16005. designer.SetDataSource("CostBDRCB", "单人成本");
  16006. designer.SetDataSource("CostBRS", "人数");
  16007. designer.SetDataSource("CostBXS", "系数");
  16008. designer.SetDataSource("CostBZCB", "总成本");
  16009. designer.SetDataSource("CostBDRBJ", "单人报价");
  16010. designer.SetDataSource("CostBZBJ", "总报价");
  16011. designer.SetDataSource("CostBDRLR", "单人利润");
  16012. designer.SetDataSource("CostBZLR", "总利润");
  16013. designer.SetDataSource("CostBDRCBOM", "单人成本");
  16014. designer.SetDataSource("CostBRSOM", "人数");
  16015. designer.SetDataSource("CostBZCBOM", "总成本");
  16016. designer.SetDataSource("CostBDRBJOM", "单人报价");
  16017. designer.SetDataSource("CostBZBJOM", "总报价");
  16018. designer.SetDataSource("CostBDRLROM", "单人利润");
  16019. designer.SetDataSource("CostBZLROM", "总利润");
  16020. #endregion
  16021. }
  16022. #endregion
  16023. designer.SetDataSource("TzZCB2", TzZCB2);
  16024. designer.SetDataSource("TzZBJ2", TzZBJ2);
  16025. designer.SetDataSource("TzZLR2", TzZLR2);
  16026. string[] dataSourceKeys = new string[]
  16027. {
  16028. "VF",
  16029. "TGS",
  16030. "TGOF",
  16031. "TGM",
  16032. "TGA",
  16033. "TGTF",
  16034. "TGEF",
  16035. "CFM",
  16036. "CFOF",
  16037. "B",
  16038. "L",
  16039. "D",
  16040. "TBR",
  16041. "SGR",
  16042. "JSES",
  16043. "Suite",
  16044. "TV",
  16045. "1L",
  16046. "IF",
  16047. "EF",
  16048. "BRF",
  16049. "TE",
  16050. "TGT",
  16051. "DRVT",
  16052. "PC",
  16053. "TLF",
  16054. "ECT"
  16055. };
  16056. foreach (var item in dataSourceKeys)
  16057. {
  16058. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  16059. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  16060. var find = dto.titleModel.FirstOrDefault(expr);
  16061. if (find != null)
  16062. {
  16063. designer.SetDataSource(item, find.text);
  16064. }
  16065. else
  16066. {
  16067. designer.SetDataSource(item, 0);
  16068. }
  16069. }
  16070. designer.SetDataSource(dt);
  16071. //根据数据源处理生成报表内容
  16072. designer.Process();
  16073. designer.Workbook.Worksheets[0].Name = "费用明细";
  16074. designer.Workbook.Worksheets[1].Name = "费用总核算";
  16075. Worksheet sheet = designer.Workbook.Worksheets[0];
  16076. #region 隐藏舱位
  16077. var settingAir = new[]
  16078. {
  16079. new { key = "经济舱", index = 7 },
  16080. new { key = "公务舱", index = 19 },
  16081. new { key = "头等舱", index = 11 }
  16082. };
  16083. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  16084. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  16085. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  16086. .Select((c, s) => s.Name)
  16087. .ToList()
  16088. .GroupBy(x => x)
  16089. .Select(x => x.Key);
  16090. foreach (var item in settingAir)
  16091. {
  16092. if (!airType.Contains(item.key))
  16093. {
  16094. hideRowsList.Add(item.index);
  16095. }
  16096. }
  16097. #endregion
  16098. foreach (var Rowindex in hideRowsList)
  16099. {
  16100. ws.Cells.HideRows(Rowindex, 2);
  16101. }
  16102. ws = designer.Workbook.Worksheets[0];
  16103. foreach (var Column in hideColumnList)
  16104. {
  16105. ws.Cells.HideColumns(Column, 1);
  16106. }
  16107. byte[] bytes = null;
  16108. string strFileName = di.TeamName + "-团组-成本.xls";
  16109. using (MemoryStream stream = new MemoryStream())
  16110. {
  16111. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16112. bytes = stream.ToArray();
  16113. }
  16114. return Ok(JsonView(true, "", new
  16115. {
  16116. Data = bytes,
  16117. strFileName,
  16118. }));
  16119. }
  16120. /// <summary>
  16121. /// 导出客户报表
  16122. /// </summary>
  16123. /// <returns></returns>
  16124. [HttpPost]
  16125. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16126. {
  16127. var jw = JsonView(false);
  16128. if (dto.Diid == 0)
  16129. {
  16130. return Ok(JsonView(false, "请传递团组id"));
  16131. }
  16132. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16133. if (deleInfo.Code != 0)
  16134. {
  16135. return Ok(JsonView(false, "团组信息查询失败!"));
  16136. }
  16137. var di = deleInfo.Data as DelegationInfoWebView;
  16138. if (di == null)
  16139. {
  16140. return Ok(JsonView(false, "团组信息查询失败!"));
  16141. }
  16142. //文件名
  16143. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16144. //获取模板
  16145. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16146. //载入模板
  16147. Document doc = new Document(tmppath);
  16148. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16149. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16150. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16151. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16152. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16153. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16154. if (AParameter == null)
  16155. {
  16156. return Ok(JsonView(false, "系数不存在!"));
  16157. }
  16158. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  16159. , TzAirDesc, TzZCost;
  16160. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  16161. = TzAirDesc = TzZCost = string.Empty;
  16162. TzNumber = AParameter.CostTypenumber.ToString();
  16163. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  16164. CarGuides1 = dto.CarGuides1;
  16165. Meal = dto.Meal;
  16166. SubsidizedMeals = dto.SubsidizedMeals;
  16167. NightRepair = dto.NightRepair;
  16168. AttractionsTickets = dto.AttractionsTickets;
  16169. MiscellaneousFees = dto.MiscellaneousFees;
  16170. ATip = dto.ATip;
  16171. TzHotelDesc = "";
  16172. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  16173. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  16174. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  16175. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  16176. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  16177. TzAirDesc = "";
  16178. TzZCost = dto.TzZCost;
  16179. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  16180. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  16181. var index = 1;
  16182. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  16183. foreach (var item in TzHotelDescArr)
  16184. {
  16185. if (AinfoArr != null)
  16186. {
  16187. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16188. if (Ainfo != null)
  16189. {
  16190. if (int.Parse(Ainfo.rs) <= 0)
  16191. {
  16192. continue;
  16193. }
  16194. var hotelText = string.Empty;
  16195. switch (item)
  16196. {
  16197. case "SGR":
  16198. hotelText = "单人间";
  16199. break;
  16200. case "JSES":
  16201. hotelText = "小套房";
  16202. break;
  16203. case "SUITE":
  16204. hotelText = "套房";
  16205. break;
  16206. case "TBR":
  16207. hotelText = "双人间";
  16208. break;
  16209. }
  16210. if (item != "TBR")
  16211. {
  16212. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  16213. }
  16214. else
  16215. {
  16216. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  16217. }
  16218. index++;
  16219. }
  16220. }
  16221. }
  16222. index = 1;
  16223. foreach (var item in TzAirDescArr)
  16224. {
  16225. if (AinfoArr != null)
  16226. {
  16227. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16228. if (Ainfo != null)
  16229. {
  16230. if (int.Parse(Ainfo.rs) <= 0)
  16231. {
  16232. continue;
  16233. }
  16234. TzAirDesc += "(" + index + ".) " + item + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  16235. index++;
  16236. }
  16237. }
  16238. }
  16239. if (dto.costType == "B")
  16240. {
  16241. if (BParameter == null)
  16242. {
  16243. return Ok(JsonView(false, "B段系数不存在!"));
  16244. }
  16245. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16246. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16247. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16248. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16249. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16250. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16251. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16252. foreach (var item in TzHotelDescArr)
  16253. {
  16254. if (AinfoArr != null)
  16255. {
  16256. TzHotelDesc += "B段信息 \r\n";
  16257. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16258. if (Ainfo != null)
  16259. {
  16260. if (int.Parse(Ainfo.rs) <= 0)
  16261. {
  16262. continue;
  16263. }
  16264. var hotelText = string.Empty;
  16265. switch (item)
  16266. {
  16267. case "SGR":
  16268. hotelText = "单人间";
  16269. break;
  16270. case "JSES":
  16271. hotelText = "小套房";
  16272. break;
  16273. case "SUITE":
  16274. hotelText = "套房";
  16275. break;
  16276. case "TBR":
  16277. hotelText = "双人间";
  16278. break;
  16279. }
  16280. if (item != "TBR")
  16281. {
  16282. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  16283. }
  16284. else
  16285. {
  16286. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  16287. }
  16288. index++;
  16289. }
  16290. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16291. }
  16292. }
  16293. index = 1;
  16294. foreach (var item in TzAirDescArr)
  16295. {
  16296. if (AinfoArr != null)
  16297. {
  16298. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16299. if (Ainfo != null)
  16300. {
  16301. if (int.Parse(Ainfo.rs) <= 0)
  16302. {
  16303. continue;
  16304. }
  16305. TzAirDesc += "(" + index + ".) " + item + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  16306. index++;
  16307. }
  16308. }
  16309. }
  16310. }
  16311. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16312. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16313. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16314. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16315. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16316. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16317. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16318. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16319. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16320. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16321. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16322. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16323. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16324. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16325. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16326. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16327. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16328. DickeyValue.Add("TzZCost", TzZCost);
  16329. foreach (var key in DickeyValue.Keys)
  16330. {
  16331. if (doc.Range.Bookmarks[key] != null)
  16332. {
  16333. Bookmark mark = doc.Range.Bookmarks[key];
  16334. mark.Text = DickeyValue[key];
  16335. }
  16336. }
  16337. byte[] bytes = null;
  16338. string strFileName = di.TeamName + "-客户报价.doc";
  16339. using (MemoryStream stream = new MemoryStream())
  16340. {
  16341. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  16342. bytes = stream.ToArray();
  16343. }
  16344. return Ok(JsonView(true, "", new
  16345. {
  16346. Data = bytes,
  16347. strFileName,
  16348. }));
  16349. }
  16350. /// <summary>
  16351. /// 团组成本 各模块(酒店,地接,机票)成本提示
  16352. /// </summary>
  16353. /// <param name="dto"></param>
  16354. /// <returns></returns>
  16355. [HttpPost]
  16356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16357. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  16358. {
  16359. try
  16360. {
  16361. #region 参数验证
  16362. if (dto.DiId < 0)
  16363. {
  16364. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  16365. }
  16366. List<int> cTableIds = new List<int>() {
  16367. 76 ,//酒店预订
  16368. 77 ,//行程
  16369. 79 ,//车/导游地接
  16370. 80 ,//签证
  16371. 81 ,//邀请/公务活
  16372. 82 ,//团组客户保险
  16373. 85 ,//机票预订
  16374. 98 ,//其他款项
  16375. 285 ,//收款退还
  16376. 751 ,//酒店早餐
  16377. 1015 // 超支费用
  16378. };
  16379. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  16380. {
  16381. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  16382. }
  16383. #endregion
  16384. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  16385. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  16386. if (_GroupCostParameters.Count <= 0)
  16387. {
  16388. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  16389. }
  16390. if (_GroupCostParameters[0].IsShare == 0)
  16391. {
  16392. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  16393. }
  16394. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16395. //处理date为空问题
  16396. if (_GroupCosts.Count > 0)
  16397. {
  16398. for (int i = 0; i < _GroupCosts.Count; i++)
  16399. {
  16400. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  16401. {
  16402. if (i > 0)
  16403. {
  16404. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  16405. }
  16406. }
  16407. }
  16408. }
  16409. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  16410. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  16411. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  16412. string currCode = "";
  16413. #region currCode 验证
  16414. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16415. if (isInt)
  16416. {
  16417. var currData = currDatas.Find(it => it.Id == intCurrency);
  16418. if (currData != null)
  16419. {
  16420. currCode = currData.Name;
  16421. }
  16422. }
  16423. else
  16424. {
  16425. currCode = _GroupCostParameters[0].Currency.Trim();
  16426. }
  16427. #endregion
  16428. //op,酒店单段模式存储
  16429. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16430. {
  16431. CurrencyCode = currCode,
  16432. Rate = _GroupCostParameters[0].Rate,
  16433. CostType = _GroupCostParameters[0].CostType,
  16434. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16435. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16436. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16437. };
  16438. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16439. if (_GroupCostParameters.Count == 2)
  16440. {
  16441. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16442. }
  16443. foreach (var item in _GroupCostParameters)
  16444. {
  16445. decimal _rate = 1;
  16446. decimal _rate1 = item.Rate;
  16447. decimal _scale = 1;
  16448. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16449. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16450. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16451. //if (userInfo != null)
  16452. //{
  16453. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16454. // {
  16455. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16456. // {
  16457. // _scale = 1.00M;
  16458. // }
  16459. // }
  16460. //}
  16461. #endregion
  16462. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16463. {
  16464. CurrencyCode = currCode,
  16465. Rate = _rate1,
  16466. CostType = item.CostType,
  16467. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16468. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16469. CostTypeNumber = item.CostTypenumber
  16470. };
  16471. if (_GroupCostParameters.Count > 1)
  16472. {
  16473. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16474. }
  16475. else
  16476. {
  16477. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16478. }
  16479. if (dto.CTable == 79)//
  16480. {
  16481. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16482. modulePromptInfo.TotalCost = item.DJCB;
  16483. }
  16484. List<string> costTypes = new List<string>() { "A", "B" };
  16485. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16486. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16487. if (_GroupCostsDuplicates.Count() == 1)
  16488. {
  16489. _GroupCostsTypeData = _GroupCosts;
  16490. }
  16491. else
  16492. {
  16493. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16494. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16495. }
  16496. /*
  16497. * 76 酒店预订
  16498. * 77 行程
  16499. * 79 车/导游地接
  16500. * 80 签证
  16501. * 81 邀请/公务活动
  16502. * 82 团组客户保险
  16503. * 85 机票预订
  16504. * 98 其他款项
  16505. * 285 收款退还
  16506. * 751 酒店早餐
  16507. * 1015 超支费用
  16508. */
  16509. switch (dto.CTable)
  16510. {
  16511. case 76: // 酒店预订
  16512. _ModuleSubPromptInfo.AddRange(
  16513. _GroupCostsTypeData.Select(it => new
  16514. {
  16515. it.DAY,
  16516. it.Date,
  16517. it.ACCON,
  16518. it.ITIN,
  16519. it.SGR,
  16520. it.TBR,
  16521. it.JS_ES,
  16522. it.Suite
  16523. })
  16524. );
  16525. break;
  16526. case 79: // 车/导游地接
  16527. _ModuleSubPromptInfo.AddRange(
  16528. _GroupCostsTypeData.Select(it => new
  16529. {
  16530. Date = it.Date, //日期
  16531. CarFee = it.CarCost * _rate * _scale, //车费用
  16532. CarType = it.CarType, //车型
  16533. DriverFee = it.CFS * _rate * _scale, //司机工资
  16534. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16535. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16536. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16537. GuideFee = it.TGS * _rate * _scale, //导游费用
  16538. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16539. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16540. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16541. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16542. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16543. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16544. Breakfast = it.B * _rate * _scale, //早餐费
  16545. Lunch = it.L * _rate * _scale, //午餐费
  16546. Dinner = it.D * _rate * _scale, //晚餐费
  16547. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16548. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16549. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16550. TicketFee = it.EF * _rate * _scale, //门票费
  16551. TicketRemark = it.EFR, //门票费描述
  16552. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16553. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16554. SpentCash = it.PC * _rate * _scale, //零用金
  16555. LeadersFee = it.TLF * _rate * _scale, //领队费
  16556. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16557. })
  16558. );
  16559. break;
  16560. case 85: // 机票
  16561. List<dynamic> datas = new List<dynamic>();
  16562. datas.Add(
  16563. new
  16564. {
  16565. AirType = "经济舱",
  16566. AirNum = item.JJCRS,
  16567. AirDRCB = item.JJCCB,
  16568. AirZCB = (item.JJCRS * item.JJCCB)
  16569. }
  16570. );
  16571. datas.Add(
  16572. new
  16573. {
  16574. AirType = "公务舱",
  16575. AirNum = item.GWCRS,
  16576. AirDRCB = item.GWCCB,
  16577. AirZCB = (item.GWCRS * item.GWCCB)
  16578. }
  16579. );
  16580. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16581. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16582. modulePromptInfo.Data = new
  16583. {
  16584. airFeeData = datas,
  16585. airInitData = initDatas
  16586. };
  16587. _ModulePromptInfos.Add(modulePromptInfo);
  16588. break;
  16589. default:
  16590. break;
  16591. }
  16592. }
  16593. if (dto.CTable != 85)
  16594. {
  16595. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16596. _ModulePromptInfos.Add(_ModulePromptInfo);
  16597. }
  16598. _view.ModulePromptInfos = _ModulePromptInfos;
  16599. return Ok(JsonView(true, "操作成功!", _view));
  16600. }
  16601. catch (Exception ex)
  16602. {
  16603. return Ok(JsonView(false, ex.Message));
  16604. }
  16605. }
  16606. /// <summary>
  16607. /// 根据黑屏代码重新生成行程
  16608. /// </summary>
  16609. /// <param name="dto"></param>
  16610. /// <returns></returns>
  16611. [HttpPost]
  16612. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16613. {
  16614. var jw = JsonView(false, "Error");
  16615. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16616. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16617. .Select(x => new
  16618. {
  16619. x.Id,
  16620. x.Title
  16621. })
  16622. .ToList();
  16623. if (Create.Any())
  16624. {
  16625. jw.Msg = "获取成功!";
  16626. jw.Code = 200;
  16627. jw.Data = new
  16628. {
  16629. BlackCodeListSelect = Create,
  16630. blackCodeIsTrue = true
  16631. };
  16632. }
  16633. else
  16634. {
  16635. jw.Code = 400;
  16636. jw.Data = new
  16637. {
  16638. BlackCodeListSelect = Create,
  16639. blackCodeIsTrue = false,
  16640. };
  16641. }
  16642. return Ok(jw);
  16643. }
  16644. /// <summary>
  16645. /// 根据黑屏代码Id重新生成行程
  16646. /// </summary>
  16647. /// <param name="dto"></param>
  16648. /// <returns></returns>
  16649. [HttpPost]
  16650. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16651. {
  16652. var jw = JsonView(false, "Error");
  16653. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16654. if (result.Code == 0)
  16655. {
  16656. jw.Msg = "获取成功!";
  16657. jw.Code = 200;
  16658. jw.Data = new
  16659. {
  16660. groupCost = result.Data,
  16661. blackCodeIsTrue = true
  16662. };
  16663. }
  16664. else
  16665. {
  16666. jw.Code = 400;
  16667. jw.Data = new
  16668. {
  16669. groupCost = result.Data,
  16670. blackCodeIsTrue = false,
  16671. };
  16672. }
  16673. return Ok(jw);
  16674. }
  16675. /// <summary>
  16676. /// 成本获取OP历史车费用
  16677. /// </summary>
  16678. /// <param name="dto"></param>
  16679. /// <returns></returns>
  16680. [HttpPost]
  16681. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16682. {
  16683. var jw = JsonView(false);
  16684. try
  16685. {
  16686. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16687. //获取现有所有车的数据
  16688. if (!dto.Param.IsNullOrWhiteSpace())
  16689. {
  16690. string sql = $@"
  16691. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16692. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16693. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16694. WHERE gctggr.IsDel = 0 and gctggrc.SId = 91 AND gdi.IsDel = 0 AND gctggrc.Price != 0 AND (ssd.Id in (1061,1069) or ssd.Id is NULL) AND gctggr.ServiceStartTime is not null
  16695. AND gctggr.ServiceEndTime is not NULL
  16696. ORDER by gctggrc.id DESC
  16697. ";
  16698. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16699. var numeberResult = await Task.Run(() =>
  16700. {
  16701. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16702. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16703. return numberArr;
  16704. });
  16705. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16706. foreach (var item in numeberResult)
  16707. {
  16708. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16709. {
  16710. Country = "数据异常!",
  16711. City = string.Empty,
  16712. };
  16713. item.Area = find.Country + " " + find.City;
  16714. }
  16715. dbResult.AddRange(numeberResult);
  16716. if (dto.Param.Contains("、"))
  16717. {
  16718. var sp = dto.Param.Split("、");
  16719. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16720. .Where(x =>
  16721. {
  16722. return System.Array.Exists(sp, e =>
  16723. {
  16724. bool where = false;
  16725. if (x.Area != null)
  16726. {
  16727. where = x.Area.Contains(e);
  16728. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16729. {
  16730. return false;
  16731. }
  16732. }
  16733. if (x.PriceName != null && !where)
  16734. {
  16735. where = x.PriceName.Contains(e);
  16736. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16737. {
  16738. return false;
  16739. }
  16740. }
  16741. return where;
  16742. });
  16743. }).ToList();
  16744. }
  16745. else
  16746. {
  16747. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16748. .Where(x =>
  16749. {
  16750. bool where = false;
  16751. if (x.Area != null)
  16752. {
  16753. where = x.Area.Contains(dto.Param);
  16754. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16755. {
  16756. return false;
  16757. }
  16758. }
  16759. if (x.PriceName != null && !where)
  16760. {
  16761. where = x.PriceName.Contains(dto.Param);
  16762. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16763. {
  16764. return false;
  16765. }
  16766. }
  16767. return where;
  16768. }
  16769. )
  16770. .ToList();
  16771. }
  16772. }
  16773. var view = dbResult.Select(x =>
  16774. {
  16775. decimal dp = 0.00M;
  16776. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16777. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16778. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16779. {
  16780. if (startB && endB)
  16781. {
  16782. var timesp = endD.Subtract(startD);
  16783. if ((timesp.Days + 1) != 0)
  16784. {
  16785. dp = x.Price / (timesp.Days + 1);
  16786. }
  16787. }
  16788. }
  16789. else
  16790. {
  16791. dp = x.Price;
  16792. }
  16793. return new
  16794. {
  16795. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16796. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16797. x.Area,
  16798. x.id,
  16799. price = x.Price.ToString("F2"),
  16800. x.PriceName,
  16801. x.PriceContent,
  16802. x.TeamName,
  16803. x.DatePrice,
  16804. dayPrice = dp.ToString("F2"),
  16805. };
  16806. }).OrderByDescending(x => x.id).ToList();
  16807. jw = JsonView(true, "获取成功!", view);
  16808. }
  16809. catch (Exception e)
  16810. {
  16811. jw = JsonView(false, e.Message);
  16812. }
  16813. return Ok(jw);
  16814. }
  16815. [HttpPost]
  16816. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16817. {
  16818. var jw = JsonView(true);
  16819. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16820. #region SQL语句
  16821. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16822. //{
  16823. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16824. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16825. // WHEN COUNT(*) >= 0 THEN 'True'
  16826. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16827. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16828. // ")
  16829. // .ToList();
  16830. //}
  16831. //else
  16832. //{
  16833. // string likeKey = string.Empty;
  16834. // foreach (var item in dto.Keyword)
  16835. // {
  16836. // likeKey += "%" + item;
  16837. // }
  16838. // likeKey += "%";
  16839. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16840. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16841. // WHEN COUNT(*) >= 0 THEN 'True'
  16842. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16843. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16844. // ")
  16845. // .ToList();
  16846. //}
  16847. #endregion
  16848. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16849. {
  16850. @KeyWord = dto.Keyword
  16851. });
  16852. if (table != null && table.Rows.Count > 0)
  16853. {
  16854. foreach (DataRow row in table.Rows)
  16855. {
  16856. matches.Add(new DelegationInfoAndIsTrueView
  16857. {
  16858. Id = row.Field<int>("Id"),
  16859. GroupName = row.Field<string>("GroupName"),
  16860. isTrue = row.Field<string>("isTrue")
  16861. });
  16862. }
  16863. }
  16864. if (matches.Any())
  16865. {
  16866. jw.Data = matches;
  16867. }
  16868. else
  16869. {
  16870. jw.Code = 201;
  16871. jw.Msg = "empty list";
  16872. jw.Data = new List<string>(1);
  16873. }
  16874. return Ok(jw);
  16875. }
  16876. /// <summary>
  16877. /// 报价Word下载
  16878. /// </summary>
  16879. /// <param name="dto"></param>
  16880. /// <returns></returns>
  16881. [HttpPost]
  16882. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16883. {
  16884. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16885. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16886. if (di == null)
  16887. {
  16888. return Ok(JsonView(false, "团组不存在!"));
  16889. }
  16890. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16891. if (mainPrice == null || mainPrice.IsShare == 0)
  16892. {
  16893. return Ok(JsonView(false, "团组成本不存在!"));
  16894. }
  16895. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16896. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16897. if (costTypeHotelNumbers == null)
  16898. {
  16899. return Ok(JsonView(false, "团组成本不存在!"));
  16900. }
  16901. //文件名
  16902. string strFileName = di.TeamName + "-收款账单.doc";
  16903. //获取模板
  16904. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16905. //载入模板
  16906. Document doc = new Document(tmppath);
  16907. decimal allPrice = 0.00M;
  16908. string itemStr = string.Empty;
  16909. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16910. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16911. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16912. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16913. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16914. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16915. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16916. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16917. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16918. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16919. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16920. {
  16921. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16922. ("BXRS", "BXCB", "BXXS", "bx"),
  16923. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16924. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16925. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16926. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16927. ("CPRS", "CPCB", "CPXS", "cp"),
  16928. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16929. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16930. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16931. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16932. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16933. ("DJRS", "DJCB", "DJXS", "dj"),
  16934. ("GWRS", "GWCB", "GWXS", "gw"),
  16935. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16936. };
  16937. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16938. var rightSum = 0.00M;
  16939. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16940. {
  16941. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16942. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16943. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16944. if (prefix == "tbr")
  16945. {
  16946. rsValue *= 2;
  16947. cbValue /= 2;
  16948. }
  16949. if (OtherCostPropertyBJ.Contains(prefix))
  16950. {
  16951. rightSum += cbValue * xsValue;
  16952. }
  16953. }
  16954. var hotelRooms = new Dictionary<string, int>
  16955. {
  16956. { "SGR", costTypeHotelNumbers.SGR },
  16957. { "TBR", costTypeHotelNumbers.TBR },
  16958. { "JSES", costTypeHotelNumbers.JSES },
  16959. { "SUITE", costTypeHotelNumbers.SUITE }
  16960. };
  16961. var flights = new Dictionary<string, int>
  16962. {
  16963. { "经济舱", mainPrice.JJCRS },
  16964. { "公务舱", mainPrice.GWCRS },
  16965. { "头等舱", mainPrice.TDCRS }
  16966. };
  16967. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16968. {
  16969. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16970. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16971. { "头等舱", new[] { "SUITE", "JSES" } }
  16972. };
  16973. var result = new Dictionary<string, int>();
  16974. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16975. foreach (var flight in flights.Keys)
  16976. {
  16977. // 获取当前舱位的匹配规则
  16978. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16979. {
  16980. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16981. }
  16982. }
  16983. #region right计算
  16984. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16985. {
  16986. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16987. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16988. airHotelPriceList.Add(new
  16989. AirHotelPrice
  16990. {
  16991. Name = "经济舱TBR",
  16992. Price = rightSum + air + hotel,
  16993. Count = result["经济舱TBR"] * 2
  16994. });
  16995. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16996. }
  16997. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16998. {
  16999. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17000. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17001. airHotelPriceList.Add(new
  17002. AirHotelPrice
  17003. {
  17004. Name = "经济舱SGR",
  17005. Price = rightSum + air + hotel,
  17006. Count = result["经济舱SGR"]
  17007. });
  17008. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17009. }
  17010. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17011. {
  17012. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17013. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17014. airHotelPriceList.Add(new
  17015. AirHotelPrice
  17016. {
  17017. Name = "公务舱SGR",
  17018. Price = rightSum + air + hotel,
  17019. Count = result["公务舱SGR"]
  17020. });
  17021. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17022. }
  17023. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17024. {
  17025. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17026. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17027. airHotelPriceList.Add(new
  17028. AirHotelPrice
  17029. {
  17030. Name = "公务舱JSES",
  17031. Price = rightSum + air + hotel,
  17032. Count = result["公务舱JSES"]
  17033. });
  17034. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17035. }
  17036. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17037. {
  17038. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17039. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17040. airHotelPriceList.Add(new
  17041. AirHotelPrice
  17042. {
  17043. Name = "公务舱SUITE",
  17044. Price = rightSum + air + hotel,
  17045. Count = result["公务舱SUITE"]
  17046. });
  17047. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17048. }
  17049. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17050. {
  17051. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17052. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17053. airHotelPriceList.Add(new
  17054. AirHotelPrice
  17055. {
  17056. Name = "经济舱SUITE",
  17057. Price = rightSum + air + hotel,
  17058. Count = result["经济舱SUITE"]
  17059. });
  17060. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17061. }
  17062. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17063. {
  17064. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17065. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17066. airHotelPriceList.Add(new
  17067. AirHotelPrice
  17068. {
  17069. Name = "头等舱JSES",
  17070. Price = rightSum + air + hotel,
  17071. Count = result["头等舱JSES"]
  17072. });
  17073. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17074. }
  17075. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17076. {
  17077. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17078. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17079. airHotelPriceList.Add(new
  17080. AirHotelPrice
  17081. {
  17082. Name = "头等舱SUITE",
  17083. Price = rightSum + air + hotel,
  17084. Count = result["头等舱SUITE"]
  17085. });
  17086. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17087. }
  17088. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17089. {
  17090. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17091. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17092. airHotelPriceList.Add(new
  17093. AirHotelPrice
  17094. {
  17095. Name = "经济舱JSES",
  17096. Price = rightSum + air + hotel,
  17097. Count = result["经济舱JSES"]
  17098. });
  17099. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17100. }
  17101. #endregion
  17102. foreach (var item in airSouer.Keys)
  17103. {
  17104. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17105. if (find != null && find.Count > 0)
  17106. {
  17107. if (item.Contains("TBR"))
  17108. {
  17109. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17110. }
  17111. else
  17112. {
  17113. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17114. }
  17115. }
  17116. }
  17117. #region 替换Word模板书签内容
  17118. Dictionary<string, string> marks = new Dictionary<string, string>();
  17119. marks.Add("To", di.ClientUnit);//付款方
  17120. marks.Add("ToTel", di.TellPhone);//付款方电话
  17121. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17122. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17123. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17124. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17125. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17126. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17127. marks.Add("PayItemContent", itemStr);//详细信息
  17128. marks.Add("Total", allPrice.ToString("F2"));//合计
  17129. #endregion
  17130. foreach (var item in marks.Keys)
  17131. {
  17132. if (doc.Range.Bookmarks[item] != null)
  17133. {
  17134. Bookmark mark = doc.Range.Bookmarks[item];
  17135. mark.Text = marks[item];
  17136. }
  17137. }
  17138. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17139. doc.Save(savePaht);
  17140. var jw = new JsonView();
  17141. jw.Msg = "生成成功!";
  17142. jw.Code = 200;
  17143. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17144. return Ok(jw);
  17145. }
  17146. /// <summary>
  17147. /// 详细报价费用Excel下载
  17148. /// </summary>
  17149. /// <param name="dto"></param>
  17150. /// <returns></returns>
  17151. [HttpPost]
  17152. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17153. {
  17154. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17155. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17156. if (di == null)
  17157. {
  17158. return Ok(JsonView(false, "团组不存在!"));
  17159. }
  17160. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17161. if (mainPrice == null || mainPrice.IsShare == 0)
  17162. {
  17163. return Ok(JsonView(false, "团组成本不存在!"));
  17164. }
  17165. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17166. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17167. if (costTypeHotelNumbers == null)
  17168. {
  17169. return Ok(JsonView(false, "团组成本不存在!"));
  17170. }
  17171. WorkbookDesigner designer = new WorkbookDesigner();
  17172. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  17173. List<int> hideRowsList = new List<int>();
  17174. int conterStartIndex = 3;
  17175. int rowIndex = conterStartIndex;
  17176. designer.SetDataSource("GroupName", di.TeamName);
  17177. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17178. {
  17179. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17180. ("BXRS", "BXCB", "BXXS", "bx"),
  17181. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17182. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17183. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  17184. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  17185. ("CPRS", "CPCB", "CPXS", "cp") ,
  17186. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  17187. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  17188. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  17189. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  17190. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  17191. ("DJRS", "DJCB", "DJXS", "dj") ,
  17192. ("GWRS", "GWCB", "GWXS", "gw") ,
  17193. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  17194. };
  17195. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17196. var rightSum = 0.00M;
  17197. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17198. {
  17199. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17200. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17201. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17202. if (prefix == "tbr")
  17203. {
  17204. rsValue *= 2;
  17205. cbValue /= 2;
  17206. }
  17207. if (OtherCostPropertyBJ.Contains(prefix))
  17208. {
  17209. rightSum += cbValue * xsValue;
  17210. }
  17211. if (rsValue == 0)
  17212. {
  17213. hideRowsList.Add(rowIndex);
  17214. }
  17215. else
  17216. {
  17217. designer.SetDataSource($"{prefix}rs", rsValue);
  17218. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  17219. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17220. }
  17221. rowIndex += 2;
  17222. }
  17223. var hotelRooms = new Dictionary<string, int>
  17224. {
  17225. { "SGR", costTypeHotelNumbers.SGR },
  17226. { "TBR", costTypeHotelNumbers.TBR },
  17227. { "JSES", costTypeHotelNumbers.JSES },
  17228. { "SUITE", costTypeHotelNumbers.SUITE }
  17229. };
  17230. var flights = new Dictionary<string, int>
  17231. {
  17232. { "经济舱", mainPrice.JJCRS },
  17233. { "公务舱", mainPrice.GWCRS },
  17234. { "头等舱", mainPrice.TDCRS }
  17235. };
  17236. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17237. {
  17238. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17239. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17240. { "头等舱", new[] { "SUITE", "JSES" } }
  17241. };
  17242. var result = new Dictionary<string, int>();
  17243. foreach (var flight in flights.Keys)
  17244. {
  17245. // 获取当前舱位的匹配规则
  17246. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17247. {
  17248. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17249. }
  17250. }
  17251. var allPrice = 0.00M;
  17252. #region right计算
  17253. int airRowIndex = 35;
  17254. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17255. {
  17256. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17257. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17258. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  17259. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17260. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17261. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17262. }
  17263. else
  17264. {
  17265. hideRowsList.Add(airRowIndex);
  17266. }
  17267. airRowIndex += 2;
  17268. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17269. {
  17270. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17271. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17272. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17273. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17274. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17275. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17276. }
  17277. else
  17278. {
  17279. hideRowsList.Add(airRowIndex);
  17280. }
  17281. airRowIndex += 2;
  17282. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17283. {
  17284. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17285. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17286. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17287. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17288. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17289. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17290. }
  17291. else
  17292. {
  17293. hideRowsList.Add(airRowIndex);
  17294. }
  17295. airRowIndex += 2;
  17296. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17297. {
  17298. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17299. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17300. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17301. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17302. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17303. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17304. }
  17305. else
  17306. {
  17307. hideRowsList.Add(airRowIndex);
  17308. }
  17309. airRowIndex += 2;
  17310. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17311. {
  17312. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17313. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17314. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17315. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17316. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17317. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17318. }
  17319. else
  17320. {
  17321. hideRowsList.Add(airRowIndex);
  17322. }
  17323. airRowIndex += 2;
  17324. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17325. {
  17326. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17327. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17328. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17329. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17330. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17331. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17332. }
  17333. else
  17334. {
  17335. hideRowsList.Add(airRowIndex);
  17336. }
  17337. airRowIndex += 2;
  17338. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17339. {
  17340. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17341. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17342. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  17343. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  17344. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  17345. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17346. }
  17347. else
  17348. {
  17349. hideRowsList.Add(airRowIndex);
  17350. }
  17351. airRowIndex += 2;
  17352. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17353. {
  17354. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17355. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17356. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  17357. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  17358. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  17359. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17360. }
  17361. else
  17362. {
  17363. hideRowsList.Add(airRowIndex);
  17364. }
  17365. airRowIndex += 2;
  17366. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17367. {
  17368. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17369. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17370. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  17371. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  17372. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  17373. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17374. }
  17375. else
  17376. {
  17377. hideRowsList.Add(airRowIndex);
  17378. }
  17379. #endregion
  17380. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  17381. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  17382. var ws = designer.Workbook.Worksheets[0];
  17383. foreach (var Rowindex in hideRowsList)
  17384. {
  17385. ws.Cells.HideRows(Rowindex, 2);
  17386. }
  17387. designer.Process();
  17388. designer.Workbook.Save(savePaht);
  17389. return Ok(JsonView(true, "生成成功!", new
  17390. {
  17391. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  17392. }));
  17393. }
  17394. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  17395. {
  17396. foreach (var roomType in roomTypes)
  17397. {
  17398. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  17399. {
  17400. hotelRooms[roomType]--;
  17401. flights[flightType]--;
  17402. if (roomType == "TBR")
  17403. {
  17404. flights[flightType]--; // 双人间在减少1
  17405. }
  17406. string key = flightType + roomType;
  17407. if (result.Keys.Contains(key))
  17408. {
  17409. result[key]++;
  17410. }
  17411. else
  17412. {
  17413. result.Add(key, 1);
  17414. }
  17415. }
  17416. }
  17417. }
  17418. private class AirHotelPrice
  17419. {
  17420. public string Name { get; set; }
  17421. public decimal Price { get; set; }
  17422. public int Count { get; set; }
  17423. }
  17424. /// <summary>
  17425. /// 团组系数设置
  17426. /// </summary>
  17427. /// <param name="dto"></param>
  17428. /// <returns></returns>
  17429. [HttpPost]
  17430. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17431. {
  17432. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17433. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17434. if (di == null)
  17435. {
  17436. return Ok(JsonView(false, "团组不存在!"));
  17437. }
  17438. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  17439. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  17440. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  17441. // FirstAsync(firstExpression.ToExpression());
  17442. #region JSON
  17443. string hcpJson = @"
  17444. [
  17445. {
  17446. ""min"": 1,
  17447. ""max"": 500,
  17448. ""value"": 1.50
  17449. },
  17450. {
  17451. ""min"": 501,
  17452. ""max"": 1000,
  17453. ""value"": 1.40
  17454. },
  17455. {
  17456. ""min"": 1001,
  17457. ""max"": 2000,
  17458. ""value"": 1.35
  17459. }
  17460. ]";
  17461. #endregion
  17462. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  17463. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  17464. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  17465. .ToList();
  17466. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  17467. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  17468. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  17469. // new List<(Predicate<decimal>, decimal)>()
  17470. // {
  17471. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  17472. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  17473. // }
  17474. // ));
  17475. #region 签证系数
  17476. var visaXS = 0.00M;
  17477. switch (dto.VisaCB)
  17478. {
  17479. case decimal n when (n > 1 && n < 500):
  17480. switch (dto.VisaRS)
  17481. {
  17482. case 2 or 3:
  17483. visaXS = 1.35M;
  17484. break;
  17485. case 4 or 5:
  17486. visaXS = 1.30M;
  17487. break;
  17488. case 6 or 7:
  17489. visaXS = 1.25M;
  17490. break;
  17491. case 8 or 9 or 10:
  17492. visaXS = 1.20M;
  17493. break;
  17494. case > 10:
  17495. visaXS = 1.15M;
  17496. break;
  17497. default:
  17498. visaXS = 0.00M;
  17499. break;
  17500. }
  17501. break;
  17502. case decimal n when (n >= 500 && n < 1000):
  17503. switch (dto.VisaRS)
  17504. {
  17505. case 2 or 3 or 4:
  17506. visaXS = 1.30M;
  17507. break;
  17508. case 5 or 6 or 7 or 8:
  17509. visaXS = 1.25M;
  17510. break;
  17511. case 9 or 10:
  17512. visaXS = 1.20M;
  17513. break;
  17514. case > 10:
  17515. visaXS = 1.15M;
  17516. break;
  17517. default:
  17518. visaXS = 0.00M;
  17519. break;
  17520. }
  17521. break;
  17522. default:
  17523. switch (dto.VisaRS)
  17524. {
  17525. case 2 or 3 or 4:
  17526. visaXS = 1.30M;
  17527. break;
  17528. case 5 or 6 or 7 or 8:
  17529. visaXS = 1.25M;
  17530. break;
  17531. case 9 or 10:
  17532. visaXS = 1.20M;
  17533. break;
  17534. case > 10:
  17535. visaXS = 1.15M;
  17536. break;
  17537. default:
  17538. visaXS = 0.00M;
  17539. break;
  17540. }
  17541. break;
  17542. }
  17543. #endregion
  17544. #region 火车系数
  17545. var hcpXS = 0.00M;
  17546. foreach (var (condition, result) in hcpSwitchDictionary)
  17547. {
  17548. if (condition(dto.HCPCB))
  17549. {
  17550. hcpXS = result;
  17551. break;
  17552. }
  17553. }
  17554. #endregion
  17555. #region 机票系数
  17556. #region 经济舱系数
  17557. var jjcXS = 0.00M;
  17558. switch (dto.JJCCB)
  17559. {
  17560. case decimal x when (x >= 1000 && x <= 3000):
  17561. jjcXS = 2.6M;
  17562. break;
  17563. case decimal x when (x >= 3001 && x <= 8000):
  17564. jjcXS = 2.3M;
  17565. break;
  17566. case decimal x when (x >= 8001 && x <= 15000):
  17567. jjcXS = 2.1M;
  17568. break;
  17569. case decimal x when (x >= 15001 && x <= 30000):
  17570. jjcXS = 1.95M;
  17571. break;
  17572. case > 30000:
  17573. jjcXS = 1.8M;
  17574. break;
  17575. default:
  17576. break;
  17577. }
  17578. #endregion
  17579. #region 公务舱系数
  17580. var gwcXS = 0.00M;
  17581. switch (dto.GWCCB)
  17582. {
  17583. case decimal x when (x >= 1000 && x <= 3000):
  17584. gwcXS = 2.5M;
  17585. break;
  17586. case decimal x when (x >= 3001 && x <= 8000):
  17587. gwcXS = 2.2M;
  17588. break;
  17589. case decimal x when (x >= 8001 && x <= 15000):
  17590. gwcXS = 2.0M;
  17591. break;
  17592. case decimal x when (x >= 15001 && x <= 30000):
  17593. gwcXS = 1.85M;
  17594. break;
  17595. case > 30000:
  17596. gwcXS = 1.7M;
  17597. break;
  17598. default:
  17599. break;
  17600. }
  17601. #endregion
  17602. #region 头等舱系数
  17603. var tdcXS = 0.00M;
  17604. switch (dto.TDCCB)
  17605. {
  17606. case > 70000:
  17607. tdcXS = 1.5M;
  17608. break;
  17609. default:
  17610. tdcXS = 1.9M;
  17611. break;
  17612. }
  17613. #endregion
  17614. #endregion
  17615. #region 酒店系数
  17616. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  17617. {
  17618. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  17619. {1.5M, new List<string>(){"越南社会主义共和国",
  17620. "老挝",
  17621. "柬埔寨",
  17622. "泰国",
  17623. "缅甸",
  17624. "马来西亚",
  17625. //"新加坡",
  17626. "文莱达鲁萨兰",
  17627. "印度尼西亚",
  17628. "东帝汶"}},
  17629. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  17630. };
  17631. #region SGR
  17632. var sgrXS = 1.25M;
  17633. #endregion
  17634. #region TBR
  17635. var tbrXS = 1.25M;
  17636. #endregion
  17637. #region JSES
  17638. var jsesXS = 1.25M;
  17639. #endregion
  17640. #region SUITE
  17641. var suiteXS = 1.25M;
  17642. #endregion
  17643. var countryArr = di.VisitCountry.Split("|");
  17644. foreach (var item in dic)
  17645. {
  17646. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  17647. .Count();
  17648. if (extsisCount > 0)
  17649. {
  17650. jsesXS = item.Key;
  17651. sgrXS = item.Key;
  17652. tbrXS = item.Key;
  17653. suiteXS = item.Key;
  17654. }
  17655. }
  17656. #endregion
  17657. #region 地接系数
  17658. var djXS = 0.00M;
  17659. switch (dto.DJRS)
  17660. {
  17661. case 2 or 3:
  17662. djXS = 2.65M;
  17663. break;
  17664. case 4:
  17665. djXS = 2.6M;
  17666. break;
  17667. case 5 or 6:
  17668. djXS = 2.5M;
  17669. break;
  17670. case 7 or 8:
  17671. djXS = 2.4M;
  17672. break;
  17673. case 9 or 10:
  17674. djXS = 2.3M;
  17675. break;
  17676. case 11:
  17677. djXS = 2.2M;
  17678. break;
  17679. case 12:
  17680. djXS = 2.1M;
  17681. break;
  17682. case 13 or 14:
  17683. djXS = 2M;
  17684. break;
  17685. case 15:
  17686. djXS = 1.9M;
  17687. break;
  17688. case 16 or 17 or 18:
  17689. djXS = 1.8M;
  17690. break;
  17691. case 19 or 20:
  17692. djXS = 1.7M;
  17693. break;
  17694. }
  17695. #endregion
  17696. #region 零用金系数
  17697. var lyjXS = 0.00M;
  17698. switch (dto.LYJRS)
  17699. {
  17700. case 2:
  17701. lyjXS = 1.25M;
  17702. break;
  17703. case 3 or 4 or 5:
  17704. lyjXS = 1.2M;
  17705. break;
  17706. case int number when (number > 5 && number < 10):
  17707. lyjXS = 1.15M;
  17708. break;
  17709. case > 10:
  17710. lyjXS = 1.1M;
  17711. break;
  17712. default:
  17713. break;
  17714. }
  17715. #endregion
  17716. return Ok(JsonView(true, "查询成功", new ArrayList()
  17717. {
  17718. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  17719. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  17720. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  17721. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  17722. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  17723. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  17724. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  17725. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  17726. new { label = "地接系数", value = djXS, key = "djXS" },
  17727. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  17728. new { label = "公务系数", value = 2M, key = "gwXS" }
  17729. }));
  17730. }
  17731. #endregion
  17732. #region 酒店预订 New 2023-12-28 17:45
  17733. /// <summary>
  17734. /// 酒店预订
  17735. /// 酒店费用列表 根据团组Id查询
  17736. /// </summary>
  17737. /// <param name="_dto"></param>
  17738. /// <returns></returns>
  17739. [HttpPost]
  17740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17741. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17742. {
  17743. #region 参数验证
  17744. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17745. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17746. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17747. #region 团组操作权限验证 76 酒店预定模块
  17748. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17749. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17750. #endregion
  17751. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17752. #region 页面操作权限验证
  17753. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17754. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17755. #endregion
  17756. #endregion
  17757. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17758. }
  17759. /// <summary>
  17760. /// 酒店预订
  17761. /// 基础数据
  17762. /// </summary>
  17763. /// <param name="_dto"></param>
  17764. /// <returns></returns>
  17765. [HttpPost]
  17766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17767. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17768. {
  17769. #region 参数验证
  17770. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17771. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17772. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17773. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17774. #region 页面操作权限验证
  17775. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17776. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17777. #endregion
  17778. #region 团组操作权限验证 76 酒店预定模块
  17779. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17780. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17781. #endregion
  17782. #endregion
  17783. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17784. }
  17785. /// <summary>
  17786. /// 酒店预订
  17787. /// 创建 入住卷号码
  17788. /// </summary>
  17789. /// <param name="_dto"></param>
  17790. /// <returns></returns>
  17791. [HttpPost]
  17792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17793. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17794. {
  17795. #region 参数验证
  17796. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17797. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17798. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17799. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17800. #region 页面操作权限验证
  17801. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17802. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17803. #endregion
  17804. #region 团组操作权限验证 76 酒店预定模块
  17805. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17806. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17807. #endregion
  17808. #endregion
  17809. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17810. if (data.Code != 0)
  17811. {
  17812. return Ok(JsonView(false, data.Msg));
  17813. }
  17814. return Ok(JsonView(true, data.Msg, data.Data));
  17815. }
  17816. /// <summary>
  17817. /// 酒店预订
  17818. /// 详情
  17819. /// </summary>
  17820. /// <param name="_dto"></param>
  17821. /// <returns></returns>
  17822. [HttpPost]
  17823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17824. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17825. {
  17826. #region 参数验证
  17827. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17828. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17829. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17830. #region 团组操作权限验证 76 酒店预定模块
  17831. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17832. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17833. #endregion
  17834. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17835. #region 页面操作权限验证
  17836. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17837. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17838. #endregion
  17839. #endregion
  17840. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17841. }
  17842. /// <summary>
  17843. /// 酒店预订
  17844. /// Add Or Edit
  17845. /// </summary>
  17846. /// <param name="_dto"></param>
  17847. /// <returns></returns>
  17848. [HttpPost]
  17849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17850. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17851. {
  17852. #region 参数验证
  17853. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17854. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17855. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17856. #region 团组操作权限验证 76 酒店预定模块
  17857. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17858. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17859. #endregion
  17860. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17861. #region 页面操作权限验证
  17862. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17863. if (_dto.Id == 0) // Add
  17864. {
  17865. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17866. }
  17867. else if (_dto.Id > 1) // Edit
  17868. {
  17869. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17870. }
  17871. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17872. #endregion
  17873. #endregion
  17874. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17875. if (_view.Code != 200)
  17876. {
  17877. return Ok(_view);
  17878. }
  17879. #region 成本无酒店价格数据进入超支
  17880. _sqlSugar.BeginTran();
  17881. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17882. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17883. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17884. for (int i = 0; i < groupCost.Count; i++)
  17885. {
  17886. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17887. {
  17888. groupCost[i].Date = groupCost[i - 1].Date;
  17889. }
  17890. }
  17891. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17892. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17893. List<Fin_GroupExtraCostDto_OP>();
  17894. if (start_Bool && end_Bool)
  17895. {
  17896. while (start_Time < end_Time)
  17897. {
  17898. foreach (var item in groupCost_Grp)
  17899. {
  17900. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17901. {
  17902. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17903. {
  17904. extraCostList.Add(new
  17905. Fin_GroupExtraCostDto_OP
  17906. {
  17907. Area = _dto.AreaId,
  17908. coefficient = 1.5M,
  17909. createUser = _dto.UserId,
  17910. currency = _dto.CardPriceCurrency,
  17911. diId = _dto.DiId,
  17912. ManagerConfirm = 0,
  17913. SupervisorConfirm = 0,
  17914. SYsupervisorConfirm = 0,
  17915. editType = 1,
  17916. PortType = 1,
  17917. price = _dto.CardPrice,
  17918. PriceCount = 1,
  17919. priceType = 1027,
  17920. priceDetailType = 1044,
  17921. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17922. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17923. });
  17924. }
  17925. }
  17926. }
  17927. start_Time = start_Time.AddDays(1);
  17928. }
  17929. }
  17930. if (extraCostList.Any())
  17931. {
  17932. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17933. }
  17934. _sqlSugar.CommitTran();
  17935. #endregion
  17936. #region 应用推送
  17937. try
  17938. {
  17939. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17940. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17941. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17942. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17943. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17944. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17945. var diId = _dto.DiId;
  17946. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17947. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17948. #region 操作记录
  17949. var opInfo = new Crm_TableOperationRecord()
  17950. {
  17951. TableName = "Grp_HotelReservations",
  17952. PortType = _dto.PortType,
  17953. DataId = hotelId,
  17954. CreateUserId = _dto.UserId
  17955. };
  17956. //var opStatus = OperationEnum.NoOperation;
  17957. if (_dto.Id < 1) //添加操作
  17958. {
  17959. opInfo.OperationItem = OperationEnum.Add;
  17960. }
  17961. else if (_dto.Id > 0)
  17962. {
  17963. opInfo.OperationItem = OperationEnum.Edit;
  17964. }
  17965. string opRemark = string.Empty;
  17966. if (ccpInfo != null)
  17967. {
  17968. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17969. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17970. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17971. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17972. }
  17973. opInfo.Remark = opRemark;
  17974. await _tableorRep.AddAsync(opInfo);
  17975. #endregion
  17976. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17977. //2024-10-21 新增LZ UID
  17978. var userIds = new List<int>() { 21 };
  17979. string title = $"费用审核";
  17980. string content = "";
  17981. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17982. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17983. try
  17984. {
  17985. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17986. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17987. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17988. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17989. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17990. }
  17991. catch (Exception ex)
  17992. {
  17993. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17994. }
  17995. }
  17996. catch (Exception ex)
  17997. {
  17998. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17999. }
  18000. try
  18001. {
  18002. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18003. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18004. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18005. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18006. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18007. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18008. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18009. //自动审核
  18010. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  18011. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  18012. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  18013. //2024-10-21 新增LZ UID
  18014. var userIds = new List<int>() { 21 };
  18015. string title = $"系统通知";
  18016. var diId = _dto.DiId;
  18017. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18018. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18019. string content = "";
  18020. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18021. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18022. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18023. }
  18024. catch (Exception ex)
  18025. {
  18026. }
  18027. #endregion
  18028. return Ok(_view);
  18029. }
  18030. /// <summary>
  18031. /// 酒店自动审核测试
  18032. /// Add Or Edit
  18033. /// </summary>
  18034. /// <param name="diid"></param>
  18035. /// <param name="dataId"></param>
  18036. /// <returns></returns>
  18037. [HttpPost]
  18038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18039. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  18040. {
  18041. #region 应用推送
  18042. try
  18043. {
  18044. //自动审核
  18045. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  18046. }
  18047. catch (Exception ex)
  18048. {
  18049. return Ok(JsonView(false, ex.Message));
  18050. }
  18051. #endregion
  18052. return Ok(JsonView(false, "操作成功"));
  18053. }
  18054. /// <summary>
  18055. /// 酒店预订
  18056. /// Del
  18057. /// </summary>
  18058. /// <param name="_dto"></param>
  18059. /// <returns></returns>
  18060. [HttpPost]
  18061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18062. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  18063. {
  18064. #region 参数验证
  18065. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18066. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18067. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18068. #region 团组操作权限验证 76 酒店预定模块
  18069. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18070. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18071. #endregion
  18072. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18073. #region 页面操作权限验证
  18074. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18075. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18076. #endregion
  18077. #endregion
  18078. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  18079. #region 操作记录
  18080. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  18081. {
  18082. TableName = "Grp_HotelReservations",
  18083. PortType = _dto.PortType,
  18084. OperationItem = OperationEnum.Del,
  18085. DataId = _dto.Id,
  18086. CreateUserId = _dto.UserId
  18087. });
  18088. #endregion
  18089. return Ok(data);
  18090. }
  18091. /// <summary>
  18092. /// 酒店预订
  18093. /// 生成VOUCHER
  18094. /// 2024.05.06 之前版本
  18095. /// </summary>
  18096. /// <param name="_dto"></param>
  18097. /// <returns></returns>
  18098. [HttpPost]
  18099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18100. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18101. {
  18102. try
  18103. {
  18104. #region 参数验证
  18105. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18106. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18107. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18108. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18109. #region 团组操作权限验证 76 酒店预定模块
  18110. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18111. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18112. #endregion
  18113. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18114. #region 页面操作权限验证
  18115. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18116. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18117. #endregion
  18118. #endregion
  18119. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18120. //判断数据是否完整
  18121. if (hr != null)
  18122. {
  18123. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18124. {
  18125. string strFileName = "HotelStatement/";
  18126. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18127. if (dele != null)
  18128. strFileName += dele.TourCode;
  18129. //载入模板
  18130. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18131. Document doc = new Document(sss);
  18132. DocumentBuilder builder = new DocumentBuilder(doc);
  18133. #region 替换Word模板书签内容
  18134. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18135. //入住卷预定号码
  18136. if (doc.Range.Bookmarks["VNO"] != null)
  18137. {
  18138. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18139. mark.Text = hr.CheckNumber;
  18140. }
  18141. //酒店时间
  18142. if (doc.Range.Bookmarks["Date"] != null)
  18143. {
  18144. Bookmark mark = doc.Range.Bookmarks["Date"];
  18145. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18146. }
  18147. //团号
  18148. if (doc.Range.Bookmarks["TNo"] != null)
  18149. {
  18150. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18151. mark.Text = dele.TourCode;
  18152. }
  18153. //预定号码
  18154. if (doc.Range.Bookmarks["BookingId"] != null)
  18155. {
  18156. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  18157. mark.Text = hr.ReservationsNo;
  18158. }
  18159. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  18160. {
  18161. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  18162. mark.Text = hr.DetermineNo;
  18163. }
  18164. //酒店城市
  18165. if (doc.Range.Bookmarks["City"] != null)
  18166. {
  18167. Bookmark mark = doc.Range.Bookmarks["City"];
  18168. mark.Text = hr.City;
  18169. }
  18170. //酒店名称
  18171. if (doc.Range.Bookmarks["HName"] != null)
  18172. {
  18173. Bookmark mark = doc.Range.Bookmarks["HName"];
  18174. mark.Text = hr.HotelName;
  18175. }
  18176. //酒店地址
  18177. if (doc.Range.Bookmarks["Address"] != null)
  18178. {
  18179. Bookmark mark = doc.Range.Bookmarks["Address"];
  18180. mark.Text = hr.HotelAddress;
  18181. }
  18182. //酒店电话
  18183. if (doc.Range.Bookmarks["Tel"] != null)
  18184. {
  18185. Bookmark mark = doc.Range.Bookmarks["Tel"];
  18186. mark.Text = hr.HotelTel;
  18187. }
  18188. //酒店传真
  18189. if (doc.Range.Bookmarks["Fax"] != null)
  18190. {
  18191. Bookmark mark = doc.Range.Bookmarks["Fax"];
  18192. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  18193. {
  18194. mark.Text = hr.HotelFax;
  18195. }
  18196. }
  18197. //入住时间
  18198. if (doc.Range.Bookmarks["CIn"] != null)
  18199. {
  18200. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18201. Bookmark mark = doc.Range.Bookmarks["CIn"];
  18202. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  18203. }
  18204. //退房时间
  18205. if (doc.Range.Bookmarks["COut"] != null)
  18206. {
  18207. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18208. Bookmark mark = doc.Range.Bookmarks["COut"];
  18209. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18210. }
  18211. //客户名称
  18212. if (doc.Range.Bookmarks["GName"] != null)
  18213. {
  18214. string guestName = "";
  18215. string[] clients = Array.Empty<string>();
  18216. if (hr.GuestName.Contains(","))
  18217. {
  18218. clients = hr.GuestName.Split(",");
  18219. }
  18220. else
  18221. {
  18222. clients = new string[] { hr.GuestName };
  18223. }
  18224. List<int> clientIds_int = new List<int>();
  18225. if (clients.Length > 0)
  18226. {
  18227. foreach (var item in clients)
  18228. {
  18229. if (item.IsNumeric())
  18230. {
  18231. clientIds_int.Add(int.Parse(item));
  18232. }
  18233. }
  18234. }
  18235. if (clientIds_int.Count > 0)
  18236. {
  18237. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18238. foreach (var client in _clientDatas)
  18239. {
  18240. //男
  18241. if (client.Sex == 0) guestName += $"Mr.";
  18242. //女
  18243. else if (client.Sex == 1) guestName += $"Ms.";
  18244. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18245. {
  18246. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18247. }
  18248. //guestName += $"{client.Pinyin},";
  18249. }
  18250. if (guestName.Length > 0)
  18251. {
  18252. guestName = guestName.Substring(0, guestName.Length - 1);
  18253. }
  18254. }
  18255. else
  18256. {
  18257. guestName = hr.GuestName;
  18258. }
  18259. Bookmark mark = doc.Range.Bookmarks["GName"];
  18260. mark.Text = guestName;
  18261. }
  18262. //房间介绍
  18263. if (doc.Range.Bookmarks["ROOM"] != null)
  18264. {
  18265. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18266. mark.Text = hr.RoomExplanation;
  18267. }
  18268. //报价描述
  18269. if (doc.Range.Bookmarks["NOTE"] != null)
  18270. {
  18271. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18272. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18273. if (ss != null)
  18274. mark.Text = ss.Name;
  18275. }
  18276. //入住时间
  18277. if (doc.Range.Bookmarks["CheckIn"] != null)
  18278. {
  18279. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18280. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18281. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18282. }
  18283. //退房时间
  18284. if (doc.Range.Bookmarks["CheckOut"] != null)
  18285. {
  18286. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18287. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18288. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18289. }
  18290. //日期
  18291. if (doc.Range.Bookmarks["DT"] != null)
  18292. {
  18293. Bookmark mark = doc.Range.Bookmarks["DT"];
  18294. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18295. }
  18296. //名称
  18297. if (doc.Range.Bookmarks["VName"] != null)
  18298. {
  18299. Bookmark mark = doc.Range.Bookmarks["VName"];
  18300. mark.Text = hr.HotelName;
  18301. }
  18302. //号码
  18303. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18304. {
  18305. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18306. mark.Text = hr.CheckNumber;
  18307. }
  18308. #endregion
  18309. strFileName += "VOUCHER.doc";
  18310. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18311. doc.Save(fileDir);
  18312. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18313. return Ok(JsonView(true, "操作成功!", Url));
  18314. }
  18315. else
  18316. {
  18317. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18318. }
  18319. }
  18320. else
  18321. {
  18322. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18323. }
  18324. }
  18325. catch (Exception ex)
  18326. {
  18327. return Ok(JsonView(false, ex.Message));
  18328. }
  18329. }
  18330. /// <summary>
  18331. /// 酒店预订
  18332. /// 生成VOUCHER
  18333. /// 2024.05.06 之后版本
  18334. /// </summary>
  18335. /// <param name="_dto"></param>
  18336. /// <returns></returns>
  18337. [HttpPost]
  18338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18339. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  18340. {
  18341. #region 参数验证
  18342. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18343. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18344. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18345. #region 团组操作权限验证 76 酒店预定模块
  18346. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18347. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18348. #endregion
  18349. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18350. #region 页面操作权限验证
  18351. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18352. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18353. #endregion
  18354. #endregion
  18355. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  18356. //判断数据是否完整
  18357. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18358. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18359. string strFileName = "HotelStatement/";
  18360. string guestNames = ""; //格式Mr.xxx Ms.xxx
  18361. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  18362. #region 数据处理
  18363. List<int> guestIds = new List<int>();
  18364. //int index = 0;
  18365. foreach (var item in hrDtas)
  18366. {
  18367. if (item.GuestName.Contains(","))
  18368. {
  18369. string[] guestIdArr = item.GuestName.Split(',');
  18370. foreach (var guestIdStr in guestIdArr)
  18371. {
  18372. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  18373. if (guestBool)
  18374. {
  18375. guestIds.Add(guestId);
  18376. }
  18377. }
  18378. }
  18379. else guestNames += item.GuestName;
  18380. var voucherInfo = new HotelVoucherInfoView()
  18381. {
  18382. HotelName = item.HotelName,
  18383. CheckInDate = item.CheckInDate,
  18384. CheckOutDate = item.CheckOutDate,
  18385. ConfirmationNumber = item.DetermineNo.Trim(),
  18386. RoomType = item.RoomExplanation
  18387. };
  18388. vouchers.Add(voucherInfo);
  18389. }
  18390. if (guestIds.Count > 0)
  18391. {
  18392. guestIds = guestIds.Distinct().ToList();
  18393. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  18394. if (guestDatas.Count > 0)
  18395. {
  18396. guestNames = "";
  18397. foreach (var guest in guestDatas)
  18398. {
  18399. string guestName = "";
  18400. if (guest.Sex == 0) guestName += @"MR.";
  18401. else if (guest.Sex == 1) guestName += @"MS.";
  18402. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18403. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18404. guestNames += @$"{guestName.Trim()}、";
  18405. }
  18406. if (guestNames.Length > 0)
  18407. {
  18408. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18409. }
  18410. }
  18411. }
  18412. #endregion
  18413. //载入模板
  18414. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  18415. Document doc = new Document(sss);
  18416. DocumentBuilder builder = new DocumentBuilder(doc);
  18417. if (doc.Range.Bookmarks["GuestName"] != null)
  18418. {
  18419. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  18420. mark.Text = guestNames;
  18421. }
  18422. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18423. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  18424. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  18425. for (int i = 1; i <= vouchers.Count; i++)
  18426. {
  18427. HotelVoucherInfoView hviv = vouchers[i - 1];
  18428. builder.MoveToCell(0, i, 0, 0);
  18429. builder.Write(hviv.HotelName);
  18430. builder.MoveToCell(0, i, 1, 0);
  18431. builder.Write(hviv.CheckInDate);
  18432. builder.MoveToCell(0, i, 2, 0);
  18433. builder.Write(hviv.CheckOutDate);
  18434. builder.MoveToCell(0, i, 3, 0);
  18435. builder.Write(hviv.RoomType);
  18436. builder.MoveToCell(0, i, 4, 0);
  18437. builder.Write(hviv.ConfirmationNumber);
  18438. }
  18439. //删除多余行
  18440. int currRowIndex = vouchers.Count + 1;
  18441. int delRows = 21 - currRowIndex;
  18442. if (delRows > 0)
  18443. {
  18444. for (int i = 0; i < delRows; i++)
  18445. {
  18446. table.Rows.RemoveAt(currRowIndex);
  18447. //cultivateRowIndex++;
  18448. }
  18449. }
  18450. strFileName += "VOUCHER.docx";
  18451. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18452. doc.Save(fileDir);
  18453. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18454. return Ok(JsonView(true, "操作成功!", Url));
  18455. }
  18456. /// <summary>
  18457. /// 酒店预订
  18458. /// 生成VOUCHER 批量生成
  18459. /// New
  18460. /// </summary>
  18461. /// <param name="_dto"></param>
  18462. /// <returns></returns>
  18463. [HttpPost]
  18464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18465. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  18466. {
  18467. #region 参数验证
  18468. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18469. if (_dto.PageId < 1) _dto.PageId = 28;
  18470. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18471. #region 团组操作权限验证 76 酒店预定模块
  18472. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18473. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18474. #endregion
  18475. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18476. #region 页面操作权限验证
  18477. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18478. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18479. #endregion
  18480. #endregion
  18481. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  18482. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  18483. .OrderBy(x => x.CheckInDate)
  18484. .ToListAsync();
  18485. //判断数据是否完整
  18486. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18487. string strFileName = "HotelStatement/";
  18488. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18489. if (dele != null)
  18490. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  18491. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  18492. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  18493. .Where(it => it.IsDel == 0)
  18494. .ToListAsync();
  18495. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  18496. for (int i = 0; i < hrDtas.Count; i++)
  18497. {
  18498. string guestNames = string.Empty;
  18499. List<int> guestIds = new List<int>();
  18500. var item = hrDtas[i];
  18501. //处理客户姓名
  18502. if (item.GuestName.Contains(","))
  18503. {
  18504. string[] guestIdArr = item.GuestName.Split(',');
  18505. foreach (var guestIdStr in guestIdArr)
  18506. if (int.TryParse(guestIdStr, out int guestId))
  18507. guestIds.Add(guestId);
  18508. }
  18509. else
  18510. {
  18511. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  18512. if (guestIdBool)
  18513. {
  18514. guestIds.Add(guestId);
  18515. }
  18516. //NaN
  18517. if (item.GuestName.Contains("NaN"))
  18518. {
  18519. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  18520. }
  18521. }
  18522. if (guestIds.Count > 0)
  18523. {
  18524. guestIds = guestIds.Distinct().ToList();
  18525. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  18526. if (guestDatas1.Count > 0)
  18527. {
  18528. guestNames = "";
  18529. foreach (var guest in guestDatas1)
  18530. {
  18531. string guestName = "";
  18532. if (guest.Sex == 0) guestName += @"MR.";
  18533. else if (guest.Sex == 1) guestName += @"MS.";
  18534. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18535. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18536. guestNames += @$"{guestName.Trim()}、";
  18537. }
  18538. if (guestNames.Length > 0)
  18539. {
  18540. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18541. }
  18542. }
  18543. }
  18544. //if (!string.IsNullOrEmpty(guestNames))
  18545. //{
  18546. hrDtas[i].GuestName = guestNames;
  18547. //}
  18548. }
  18549. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  18550. Document doc = new Document();
  18551. DocumentBuilder builder = new DocumentBuilder(doc);
  18552. try
  18553. {
  18554. builder.MoveToDocumentStart();
  18555. foreach (var item in hrDtas)
  18556. {
  18557. //标题
  18558. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18559. builder.ParagraphFormat.LineSpacing = 1;
  18560. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18561. builder.ParagraphFormat.Style.Font.Size = 9;
  18562. builder.ParagraphFormat.Style.Font.Bold = true;
  18563. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18564. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  18565. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18566. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18567. builder.ParagraphFormat.LineSpacing = 1;
  18568. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18569. builder.ParagraphFormat.Style.Font.Size = 9;
  18570. builder.ParagraphFormat.Style.Font.Bold = true;
  18571. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  18572. builder.StartTable();
  18573. // 设置边框颜色
  18574. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  18575. //设置边框样式
  18576. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  18577. //表格
  18578. #region 第一行
  18579. builder.InsertCell();
  18580. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18581. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18582. //builder.CellFormat.AllowAutoFit = false;
  18583. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18584. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18585. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18586. builder.CellFormat.WrapText = true; //自动换行
  18587. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18588. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  18589. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18590. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18591. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18592. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18593. builder.Write("TOUR NO:");
  18594. builder.InsertCell();
  18595. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18596. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18597. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18598. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18599. builder.ParagraphFormat.Style.Font.Bold = false;
  18600. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18601. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18602. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18603. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18604. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18605. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18606. builder.Write($"{dele?.TourCode ?? "-"}");
  18607. builder.InsertCell();
  18608. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18609. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18610. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18611. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18612. builder.ParagraphFormat.Style.Font.Bold = false;
  18613. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18614. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18615. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18616. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18617. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18618. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18619. builder.Write($"CITY:");
  18620. builder.InsertCell();
  18621. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18622. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18623. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18624. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18625. builder.ParagraphFormat.Style.Font.Bold = false;
  18626. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18627. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18628. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18629. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18630. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18631. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18632. builder.Write($"{item.City}");
  18633. builder.EndRow();
  18634. #endregion
  18635. #region 第二行
  18636. builder.InsertCell();
  18637. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18638. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18639. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18640. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18641. builder.ParagraphFormat.Style.Font.Bold = false;
  18642. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18643. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18644. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18645. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18646. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18647. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18648. builder.Write("CONFIRMATION NO:");
  18649. builder.InsertCell();
  18650. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18651. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18652. builder.ParagraphFormat.Style.Font.Size = 8;
  18653. builder.ParagraphFormat.Style.Font.Bold = false;
  18654. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18655. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18656. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18657. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18658. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18659. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18660. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18661. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18662. builder.Write($"{item.DetermineNo}");
  18663. builder.InsertCell();
  18664. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18665. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18666. builder.InsertCell();
  18667. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18668. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18669. builder.EndRow();
  18670. #endregion
  18671. #region 第三行
  18672. builder.InsertCell();
  18673. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18674. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18675. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18676. builder.ParagraphFormat.Style.Font.Bold = false;
  18677. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18678. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18679. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18680. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18681. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18682. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18683. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18684. builder.Write($"HOTEL NAME:");
  18685. builder.InsertCell();
  18686. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18687. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18688. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18689. builder.ParagraphFormat.Style.Font.Bold = false;
  18690. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18691. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18692. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18693. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18694. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18695. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18696. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18697. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18698. builder.Write($"{item.HotelName}");
  18699. builder.InsertCell();
  18700. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18701. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18702. builder.InsertCell();
  18703. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18704. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18705. builder.EndRow();
  18706. #endregion
  18707. #region 第四行
  18708. builder.InsertCell();
  18709. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18710. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18711. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18712. builder.ParagraphFormat.Style.Font.Bold = false;
  18713. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18714. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18715. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18716. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18717. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18718. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18719. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18720. builder.Write($"HOTEL ADDRESS:");
  18721. builder.InsertCell();
  18722. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18723. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18724. builder.ParagraphFormat.Style.Font.Size = 8;
  18725. builder.ParagraphFormat.Style.Font.Bold = false;
  18726. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18727. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18728. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18729. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18730. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18731. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18732. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18733. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18734. builder.Write($"{item.HotelAddress}");
  18735. builder.InsertCell();
  18736. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18737. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18738. builder.InsertCell();
  18739. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18740. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18741. builder.EndRow();
  18742. #endregion
  18743. #region 第五行
  18744. builder.InsertCell();
  18745. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18746. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18747. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18748. builder.ParagraphFormat.Style.Font.Bold = false;
  18749. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18750. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18751. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18752. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18753. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18754. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18755. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18756. builder.Write("TEL:");
  18757. builder.InsertCell();
  18758. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18759. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18760. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18761. builder.ParagraphFormat.Style.Font.Bold = false;
  18762. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18763. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18764. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18765. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18766. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18767. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18768. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18769. builder.Write($"{item.HotelTel}");
  18770. builder.InsertCell();
  18771. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18772. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18773. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18774. builder.ParagraphFormat.Style.Font.Bold = false;
  18775. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18776. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18777. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18778. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18779. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18780. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18781. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18782. builder.Write($"FAX:");
  18783. builder.InsertCell();
  18784. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18785. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18786. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18787. builder.ParagraphFormat.Style.Font.Bold = false;
  18788. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18789. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18790. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18791. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18792. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18793. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18794. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18795. builder.Write($"{item.HotelFax}");
  18796. builder.EndRow();
  18797. #endregion
  18798. #region 第六行
  18799. builder.InsertCell();
  18800. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18801. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18802. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18803. builder.ParagraphFormat.Style.Font.Bold = false;
  18804. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18805. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18806. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18807. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18808. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18809. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18810. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18811. builder.Write("CHECK IN:");
  18812. builder.InsertCell();
  18813. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18814. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18815. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18816. builder.ParagraphFormat.Style.Font.Bold = false;
  18817. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18818. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18819. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18820. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18821. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18822. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18823. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18824. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18825. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18826. builder.Write($"{checkInStr}");
  18827. builder.InsertCell();
  18828. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18829. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18830. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18831. builder.ParagraphFormat.Style.Font.Bold = false;
  18832. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18833. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18834. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18835. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18836. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18837. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18838. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18839. builder.Write($"CHECK OUT:");
  18840. builder.InsertCell();
  18841. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18842. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18843. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18844. builder.ParagraphFormat.Style.Font.Bold = false;
  18845. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18846. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18847. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18848. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18849. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18850. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18851. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18852. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18853. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18854. builder.Write($"{checkOutStr}");
  18855. builder.EndRow();
  18856. #endregion
  18857. #region 第七行
  18858. builder.InsertCell();
  18859. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18860. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18861. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18862. builder.ParagraphFormat.Style.Font.Bold = false;
  18863. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18864. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18865. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18866. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18867. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18868. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18869. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18870. builder.Write($"GUEST NAME:");
  18871. builder.InsertCell();
  18872. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18873. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18874. builder.ParagraphFormat.Style.Font.Size = 8;
  18875. builder.ParagraphFormat.Style.Font.Bold = false;
  18876. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18877. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18878. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18879. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18880. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18881. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18882. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18883. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18884. builder.Write($"{item.GuestName.Trim()}");
  18885. builder.InsertCell();
  18886. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18887. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18888. builder.InsertCell();
  18889. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18890. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18891. builder.EndRow();
  18892. #endregion
  18893. #region 第八行
  18894. builder.InsertCell();
  18895. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18896. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18897. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18898. builder.ParagraphFormat.Style.Font.Bold = false;
  18899. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18900. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18901. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18902. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18903. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18904. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18905. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18906. builder.Write($"ROOM TYPE:");
  18907. builder.InsertCell();
  18908. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18909. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18910. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18911. builder.ParagraphFormat.Style.Font.Bold = false;
  18912. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18913. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18914. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18915. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18916. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18917. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18918. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18919. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18920. builder.Write($"{item.RoomExplanation}");
  18921. builder.InsertCell();
  18922. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18923. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18924. builder.InsertCell();
  18925. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18926. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18927. builder.EndRow();
  18928. #endregion
  18929. #region 第九行
  18930. builder.InsertCell();
  18931. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18932. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18933. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18934. builder.ParagraphFormat.Style.Font.Bold = false;
  18935. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18936. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18937. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18938. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18939. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18940. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18941. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18942. builder.Write($"NOTE:");
  18943. builder.InsertCell();
  18944. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18945. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18946. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18947. builder.ParagraphFormat.Style.Font.Bold = false;
  18948. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18949. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18950. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18951. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18952. builder.Write($"ROOM WITH BREAKFAST AND TAX ONLY.\r\nTHIS SERVICE IS PAYABLE BY C-TRIP. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST.");
  18953. builder.InsertCell();
  18954. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18955. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18956. builder.InsertCell();
  18957. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18958. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18959. builder.EndRow();
  18960. #endregion
  18961. builder.EndTable();
  18962. //换行
  18963. builder.Writeln("");
  18964. builder.Writeln("");
  18965. }
  18966. #region 获取文档中的所有表格 设置文字自适应
  18967. // 获取文档中的所有表格。
  18968. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18969. {
  18970. // 遍历表格中的所有行。
  18971. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18972. {
  18973. foreach (Cell cell in row.Cells)
  18974. {
  18975. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18976. cellFormat.Width = 0;
  18977. }
  18978. }
  18979. }
  18980. #endregion
  18981. #region 设置页眉
  18982. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18983. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18984. if (System.IO.File.Exists(voucherHeaderPath))
  18985. {
  18986. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18987. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18988. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18989. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18990. // 调整图片位置
  18991. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18992. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18993. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18994. shape.Left = 0; // 将图片距离页面左边缘的距离
  18995. shape.Width = 81; // 设置图片宽度
  18996. shape.Height = 36; // 设置图片高度
  18997. }
  18998. //靠右
  18999. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19000. //// 设置页脚上下边距
  19001. //builder.PageSetup.HeaderDistance = 42;
  19002. // 添加页眉线
  19003. Aspose.Words.Border borderHeader = null;
  19004. try
  19005. {
  19006. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  19007. }
  19008. catch (Exception e)
  19009. {
  19010. // TODO Auto-generated catch block
  19011. //e.printStackTrace();
  19012. }
  19013. borderHeader.Shadow = true;
  19014. borderHeader.DistanceFromText = 2;
  19015. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  19016. #endregion
  19017. }
  19018. catch (Exception ex)
  19019. {
  19020. }
  19021. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19022. doc.Save(fileDir);
  19023. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19024. return Ok(JsonView(true, "操作成功!", Url));
  19025. }
  19026. /// <summary>
  19027. /// 酒店预订
  19028. /// 生成 预定成本 Excel
  19029. /// </summary>
  19030. /// <param name="_dto"></param>
  19031. /// <returns></returns>
  19032. [HttpPost]
  19033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19034. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  19035. {
  19036. #region 参数验证
  19037. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  19038. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  19039. if (!vadalitorRes.IsValid)
  19040. {
  19041. var errors = new StringBuilder();
  19042. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  19043. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  19044. }
  19045. #region 团组操作权限验证 76 酒店预定模块
  19046. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19047. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19048. #endregion
  19049. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19050. #region 页面操作权限验证
  19051. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19052. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19053. #endregion
  19054. #endregion
  19055. decimal _rate = 1.00M;
  19056. string _currency = string.Empty;
  19057. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  19058. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19059. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  19060. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19061. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  19062. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  19063. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  19064. if (_GroupCostParameter == null)
  19065. {
  19066. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  19067. bool isIntType = int.TryParse(_currency, out int currId);
  19068. if (isIntType)
  19069. {
  19070. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19071. }
  19072. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19073. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19074. if (currInfo == null)
  19075. {
  19076. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19077. }
  19078. else _rate = currInfo.Rate;
  19079. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  19080. {
  19081. _rate = _GroupCostParameter.Rate;
  19082. }
  19083. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19084. //string strFileName = "HotelStatement/";
  19085. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19086. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19087. var rateDatas = new List<dynamic>();
  19088. #region 数据处理
  19089. foreach (var item in hrDtas)
  19090. {
  19091. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19092. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19093. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19094. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19095. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19096. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  19097. {
  19098. continue;
  19099. }
  19100. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19101. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19102. string singleRoomFeeStr = string.Empty,
  19103. doubleRoomFeeStr = string.Empty,
  19104. suiteRoomFeeStr = string.Empty,
  19105. otherRoomFeeStr = string.Empty,
  19106. payMoneyStr = string.Empty,
  19107. cardPriceStr = string.Empty;
  19108. if (roomCurr.Equals("CNY"))
  19109. {
  19110. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19111. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19112. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19113. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19114. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19115. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19116. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19117. }
  19118. else
  19119. {
  19120. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19121. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19122. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19123. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19124. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19125. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19126. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19127. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19128. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19129. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19130. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19131. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19132. if (ccpPaymentCurrency.Equals("CNY"))
  19133. {
  19134. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19135. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19136. }
  19137. else
  19138. {
  19139. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19140. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19141. }
  19142. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19143. if (hotelcardPriceCurrency.Equals("CNY"))
  19144. {
  19145. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19146. }
  19147. else
  19148. {
  19149. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19150. }
  19151. }
  19152. string breakfastPriceStr = string.Empty,
  19153. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19154. governmentRentStr = string.Empty,
  19155. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19156. cityTaxStr = string.Empty,
  19157. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19158. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  19159. if (!string.IsNullOrEmpty(breakfastCurrency1))
  19160. {
  19161. if (breakfastCurrency1.Equals("CNY"))
  19162. {
  19163. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19164. }
  19165. else
  19166. {
  19167. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  19168. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  19169. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  19170. }
  19171. }
  19172. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19173. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  19174. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  19175. {
  19176. if (governmentRentCurrency.Equals("CNY"))
  19177. {
  19178. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19179. }
  19180. else
  19181. {
  19182. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  19183. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  19184. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  19185. }
  19186. }
  19187. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19188. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  19189. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  19190. {
  19191. if (cityTaxStrCurrency1.Equals("CNY"))
  19192. {
  19193. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19194. }
  19195. else
  19196. {
  19197. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  19198. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  19199. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  19200. }
  19201. }
  19202. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19203. int payDId = roomInfo?.PayDId ?? 0;
  19204. pcfds.Add(new HotelReservations_PCFD_View()
  19205. {
  19206. City = item.City,
  19207. HotelName = item.HotelName,
  19208. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19209. // SingleRoomCount = item.SingleRoomCount,
  19210. SingleRoomPrice = singleRoomFeeStr,
  19211. // DoubleRoomCount = item.DoubleRoomCount,
  19212. DoubleRoomPrice = doubleRoomFeeStr,
  19213. //SuiteRoomCount = item.SuiteRoomCount,
  19214. SuiteRoomPrice = suiteRoomFeeStr,
  19215. OtherRoomPrice = otherRoomFeeStr,
  19216. //OtherRoomCount = item.OtherRoomCount,
  19217. BreakfastPrice = breakfastPriceStr,
  19218. GovernmentRent = governmentRentStr,
  19219. CityTax = cityTaxStr,
  19220. RoomExplanation = item.RoomExplanation,
  19221. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19222. PayTime = roomInfo?.ConsumptionDate,
  19223. BankNo = roomInfo?.BankNo,
  19224. PayMoney = payMoneyStr,
  19225. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19226. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19227. CardPrice = cardPriceStr,
  19228. Remark = ccpInfo.Remark
  19229. });
  19230. }
  19231. #endregion
  19232. //载入模板
  19233. WorkbookDesigner designer = new WorkbookDesigner();
  19234. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19235. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19236. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19237. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19238. var rateDatas1 = rateDatas.Distinct();
  19239. var rateStr = string.Empty;
  19240. foreach (var item in rateDatas1)
  19241. {
  19242. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19243. }
  19244. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19245. designer.SetDataSource("Opertor", userInfo.CnName);
  19246. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19247. dt.TableName = "ViewMyHotelReservations";
  19248. designer.SetDataSource(dt);
  19249. designer.Process();
  19250. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19251. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19252. designer.Workbook.Save(serverPath);
  19253. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19254. #region 删除指定行
  19255. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19256. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19257. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19258. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19259. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19260. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19261. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19262. cssIndex = dt.Columns["CityTax"].Ordinal,
  19263. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19264. remarkIndex = dt.Columns["Remark"].Ordinal;
  19265. //删除指定列
  19266. foreach (DataRow item in dt.Rows)
  19267. {
  19268. string singleStr = item["SingleRoomPrice"].ToString();
  19269. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19270. if (containsDigitButNotZero1) singleDel = false;
  19271. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19272. string doubleStr = item["DoubleRoomPrice"].ToString();
  19273. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19274. if (containsDigitButNotZero2) doubleDel = false;
  19275. string suiteStr = item["SuiteRoomPrice"].ToString();
  19276. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19277. if (containsDigitButNotZero3) suiteDel = false;
  19278. string otherStr = item["OtherRoomPrice"].ToString();
  19279. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19280. if (containsDigitButNotZero4) otherDel = false;
  19281. string zcStr = item["BreakfastPrice"].ToString();
  19282. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19283. if (containsDigitButNotZero5) zcDel = false;
  19284. string dsStr = item["GovernmentRent"].ToString();
  19285. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19286. if (containsDigitButNotZero6) dsDel = false;
  19287. string cssStr = item["CityTax"].ToString();
  19288. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19289. if (containsDigitButNotZero7) cssDel = false;
  19290. string cpStr = item["ConsumptionPatterns"].ToString();
  19291. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19292. string remarkStr = item["Remark"].ToString();
  19293. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19294. }
  19295. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19296. DeleteColumn(serverPath, cpIndex, cpDel);
  19297. DeleteColumn(serverPath, dsIndex, dsDel);
  19298. DeleteColumn(serverPath, cssIndex, cssDel);
  19299. DeleteColumn(serverPath, zcIndex, zcDel);
  19300. DeleteColumn(serverPath, otherIndex, otherDel);
  19301. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19302. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19303. DeleteColumn(serverPath, singleIndex, singleDel);
  19304. #endregion
  19305. //只保留第一个表格
  19306. DeleteSheet(serverPath);
  19307. return Ok(JsonView(true, "操作成功", url = rst));
  19308. }
  19309. else
  19310. {
  19311. _currency = _GroupCostParameter.Currency;
  19312. bool isIntType = int.TryParse(_currency, out int currId);
  19313. if (isIntType)
  19314. {
  19315. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19316. }
  19317. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19318. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19319. if (currInfo == null)
  19320. {
  19321. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19322. }
  19323. if (!_currency.ToUpper().Equals("CNY"))
  19324. {
  19325. _rate = _GroupCostParameter.Rate;
  19326. }
  19327. _rate = currInfo.Rate;
  19328. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19329. //string strFileName = "HotelStatement/";
  19330. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19331. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19332. #region 数据处理
  19333. foreach (var item in hrDtas)
  19334. {
  19335. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19336. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19337. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19338. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19339. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19340. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19341. string singleRoomFeeStr = string.Empty,
  19342. doubleRoomFeeStr = string.Empty,
  19343. suiteRoomFeeStr = string.Empty,
  19344. otherRoomFeeStr = string.Empty,
  19345. payMoneyStr = string.Empty,
  19346. cardPriceStr = string.Empty;
  19347. if (roomCurr.Equals(_currency))
  19348. {
  19349. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  19350. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  19351. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  19352. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  19353. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  19354. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  19355. }
  19356. else
  19357. {
  19358. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19359. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19360. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19361. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19362. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19363. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19364. }
  19365. string breakfastPriceStr = string.Empty,
  19366. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19367. governmentRentStr = string.Empty,
  19368. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19369. cityTaxStrStr = string.Empty,
  19370. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19371. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  19372. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  19373. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  19374. int payDId = roomInfo?.PayDId ?? 0;
  19375. pcfds.Add(new HotelReservations_PCFD_View()
  19376. {
  19377. City = item.City,
  19378. HotelName = item.HotelName,
  19379. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19380. // SingleRoomCount = item.SingleRoomCount,
  19381. SingleRoomPrice = singleRoomFeeStr,
  19382. // DoubleRoomCount = item.DoubleRoomCount,
  19383. DoubleRoomPrice = doubleRoomFeeStr,
  19384. //SuiteRoomCount = item.SuiteRoomCount,
  19385. SuiteRoomPrice = suiteRoomFeeStr,
  19386. OtherRoomPrice = otherRoomFeeStr,
  19387. //OtherRoomCount = item.OtherRoomCount,
  19388. BreakfastPrice = breakfastPriceStr,
  19389. GovernmentRent = governmentRentStr,
  19390. CityTax = cityTaxStrStr,
  19391. RoomExplanation = item.RoomExplanation,
  19392. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19393. PayTime = roomInfo?.ConsumptionDate,
  19394. BankNo = roomInfo?.BankNo,
  19395. PayMoney = payMoneyStr,
  19396. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19397. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19398. CardPrice = cardPriceStr,
  19399. Remark = ccpInfo.Remark
  19400. });
  19401. }
  19402. #endregion
  19403. //载入模板
  19404. WorkbookDesigner designer = new WorkbookDesigner();
  19405. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19406. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19407. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19408. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19409. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  19410. designer.SetDataSource("Opertor", userInfo.CnName);
  19411. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19412. dt.TableName = "ViewMyHotelReservations";
  19413. designer.SetDataSource(dt);
  19414. designer.Process();
  19415. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19416. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19417. designer.Workbook.Save(serverPath);
  19418. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19419. #region 删除指定行
  19420. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19421. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19422. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19423. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19424. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19425. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19426. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19427. cssIndex = dt.Columns["CityTax"].Ordinal,
  19428. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19429. remarkIndex = dt.Columns["Remark"].Ordinal;
  19430. //删除指定列
  19431. foreach (DataRow item in dt.Rows)
  19432. {
  19433. string singleStr = item["SingleRoomPrice"].ToString();
  19434. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19435. if (containsDigitButNotZero1) singleDel = false;
  19436. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19437. string doubleStr = item["DoubleRoomPrice"].ToString();
  19438. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19439. if (containsDigitButNotZero2) doubleDel = false;
  19440. string suiteStr = item["SuiteRoomPrice"].ToString();
  19441. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19442. if (containsDigitButNotZero3) suiteDel = false;
  19443. string otherStr = item["OtherRoomPrice"].ToString();
  19444. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19445. if (containsDigitButNotZero4) otherDel = false;
  19446. string zcStr = item["BreakfastPrice"].ToString();
  19447. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19448. if (containsDigitButNotZero5) zcDel = false;
  19449. string dsStr = item["GovernmentRent"].ToString();
  19450. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19451. if (containsDigitButNotZero6) dsDel = false;
  19452. string cssStr = item["CityTax"].ToString();
  19453. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19454. if (containsDigitButNotZero7) cssDel = false;
  19455. string cpStr = item["ConsumptionPatterns"].ToString();
  19456. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19457. string remarkStr = item["Remark"].ToString();
  19458. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19459. }
  19460. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19461. DeleteColumn(serverPath, cpIndex, cpDel);
  19462. DeleteColumn(serverPath, dsIndex, dsDel);
  19463. DeleteColumn(serverPath, cssIndex, cssDel);
  19464. DeleteColumn(serverPath, zcIndex, zcDel);
  19465. DeleteColumn(serverPath, otherIndex, otherDel);
  19466. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19467. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19468. DeleteColumn(serverPath, singleIndex, singleDel);
  19469. #endregion
  19470. //只保留第一个表格
  19471. DeleteSheet(serverPath);
  19472. return Ok(JsonView(true, "操作成功", url = rst));
  19473. }
  19474. //return Ok(JsonView(false));
  19475. }
  19476. /// <summary>
  19477. /// 删除指定列
  19478. /// </summary>
  19479. /// <param name="file"></param>
  19480. /// <param name="columnIndex"></param>
  19481. /// <param name="isDel"></param>
  19482. private void DeleteColumn(string file, int columnIndex, bool isDel)
  19483. {
  19484. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19485. //wb.Save(file);
  19486. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  19487. if (sheet1 != null)
  19488. {
  19489. if (isDel)
  19490. {
  19491. Cells cells = sheet1.Cells;
  19492. cells.DeleteColumn(columnIndex);
  19493. }
  19494. }
  19495. wb.Save(file);
  19496. }
  19497. /// <summary>
  19498. /// 删除sheet
  19499. /// </summary>
  19500. /// <param name="file"></param>
  19501. private void DeleteSheet(string file)
  19502. {
  19503. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19504. //wb.Save(file);
  19505. List<string> sheets = new List<string>();
  19506. foreach (var item in wb.Worksheets)
  19507. {
  19508. sheets.Add(item.Name);
  19509. }
  19510. if (sheets.Count > 0)
  19511. {
  19512. sheets.RemoveAt(0);//不删除第一个sheet
  19513. foreach (var item in sheets)
  19514. {
  19515. wb.Worksheets.RemoveAt(item);
  19516. }
  19517. }
  19518. wb.Save(file);
  19519. }
  19520. /// <summary>
  19521. /// 酒店预订
  19522. /// 确认单
  19523. /// </summary>
  19524. /// <param name="_dto"></param>
  19525. /// <returns></returns>
  19526. [HttpPost]
  19527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19528. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  19529. {
  19530. try
  19531. {
  19532. #region 参数验证
  19533. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19534. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19535. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19536. #region 团组操作权限验证 76 酒店预定模块
  19537. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19538. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19539. #endregion
  19540. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19541. #region 页面操作权限验证
  19542. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19543. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19544. #endregion
  19545. #endregion
  19546. //团组信息
  19547. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  19548. //酒店数据
  19549. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  19550. if (listhoteldata.Count < 0)
  19551. {
  19552. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  19553. }
  19554. //利datatable存储
  19555. DataTable dt = new DataTable();
  19556. dt.Columns.Add("CheckInDate", typeof(string));
  19557. dt.Columns.Add("City", typeof(string));
  19558. dt.Columns.Add("Hotel", typeof(string));
  19559. dt.Columns.Add("Room", typeof(string));
  19560. for (int i = 0; i < listhoteldata.Count; i++)
  19561. {
  19562. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  19563. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  19564. while (dayStart < dayEnd)
  19565. {
  19566. string temp = "";
  19567. DataRow row = dt.NewRow();
  19568. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  19569. row["City"] = listhoteldata[i].City;
  19570. row["Hotel"] = listhoteldata[i].HotelName;
  19571. if (listhoteldata[i].SingleRoomCount > 0)
  19572. {
  19573. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  19574. }
  19575. if (listhoteldata[i].DoubleRoomCount > 0)
  19576. {
  19577. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  19578. }
  19579. if (listhoteldata[i].SuiteRoomCount > 0)
  19580. {
  19581. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  19582. }
  19583. if (listhoteldata[i].OtherRoomCount > 0)
  19584. {
  19585. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  19586. }
  19587. row["Room"] = temp;
  19588. dt.Rows.Add(row);
  19589. dayStart = dayStart.AddDays(1);
  19590. }
  19591. }
  19592. Dictionary<string, string> dic = new Dictionary<string, string>();
  19593. dic.Add("Dele", di.TeamName);
  19594. dic.Add("City", di.VisitCountry);
  19595. //模板路径
  19596. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  19597. //载入模板
  19598. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  19599. DocumentBuilder builder = new DocumentBuilder(doc);
  19600. foreach (var key in dic.Keys)
  19601. {
  19602. builder.MoveToBookmark(key);
  19603. builder.Write(dic[key]);
  19604. }
  19605. //获取word里所有表格
  19606. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19607. //获取所填表格的序数
  19608. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19609. var rowStart = tableOne.Rows[0]; //获取第1行
  19610. //循环赋值
  19611. for (int i = 0; i < dt.Rows.Count; i++)
  19612. {
  19613. builder.MoveToCell(0, i + 1, 0, 0);
  19614. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  19615. builder.MoveToCell(0, i + 1, 1, 0);
  19616. builder.Write(dt.Rows[i]["City"].ToString());
  19617. builder.MoveToCell(0, i + 1, 2, 0);
  19618. builder.Write(dt.Rows[i]["Hotel"].ToString());
  19619. builder.MoveToCell(0, i + 1, 3, 0);
  19620. builder.Write(dt.Rows[i]["Room"].ToString());
  19621. }
  19622. //删除多余行
  19623. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  19624. {
  19625. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  19626. }
  19627. string strFileName = di.TeamName + "酒店确认单.doc";
  19628. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  19629. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  19630. return Ok(JsonView(true, "成功", url));
  19631. }
  19632. catch (Exception ex)
  19633. {
  19634. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  19635. }
  19636. }
  19637. #endregion
  19638. #region 团组状态
  19639. /// <summary>
  19640. /// 团组状态列表 Page
  19641. /// </summary>
  19642. /// <param name="dto">团组列表请求dto</param>
  19643. /// <returns></returns>
  19644. [HttpPost]
  19645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19646. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  19647. {
  19648. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19649. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  19650. {
  19651. string sqlWhere = string.Empty;
  19652. if (dto.IsSure == 0) //未完成
  19653. {
  19654. sqlWhere += string.Format(@" And IsSure = 0");
  19655. }
  19656. else if (dto.IsSure == 1) //已完成
  19657. {
  19658. sqlWhere += string.Format(@" And IsSure = 1");
  19659. }
  19660. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  19661. {
  19662. string tj = dto.SearchCriteria;
  19663. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  19664. tj, tj, tj, tj, tj);
  19665. }
  19666. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19667. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19668. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19669. From (
  19670. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19671. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19672. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19673. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19674. From Grp_DelegationInfo gdi
  19675. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19676. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19677. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19678. Where gdi.IsDel = 0 {0}
  19679. ) temp ", sqlWhere);
  19680. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19681. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19682. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19683. }
  19684. else
  19685. {
  19686. return Ok(JsonView(false, "查询失败"));
  19687. }
  19688. }
  19689. /// <summary>
  19690. /// 团组状态
  19691. /// 设置操作完成
  19692. /// </summary>
  19693. /// <param name="dto">团组列表请求dto</param>
  19694. /// <returns></returns>
  19695. [HttpPost]
  19696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19697. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19698. {
  19699. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19700. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19701. {
  19702. Id = dto.Id,
  19703. IsSure = 1
  19704. };
  19705. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19706. .UpdateColumns(it => new { it.IsSure })
  19707. .WhereColumns(it => new { it.Id })
  19708. .ExecuteCommandAsync();
  19709. if (result > 0)
  19710. {
  19711. return Ok(JsonView(true, "操作完成!"));
  19712. }
  19713. return Ok(JsonView(false, "操作失败!"));
  19714. }
  19715. #endregion
  19716. #region 保险费用录入
  19717. /// <summary>
  19718. /// 根据团组Id查询保险费用列表
  19719. /// </summary>
  19720. /// <param name="dto"></param>
  19721. /// <returns></returns>
  19722. [HttpPost]
  19723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19724. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19725. {
  19726. Result groupData = await _customersRep.CustomersByDiId(dto);
  19727. if (groupData.Code != 0)
  19728. {
  19729. return Ok(JsonView(false, groupData.Msg));
  19730. }
  19731. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19732. }
  19733. /// <summary>
  19734. /// 根据保险费用Id查询保险费用详细
  19735. /// </summary>
  19736. /// <param name="dto"></param>
  19737. /// <returns></returns>
  19738. [HttpPost]
  19739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19740. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19741. {
  19742. try
  19743. {
  19744. Result groupData = await _customersRep.CustomersById(dto);
  19745. if (groupData.Code != 0)
  19746. {
  19747. return Ok(JsonView(false, groupData.Msg));
  19748. }
  19749. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19750. }
  19751. catch (Exception ex)
  19752. {
  19753. return Ok(JsonView(false, ex.Message));
  19754. }
  19755. }
  19756. /// <summary>
  19757. /// 保险费用录入页面初始化绑定
  19758. /// </summary>
  19759. /// <param name="dto"></param>
  19760. /// <returns></returns>
  19761. [HttpPost]
  19762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19763. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19764. {
  19765. try
  19766. {
  19767. Result groupData = await _customersRep.CustomersInitialize(dto);
  19768. if (groupData.Code != 0)
  19769. {
  19770. return Ok(JsonView(false, groupData.Msg));
  19771. }
  19772. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19773. }
  19774. catch (Exception ex)
  19775. {
  19776. return Ok(JsonView(false, ex.Message));
  19777. }
  19778. }
  19779. /// <summary>
  19780. /// 保险费用操作(Status:1.新增,2.修改)
  19781. /// </summary>
  19782. /// <param name="dto"></param>
  19783. /// <returns></returns>
  19784. [HttpPost]
  19785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19786. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19787. {
  19788. Result groupData = await _customersRep.OpCustomers(dto);
  19789. if (groupData.Code != 0)
  19790. {
  19791. return Ok(JsonView(false, groupData.Msg));
  19792. }
  19793. #region 应用推送
  19794. try
  19795. {
  19796. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19797. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19798. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19799. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19800. //自动审核
  19801. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19802. //2024-10-21 新增LZ UID
  19803. var userIds = new List<int>() { 21 };
  19804. string title = $"系统通知";
  19805. var diId = dto.DiId;
  19806. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19807. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19808. string content = "";
  19809. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19810. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19811. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19812. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19813. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19814. }
  19815. catch (Exception ex)
  19816. {
  19817. }
  19818. #endregion
  19819. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19820. }
  19821. /// <summary>
  19822. /// 保险文件上传
  19823. /// </summary>
  19824. /// <param name="file"></param>
  19825. /// <returns></returns>
  19826. [HttpPost]
  19827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19828. public async Task<IActionResult> UploadCus(IFormFile file)
  19829. {
  19830. try
  19831. {
  19832. if (file != null)
  19833. {
  19834. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19835. //文件名称
  19836. string projectFileName = file.FileName;
  19837. //上传的文件的路径
  19838. string filePath = "";
  19839. if (!Directory.Exists(fileDir))
  19840. {
  19841. Directory.CreateDirectory(fileDir);
  19842. }
  19843. //上传的文件的路径
  19844. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19845. using (FileStream fs = System.IO.File.Create(filePath))
  19846. {
  19847. file.CopyTo(fs);
  19848. fs.Flush();
  19849. }
  19850. return Ok(JsonView(true, "上传成功!", projectFileName));
  19851. }
  19852. else
  19853. {
  19854. return Ok(JsonView(false, "上传失败!"));
  19855. }
  19856. }
  19857. catch (Exception ex)
  19858. {
  19859. return Ok(JsonView(false, ex.Message));
  19860. }
  19861. }
  19862. /// <summary>
  19863. /// 保险删除指定文件
  19864. /// </summary>
  19865. /// <param name="dto"></param>
  19866. /// <returns></returns>
  19867. [HttpPost]
  19868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19869. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19870. {
  19871. try
  19872. {
  19873. string filePath = "";
  19874. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19875. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19876. //int id = 0;
  19877. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19878. // 删除该文件
  19879. try
  19880. {
  19881. System.IO.File.Delete(filePath);
  19882. var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
  19883. {
  19884. Attachment = "",
  19885. }).ExecuteCommandAsync();
  19886. if (result != 0)
  19887. {
  19888. return Ok(JsonView(true, "成功!"));
  19889. }
  19890. else
  19891. {
  19892. return Ok(JsonView(false, "失败!"));
  19893. }
  19894. }
  19895. catch (Exception)
  19896. {
  19897. var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
  19898. {
  19899. Attachment = "",
  19900. }).ExecuteCommandAsync();
  19901. if (result != 0)
  19902. {
  19903. return Ok(JsonView(true, "成功!"));
  19904. }
  19905. else
  19906. {
  19907. return Ok(JsonView(false, "失败!"));
  19908. }
  19909. }
  19910. }
  19911. catch (Exception ex)
  19912. {
  19913. return Ok(JsonView(false, "程序错误!"));
  19914. throw;
  19915. }
  19916. }
  19917. /// <summary>
  19918. /// 保险费用操作(删除)
  19919. /// </summary>
  19920. /// <param name="dto"></param>
  19921. /// <returns></returns>
  19922. [HttpPost]
  19923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19924. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19925. {
  19926. try
  19927. {
  19928. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19929. if (!res)
  19930. {
  19931. return Ok(JsonView(false, "删除失败"));
  19932. }
  19933. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19934. {
  19935. IsDel = 1,
  19936. DeleteUserId = dto.DeleteUserId,
  19937. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19938. }).ExecuteCommandAsync();
  19939. return Ok(JsonView(true, "删除成功!"));
  19940. }
  19941. catch (Exception ex)
  19942. {
  19943. return Ok(JsonView(false, "程序错误!"));
  19944. throw;
  19945. }
  19946. }
  19947. #endregion
  19948. #region 接团客户名单 PageId 104
  19949. /// <summary>
  19950. /// 接团客户名单
  19951. /// 迁移数据(慎用!)
  19952. /// </summary>
  19953. /// <returns></returns>
  19954. [HttpPost]
  19955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19956. public async Task<IActionResult> PostTourClientListChange()
  19957. {
  19958. try
  19959. {
  19960. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19961. //var groupClinetData1
  19962. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19963. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19964. int updateCount = 0;
  19965. if (oldOAClientList.Count > 0)
  19966. {
  19967. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19968. _sqlSugar.BeginTran();
  19969. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19970. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19971. foreach (var item in oldOAClientList)
  19972. {
  19973. int comId = 0;
  19974. string format = "yyyy-MM-dd HH:mm:ss";
  19975. string data11 = "1990-01-01 00:00";
  19976. var data1 = IsValidDate(item.OPdate, format);
  19977. if (data1) data11 = item.OPdate;
  19978. //客户公司验证
  19979. if (!string.IsNullOrEmpty(item.Company))
  19980. {
  19981. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19982. if (clientComInfo == null) // add
  19983. {
  19984. var addInfo = new Crm_CustomerCompany()
  19985. {
  19986. CompanyAbbreviation = "",
  19987. CompanyFullName = item.Company,
  19988. Address = "",
  19989. PostCodes = "",
  19990. LastedOpUserId = item.OPer,
  19991. LastedOpDt = Convert.ToDateTime(data11),
  19992. CreateUserId = item.OPer,
  19993. CreateTime = Convert.ToDateTime(data11),
  19994. IsDel = 0
  19995. };
  19996. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19997. if (comId1 > 0) comId = comId1;
  19998. }
  19999. else comId = clientComInfo.Id;
  20000. }
  20001. //客户人员验证
  20002. int clientId = 0;
  20003. string name = item.LastName + item.Name;
  20004. if (!string.IsNullOrEmpty(name))
  20005. {
  20006. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  20007. if (clientInfo == null)
  20008. {
  20009. DateTime? dateTime = null;
  20010. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  20011. if (isDt) dateTime = birthDayDt;
  20012. var addInfo1 = new Crm_DeleClient()
  20013. {
  20014. CrmCompanyId = comId,
  20015. DiId = -1,
  20016. LastName = item.LastName,
  20017. FirstName = item.Name,
  20018. OldName = "",
  20019. Pinyin = item.Pinyin,
  20020. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  20021. Marriage = 0,
  20022. Phone = item.Phone,
  20023. Job = item.Job,
  20024. BirthDay = dateTime
  20025. };
  20026. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  20027. if (clientId1 > 0) clientId = clientId1;
  20028. }
  20029. else clientId = clientInfo.Id;
  20030. }
  20031. if (clientId < 1)
  20032. {
  20033. continue;
  20034. }
  20035. int airType = 0;
  20036. if (item.AirType == "超经舱") airType = 459;
  20037. else if (item.AirType == "公务舱") airType = 458;
  20038. else if (item.AirType == "经济舱") airType = 460;
  20039. else if (item.AirType == "其他") airType = 565;
  20040. else if (item.AirType == "头等舱") airType = 457;
  20041. var _TourClientListEntity = new Grp_TourClientList()
  20042. {
  20043. DiId = item.Diid,
  20044. ClientId = clientId,
  20045. CreateUserId = item.OPer,
  20046. CreateTime = Convert.ToDateTime(data11),
  20047. Remark = item.Remark,
  20048. IsDel = item.Isdel,
  20049. ShippingSpaceTypeId = airType,
  20050. ShippingSpaceSpecialNeeds = item.AirRemark,
  20051. HotelSpecialNeeds = item.RoomType
  20052. };
  20053. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  20054. if (_TourClientList > 0)
  20055. {
  20056. updateCount++;
  20057. }
  20058. }
  20059. _sqlSugar.CommitTran();
  20060. }
  20061. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  20062. }
  20063. catch (Exception ex)
  20064. {
  20065. _sqlSugar.RollbackTran();
  20066. return Ok(JsonView(false, ex.Message));
  20067. }
  20068. //return Ok(JsonView(true));
  20069. }
  20070. private bool IsValidDate(string dateString, string format)
  20071. {
  20072. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  20073. }
  20074. /// <summary>
  20075. /// 接团客户名单
  20076. /// 根据团组Id查询List
  20077. /// </summary>
  20078. /// <param name="_dto"></param>
  20079. /// <returns></returns>
  20080. [HttpPost]
  20081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20082. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  20083. {
  20084. #region 参数验证
  20085. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  20086. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  20087. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  20088. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20089. #region 页面操作权限验证
  20090. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20091. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20092. #endregion
  20093. #endregion
  20094. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  20095. if (viewData.Code != 0)
  20096. {
  20097. return Ok(JsonView(false, viewData.Msg));
  20098. }
  20099. return Ok(JsonView(viewData.Data));
  20100. }
  20101. /// <summary>
  20102. /// 接团客户名单
  20103. /// 基础数据 Init
  20104. /// </summary>
  20105. /// <param name="_dto"></param>
  20106. /// <returns></returns>
  20107. [HttpPost]
  20108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20109. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20110. {
  20111. #region 参数验证
  20112. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20113. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20114. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20115. #region 页面操作权限验证
  20116. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20117. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20118. #endregion
  20119. #endregion
  20120. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20121. }
  20122. /// <summary>
  20123. /// 接团客户名单
  20124. /// 根据 Id查询 Details
  20125. /// </summary>
  20126. /// <param name="_dto"></param>
  20127. /// <returns></returns>
  20128. [HttpPost]
  20129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20130. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20131. {
  20132. #region 参数验证
  20133. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20134. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20135. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20136. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20137. #region 页面操作权限验证
  20138. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20139. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20140. #endregion
  20141. #endregion
  20142. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20143. if (viewData.Code != 0)
  20144. {
  20145. return Ok(JsonView(false, viewData.Msg));
  20146. }
  20147. return Ok(JsonView(viewData.Data));
  20148. }
  20149. /// <summary>
  20150. /// 接团客户名单
  20151. /// Add Or Edit
  20152. /// </summary>
  20153. /// <param name="_dto"></param>
  20154. /// <returns></returns>
  20155. [HttpPost]
  20156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20157. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  20158. {
  20159. #region 参数验证
  20160. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20161. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20162. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20163. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20164. #region 页面操作权限验证
  20165. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20166. if (_dto.Id == 0) //添加
  20167. {
  20168. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20169. }
  20170. else if (_dto.Id >= 0) //修改
  20171. {
  20172. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20173. }
  20174. #endregion
  20175. #endregion
  20176. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  20177. if (viewData.Code != 0)
  20178. {
  20179. return Ok(JsonView(false, viewData.Msg));
  20180. }
  20181. return Ok(JsonView(true));
  20182. }
  20183. /// <summary>
  20184. /// 接团客户名单
  20185. /// json字符串 AddMultiple(添加多个)
  20186. /// </summary>
  20187. /// <param name="_dto"></param>
  20188. /// <returns></returns>
  20189. [HttpPost]
  20190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20191. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  20192. {
  20193. #region 参数验证
  20194. string jsonLabel = _dto.JsonLabel;
  20195. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20196. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20197. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20198. #region 页面操作权限验证
  20199. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20200. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20201. #endregion
  20202. #endregion
  20203. var request = new TourClientListAddMultipleDto();
  20204. request.DiId = _dto.DiId;
  20205. request.UserId = _dto.UserId;
  20206. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  20207. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  20208. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  20209. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  20210. var infos = new List<TourClientListInfo>();
  20211. foreach (var data in datas)
  20212. {
  20213. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  20214. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  20215. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  20216. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  20217. {
  20218. continue;
  20219. }
  20220. infos.Add(new TourClientListInfo()
  20221. {
  20222. IsAccompany = 1,
  20223. LastName = lastName,
  20224. FirstName = firstName,
  20225. Pinyin = lastNameEn + @"/" + firstNameEn,
  20226. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20227. CompanyFullName = data.CompanyFullName,
  20228. Job = data.Job
  20229. });
  20230. }
  20231. if (infos.Any())
  20232. {
  20233. var viewData = await _tourClientListRep._AddMultiple(request);
  20234. if (viewData.Code != 0)
  20235. {
  20236. return Ok(JsonView(false, viewData.Msg));
  20237. }
  20238. return Ok(JsonView(true));
  20239. }
  20240. return Ok(JsonView(false));
  20241. }
  20242. /// <summary>
  20243. /// 接团客户名单
  20244. /// AddMultiple(添加多个)
  20245. /// </summary>
  20246. /// <param name="_dto"></param>
  20247. /// <returns></returns>
  20248. [HttpPost]
  20249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20250. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20251. {
  20252. #region 参数验证
  20253. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20254. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20255. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20256. #region 页面操作权限验证
  20257. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20258. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20259. #endregion
  20260. #endregion
  20261. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20262. if (viewData.Code != 0)
  20263. {
  20264. return Ok(JsonView(false, viewData.Msg));
  20265. }
  20266. return Ok(JsonView(true));
  20267. }
  20268. /// <summary>
  20269. /// 接团客户名单
  20270. /// Del
  20271. /// </summary>
  20272. /// <param name="_dto"></param>
  20273. /// <returns></returns>
  20274. [HttpPost]
  20275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20276. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20277. {
  20278. #region 参数验证
  20279. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20280. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20281. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20282. #region 页面操作权限验证
  20283. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20284. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20285. #endregion
  20286. #endregion
  20287. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20288. if (viewData.Code != 0)
  20289. {
  20290. return Ok(JsonView(false, viewData.Msg));
  20291. }
  20292. return Ok(JsonView(true));
  20293. }
  20294. /// <summary>
  20295. /// 接团客户名单
  20296. /// 文件下载 客户名单
  20297. /// </summary>
  20298. /// <param name="_dto"></param>
  20299. /// <returns></returns>
  20300. [HttpPost]
  20301. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20302. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20303. {
  20304. #region 参数验证
  20305. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20306. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20307. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20308. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20309. #region 页面操作权限验证
  20310. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20311. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20312. #endregion
  20313. #endregion
  20314. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20315. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20316. From Grp_TourClientList tcl
  20317. Left Join
  20318. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20319. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20320. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20321. From Crm_DeleClient dc
  20322. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20323. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20324. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20325. Where dc.IsDel = 0) temp
  20326. On temp.DcId =tcl.ClientId
  20327. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20328. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20329. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20330. //载入模板
  20331. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20332. if (_dto.Language == 1)
  20333. {
  20334. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20335. }
  20336. //载入模板
  20337. var doc = new Document(tempPath);
  20338. DocumentBuilder builder = new DocumentBuilder(doc);
  20339. //获取word里所有表格
  20340. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20341. //获取所填表格的序数
  20342. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20343. var rowStart = tableOne.Rows[0]; //获取第1行
  20344. if (_dto.Language == 0)
  20345. {
  20346. //循环赋值
  20347. for (int i = 0; i < DcList.Count; i++)
  20348. {
  20349. EncryptionProcessor.DecryptProperties(DcList[i]);
  20350. builder.MoveToCell(0, i + 1, 0, 0);
  20351. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  20352. builder.MoveToCell(0, i + 1, 1, 0);
  20353. int sex = DcList[i].Sex;
  20354. string sexStr = string.Empty;
  20355. if (sex == 0) sexStr = "男";
  20356. else if (sex == 1) sexStr = "女";
  20357. else sexStr = "未设置";
  20358. builder.Write(sexStr);
  20359. builder.MoveToCell(0, i + 1, 2, 0);
  20360. string birthDay = DcList[i].BirthDay;
  20361. string birthDayStr = string.Empty;
  20362. if (!string.IsNullOrEmpty(birthDay))
  20363. {
  20364. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  20365. }
  20366. builder.Write(birthDayStr);
  20367. builder.MoveToCell(0, i + 1, 3, 0);
  20368. string company = "";
  20369. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20370. {
  20371. company = DcList[i].CompanyFullName.ToString();
  20372. }
  20373. builder.Write(company);
  20374. builder.MoveToCell(0, i + 1, 4, 0);
  20375. builder.Write(DcList[i].Job);
  20376. }
  20377. }
  20378. else if (_dto.Language == 1)
  20379. {
  20380. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  20381. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  20382. List<string> transArrayStr = new List<string>();
  20383. string transStrRes1 = "";
  20384. for (int i = 0; i < DcList.Count; i++)
  20385. {
  20386. var dc = DcList[i];
  20387. EncryptionProcessor.DecryptProperties(dc);
  20388. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  20389. if (dc.Job.Equals("暂无")) dc.Job = "-";
  20390. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  20391. if (DcList.Count - 1 == i) transStrRes1 += str1;
  20392. else transStrRes1 += $"{str1}|";
  20393. }
  20394. #region AI转英文
  20395. string jsonValue = JsonConvert.SerializeObject(DcList);
  20396. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  20397. List<SeedMessages> messages = new List<SeedMessages>()
  20398. {
  20399. new SeedMessages
  20400. {
  20401. Role = KimiRole.user,
  20402. Content = jsonValue + text
  20403. }
  20404. };
  20405. KiMiApiClient client = new KiMiApiClient();
  20406. var kimiApiResult = await client.SeedMessage(messages);
  20407. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20408. string clients = kimiApiResult_JObject["content"].ToString();
  20409. string startStr = "```json", endStr = "```";
  20410. // 判断并清除开头部分
  20411. if (clients.StartsWith(startStr))
  20412. {
  20413. clients = clients.Remove(0, startStr.Length);
  20414. }
  20415. // 判断并清除结尾部分
  20416. if (clients.EndsWith(endStr))
  20417. {
  20418. clients = clients.Remove(clients.Length - endStr.Length);
  20419. }
  20420. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  20421. //循环赋值
  20422. for (int i = 0; i < en_Json.Count; i++)
  20423. {
  20424. var dc = en_Json[i];
  20425. var dc1 = DcList.Find(x => x.Id == dc.Id);
  20426. string PYName = dc.FirstName + " " + dc.LastName;
  20427. builder.MoveToCell(0, i + 1, 0, 0);
  20428. builder.Write(PYName);
  20429. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  20430. builder.MoveToCell(0, i + 1, 1, 0);
  20431. builder.Write(sex);
  20432. DateTime birthDt;
  20433. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  20434. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20435. builder.MoveToCell(0, i + 1, 2, 0);
  20436. builder.Write(birthday);
  20437. string company = string.Empty, job = string.Empty;
  20438. company = dc.CompanyFullName;
  20439. job = dc.Job;
  20440. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  20441. {
  20442. //查询对照表
  20443. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  20444. if (tempCec != null)
  20445. {
  20446. company = tempCec.enName;
  20447. }
  20448. }
  20449. builder.MoveToCell(0, i + 1, 3, 0);
  20450. builder.Write(company);
  20451. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  20452. {
  20453. //查询对照表
  20454. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  20455. if (tempPec != null)
  20456. {
  20457. job = tempPec.enName;
  20458. }
  20459. }
  20460. builder.MoveToCell(0, i + 1, 4, 0);
  20461. builder.Write(job);
  20462. }
  20463. #endregion
  20464. #region 旧翻译英文处理
  20465. ////string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
  20466. //string transStrRes = "";
  20467. //if (transStrRes1.Length > 0)
  20468. //{
  20469. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  20470. //}
  20471. ////0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
  20472. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  20473. ////List<string> transArray = new List<string> { };
  20474. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  20475. //if (transStrRes.Contains("|"))
  20476. //{
  20477. // string[] transArray1 = transStrRes.Split('|');
  20478. // if (transArray1.Length > 0)
  20479. // {
  20480. // foreach (var item in transArray1)
  20481. // {
  20482. // if (item.Contains("&"))
  20483. // {
  20484. // string[] transArray2 = item.Split('&');
  20485. // int index = 0;
  20486. // string companyName = "", job = "";
  20487. // if (transArray2.Length > 0)
  20488. // {
  20489. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  20490. // if (1 < transArray2.Length) companyName = transArray2[1];
  20491. // if (2 < transArray2.Length) job = transArray2[2];
  20492. // }
  20493. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  20494. // }
  20495. // }
  20496. // }
  20497. //}
  20498. ////循环赋值
  20499. //for (int i = 0; i < DcList.Count; i++)
  20500. //{
  20501. // string PYName = "";
  20502. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  20503. // {
  20504. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  20505. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  20506. // PYName = PY_First + " " + PY_Last;
  20507. // }
  20508. // else
  20509. // {
  20510. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  20511. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  20512. // PYName = PY_First + " " + PY_Last;
  20513. // }
  20514. // builder.MoveToCell(0, i + 1, 0, 0);
  20515. // builder.Write(PYName);
  20516. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  20517. // builder.MoveToCell(0, i + 1, 1, 0);
  20518. // builder.Write(sex);
  20519. // DateTime birthDt;
  20520. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  20521. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20522. // builder.MoveToCell(0, i + 1, 2, 0);
  20523. // builder.Write(birthday);
  20524. // string company = string.Empty, job = string.Empty;
  20525. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  20526. // if (dcTransInfo != null)
  20527. // {
  20528. // company = dcTransInfo.CompanyName;
  20529. // job = dcTransInfo.Job;
  20530. // }
  20531. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20532. // {
  20533. // //查询对照表
  20534. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  20535. // if (tempCec != null)
  20536. // {
  20537. // company = tempCec.enName;
  20538. // }
  20539. // //翻译
  20540. // else
  20541. // {
  20542. // }
  20543. // }
  20544. // builder.MoveToCell(0, i + 1, 3, 0);
  20545. // builder.Write(company);
  20546. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  20547. // {
  20548. // //查询对照表
  20549. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  20550. // if (tempPec != null)
  20551. // {
  20552. // job = tempPec.enName;
  20553. // }
  20554. // //翻译
  20555. // else
  20556. // {
  20557. // }
  20558. // }
  20559. // builder.MoveToCell(0, i + 1, 4, 0);
  20560. // builder.Write(job);
  20561. //}
  20562. #endregion
  20563. }
  20564. //删除多余行
  20565. while (tableOne.Rows.Count > DcList.Count + 1)
  20566. {
  20567. tableOne.Rows.RemoveAt(DcList.Count + 1);
  20568. }
  20569. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  20570. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  20571. doc.Save(fileDir);
  20572. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  20573. return Ok(JsonView(true, "操作成功!", Url));
  20574. }
  20575. private class TranslateInfo
  20576. {
  20577. public int Index { get; set; }
  20578. public string CompanyName { get; set; }
  20579. public string Job { get; set; }
  20580. }
  20581. [HttpPost]
  20582. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  20583. {
  20584. if (files.Count == 0)
  20585. {
  20586. return Ok(JsonView(false, "文件为空"));
  20587. }
  20588. KiMiApiClient KiMiApi = new KiMiApiClient();
  20589. var seedConter = await KiMiApi.UploadFilesAsync(files);
  20590. if (seedConter.Count == 0)
  20591. {
  20592. return Ok(JsonView(false, "上传结果为空!"));
  20593. }
  20594. var messages = new List<SeedMessages>
  20595. {
  20596. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  20597. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  20598. };
  20599. messages.InsertRange(1, seedConter);
  20600. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  20601. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20602. string clients = kimiApiResult_JObject["content"].ToString();
  20603. string startStr = "```json", endStr = "```";
  20604. // 判断并清除开头部分
  20605. if (clients.StartsWith(startStr))
  20606. {
  20607. clients = clients.Remove(0, startStr.Length);
  20608. }
  20609. // 判断并清除结尾部分
  20610. if (clients.EndsWith(endStr))
  20611. {
  20612. clients = clients.Remove(clients.Length - endStr.Length);
  20613. }
  20614. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  20615. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  20616. {
  20617. {"姓", "LastName" },
  20618. {"名", "FirstName" },
  20619. {"姓名拼音", "Pinyin" },
  20620. {"性别", "Sex" },
  20621. {"单位", "CompanyFullName" },
  20622. {"职务", "Job" },
  20623. {"出生日期", "Birthday" },
  20624. };
  20625. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  20626. foreach (var item in clients_JObject)
  20627. {
  20628. BaiduClientOCRView cdc = new BaiduClientOCRView();
  20629. foreach (var field in clientFieldMap.Keys)
  20630. {
  20631. if (item.TryGetValue(field, out JToken value))
  20632. {
  20633. var getValue = value.ToString();
  20634. System.Type type = cdc.GetType();
  20635. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  20636. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  20637. propertyInfo.SetValue(cdc, propertyValue);
  20638. }
  20639. }
  20640. crmClients.Add(cdc);
  20641. }
  20642. return Ok(JsonView(new
  20643. {
  20644. fileCount = files.Count,
  20645. UploadCount = seedConter.Count,
  20646. ApiResult = clients,
  20647. CrmClients = crmClients
  20648. }));
  20649. }
  20650. #endregion
  20651. #region 团组倒推表
  20652. /// <summary>
  20653. /// 倒推表基础数据
  20654. /// Init
  20655. /// </summary>
  20656. /// <returns></returns>
  20657. [HttpPost]
  20658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20659. public async Task<IActionResult> PostInvertedListInit()
  20660. {
  20661. var viewData = await _invertedListRep._Init();
  20662. if (viewData.Code != 0)
  20663. {
  20664. return Ok(JsonView(false, viewData.Msg));
  20665. }
  20666. return Ok(JsonView(viewData.Data));
  20667. }
  20668. /// <summary>
  20669. /// 倒推表
  20670. /// Info
  20671. /// </summary>
  20672. /// <param name="dto"></param>
  20673. /// <returns></returns>
  20674. [HttpPost]
  20675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20676. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20677. {
  20678. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20679. if (viewData.Code != 0)
  20680. {
  20681. return Ok(JsonView(false, viewData.Msg));
  20682. }
  20683. return Ok(JsonView(viewData.Data));
  20684. }
  20685. /// <summary>
  20686. /// 倒推表
  20687. /// Create
  20688. /// </summary>
  20689. /// <param name="dto"></param>
  20690. /// <returns></returns>
  20691. [HttpPost]
  20692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20693. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20694. {
  20695. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20696. if (viewData.Code != 0)
  20697. {
  20698. return Ok(JsonView(false, viewData.Msg));
  20699. }
  20700. return Ok(JsonView(viewData.Data));
  20701. }
  20702. /// <summary>
  20703. /// 倒推表
  20704. /// Update
  20705. /// </summary>
  20706. /// <param name="dto"></param>
  20707. /// <returns></returns>
  20708. [HttpPost]
  20709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20710. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20711. {
  20712. var viewData = await _invertedListRep._Update(dto);
  20713. if (viewData.Code != 0)
  20714. {
  20715. return Ok(JsonView(false, viewData.Msg));
  20716. }
  20717. return Ok(JsonView(viewData.Data));
  20718. }
  20719. /// <summary>
  20720. /// 倒推表
  20721. /// File Download
  20722. /// </summary>
  20723. /// <param name="dto"></param>
  20724. /// <returns></returns>
  20725. [HttpPost]
  20726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20727. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20728. {
  20729. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20730. if (info2.Code != 0)
  20731. {
  20732. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20733. }
  20734. var info1 = info2.Data as InvertedListInfoView;
  20735. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20736. string teamName = "";
  20737. if (info != null) teamName = info.TeamName;
  20738. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20739. var doc = new Document();
  20740. var builder = new DocumentBuilder(doc);
  20741. #region old insert
  20742. ////载入模板
  20743. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20744. //Document doc = new Document(tempPath);
  20745. //DocumentBuilder builder = new DocumentBuilder(doc);
  20746. //利用键值对存放数据
  20747. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20748. //dic.Add("TeamName", teamName);
  20749. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20750. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20751. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20752. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20753. //dic.Add("SQRemark", info1.ApprovalRemark);
  20754. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20755. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20756. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20757. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20758. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20759. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20760. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20761. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20762. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20763. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20764. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20765. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20766. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20767. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20768. //#region 填充word模板书签内容
  20769. //foreach (var key in dic.Keys)
  20770. //{
  20771. // builder.MoveToBookmark(key);
  20772. // builder.Write(dic[key]);
  20773. //}
  20774. //#endregion
  20775. #endregion
  20776. #region New Insert
  20777. string titleFont = $"仿宋",
  20778. contentFont = $"仿宋";
  20779. var fontColor = Color.FromArgb(64, 64, 64);
  20780. //设置标题 团组名称
  20781. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20782. builder.Font.Name = titleFont;
  20783. builder.Font.Color = fontColor;
  20784. builder.Font.Size = 12;
  20785. builder.Font.Bold = true;
  20786. builder.Writeln(teamName);
  20787. //设置副标题 团组出访时间
  20788. builder.Font.Size = 12;
  20789. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20790. builder.Writeln();
  20791. var backgroundColor = Color.FromArgb(199, 199, 199);
  20792. var table = builder.StartTable();
  20793. builder.InsertCell();
  20794. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20795. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20796. builder.CellFormat.Borders.LineWidth = 1;
  20797. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20798. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20799. builder.RowFormat.Height = 40;
  20800. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20801. builder.Font.Name = contentFont;
  20802. builder.Font.Size = 12;
  20803. builder.Font.Bold = true;
  20804. builder.Font.Color = fontColor;
  20805. builder.Write("时间");
  20806. builder.InsertCell();
  20807. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20808. builder.Write("流程");
  20809. builder.InsertCell();
  20810. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20811. builder.Write("说明");
  20812. builder.EndRow();
  20813. //报批资料准备
  20814. if (info1.IsSelectedAirportd)
  20815. {
  20816. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20817. }
  20818. //报批/提供送签资料
  20819. if (info1.IsSelectedApprovalData)
  20820. {
  20821. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20822. }
  20823. //出批件护照办理
  20824. if (info1.IsSelectedIssueApproval)
  20825. {
  20826. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20827. }
  20828. //签证资料准备
  20829. if (info1.IsSelectedVisaInfo)
  20830. {
  20831. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20832. }
  20833. //送签
  20834. if (info1.IsSelectedSendVisa)
  20835. {
  20836. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20837. }
  20838. //出签
  20839. if (info1.IsSelectedIssueVisa)
  20840. {
  20841. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20842. }
  20843. //机票
  20844. if (info1.IsSelectedAirTicket)
  20845. {
  20846. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20847. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20848. }
  20849. //酒店
  20850. if (info1.IsSelectedHotel)
  20851. {
  20852. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20853. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20854. }
  20855. //开行前会
  20856. if (info1.IsSelectedPreTripMeeting)
  20857. {
  20858. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20859. }
  20860. //送机
  20861. if (info1.IsSelectedAirportdDropOff)
  20862. {
  20863. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20864. }
  20865. builder.EndTable();
  20866. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20867. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20868. for (int i = 0; i < table.Rows.Count; i++)
  20869. {
  20870. var row = table.Rows[i];
  20871. //设置宽度
  20872. row.Cells[0].CellFormat.Width = 20.00;
  20873. row.Cells[1].CellFormat.Width = 30.00;
  20874. row.Cells[2].CellFormat.Width = 50.00;
  20875. if (i != 0)
  20876. {
  20877. //边框设置
  20878. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20879. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20880. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20881. }
  20882. }
  20883. #region 页脚插入图片
  20884. // 创建页脚
  20885. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20886. doc.FirstSection.HeadersFooters.Add(footer);
  20887. Paragraph para = new Paragraph(doc);
  20888. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20889. footer.AppendChild(para);
  20890. builder.MoveTo(para);
  20891. string imagePath = "./Images/FMGJ_Log.png";
  20892. builder.InsertImage(imagePath);
  20893. #endregion
  20894. #endregion
  20895. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20896. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20897. string filePath = fileDir + $@"InvertedList/{fileName}";
  20898. doc.Save(filePath);
  20899. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20900. return Ok(JsonView(true, "操作成功!", Url));
  20901. }
  20902. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20903. {
  20904. var fontColor = Color.FromArgb(64, 64, 64);
  20905. builder.InsertCell();
  20906. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20907. builder.RowFormat.Height = 40;
  20908. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20909. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20910. builder.Font.Name = fontName;
  20911. builder.Font.Size = 8;
  20912. builder.Font.Bold = true;
  20913. builder.Font.Color = fontColor;
  20914. builder.Write(dateTime);
  20915. builder.InsertCell();
  20916. builder.Font.Size = 9;
  20917. builder.Font.Bold = true;
  20918. builder.Font.Color = fontColor;
  20919. builder.Write(content);
  20920. builder.InsertCell();
  20921. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20922. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20923. builder.Font.Size = 9;
  20924. builder.Font.Bold = false;
  20925. builder.Font.Color = fontColor;
  20926. builder.Write(reamrk);
  20927. builder.EndRow();
  20928. }
  20929. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20930. {
  20931. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20932. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20933. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20934. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20935. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20936. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20937. }
  20938. #endregion
  20939. #region 会务倒推表
  20940. /// <summary>
  20941. /// 会务倒推表
  20942. /// Init
  20943. /// </summary>
  20944. /// <returns></returns>
  20945. [HttpPost]
  20946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20947. public async Task<IActionResult> InforRetrogressTableInit()
  20948. {
  20949. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20950. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20951. return Ok(JsonView(false, groupData.Msg));
  20952. }
  20953. /// <summary>
  20954. /// 会务倒推表
  20955. /// ExcelDownload
  20956. /// </summary>
  20957. /// <param name="dto"></param>
  20958. /// <returns></returns>
  20959. [HttpPost]
  20960. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20962. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20963. {
  20964. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20965. var validatorRes = await validator.ValidateAsync(dto);
  20966. if (!validatorRes.IsValid)
  20967. {
  20968. StringBuilder sb = new StringBuilder();
  20969. foreach (var item in validatorRes.Errors)
  20970. {
  20971. sb.AppendLine(item.ErrorMessage);
  20972. }
  20973. return Ok(JsonView(false, sb.ToString()));
  20974. }
  20975. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20976. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20977. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20978. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20979. #region Excel
  20980. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20981. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20982. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20983. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20984. var fileNamePrefix = string.Empty;
  20985. if (days >= 30)
  20986. {
  20987. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20988. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20989. }
  20990. else if (days < 30 && days > 7)
  20991. {
  20992. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20993. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20994. }
  20995. else if (days <= 7)
  20996. {
  20997. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20998. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20999. }
  21000. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  21001. fileName = CommonFun.ValidFileName(fileName);
  21002. //载入模板
  21003. WorkbookDesigner designer = new WorkbookDesigner();
  21004. designer.Workbook = new Workbook(tempPath);
  21005. designer.Process();
  21006. if (!Directory.Exists(savePath))
  21007. {
  21008. Directory.CreateDirectory(savePath);
  21009. }
  21010. string serverPath = $"{savePath}{fileName}";
  21011. designer.Workbook.Save(serverPath);
  21012. string rst = $"{servicePath}{ftpPath}{fileName}";
  21013. #endregion
  21014. return Ok(JsonView(new { url = rst }));
  21015. }
  21016. #endregion
  21017. #region 三公签证费用(签证费、代办费)
  21018. /// <summary>
  21019. /// 三公签证费用(签证费、代办费)
  21020. /// List
  21021. /// </summary>
  21022. /// <returns></returns>
  21023. [HttpPost]
  21024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21025. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  21026. {
  21027. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  21028. }
  21029. /// <summary>
  21030. /// 三公签证费用(签证费、代办费)
  21031. /// Add Or Update
  21032. /// </summary>
  21033. /// <returns></returns>
  21034. [HttpPost]
  21035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21036. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  21037. {
  21038. var _view = await _visaFeeInfoRep.Update(_dto);
  21039. if (_view.Code != 0)
  21040. {
  21041. return Ok(JsonView(false, _view.Msg));
  21042. }
  21043. return Ok(JsonView(true, _view.Msg));
  21044. }
  21045. #endregion
  21046. #region 酒店询价
  21047. /// <summary>
  21048. /// 酒店询价
  21049. /// Init
  21050. /// </summary>
  21051. /// <returns></returns>
  21052. [HttpPost]
  21053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21054. public async Task<IActionResult> PostHotelInquiryInit()
  21055. {
  21056. var res = await _hotelInquiryRep._Init();
  21057. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21058. return Ok(JsonView(true, res.Msg, res.Data));
  21059. }
  21060. /// <summary>
  21061. /// 酒店询价
  21062. /// page Item
  21063. /// </summary>
  21064. /// <param name="_dto"></param>
  21065. /// <returns></returns>
  21066. [HttpPost]
  21067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21068. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  21069. {
  21070. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  21071. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21072. var view = res.Data as PageDataViewBase;
  21073. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  21074. }
  21075. /// <summary>
  21076. /// 酒店询价
  21077. /// info
  21078. /// </summary>
  21079. /// <param name="_dto"></param>
  21080. /// <returns></returns>
  21081. [HttpPost]
  21082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21083. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  21084. {
  21085. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  21086. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21087. return Ok(JsonView(true, res.Msg, res.Data));
  21088. }
  21089. /// <summary>
  21090. /// 酒店询价
  21091. /// Add Or Edit
  21092. /// </summary>
  21093. /// <param name="_dto"></param>
  21094. /// <returns></returns>
  21095. [HttpPost]
  21096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21097. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  21098. {
  21099. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  21100. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21101. return Ok(JsonView(true, res.Msg, res.Data));
  21102. }
  21103. /// <summary>
  21104. /// 酒店询价
  21105. /// Del
  21106. /// </summary>
  21107. /// <param name="_dto"></param>
  21108. /// <returns></returns>
  21109. [HttpPost]
  21110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21111. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21112. {
  21113. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21114. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21115. return Ok(JsonView(true, res.Msg, res.Data));
  21116. }
  21117. #endregion
  21118. #region 下载匹配op行程单
  21119. /// <summary>
  21120. /// 匹配op行程单
  21121. /// Init
  21122. /// </summary>
  21123. /// <param name="dto">团组列表请求dto</param>
  21124. /// <returns></returns>
  21125. [HttpPost]
  21126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21127. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21128. {
  21129. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21130. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21131. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21132. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21133. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21134. .Where(it => it.IsDel == 0)
  21135. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21136. .OrderByDescending(it => it.VisitStartDate)
  21137. .ToList();
  21138. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21139. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21140. var diids = groupInfos.Select(it => it.Id).ToList();
  21141. List<string> countrys = new List<string>();
  21142. foreach (var item in country)
  21143. {
  21144. var data = _groupRepository.FormartTeamName(item);
  21145. var dataArray = _groupRepository.GroupSplitCountry(data);
  21146. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21147. }
  21148. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  21149. List<string> areaArray = new List<string>(); //GetGroupCityLine
  21150. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  21151. foreach (var item in areaItem)
  21152. {
  21153. string areaStr = item.Value;
  21154. if (!string.IsNullOrEmpty(areaStr))
  21155. {
  21156. string[] str1 = areaStr.Split("-");
  21157. if (str1.Length > 0)
  21158. {
  21159. areaArray.AddRange(str1);
  21160. }
  21161. }
  21162. }
  21163. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  21164. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  21165. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  21166. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  21167. .ToList();
  21168. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  21169. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  21170. .Where(it => countriesIds.Contains(it.Id))
  21171. .Select(it => new { it.Id, Name = it.Name_CN })
  21172. .ToList();
  21173. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  21174. .Select(it => it.TeamName).ToList();
  21175. stopwatch.Stop();
  21176. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  21177. }
  21178. ///// <summary>
  21179. ///// 匹配op行程单
  21180. ///// Init 查询区域数据
  21181. ///// </summary>
  21182. ///// <param name="dto">团组列表请求dto</param>
  21183. ///// <returns></returns>
  21184. //[HttpPost]
  21185. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21186. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  21187. //{
  21188. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21189. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  21190. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  21191. // if (string.IsNullOrEmpty(countriesDataStr))
  21192. // {
  21193. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  21194. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  21195. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  21196. // }
  21197. // else
  21198. // {
  21199. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  21200. // }
  21201. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  21202. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  21203. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  21204. // List<dynamic> childList = new List<dynamic>();
  21205. // int parentId = dto.CountriesId;
  21206. // if (provinceData.Count > 1)
  21207. // {
  21208. // foreach (var item1 in provinceData)
  21209. // {
  21210. // List<dynamic> childList1 = new List<dynamic>();
  21211. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  21212. // foreach (var item2 in citiesData1)
  21213. // {
  21214. // List<dynamic> childList2 = new List<dynamic>();
  21215. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21216. // foreach (var item3 in countiesData1)
  21217. // {
  21218. // childList2.Add(new
  21219. // {
  21220. // id = item3.Id,
  21221. // parentId = item2.Id,
  21222. // level = "district",
  21223. // name = item3.Name_CN,
  21224. // });
  21225. // }
  21226. // childList1.Add(new
  21227. // {
  21228. // id = item2.Id,
  21229. // parentId = item1.Id,
  21230. // level = "city",
  21231. // name = item2.Name_CN,
  21232. // childList = childList2
  21233. // });
  21234. // }
  21235. // childList.Add(new
  21236. // {
  21237. // id = item1.Id,
  21238. // parentId = parentId,
  21239. // level = "province",
  21240. // name = item1.Name_CN,
  21241. // childList = childList1
  21242. // });
  21243. // }
  21244. // //城市
  21245. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  21246. // foreach (var item2 in citiesData2)
  21247. // {
  21248. // List<dynamic> childList22 = new List<dynamic>();
  21249. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21250. // foreach (var item3 in countiesData1)
  21251. // {
  21252. // childList22.Add(new
  21253. // {
  21254. // id = item3.Id,
  21255. // parentId = item2.Id,
  21256. // level = "district",
  21257. // name = item3.Name_CN,
  21258. // });
  21259. // }
  21260. // childList.Add(new
  21261. // {
  21262. // id = item2.Id,
  21263. // parentId = parentId,
  21264. // level = "city",
  21265. // name = item2.Name_CN,
  21266. // childList = childList22
  21267. // });
  21268. // }
  21269. // }
  21270. // else
  21271. // {
  21272. // foreach (var item2 in citiesData)
  21273. // {
  21274. // string cname = item2.Name_CN;
  21275. // List<dynamic> childList1 = new List<dynamic>();
  21276. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21277. // foreach (var item3 in countiesData1)
  21278. // {
  21279. // childList1.Add(new
  21280. // {
  21281. // Id = item3.Id,
  21282. // parentId = item2.Id,
  21283. // level = "district",
  21284. // name = item3.Name_CN
  21285. // });
  21286. // }
  21287. // childList.Add(new
  21288. // {
  21289. // id = item2.Id,
  21290. // parentId = parentId,
  21291. // level = "city",
  21292. // name = item2.Name_CN,
  21293. // childList = childList1
  21294. // });
  21295. // }
  21296. // }
  21297. // stopwatch.Stop();
  21298. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21299. //}
  21300. /// <summary>
  21301. /// 匹配op行程单
  21302. /// 接团信息列表 Page
  21303. /// </summary>
  21304. /// <param name="dto">团组列表请求dto</param>
  21305. /// <returns></returns>
  21306. [HttpPost]
  21307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21308. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21309. {
  21310. var swatch = new Stopwatch();
  21311. swatch.Start();
  21312. #region 参数验证
  21313. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21314. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21315. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21316. #region 页面操作权限验证
  21317. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21318. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21319. #endregion
  21320. #endregion
  21321. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21322. {
  21323. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21324. //string sqlWhere = "";
  21325. if (!string.IsNullOrEmpty(dto.Country))
  21326. {
  21327. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  21328. }
  21329. if (!string.IsNullOrEmpty(dto.Area))
  21330. {
  21331. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  21332. }
  21333. if (!string.IsNullOrEmpty(dto.TeamName))
  21334. {
  21335. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  21336. }
  21337. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  21338. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  21339. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  21340. swatch.Stop();
  21341. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  21342. }
  21343. else
  21344. {
  21345. return Ok(JsonView(false, "查询失败"));
  21346. }
  21347. }
  21348. /// <summary>
  21349. /// 匹配op行程单
  21350. /// 行程单下载
  21351. /// </summary>
  21352. /// <param name="dto">团组列表请求dto</param>
  21353. /// <returns></returns>
  21354. [HttpPost]
  21355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21356. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  21357. {
  21358. #region 参数验证
  21359. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21360. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21361. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21362. #region 页面操作权限验证
  21363. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21364. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  21365. #endregion
  21366. #endregion
  21367. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21368. {
  21369. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  21370. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  21371. }
  21372. else
  21373. {
  21374. return Ok(JsonView(false, "下载失败!"));
  21375. }
  21376. }
  21377. #endregion
  21378. #region 国家信息 数据 注释
  21379. //[HttpPost]
  21380. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  21381. //{
  21382. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  21383. // foreach (var item in dto)
  21384. // {
  21385. // infos.Add(new Grp_GroupsTaskAssignment()
  21386. // {
  21387. // DIId = item,
  21388. // CTId = 82,
  21389. // UId = 248,
  21390. // IsEnable = 1,
  21391. // CreateUserId = 233,
  21392. // CreateTime = DateTime.Now,
  21393. // IsDel = 0
  21394. // });
  21395. // infos.Add(new Grp_GroupsTaskAssignment()
  21396. // {
  21397. // DIId = item,
  21398. // CTId = 82,
  21399. // UId = 286,
  21400. // IsEnable = 1,
  21401. // CreateUserId = 233,
  21402. // CreateTime = DateTime.Now,
  21403. // IsDel = 0
  21404. // });
  21405. // }
  21406. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  21407. // return Ok("操作成功");
  21408. //}
  21409. //public class paramJsonDto
  21410. //{
  21411. // public List<CountriesInfo> str { get; set; }
  21412. //}
  21413. //[HttpPost]
  21414. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  21415. //{
  21416. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  21417. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  21418. // List<Sys_Cities> cities = new List<Sys_Cities>();
  21419. // List<Sys_Cities> districts = new List<Sys_Cities>();
  21420. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21421. // _sqlSugar.BeginTran();
  21422. // int countitiesIndex = 0;
  21423. // foreach (var item in dto.str)
  21424. // {
  21425. // dynamic data = item.c;
  21426. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  21427. // if (data != null)
  21428. // {
  21429. // countitiesIndex++;
  21430. // foreach (var item1 in data)
  21431. // {
  21432. // string cnname = item1.cn;
  21433. // string enname = item1.en;
  21434. // Sys_Cities provinceInfo = new Sys_Cities()
  21435. // {
  21436. // CountriesId = countriesId,
  21437. // Name_CN = cnname,
  21438. // Name_EN = enname,
  21439. // ParentId = 0,
  21440. // IsCapital = 1,
  21441. // CreateUserId = 208,
  21442. // CreateTime = DateTime.Now,
  21443. // IsDel = 0
  21444. // };
  21445. // if (item1.lv == "province") //省份
  21446. // {
  21447. // provinceInfo.Level = 1;
  21448. // int provinceId = 0;
  21449. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  21450. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  21451. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21452. // var data1 = item1.c;
  21453. // foreach (var item2 in data1)
  21454. // {
  21455. // if (item2.lv == "city")
  21456. // {
  21457. // string citycnname = item2.cn;
  21458. // string cityenname = item2.en;
  21459. // Sys_Cities cityInfo = new Sys_Cities()
  21460. // {
  21461. // CountriesId = countriesId,
  21462. // ParentId = provinceId,
  21463. // Level = 2,
  21464. // Name_CN = citycnname,
  21465. // Name_EN = cityenname,
  21466. // IsCapital = 1,
  21467. // CreateUserId = 208,
  21468. // CreateTime = DateTime.Now,
  21469. // IsDel = 0
  21470. // };
  21471. // if (item2.c != null)
  21472. // {
  21473. // int cityId = 0;
  21474. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  21475. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21476. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  21477. // foreach (var item3 in item2.c)
  21478. // {
  21479. // if (item3.lv == "district")
  21480. // {
  21481. // var districtInfo = new Sys_Cities()
  21482. // {
  21483. // CountriesId = countriesId,
  21484. // Name_CN = item3.cn,
  21485. // Name_EN = item3.en,
  21486. // Level = 3,
  21487. // ParentId = cityId,
  21488. // IsCapital = 1,
  21489. // CreateUserId = 208,
  21490. // CreateTime = DateTime.Now,
  21491. // IsDel = 0
  21492. // };
  21493. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21494. // //{
  21495. // districts.Add(districtInfo);
  21496. // //}
  21497. // }
  21498. // }
  21499. // }
  21500. // else
  21501. // {
  21502. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  21503. // //{
  21504. // cities.Add(cityInfo);
  21505. // //}
  21506. // }
  21507. // }
  21508. // }
  21509. // }
  21510. // else if (item1.lv == "city")//城市
  21511. // {
  21512. // provinceInfo.Level = 2;
  21513. // if (item1.c != null)
  21514. // {
  21515. // int cityId = 0;
  21516. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  21517. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21518. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21519. // foreach (var item3 in item1.c)
  21520. // {
  21521. // if (item3.lv == "district")
  21522. // {
  21523. // var districtInfo = new Sys_Cities()
  21524. // {
  21525. // CountriesId = countriesId,
  21526. // Name_CN = item3.cn,
  21527. // Name_EN = item3.en,
  21528. // Level = 3,
  21529. // ParentId = cityId,
  21530. // IsCapital = 1,
  21531. // CreateUserId = 208,
  21532. // CreateTime = DateTime.Now,
  21533. // IsDel = 0
  21534. // };
  21535. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21536. // //{
  21537. // districts.Add(districtInfo);
  21538. // //}
  21539. // }
  21540. // }
  21541. // }
  21542. // else
  21543. // {
  21544. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  21545. // //{
  21546. // cities.Add(provinceInfo);
  21547. // //}
  21548. // }
  21549. // }
  21550. // }
  21551. // }
  21552. // }
  21553. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  21554. // cities = cities.Distinct().ToList();
  21555. // districts = districts.Distinct().ToList();
  21556. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  21557. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  21558. // cities.AddRange(districts);
  21559. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  21560. // //_sqlSugar.RollbackTran();
  21561. // _sqlSugar.CommitTran();
  21562. // return Ok(JsonView(false, "操作成功!"));
  21563. //}
  21564. //[HttpPost]
  21565. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  21566. //{
  21567. // List<CountitiesInfo> infos = dto.MyProperty;
  21568. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  21569. // _sqlSugar.BeginTran();
  21570. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21571. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  21572. // foreach (var item in infos)
  21573. // {
  21574. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  21575. // if (countryInfo != null)
  21576. // {
  21577. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  21578. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  21579. // if (cityInfo1 != null)
  21580. // {
  21581. // cityInfo1.IsCapital = 0;
  21582. // cityInfos.Add(cityInfo1);
  21583. // }
  21584. // }
  21585. // }
  21586. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  21587. // .UpdateColumns(it => it.IsCapital)
  21588. // .WhereColumns(it => it.Id)
  21589. // .ExecuteCommand();
  21590. // //_sqlSugar.RollbackTran();
  21591. // _sqlSugar.CommitTran();
  21592. // return Ok(JsonView(false, "操作成功!"));
  21593. //}
  21594. //public class CounrtiesDto
  21595. //{
  21596. // public List<CountitiesInfo> MyProperty { get; set; }
  21597. //}
  21598. //public class CountitiesInfo
  21599. //{
  21600. // /// <summary>
  21601. // /// 圣约翰
  21602. // /// </summary>
  21603. // public string capital_name_chinese { get; set; }
  21604. // /// <summary>
  21605. // ///
  21606. // /// </summary>
  21607. // public string capital_name { get; set; }
  21608. // /// <summary>
  21609. // ///
  21610. // /// </summary>
  21611. // public string country_type { get; set; }
  21612. // /// <summary>
  21613. // /// 安提瓜和巴布达
  21614. // /// </summary>
  21615. // public string country_name_chinese { get; set; }
  21616. // /// <summary>
  21617. // /// 安提瓜和巴布达
  21618. // /// </summary>
  21619. // public string country_name_chinese_short { get; set; }
  21620. // /// <summary>
  21621. // /// 安提瓜和巴布达
  21622. // /// </summary>
  21623. // public string country_name_chinese_UN { get; set; }
  21624. // /// <summary>
  21625. // ///
  21626. // /// </summary>
  21627. // public string country_name_english_abbreviation { get; set; }
  21628. // /// <summary>
  21629. // ///
  21630. // /// </summary>
  21631. // public string country_name_english_formal { get; set; }
  21632. // /// <summary>
  21633. // ///
  21634. // /// </summary>
  21635. // public string country_name_english_UN { get; set; }
  21636. // /// <summary>
  21637. // ///
  21638. // /// </summary>
  21639. // public string continent_name { get; set; }
  21640. // /// <summary>
  21641. // ///
  21642. // /// </summary>
  21643. // public string subregion_name { get; set; }
  21644. // /// <summary>
  21645. // ///
  21646. // /// </summary>
  21647. // public string country_code2 { get; set; }
  21648. // /// <summary>
  21649. // ///
  21650. // /// </summary>
  21651. // public string country_code3 { get; set; }
  21652. // /// <summary>
  21653. // ///
  21654. // /// </summary>
  21655. // public string phone_code { get; set; }
  21656. //}
  21657. //public class CountriesInfo : BasicInfo
  21658. //{
  21659. // public List<CitiesInfo> c { get; set; }
  21660. //}
  21661. //public class CitiesInfo : BasicInfo
  21662. //{
  21663. // public List<AreaInfo> c { get; set; }
  21664. //}
  21665. //public class AreaInfo : BasicInfo
  21666. //{
  21667. // public List<AreaInfo> c { get; set; }
  21668. //}
  21669. //public class BasicInfo
  21670. //{
  21671. // public string code { get; set; }
  21672. // public string cn { get; set; }
  21673. // public string lv { get; set; }
  21674. // public string en { get; set; }
  21675. //}
  21676. #endregion
  21677. #region 查看邀请方
  21678. /// <summary>
  21679. /// 查看邀请方
  21680. /// 邀请方信息 Init
  21681. /// </summary>
  21682. /// <param name="dto"></param>
  21683. /// <returns></returns>
  21684. [HttpPost]
  21685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21686. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21687. {
  21688. string sqlWhere = string.Empty;
  21689. if (!string.IsNullOrEmpty(dto.Search))
  21690. {
  21691. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21692. }
  21693. string sql = string.Format($@"Select
  21694. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21695. Id,
  21696. UnitName
  21697. From Res_InvitationOfficialActivityData
  21698. Where IsDel = 0
  21699. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21700. RefAsync<int> total = 0;
  21701. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21702. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21703. }
  21704. /// <summary>
  21705. /// 查看邀请方
  21706. /// 国家信息 Init
  21707. /// </summary>
  21708. /// <param name="dto"></param>
  21709. /// <returns></returns>
  21710. [HttpPost]
  21711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21712. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21713. {
  21714. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21715. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21716. var diids = groupInfos.Select(it => it.Id).ToList();
  21717. List<string> countrys = new List<string>();
  21718. foreach (var item in country)
  21719. {
  21720. var data = _groupRepository.FormartTeamName(item);
  21721. var dataArray = _groupRepository.GroupSplitCountry(data);
  21722. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21723. }
  21724. countrys = countrys.Distinct().ToList();
  21725. for (int i = 0; i < countrys.Count; i++)
  21726. {
  21727. string item = countrys[i];
  21728. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21729. {
  21730. countrys.Remove(item);
  21731. i--;
  21732. }
  21733. }
  21734. RefAsync<int> total = 0;
  21735. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21736. .Where(it => countrys.Contains(it.Name_CN))
  21737. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21738. .Select(it => new { id = it.Id, name = it.Name_CN })
  21739. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21740. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21741. }
  21742. /// <summary>
  21743. /// 查看邀请方
  21744. /// 城市信息 Init
  21745. /// </summary>
  21746. /// <param name="dto"></param>
  21747. /// <returns></returns>
  21748. [HttpPost]
  21749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21750. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21751. {
  21752. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21753. RefAsync<int> total = 0;
  21754. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21755. .Where(it => it.CountriesId == dto.CountiesId)
  21756. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21757. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21758. .Select(it => new { id = it.Id, name = it.Name_CN })
  21759. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21760. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21761. }
  21762. /// <summary>
  21763. /// 查看邀请方
  21764. /// 团组名称 Init
  21765. /// </summary>
  21766. /// <param name="dto"></param>
  21767. /// <returns></returns>
  21768. [HttpPost]
  21769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21770. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21771. {
  21772. var watch = new Stopwatch();
  21773. watch.Start();
  21774. RefAsync<int> total = 0;
  21775. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21776. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21777. .Where((oa, di) => oa.IsDel == 0)
  21778. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21779. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21780. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21781. .Distinct()
  21782. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21783. watch.Stop();
  21784. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21785. }
  21786. /// <summary>
  21787. /// 查看邀请方
  21788. /// 团组 & 邀请方信息
  21789. /// </summary>
  21790. /// <param name="dto"></param>
  21791. /// <returns></returns>
  21792. [HttpPost]
  21793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21794. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21795. {
  21796. var watch = new Stopwatch();
  21797. watch.Start();
  21798. RefAsync<int> total = 0;
  21799. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21800. .AS("Grp_DelegationInfo")
  21801. .Includes(x => x.InvitingInfos)
  21802. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21803. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21804. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21805. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21806. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21807. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21808. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21809. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21810. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21811. infos.ForEach(x =>
  21812. {
  21813. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21814. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21815. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21816. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21817. });
  21818. watch.Stop();
  21819. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21820. }
  21821. #endregion
  21822. #region 报批行程
  21823. /// <summary>
  21824. /// 报批行程初始化
  21825. /// </summary>
  21826. /// <param name="dto"></param>
  21827. /// <returns></returns>
  21828. [HttpPost]
  21829. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21830. {
  21831. const int chiNumber = 5;
  21832. var jw = JsonView(false);
  21833. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21834. var group = groupList.First();
  21835. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21836. group = groupList.First(x => x.Id == diid);
  21837. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21838. .Where(x => x.DiId == diid && x.IsDel == 0)
  21839. .ToArray();
  21840. var count = 1;
  21841. foreach (var item in blackCodeList)
  21842. {
  21843. if (string.IsNullOrWhiteSpace(item.Title))
  21844. {
  21845. item.Title = "未设置名称数据" + count;
  21846. }
  21847. count++;
  21848. }
  21849. ;
  21850. if (group == null)
  21851. {
  21852. jw.Msg = "暂无团组!";
  21853. return Ok(jw);
  21854. }
  21855. var data = new
  21856. {
  21857. groupList = groupList.Select(x => new
  21858. {
  21859. x.TeamName,
  21860. x.Id
  21861. }),
  21862. content = new ArrayList(),
  21863. groupInfo = new
  21864. {
  21865. group.VisitDays,
  21866. group.TourCode,
  21867. group.VisitPNumber,
  21868. group.TeamName,
  21869. group.Id,
  21870. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21871. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21872. group.ClientUnit
  21873. },
  21874. blackCodeList = blackCodeList.Select(x => new
  21875. {
  21876. x.Title,
  21877. x.Id
  21878. }),
  21879. FileTempList = new ArrayList()
  21880. {
  21881. new { Index = 1,FileName = "旧模板" },
  21882. new { Index = 2,FileName = "省外办" },
  21883. new { Index = 3,FileName = "市外办" },
  21884. }
  21885. };
  21886. var resultArr = new ArrayList();
  21887. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21888. #region 默认不生成行程
  21889. //if (content.Count == 0)
  21890. //{
  21891. // var stay = "-";
  21892. // var cityPath = "-";
  21893. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21894. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21895. // .ToList();
  21896. // //添加城市路径以及住宿地
  21897. // //黑屏代码数据
  21898. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21899. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21900. // {
  21901. // jw = JsonView(true, "黑屏代码有误!", data);
  21902. // return Ok(jw);
  21903. // }
  21904. // data = data with
  21905. // {
  21906. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21907. // {
  21908. // x.Title,
  21909. // x.Id,
  21910. // }).ToArray())
  21911. // };
  21912. // foreach (DataRow row in dtBlack.Rows)
  21913. // {
  21914. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21915. // {
  21916. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21917. // return Ok(jw);
  21918. // }
  21919. // }
  21920. // //黑屏代码获取时间区间
  21921. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21922. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21923. // _sqlSugar.BeginTran();
  21924. // for (int i = 0; i < timeArr.Count; i++)
  21925. // {
  21926. // stay = "-";
  21927. // cityPath = "-";
  21928. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21929. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21930. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21931. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21932. // if (tbSelect.Length > 0)
  21933. // {
  21934. // List<string> threeCodeStr = new List<string>();
  21935. // foreach (var item in tbSelect)
  21936. // {
  21937. // var threeCode = item["Three"].ToString() ?? "";
  21938. // if (threeCode.Length == 6)
  21939. // {
  21940. // var start = threeCode.Substring(0, 3);
  21941. // var end = threeCode.Substring(3, 3);
  21942. // if (threeCodeStr.Count == 0)
  21943. // {
  21944. // threeCodeStr.Add(start);
  21945. // threeCodeStr.Add(end);
  21946. // }
  21947. // else
  21948. // {
  21949. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21950. // {
  21951. // threeCodeStr.Add(end);
  21952. // }
  21953. // else
  21954. // {
  21955. // threeCodeStr.Add(start);
  21956. // threeCodeStr.Add(end);
  21957. // }
  21958. // }
  21959. // }
  21960. // }
  21961. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21962. // var last = threeCodeStr.Last();
  21963. // foreach (var item in threeCodeStr)
  21964. // {
  21965. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21966. // if (item.Equals(last))
  21967. // {
  21968. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21969. // }
  21970. // }
  21971. // cityPath = cityPath.Trim('-');
  21972. // }
  21973. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21974. // appro.Diid = diid ?? -1;
  21975. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21976. // appro.Id = thisId;
  21977. // appro.CreateUserId = dto.UserId;
  21978. // appro.CreateTime = DateTime.Now;
  21979. // content.Add(appro);
  21980. // }
  21981. // _sqlSugar.CommitTran();
  21982. //}
  21983. #endregion
  21984. foreach (var x in content)
  21985. {
  21986. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21987. if (chiList.Count < chiNumber)
  21988. {
  21989. for (int i = chiList.Count; i < chiNumber; i++)
  21990. {
  21991. chiList.Add(new Grp_ApprovalTravelDetails());
  21992. }
  21993. }
  21994. resultArr.Add(new
  21995. {
  21996. x.Id,
  21997. x.Date,
  21998. x.Diid,
  21999. chiList = chiList.Select(x1 => new
  22000. {
  22001. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22002. x1.Details,
  22003. x1.ParentId,
  22004. x1.Id
  22005. })
  22006. });
  22007. }
  22008. data = data with
  22009. {
  22010. content = resultArr,
  22011. };
  22012. jw = JsonView(true, "获取成功!", data);
  22013. return Ok(jw);
  22014. }
  22015. /// <summary>
  22016. /// 报批行程删除
  22017. /// </summary>
  22018. /// <param name="dto"></param>
  22019. /// <returns></returns>
  22020. [HttpPost]
  22021. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  22022. {
  22023. var jw = JsonView(false);
  22024. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22025. if (group == null)
  22026. {
  22027. jw.Msg = "团组参数有误!";
  22028. return Ok(jw);
  22029. }
  22030. try
  22031. {
  22032. _sqlSugar.BeginTran();
  22033. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  22034. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  22035. {
  22036. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22037. DeleteUserId = dto.uesrId,
  22038. IsDel = 1
  22039. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  22040. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  22041. {
  22042. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22043. DeleteUserId = dto.uesrId,
  22044. IsDel = 1
  22045. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  22046. _sqlSugar.CommitTran();
  22047. jw = JsonView(true, "删除成功");
  22048. }
  22049. catch (Exception ex)
  22050. {
  22051. jw = JsonView(false, ex.Message);
  22052. }
  22053. return Ok(jw);
  22054. }
  22055. /// <summary>
  22056. /// 报批行程保存
  22057. /// </summary>
  22058. /// <param name="dto"></param>
  22059. /// <returns></returns>
  22060. [HttpPost]
  22061. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  22062. {
  22063. var jw = JsonView(false);
  22064. var Find = dto.Arr.Find(x => x.id == 0);
  22065. if (Find != null)
  22066. {
  22067. jw.Msg = "生成的ID为0!";
  22068. return Ok(jw);
  22069. }
  22070. foreach (var item in dto.Arr)
  22071. {
  22072. foreach (var chi in item.chiList)
  22073. {
  22074. if (chi.parentId == 0)
  22075. {
  22076. chi.parentId = item.id;
  22077. }
  22078. }
  22079. }
  22080. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  22081. _sqlSugar.BeginTran();
  22082. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  22083. {
  22084. var parentIds = dto.Arr.Select(x => x.id).ToList();
  22085. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  22086. {
  22087. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22088. DeleteUserId = dto.UserId,
  22089. IsDel = 1
  22090. }).ExecuteCommand();
  22091. }
  22092. try
  22093. {
  22094. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  22095. {
  22096. CreateTime = DateTime.Now,
  22097. CreateUserId = dto.UserId,
  22098. Details = x.details,
  22099. ParentId = x.parentId,
  22100. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22101. Remark = "",
  22102. IsDel = 0
  22103. }).ToList()).ExecuteCommand();
  22104. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22105. {
  22106. Id = x.id,
  22107. Details = x.details,
  22108. ParentId = x.parentId,
  22109. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22110. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22111. {
  22112. Details = x.Details,
  22113. ParentId = x.ParentId,
  22114. Time = x.Time
  22115. }).ExecuteCommand();
  22116. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22117. {
  22118. Id = x.id,
  22119. Date = x.date,
  22120. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22121. {
  22122. Date = x.Date
  22123. }).ExecuteCommand();
  22124. _sqlSugar.CommitTran();
  22125. jw = JsonView(true, "保存成功!");
  22126. }
  22127. catch (Exception ex)
  22128. {
  22129. _sqlSugar.RollbackTran();
  22130. jw = JsonView(false, "保存失败!" + ex.Message);
  22131. }
  22132. return Ok(jw);
  22133. }
  22134. /// <summary>
  22135. /// 报批行程生成
  22136. /// </summary>
  22137. /// <param name="dto"></param>
  22138. /// <returns></returns>
  22139. [HttpPost]
  22140. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22141. {
  22142. var jw = JsonView(false);
  22143. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22144. if (group == null)
  22145. {
  22146. jw.Msg = "暂无该团组!";
  22147. return Ok(jw);
  22148. }
  22149. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  22150. //黑屏代码数据
  22151. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  22152. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22153. {
  22154. jw.Msg = "黑屏代码有误!";
  22155. return Ok(jw);
  22156. }
  22157. foreach (DataRow row in dtBlack.Rows)
  22158. {
  22159. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22160. {
  22161. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  22162. return Ok(jw);
  22163. }
  22164. }
  22165. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  22166. var resultArr = new ArrayList();
  22167. //if (officialActivitiesArr.Count == 0)
  22168. //{
  22169. // jw.Msg = "暂无公务出访信息!";
  22170. // return Ok(jw);
  22171. //}
  22172. try
  22173. {
  22174. _sqlSugar.BeginTran();
  22175. DeleteApprovalJourney(new
  22176. Domain.Dtos.Groups.DeleteApprovalJourney
  22177. {
  22178. Diid = dto.Diid,
  22179. uesrId = dto.Userid
  22180. });
  22181. var stay = "-";
  22182. var cityPath = "-";
  22183. var arriveCountry = string.Empty;
  22184. //添加城市路径以及住宿地
  22185. //黑屏代码获取时间区间
  22186. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22187. var empty = "【未收入该三字码!请机票同事录入】";
  22188. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22189. #region 配置公务活动时间
  22190. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  22191. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  22192. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  22193. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  22194. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  22195. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22196. {
  22197. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,6,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  22198. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,8,30,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  22199. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22200. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  22201. };
  22202. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22203. {
  22204. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,7,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  22205. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,9,0,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  22206. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22207. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  22208. };
  22209. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  22210. {
  22211. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,18,0,0), new List<string>{"9:00-10:30","11:00-12:00", "14:00-15:30","16:00-17:00" }),
  22212. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,15,30,0), new List<string>{"9:00-10:30", "11:00-12:00", "14:00-15:00","15:00-16:00"}),
  22213. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  22214. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  22215. };
  22216. #endregion
  22217. var nextDayNum = 0;
  22218. for (int i = 0; i < timeArr.Count; i++)
  22219. {
  22220. stay = "-";
  22221. cityPath = "-";
  22222. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22223. DateTime NewData = DateTime.Parse(timeArr[i]);
  22224. //var gwinfo = officialActivitiesArr.Where(x => DateTime.TryParse(x.Date, out DateTime gwData) && gwData.ToString("yyyy-MM-dd") == NewData.ToString("yyyy-MM-dd")).OrderBy(x => x.Time).ToList();
  22225. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22226. if (nextDayNum > 0)
  22227. {
  22228. nextDayNum--;
  22229. }
  22230. if (tbSelect.Length > 0)
  22231. {
  22232. List<string> threeCodeStr = new List<string>();
  22233. bool isTrade = false;
  22234. string trip = string.Empty;
  22235. foreach (var item in tbSelect)
  22236. {
  22237. if (nextDayNum == 0)
  22238. {
  22239. nextDayNum = Convert.ToInt32(item["Sign"]);
  22240. }
  22241. var airStartTime = item["StartTime"].ToString() ?? "0000";
  22242. var airEndTime = item["EndTime"].ToString() ?? "0000";
  22243. var takeOffTime = DateTime.Parse(timeArr[i]);
  22244. var fallToTime = DateTime.Parse(timeArr[i]);
  22245. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  22246. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  22247. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  22248. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  22249. if (nextDayNum > 0)
  22250. {
  22251. fallToTime = fallToTime.AddDays(nextDayNum);
  22252. }
  22253. trip = string.Empty;
  22254. var start = string.Empty;
  22255. var end = string.Empty;
  22256. var threeCode = item["Three"].ToString() ?? "";
  22257. if (threeCode.Length == 6)
  22258. {
  22259. start = threeCode.Substring(0, 3);
  22260. end = threeCode.Substring(3, 3);
  22261. if (threeCodeStr.Count == 0)
  22262. {
  22263. threeCodeStr.Add(start);
  22264. threeCodeStr.Add(end);
  22265. }
  22266. else
  22267. {
  22268. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22269. {
  22270. threeCodeStr.Add(end);
  22271. }
  22272. else
  22273. {
  22274. threeCodeStr.Add(start);
  22275. threeCodeStr.Add(end);
  22276. }
  22277. }
  22278. }
  22279. //处理机票信息
  22280. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22281. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22282. if (start_Object == null)
  22283. {
  22284. start_Object = new Res_ThreeCode()
  22285. {
  22286. AirPort = empty,
  22287. AirPort_En = empty,
  22288. City = empty,
  22289. Country = empty,
  22290. Four = empty,
  22291. Three = empty,
  22292. };
  22293. }
  22294. if (end_Object == null)
  22295. {
  22296. end_Object = new Res_ThreeCode()
  22297. {
  22298. AirPort = empty,
  22299. AirPort_En = empty,
  22300. City = empty,
  22301. Country = empty,
  22302. Four = empty,
  22303. Three = empty,
  22304. };
  22305. }
  22306. //机型判断
  22307. string airModel = item["AirModel"].ToString();
  22308. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22309. string flightTime = item["FlightTime"].ToString();
  22310. flightTime = ParseBlackTime(flightTime);
  22311. //航班号
  22312. string flightcode = item["Fliagtcode"].ToString();
  22313. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22314. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22315. if (aircompany == null)
  22316. {
  22317. aircompany = new Res_AirCompany
  22318. {
  22319. CnName = hsEmpty,
  22320. EnName = hsEmpty,
  22321. ShortCode = hsEmpty,
  22322. };
  22323. }
  22324. //航班前公务安排
  22325. if (tbSelect.First().Equals(item) && i != 0)
  22326. {
  22327. foreach (var takeoff in takeoffTimes)
  22328. {
  22329. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  22330. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  22331. {
  22332. foreach (var addTime in takeoff.Item2)
  22333. {
  22334. chiarr.Add(new Grp_ApprovalTravelDetails
  22335. {
  22336. Time = addTime,
  22337. CreateTime = DateTime.Now,
  22338. CreateUserId = dto.Userid,
  22339. ParentId = 0,
  22340. Details = "公务活动"
  22341. });
  22342. }
  22343. break;
  22344. }
  22345. }
  22346. }
  22347. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  22348. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  22349. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  22350. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  22351. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  22352. if (isTrade)
  22353. {
  22354. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  22355. trip += "(转机不出机场)。";
  22356. }
  22357. //else
  22358. //{
  22359. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  22360. //}
  22361. chiarr.Add(new Grp_ApprovalTravelDetails
  22362. {
  22363. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  22364. CreateTime = DateTime.Now,
  22365. CreateUserId = dto.Userid,
  22366. ParentId = 0,
  22367. Details = trip
  22368. });
  22369. //最后一条到达的时间安排公务
  22370. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  22371. {
  22372. bool isCheckCountry = false;
  22373. if (end_Object.Country != arriveCountry)
  22374. {
  22375. arriveCountry = end_Object.Country;
  22376. isCheckCountry = true;
  22377. }
  22378. if (nextDayNum == 0)
  22379. {
  22380. //需要入境的情况
  22381. if (isCheckCountry)
  22382. {
  22383. foreach (var fallTime in fallTimesCheckCountry)
  22384. {
  22385. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22386. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22387. {
  22388. foreach (var addTime in fallTime.Item2)
  22389. {
  22390. chiarr.Add(new Grp_ApprovalTravelDetails
  22391. {
  22392. Time = addTime,
  22393. CreateTime = DateTime.Now,
  22394. CreateUserId = dto.Userid,
  22395. ParentId = 0,
  22396. Details = "公务活动"
  22397. });
  22398. }
  22399. break;
  22400. }
  22401. }
  22402. }
  22403. else
  22404. {
  22405. foreach (var fallTime in fallTimesNotCheckCountry)
  22406. {
  22407. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22408. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22409. {
  22410. foreach (var addTime in fallTime.Item2)
  22411. {
  22412. chiarr.Add(new Grp_ApprovalTravelDetails
  22413. {
  22414. Time = addTime,
  22415. CreateTime = DateTime.Now,
  22416. CreateUserId = dto.Userid,
  22417. ParentId = 0,
  22418. Details = "公务活动"
  22419. });
  22420. }
  22421. break;
  22422. }
  22423. }
  22424. }
  22425. }
  22426. }
  22427. }
  22428. //添加乘车语句
  22429. //chiarr.Add(new Grp_ApprovalTravelDetails
  22430. //{
  22431. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  22432. // CreateTime = DateTime.Now,
  22433. // CreateUserId = dto.Userid,
  22434. // ParentId = 0,
  22435. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  22436. //});
  22437. //if (i != timeArr.Count - 1)
  22438. //{
  22439. // fallToTime = fallToTime.AddHours(2.5);
  22440. // foreach (var item in Times)
  22441. // {
  22442. // //排列公务时间
  22443. // if (fallToTime.Hour < item.Item1)
  22444. // {
  22445. // chiarr.Add(new Grp_ApprovalTravelDetails
  22446. // {
  22447. // Time = $"{item.Item2} - {item.Item3}",
  22448. // CreateTime = DateTime.Now,
  22449. // CreateUserId = dto.Userid,
  22450. // ParentId = 0,
  22451. // Details = "公务活动"
  22452. // });
  22453. // }
  22454. // }
  22455. //}
  22456. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22457. var last = threeCodeStr.Last();
  22458. foreach (var item in threeCodeStr)
  22459. {
  22460. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22461. if (item.Equals(last))
  22462. {
  22463. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22464. }
  22465. }
  22466. cityPath = cityPath.Trim('-');
  22467. }
  22468. else
  22469. {
  22470. foreach (var item in Times)
  22471. {
  22472. chiarr.Add(new Grp_ApprovalTravelDetails
  22473. {
  22474. Time = $"{item.Item2} - {item.Item3}",
  22475. CreateTime = DateTime.Now,
  22476. CreateUserId = dto.Userid,
  22477. ParentId = 0,
  22478. Details = "公务活动"
  22479. });
  22480. }
  22481. }
  22482. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22483. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22484. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  22485. appro.Diid = dto.Diid;
  22486. appro.CreateUserId = dto.Userid;
  22487. appro.CreateTime = DateTime.Now;
  22488. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22489. appro.Id = thisId;
  22490. //foreach (var item in gwinfo)
  22491. //{
  22492. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  22493. // chi.Details = "拜访" + item.Client;
  22494. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  22495. // {
  22496. // chi.Details += "," + item.ReqSample;
  22497. // }
  22498. // chi.ParentId = thisId;
  22499. // chi.Time = item.Time;
  22500. // chiarr.Add(chi);
  22501. //}
  22502. if (chiarr.Count < 6)
  22503. {
  22504. for (int j = chiarr.Count; j < 6; j++)
  22505. {
  22506. chiarr.Add(new
  22507. Grp_ApprovalTravelDetails());
  22508. }
  22509. }
  22510. resultArr.Add(new
  22511. {
  22512. appro.Id,
  22513. appro.Date,
  22514. appro.Diid,
  22515. chiList = chiarr.Select(x1 => new
  22516. {
  22517. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22518. x1.Details,
  22519. x1.ParentId,
  22520. x1.Id
  22521. })
  22522. });
  22523. }
  22524. _sqlSugar.CommitTran();
  22525. jw = JsonView(true, "生成成功!", resultArr);
  22526. }
  22527. catch (Exception ex)
  22528. {
  22529. jw.Code = 400;
  22530. jw.Msg = "生成失败!" + ex.Message;
  22531. }
  22532. return Ok(jw);
  22533. }
  22534. /// <summary>
  22535. /// 报批行程word导出
  22536. /// </summary>
  22537. /// <param name="dto"></param>
  22538. /// <returns></returns>
  22539. [HttpPost]
  22540. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  22541. {
  22542. var jw = JsonView(false);
  22543. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22544. if (group == null)
  22545. {
  22546. jw.Msg = "暂无该团组!";
  22547. return Ok(jw);
  22548. }
  22549. //模板路径
  22550. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  22551. var fileName = string.Empty;
  22552. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  22553. bool bold = false;
  22554. if (dto.FileIndex == 1)
  22555. {
  22556. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  22557. }
  22558. else if (dto.FileIndex == 2)
  22559. {
  22560. fileName = "省外办-报批.docx";
  22561. bold = false;
  22562. titleFont = "方正黑体简体";
  22563. timeFont = "Times New Roman";
  22564. contentFont = "方正仿宋_GBK";
  22565. }
  22566. else if (dto.FileIndex == 3)
  22567. {
  22568. fileName = "市外办-报批.docx";
  22569. titleFont = "方正黑体简体";
  22570. timeFont = "Times New Roman";
  22571. contentFont = "方正仿宋简体";
  22572. }
  22573. tempPath = tempPath + fileName;
  22574. //载入模板
  22575. Document doc = new Document(tempPath);
  22576. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22577. //获取所填表格的序数
  22578. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22579. Aspose.Words.Tables.Row titleRowClone = null;
  22580. Aspose.Words.Tables.Row CenterRowClone = null;
  22581. int index = 0;
  22582. int indexChi = 0;
  22583. int SetIndex = 0;
  22584. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  22585. //获取数据,放到datatable
  22586. foreach (var item in ApprovalTravelArr)
  22587. {
  22588. if (index > 0)
  22589. {
  22590. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  22591. tableOne.AppendChild(titleRowClone);
  22592. }
  22593. var textTime = item.Date;
  22594. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  22595. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  22596. SetIndex++;
  22597. if (ChiRep.Count > 0)
  22598. {
  22599. foreach (var itemChi in ChiRep)
  22600. {
  22601. var txtTime = itemChi.Time;
  22602. var txtDetail = itemChi.Details;
  22603. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  22604. {
  22605. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  22606. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22607. //indexChi++;
  22608. //SetIndex++;
  22609. break;
  22610. }
  22611. if (indexChi > 0)
  22612. {
  22613. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22614. tableOne.AppendChild(CenterRowClone);
  22615. }
  22616. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  22617. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  22618. indexChi++;
  22619. SetIndex++;
  22620. }
  22621. }
  22622. //else
  22623. //{
  22624. // if (indexChi > 0)
  22625. // {
  22626. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22627. // tableOne.AppendChild(CenterRowClone);
  22628. // }
  22629. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  22630. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22631. // indexChi++;
  22632. // SetIndex++;
  22633. //}
  22634. index++;
  22635. }
  22636. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  22637. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22638. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22639. jw.Code = 200;
  22640. jw.Msg = "";
  22641. return Ok(jw);
  22642. }
  22643. private string ParseBlackTime(string time)
  22644. {
  22645. // 匹配可能只有分钟的情况
  22646. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  22647. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  22648. if (match.Success)
  22649. {
  22650. string hours = match.Groups[1].Value;
  22651. string minutes = match.Groups[2].Value;
  22652. // 如果小时部分为空,则只显示分钟
  22653. if (string.IsNullOrEmpty(hours))
  22654. {
  22655. return $"{minutes}分钟";
  22656. }
  22657. // 如果分钟部分为空,则只显示小时
  22658. else if (string.IsNullOrEmpty(minutes))
  22659. {
  22660. return $"{hours}小时";
  22661. }
  22662. // 否则显示完整格式
  22663. else
  22664. {
  22665. return $"{hours}小时{minutes}分钟";
  22666. }
  22667. }
  22668. else
  22669. {
  22670. return "未知时长";
  22671. }
  22672. }
  22673. private string intToString(int numberVal)
  22674. {
  22675. string numberval = numberVal.ToString();
  22676. Dictionary<char, string> Number = new Dictionary<char, string>();
  22677. Number.Add('1', "一");
  22678. Number.Add('2', "二");
  22679. Number.Add('3', "三");
  22680. Number.Add('4', "四");
  22681. Number.Add('5', "五");
  22682. Number.Add('6', "六");
  22683. Number.Add('7', "七");
  22684. Number.Add('8', "八");
  22685. Number.Add('9', "九");
  22686. string stringNumberVal = string.Empty;
  22687. for (int i = 0; i < numberval.Length; i++)
  22688. {
  22689. if (i == 0)
  22690. {
  22691. stringNumberVal += Number[numberval[i]];
  22692. }
  22693. else if (i >= 1)
  22694. {
  22695. if (numberval[i] == '0')
  22696. {
  22697. stringNumberVal = "十";
  22698. }
  22699. else
  22700. {
  22701. stringNumberVal += "十" + Number[numberval[i]];
  22702. }
  22703. }
  22704. }
  22705. return stringNumberVal;
  22706. }
  22707. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22708. {
  22709. //获取table中的某个单元格,从0开始
  22710. Cell lshCell = table.Rows[rows].Cells[cells];
  22711. //将单元格中段落移除
  22712. foreach (Paragraph item in lshCell.Paragraphs)
  22713. {
  22714. lshCell.Paragraphs.Remove(item);
  22715. }
  22716. if (val.Contains("\r\n"))
  22717. {
  22718. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22719. foreach (var item in spArr)
  22720. {
  22721. //新建一个段落
  22722. Paragraph p = new Paragraph(doc);
  22723. var r = new Run(doc, item);
  22724. //设置字体
  22725. if (!string.IsNullOrEmpty(font))
  22726. {
  22727. r.Font.Name = font;
  22728. }
  22729. r.Font.Bold = bold;
  22730. //把设置的值赋给之前新建的段落
  22731. p.AppendChild(r);
  22732. //将此段落加到单元格内
  22733. lshCell.AppendChild(p);
  22734. }
  22735. }
  22736. else
  22737. {
  22738. //新建一个段落
  22739. Paragraph p = new Paragraph(doc);
  22740. var r = new Run(doc, val);
  22741. //设置字体
  22742. if (!string.IsNullOrEmpty(font))
  22743. {
  22744. r.Font.Name = font;
  22745. }
  22746. r.Font.Bold = bold;
  22747. //把设置的值赋给之前新建的段落
  22748. p.AppendChild(r);
  22749. //将此段落加到单元格内
  22750. lshCell.AppendChild(p);
  22751. }
  22752. }
  22753. /// <summary>
  22754. /// 报批行程AI续写
  22755. /// </summary>
  22756. /// <returns></returns>
  22757. [HttpPost]
  22758. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22759. {
  22760. var jw = JsonView(false);
  22761. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22762. {
  22763. jw.Msg = "参数有误!";
  22764. return Ok(jw);
  22765. }
  22766. KiMiApiClient kiMi = new KiMiApiClient();
  22767. List<SeedMessages> messages = new List<SeedMessages>() {
  22768. new SeedMessages
  22769. {
  22770. Role = KimiRole.system,
  22771. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22772. },
  22773. new SeedMessages
  22774. {
  22775. Role = KimiRole.user,
  22776. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22777. }
  22778. };
  22779. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22780. string data = kimi_result.Choices[0]?.Message.Content;
  22781. if (string.IsNullOrWhiteSpace(data))
  22782. {
  22783. jw.Data = "Ai续写失败!";
  22784. }
  22785. else
  22786. {
  22787. jw = JsonView(true, "success!", data);
  22788. }
  22789. return Ok(jw);
  22790. }
  22791. #endregion
  22792. #region 团组接待意见调查
  22793. /// <summary>
  22794. /// 团组接待意见调查 - 信息管理
  22795. /// 基础数据(团组)
  22796. /// </summary>
  22797. /// <returns></returns>
  22798. [HttpGet]
  22799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22800. public async Task<IActionResult> OpinionaireInit()
  22801. {
  22802. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22803. .Select(x => new
  22804. {
  22805. x.Id,
  22806. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22807. })
  22808. .OrderByDescending(x => x.Id)
  22809. .ToListAsync();
  22810. return Ok(JsonView(groupData, groupData.Count));
  22811. }
  22812. /// <summary>
  22813. /// 团组接待意见调查 - 信息管理
  22814. /// 列表
  22815. /// </summary>
  22816. /// <param name="groupId"></param>
  22817. /// <returns></returns>
  22818. [HttpGet("{groupId}")]
  22819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22820. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22821. {
  22822. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22823. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22824. .Select(x => new
  22825. {
  22826. x.Id,
  22827. x.TourGuideName,
  22828. x.CityName,
  22829. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22830. x.CreateTime
  22831. })
  22832. .OrderBy(x => x.Id)
  22833. .ToListAsync();
  22834. return Ok(JsonView(data));
  22835. }
  22836. /// <summary>
  22837. /// 团组接待意见调查 - 信息管理
  22838. /// 保存
  22839. /// </summary>
  22840. /// <param name="dto"></param>
  22841. /// <returns></returns>
  22842. [HttpPost]
  22843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22844. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22845. {
  22846. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22847. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22848. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22849. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22850. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22851. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22852. _opinionaireRep.BeginTran();
  22853. if (addData != null && addData.Count > 0)
  22854. {
  22855. foreach (var item in addData)
  22856. {
  22857. item.CreateUserId = currUserInfo.UserId;
  22858. item.DiId = dto.DiId;
  22859. }
  22860. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22861. }
  22862. if (updData != null && updData.Count > 0)
  22863. {
  22864. var upd = await _opinionaireRep._sqlSugar
  22865. .Updateable(updData)
  22866. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22867. .WhereColumns(x => new { x.Id })
  22868. .ExecuteCommandAsync();
  22869. }
  22870. _opinionaireRep.CommitTran();
  22871. return Ok(JsonView("操作成功!"));
  22872. }
  22873. /// <summary>
  22874. /// 团组接待意见调查 - 信息管理
  22875. /// 删除
  22876. /// </summary>
  22877. /// <param name="id"></param>
  22878. /// <returns></returns>
  22879. [HttpDelete("{id}")]
  22880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22881. public async Task<IActionResult> OpinionaireManageDel(int id)
  22882. {
  22883. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22884. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22885. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22886. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22887. if (!del) return Ok(JsonView("操作失败!"));
  22888. return Ok(JsonView("操作成功!"));
  22889. }
  22890. /// <summary>
  22891. /// 团组接待意见调查 - 用户
  22892. /// 列表
  22893. /// </summary>
  22894. /// <param name="diId"></param>
  22895. /// <returns></returns>
  22896. [HttpGet("{diId}")]
  22897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22898. public async Task<IActionResult> OpinionaireUserList(int diId)
  22899. {
  22900. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22901. var sql = string.Format(@"
  22902. SELECT
  22903. o.Id,
  22904. o.DiId,
  22905. di.TeamName AS 'GroupName',
  22906. di.VisitPNumber AS 'PeopleNumber',
  22907. di.ClientName AS 'LeadGroup',
  22908. di.VisitCountry AS 'Travel',
  22909. di.VisitDays AS 'Days',
  22910. o.CityName,
  22911. o.TourGuideName,
  22912. o.Catering,
  22913. o.CateringReason,
  22914. o.Stay,
  22915. o.StayReason,
  22916. o.[Route],
  22917. o.RouteReason,
  22918. o.OfficialActivity,
  22919. o.OfficialActivityReason,
  22920. o.TourGuide,
  22921. o.TourGuideReason,
  22922. o.[Translate],
  22923. o.TranslateReason,
  22924. o.Trip,
  22925. o.TripReason,
  22926. o.ESFileName,
  22927. o.SignatureDate,
  22928. o.Remark
  22929. FROM
  22930. Grp_Opinionaire o
  22931. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22932. WHERE
  22933. o.IsDel = 0
  22934. AND o.DiId = {0}
  22935. ORDER BY
  22936. o.Id ASC", diId);
  22937. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22938. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22939. return Ok(JsonView(data));
  22940. }
  22941. /// <summary>
  22942. /// 团组接待意见调查 - 用户
  22943. /// 保存
  22944. /// </summary>
  22945. /// <param name="dto"></param>
  22946. /// <returns></returns>
  22947. [HttpPost]
  22948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22949. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22950. {
  22951. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22952. foreach (var item in dto)
  22953. {
  22954. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22955. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22956. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22957. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22958. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22959. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22960. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22961. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22962. }
  22963. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22964. if (!Directory.Exists(filePathBase))
  22965. {
  22966. Directory.CreateDirectory(filePathBase);
  22967. }
  22968. #region 上传文件
  22969. var filePaths = new List<string>();
  22970. foreach (var item in dto)
  22971. {
  22972. var file = item.File;
  22973. // 将文件保存到指定位置
  22974. var filePath = Path.Combine(filePathBase, file.FileName);
  22975. using (var stream = new FileStream(filePath, FileMode.Create))
  22976. {
  22977. await file.CopyToAsync(stream);
  22978. }
  22979. //验证文件是否上传成功
  22980. if (!System.IO.File.Exists(filePath))
  22981. {
  22982. foreach (var filePathStr in filePaths)
  22983. {
  22984. System.IO.File.Delete(filePathStr);
  22985. }
  22986. return Ok(JsonView(false, "文件上传失败!"));
  22987. }
  22988. item.ESFileName = file.FileName;
  22989. }
  22990. #endregion
  22991. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22992. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22993. .UpdateColumns(x => new
  22994. {
  22995. x.Catering,
  22996. x.CateringReason,
  22997. x.Stay,
  22998. x.StayReason,
  22999. x.Route,
  23000. x.RouteReason,
  23001. x.OfficialActivity,
  23002. x.OfficialActivityReason,
  23003. x.TourGuide,
  23004. x.TourGuideReason,
  23005. x.Translate,
  23006. x.TranslateReason,
  23007. x.Trip,
  23008. x.TripReason,
  23009. x.ESFileName,
  23010. x.SignatureDate,
  23011. x.Remark
  23012. })
  23013. .WhereColumns(x => new { x.Id })
  23014. .ExecuteCommandAsync();
  23015. if (upd < 1)
  23016. {
  23017. foreach (var filePathStr in filePaths)
  23018. {
  23019. System.IO.File.Delete(filePathStr);
  23020. }
  23021. return Ok(JsonView(false));
  23022. }
  23023. return Ok(JsonView(true));
  23024. }
  23025. #endregion
  23026. #region 团组餐厅相关信息
  23027. /// <summary>
  23028. /// 团组相关餐厅信息
  23029. /// 基础数据(团组)
  23030. /// </summary>
  23031. /// <returns></returns>
  23032. [HttpGet]
  23033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23034. public async Task<IActionResult> RestaurantInit()
  23035. {
  23036. return Ok(await _restaurantRep.InitAsync());
  23037. }
  23038. /// <summary>
  23039. /// 团组相关餐厅信息
  23040. /// Item
  23041. /// </summary>
  23042. /// <param name="dto"></param>
  23043. /// <returns></returns>
  23044. [HttpPost]
  23045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23046. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  23047. {
  23048. int portType = dto.PortType,
  23049. groupId = dto.GroupId;
  23050. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23051. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23052. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  23053. }
  23054. /// <summary>
  23055. /// 团组相关餐厅信息
  23056. /// List
  23057. /// </summary>
  23058. /// <param name="dto"></param>
  23059. /// <returns></returns>
  23060. [HttpPost]
  23061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23062. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  23063. {
  23064. int portType = dto.PortType,
  23065. groupId = dto.GroupId;
  23066. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23067. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23068. var sql = string.Format(@" SELECT
  23069. ri.Id,
  23070. ri.GroupId,
  23071. ri.Date,
  23072. ri.StartTime,
  23073. ri.EndTime,
  23074. CASE WHEN ri.Type = 1 THEN '早餐'
  23075. WHEN ri.Type = 2 THEN '午餐'
  23076. WHEN ri.Type = 3 THEN '晚餐'
  23077. ELSE '其他'
  23078. END AS 'Type',
  23079. ri.Name,
  23080. ri.Address,
  23081. ri.Tel,
  23082. ri.Remark,
  23083. ri.CreateTime,
  23084. u.CnName AS CreateUserName
  23085. FROM
  23086. Grp_RestaurantInfo ri
  23087. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  23088. WHERE
  23089. ri.IsDel = 0
  23090. AND ri.GroupId = {0}
  23091. ORDER BY
  23092. ri.Date ASC
  23093. ", groupId);
  23094. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  23095. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  23096. return Ok(JsonView(infos));
  23097. }
  23098. /// <summary>
  23099. /// 团组相关餐厅信息
  23100. /// Info
  23101. /// </summary>
  23102. /// <param name="dto"></param>
  23103. /// <returns></returns>
  23104. [HttpPost]
  23105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23106. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23107. {
  23108. int portType = dto.PortType,
  23109. id = dto.Id;
  23110. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23111. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23112. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23113. }
  23114. /// <summary>
  23115. /// 团组相关餐厅信息
  23116. /// Op
  23117. /// </summary>
  23118. /// <param name="dto"></param>
  23119. /// <returns></returns>
  23120. [HttpPost]
  23121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23122. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23123. {
  23124. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23125. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23126. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23127. return Ok(await _restaurantRep.OpAsync(dto));
  23128. }
  23129. /// <summary>
  23130. /// 团组相关餐厅信息
  23131. /// Del
  23132. /// </summary>
  23133. /// <param name="dto"></param>
  23134. /// <returns></returns>
  23135. [HttpPost]
  23136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23137. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23138. {
  23139. int userId = dto.DeleteUserId;
  23140. var id = dto.Id;
  23141. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23142. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23143. return Ok(await _restaurantRep.DelAsync(dto));
  23144. }
  23145. #endregion
  23146. #region 团组会务成本
  23147. /// <summary>
  23148. /// 团组会务成本数据初始化
  23149. /// </summary>
  23150. /// <returns></returns>
  23151. [HttpPost]
  23152. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  23153. {
  23154. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23155. .OrderByDescending(x => x.CreateTime)
  23156. .Where(x => x.IsDel == 0)
  23157. .Select<DelegationEasyView>();
  23158. DelegationEasyView di = Dto.GroupId == 0 ?
  23159. expr.First() :
  23160. expr.First(x => x.Id == Dto.GroupId);
  23161. if (di == null)
  23162. {
  23163. return Ok(JsonView(false, "团组信息不存在!"));
  23164. }
  23165. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  23166. .Where(x => x.IsDel == 0 && x.STid == 21)
  23167. .Select(x => new { x.Id, Text = x.Name })
  23168. .ToListAsync();
  23169. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  23170. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  23171. .Select(x => x.Id)
  23172. .ToList();
  23173. //仅检索会务团组
  23174. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23175. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  23176. .OrderByDescending(x => x.VisitDate)
  23177. .Select(x => new { x.Id, x.TeamName })
  23178. .ToListAsync();
  23179. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  23180. var userList = await _sqlSugar.Queryable<Sys_Users>()
  23181. .Where(x => x.IsDel == 0)
  23182. .Select(x => new { x.Id, x.CnName })
  23183. .ToListAsync();
  23184. var units = await _sqlSugar.Queryable<Sys_SetData>()
  23185. .Where(x => x.IsDel == 0 && x.STid == 119)
  23186. .Select(x => new { x.Id, Text = x.Name })
  23187. .ToListAsync();
  23188. var FileType = new[]
  23189. {
  23190. new { Id = 0 , Name = "成本下载" },
  23191. new { Id = 1 , Name = "报价下载" },
  23192. new { Id = 2 , Name = "总表下载" },
  23193. };
  23194. var GM = new List<int>();
  23195. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  23196. try
  23197. {
  23198. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  23199. }
  23200. catch (Exception ex)
  23201. {
  23202. GM = new List<int>() { 21 };
  23203. }
  23204. var isReview = Dto.UserId == 21;
  23205. var isGM = GM.Contains(Dto.UserId);
  23206. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23207. .Where(x => x.IsDel == 0)
  23208. .Select<ConferenceAffairsCostView>()
  23209. .First(x => x.Diid == di.Id);
  23210. if (ConferenceAffairsCost == null)
  23211. {
  23212. ConferenceAffairsCost = new ConferenceAffairsCostView();
  23213. ConferenceAffairsCost.Diid = di.Id;
  23214. }
  23215. #region 权限校验
  23216. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  23217. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  23218. .Select(x => x.UserId)
  23219. .Distinct()
  23220. .ToList();
  23221. if (!ids.Contains(Dto.UserId) && !isGM)
  23222. {
  23223. return Ok(JsonView(201, "暂无权限!", new
  23224. {
  23225. typeData,
  23226. groupList,
  23227. currenyList,
  23228. isGM,
  23229. userList,
  23230. units,
  23231. isReview,
  23232. operatorUser = ids,
  23233. di,
  23234. FileType
  23235. }));
  23236. }
  23237. #endregion
  23238. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23239. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23240. .Select<ConferenceAffairsCostChildView>()
  23241. .OrderBy(x => x.Index)
  23242. .ToList();
  23243. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  23244. {
  23245. ConferenceAffairsCostChi[i - 1].Index = i;
  23246. }
  23247. var backData = new
  23248. {
  23249. ConferenceAffairsCost,
  23250. ConferenceAffairsCostChi,
  23251. typeData,
  23252. groupList,
  23253. currenyList,
  23254. isGM,
  23255. userList,
  23256. units,
  23257. isReview,
  23258. operatorUser = ids,
  23259. di,
  23260. FileType
  23261. };
  23262. return Ok(JsonView(true, "SUCCESS", backData));
  23263. }
  23264. /// <summary>
  23265. /// 会务成本保存
  23266. /// </summary>
  23267. /// <returns></returns>
  23268. [HttpPost]
  23269. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23270. {
  23271. _sqlSugar.BeginTran();
  23272. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23273. var childResult = new
  23274. {
  23275. success = 0,
  23276. error = 0
  23277. };
  23278. try
  23279. {
  23280. if (data.Id == 0)
  23281. {
  23282. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23283. .Where(x => x.Diid == Dto.GroupId)
  23284. .SetColumns(x => new Grp_ConferenceAffairsCost
  23285. {
  23286. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23287. DeleteUserId = Dto.UserId
  23288. })
  23289. .ExecuteCommand();
  23290. data.Diid = Dto.GroupId;
  23291. data.CreateTime = DateTime.Now;
  23292. data.CreateUserId = Dto.UserId;
  23293. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23294. .ExecuteReturnIdentity();
  23295. }
  23296. else
  23297. {
  23298. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23299. .ExecuteCommand();
  23300. data.Id = data.Id;
  23301. }
  23302. if (Dto.ConferenceAffairsCostChild.Any())
  23303. {
  23304. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23305. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23306. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  23307. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  23308. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23309. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23310. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23311. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  23312. .ExecuteCommand() : 0;
  23313. childResult = childResult with
  23314. {
  23315. error = notUpdateArr.Count(),
  23316. success = inrsetCount + updateCount
  23317. };
  23318. }
  23319. _sqlSugar.CommitTran();
  23320. }
  23321. catch (Exception ex)
  23322. {
  23323. _sqlSugar.RollbackTran();
  23324. return Ok(JsonView(false, "失败!" + ex.Message));
  23325. }
  23326. return Ok(JsonView(true, "操作成功!", childResult));
  23327. }
  23328. [HttpPost]
  23329. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  23330. {
  23331. var count = 0;
  23332. if (Dto.ConferenceAffairsCostChildids.Any())
  23333. {
  23334. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  23335. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  23336. SetColumns(x => new Grp_ConferenceAffairsCostChild
  23337. {
  23338. ReviewStatus = Dto.ReviewStatus
  23339. }).
  23340. ExecuteCommand();
  23341. }
  23342. return Ok(JsonView(true, "操作成功!", count));
  23343. }
  23344. /// <summary>
  23345. /// 会务成本所有数据清除
  23346. /// </summary>
  23347. /// <param name="Dto"></param>
  23348. /// <returns></returns>
  23349. [HttpPost]
  23350. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  23351. {
  23352. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23353. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  23354. _sqlSugar.BeginTran();
  23355. try
  23356. {
  23357. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23358. .Where(x => x.Diid == Dto.GroupId)
  23359. .SetColumns(x => new Grp_ConferenceAffairsCost
  23360. {
  23361. IsDel = 1,
  23362. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23363. DeleteUserId = Dto.UserId
  23364. })
  23365. .ExecuteCommand();
  23366. if (delCount > 0)
  23367. {
  23368. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23369. .Where(x => x.Diid == Dto.GroupId)
  23370. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23371. {
  23372. IsDel = 1,
  23373. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23374. DeleteUserId = Dto.UserId
  23375. })
  23376. .ExecuteCommand();
  23377. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23378. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23379. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23380. {
  23381. IsDel = 1,
  23382. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23383. DeleteUserId = Dto.UserId
  23384. })
  23385. .ExecuteCommand();
  23386. }
  23387. _sqlSugar.CommitTran();
  23388. }
  23389. catch (Exception ex)
  23390. {
  23391. _sqlSugar.RollbackTran();
  23392. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23393. }
  23394. return Ok(JsonView(true, "操作成功!"));
  23395. }
  23396. /// <summary>
  23397. /// 子项数据删除
  23398. /// </summary>
  23399. /// <param name="Dto"></param>
  23400. /// <returns></returns>
  23401. [HttpPost]
  23402. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  23403. {
  23404. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  23405. .Any(x => x.ReviewStatus == 1);
  23406. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  23407. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23408. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  23409. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23410. {
  23411. IsDel = 1,
  23412. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23413. DeleteUserId = Dto.UserId
  23414. })
  23415. .ExecuteCommand();
  23416. return Ok(JsonView(true, "SUCCESS!", count));
  23417. }
  23418. /// <summary>
  23419. /// 会务成本权限分配
  23420. /// </summary>
  23421. /// <param name="Dto"></param>
  23422. /// <returns></returns>
  23423. [HttpPost]
  23424. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  23425. {
  23426. _sqlSugar.BeginTran();
  23427. var count = 0;
  23428. try
  23429. {
  23430. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23431. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23432. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23433. {
  23434. IsDel = 1,
  23435. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23436. DeleteUserId = Dto.CreateUserId
  23437. })
  23438. .ExecuteCommand();
  23439. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  23440. {
  23441. CreateTime = DateTime.Now,
  23442. CreateUserId = Dto.CreateUserId,
  23443. UserId = x,
  23444. Diid = Dto.GroupId,
  23445. }).ToList()).ExecuteCommand();
  23446. _sqlSugar.CommitTran();
  23447. }
  23448. catch (Exception ex)
  23449. {
  23450. _sqlSugar.RollbackTran();
  23451. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23452. }
  23453. return Ok(JsonView(true, "操作成功!", count));
  23454. }
  23455. /// <summary>
  23456. /// 团组会务成本文件下载
  23457. /// </summary>
  23458. /// <returns></returns>
  23459. [HttpPost]
  23460. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  23461. {
  23462. var FileType = new[]
  23463. {
  23464. new { Id = 0 , Name = "成本下载" },
  23465. new { Id = 1 , Name = "报价下载" },
  23466. new { Id = 2 , Name = "总表下载" },
  23467. };
  23468. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23469. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  23470. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23471. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  23472. .Select<DelegationEasyView>()
  23473. .First();
  23474. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23475. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  23476. if (main == null)
  23477. {
  23478. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  23479. }
  23480. JsonView jw = JsonView(false);
  23481. //总表下载
  23482. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  23483. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  23484. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  23485. var field = string.Empty;
  23486. var fileTypeName = string.Empty;
  23487. field = @$"
  23488. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  23489. b.Name as PriceTypeStr ,
  23490. c.Name as CurrencyStr ,
  23491. d.Name as UnitStr ,
  23492. case a.ReviewStatus
  23493. WHEN 1 THEN '已通过'
  23494. WHEN 0 THEN '未审核'
  23495. WHEN -1 THEN '未通过'
  23496. ELSE '未审核'
  23497. END AS ReviewStatusStr
  23498. ";
  23499. if (Dto.FileTypeId == 0)
  23500. {
  23501. fileTypeName = "会务成本成本表";
  23502. loadPath += $"{fileTypeName}.xlsx";
  23503. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23504. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23505. }
  23506. else if (Dto.FileTypeId == 1)
  23507. {
  23508. fileTypeName = "会务成本报价表";
  23509. loadPath += $"{fileTypeName}.xlsx";
  23510. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23511. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23512. }
  23513. else if (Dto.FileTypeId == 2)
  23514. {
  23515. fileTypeName = "会务成本总表";
  23516. loadPath += $"{fileTypeName}.xlsx";
  23517. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23518. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23519. }
  23520. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  23521. SELECT
  23522. {field}
  23523. FROM Grp_ConferenceAffairsCostChild a
  23524. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  23525. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  23526. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  23527. WHERE a.isdel = 0
  23528. AND a.Diid = {main.Diid}
  23529. AND a.ConferenceAffairsCostId = {main.Id}
  23530. ").ToList();
  23531. var currLists = chiExcelContent.Select(x => new CurrList
  23532. {
  23533. CurrName = x.CurrencyStr,
  23534. CurrRate = x.Rate
  23535. })
  23536. .Distinct()
  23537. .ToList();
  23538. var designer = new WorkbookDesigner
  23539. {
  23540. Workbook = new Workbook(loadPath)
  23541. };
  23542. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  23543. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  23544. designer.SetDataSource("TeamName", di.TeamName);
  23545. designer.SetDataSource("City", main.City);
  23546. designer.SetDataSource("AllCost", main.CostAll);
  23547. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  23548. designer.SetDataSource("Curr", MostCurr.Name);
  23549. designer.SetDataSource("Curr1", MostCurr.Name);
  23550. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  23551. dt.TableName = "TB";
  23552. designer.SetDataSource(dt);
  23553. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  23554. dt1.TableName = "currTb";
  23555. designer.SetDataSource(dt1);
  23556. designer.Process();
  23557. designer.Workbook.Save(outputPath);
  23558. jw = JsonView(true, "操作成功!", new
  23559. {
  23560. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  23561. FilePath = networkPath
  23562. });
  23563. return Ok(jw);
  23564. }
  23565. [HttpPost]
  23566. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  23567. {
  23568. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  23569. .Select(x => x.PriceName).ToList()));
  23570. }
  23571. #endregion
  23572. #region 团组签证流程
  23573. /// <summary>
  23574. /// 团组签证流程 - 团组列表(分页)
  23575. /// </summary>
  23576. /// <returns></returns>
  23577. [HttpPost]
  23578. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  23579. {
  23580. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  23581. string groupName = dto.GroupName.Trim();
  23582. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  23583. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  23584. int portType = dto.PortType;
  23585. RefAsync<int> total = 0;
  23586. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  23587. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  23588. .Where((x, y) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId);
  23589. //构建单字模糊查询
  23590. if (!string.IsNullOrEmpty(groupName))
  23591. {
  23592. var characters = groupName.ToCharArray();
  23593. foreach (var character in characters)
  23594. {
  23595. var charString = character.ToString();
  23596. query = query.Where((x, y) =>
  23597. SqlFunc.Contains(y.TeamName, charString));
  23598. }
  23599. }
  23600. var groups = await query
  23601. .OrderByDescending((x, y) => y.VisitDate)
  23602. .Select((x, y) => new
  23603. {
  23604. y.Id,
  23605. GroupName = y.TeamName
  23606. })
  23607. .ToPageListAsync(pageIndex, pageSize, total);
  23608. var msg = "SUCCESS";
  23609. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  23610. return Ok(JsonView(true, msg, groups, total));
  23611. }
  23612. /// <summary>
  23613. /// 团组签证流程 - 详情
  23614. /// </summary>
  23615. /// <returns></returns>
  23616. [HttpPost]
  23617. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  23618. {
  23619. var res = await _visaProcessRep.Info(dto);
  23620. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  23621. return Ok(JsonView(true, res.Msg, res.Data));
  23622. }
  23623. /// <summary>
  23624. /// 团组签证流程 - 流程创建测试
  23625. /// </summary>
  23626. /// <returns></returns>
  23627. [HttpPost]
  23628. public async Task<IActionResult> VisaProcessAdd(int groupId, int currUserId)
  23629. {
  23630. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  23631. }
  23632. /// <summary>
  23633. /// 团组签证流程 - 流程Top4Init 测试
  23634. /// </summary>
  23635. /// <returns></returns>
  23636. [HttpPost]
  23637. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  23638. {
  23639. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  23640. }
  23641. /// <summary>
  23642. /// 团组签证流程 - 设置状态为已完成
  23643. /// </summary>
  23644. /// <returns></returns>
  23645. [HttpPost]
  23646. public async Task<IActionResult> VisaProcessSetCompleted(int id, int currUserId)
  23647. {
  23648. //参数验证
  23649. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == id && x.IsDel == 0).AnyAsync();
  23650. if (!stepValid) return Ok(JsonView(false, "签证流程ID无效。"));
  23651. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  23652. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  23653. var res = await _visaProcessRep.SetCompleted(id, currUserId);
  23654. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  23655. return Ok(JsonView(true, res.Msg));
  23656. }
  23657. /// <summary>
  23658. /// 团组签证流程 - 修改各步骤内容
  23659. /// </summary>
  23660. /// <returns></returns>
  23661. [HttpPost]
  23662. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  23663. {
  23664. //参数验证
  23665. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  23666. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  23667. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  23668. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  23669. if (dto.StepContents == null && dto.StepContents.Count < 1)
  23670. {
  23671. return Ok(JsonView(false, "步骤内容无效。"));
  23672. }
  23673. //各步骤值处理
  23674. object stepVal;
  23675. if (stepValid.Step == 7) stepVal = dto.StepContents;
  23676. else stepVal = dto.StepContents[0].ToString();
  23677. var stepInfo = new Grp_VisaProcessSteps
  23678. {
  23679. Id = dto.StepId,
  23680. DataType = stepValid.DataType,
  23681. TypedValue = stepVal,
  23682. LastUpdateUserId = dto.CurrUserId
  23683. };
  23684. var res = await _visaProcessRep.Update(stepInfo);
  23685. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  23686. return Ok(JsonView(true, res.Msg));
  23687. }
  23688. /// <summary>
  23689. /// 团组签证流程 - 上传文件
  23690. /// </summary>
  23691. /// <returns></returns>
  23692. [HttpPost]
  23693. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  23694. {
  23695. //参数验证
  23696. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  23697. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  23698. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  23699. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  23700. //验证文件是否存在
  23701. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  23702. //验证该步骤是否可以上传文件
  23703. var uploadSteps = new List<int>() {
  23704. 5, //实际出签时间
  23705. 6, //是否需要开出境证明
  23706. 7, //是否需要办理电子入境卡手续
  23707. };
  23708. if (!uploadSteps.Contains(stepValid.Step))
  23709. {
  23710. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  23711. }
  23712. //验证根目录
  23713. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  23714. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  23715. if (!System.IO.Directory.Exists(rootPath))
  23716. {
  23717. System.IO.Directory.CreateDirectory(rootPath);
  23718. }
  23719. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  23720. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23721. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  23722. .Select(x => $"{x.TeamName}({x.Id})")
  23723. .FirstAsync();
  23724. //创建团组文件夹
  23725. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  23726. if (!System.IO.Directory.Exists(groupPath))
  23727. {
  23728. System.IO.Directory.CreateDirectory(groupPath);
  23729. }
  23730. List<string> filePaths = new List<string>();
  23731. //保存文件
  23732. foreach (var file in dto.Files)
  23733. {
  23734. // 生成存储文件名
  23735. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  23736. var filePath = Path.Combine(groupPath, fileName);
  23737. // 保存文件到磁盘
  23738. using (var stream = new FileStream(filePath, FileMode.Create))
  23739. {
  23740. await file.CopyToAsync(stream);
  23741. }
  23742. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  23743. }
  23744. //数据库存储
  23745. var stepInfo = new Grp_VisaProcessSteps
  23746. {
  23747. Id = dto.StepId,
  23748. TypedFileNameValue = filePaths,
  23749. LastUpdateUserId = dto.CurrUserId
  23750. };
  23751. var res = await _sqlSugar.Updateable<Grp_VisaProcessSteps>()
  23752. .SetColumns(s => new Grp_VisaProcessSteps
  23753. {
  23754. AttachUrl = stepInfo.AttachUrl,
  23755. LastUpdateUserId = dto.CurrUserId,
  23756. LastUpdateTime = DateTime.Now
  23757. })
  23758. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  23759. .ExecuteCommandAsync();
  23760. if (res < 1) Ok(JsonView(false, "文件上传失败。"));
  23761. return Ok(JsonView(true));
  23762. }
  23763. #endregion
  23764. /// <summary>
  23765. /// 123132123
  23766. /// </summary>
  23767. /// <param name="_dto"></param>
  23768. /// <returns></returns>
  23769. [HttpPost]
  23770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23771. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  23772. {
  23773. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  23774. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  23775. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  23776. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  23777. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  23778. dicDetail.Add(789, 1034);
  23779. dicDetail.Add(790, 1035);
  23780. dicDetail.Add(791, 1036);
  23781. dicDetail.Add(792, 1037);
  23782. dicDetail.Add(793, 1038);
  23783. dicDetail.Add(794, 1039);
  23784. dicDetail.Add(795, 1040);
  23785. dicDetail.Add(796, 1041);
  23786. dicDetail.Add(797, 1042);
  23787. dicDetail.Add(798, 1043);
  23788. dicDetail.Add(801, 1044);
  23789. dicDetail.Add(802, 1045);
  23790. dicDetail.Add(803, 1046);
  23791. Dictionary<int, int> dic = new Dictionary<int, int>();
  23792. dic.Add(806, 1027);
  23793. dic.Add(807, 1028);
  23794. dic.Add(808, 1029);
  23795. dic.Add(809, 1030);
  23796. dic.Add(810, 1031);
  23797. dic.Add(811, 1032);
  23798. dic.Add(812, 1033);
  23799. foreach (var item in list_visa)
  23800. {
  23801. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  23802. temp.Coefficient = item.coefficient;
  23803. DateTime dtCrt;
  23804. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  23805. if (b1)
  23806. {
  23807. temp.CreateTime = dtCrt;
  23808. }
  23809. else
  23810. {
  23811. temp.CreateTime = DateTime.Now;
  23812. }
  23813. temp.CreateUserId = item.Operators;
  23814. temp.DeleteTime = "";
  23815. temp.DeleteUserId = 0;
  23816. temp.DiId = int.Parse(item.DIID);
  23817. temp.FilePath = item.FilePath;
  23818. temp.IsDel = item.IsDel;
  23819. temp.Price = item.Price;
  23820. temp.PriceCount = 1;
  23821. temp.PriceCurrency = item.Currency;
  23822. int detailId = 0;
  23823. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  23824. {
  23825. detailId = dicDetail[item.PriceTypeDetail];
  23826. }
  23827. temp.PriceDetailType = detailId;
  23828. temp.PriceDt = DateTime.Now;
  23829. temp.PriceName = item.PriceName;
  23830. temp.PriceSum = item.Price;
  23831. int tid = 0;
  23832. if (dic.ContainsKey(item.PriceType))
  23833. {
  23834. tid = dic[item.PriceType];
  23835. }
  23836. temp.PriceType = tid;
  23837. temp.Remark = item.Remark;
  23838. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  23839. }
  23840. return Ok(JsonView(true, "操作成功!"));
  23841. }
  23842. [HttpPost]
  23843. public IActionResult TimeTest()
  23844. {
  23845. var jw = JsonView(false, "error");
  23846. _sqlSugar.BeginTran();
  23847. try
  23848. {
  23849. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  23850. .Select(x => new Crm_NewClientData
  23851. {
  23852. Id = x.Id,
  23853. Client = x.Client,
  23854. Contact = x.Contact,
  23855. Location = x.Location,
  23856. })
  23857. .ToList();
  23858. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  23859. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  23860. Stopwatch stopwatch = new Stopwatch();
  23861. // 开始计时
  23862. stopwatch.Start();
  23863. foreach (var item in clientList)
  23864. {
  23865. EncryptionProcessor.DecryptProperties(item);
  23866. }
  23867. stopwatch.Stop();
  23868. jw.Code = 200;
  23869. jw.Data = stopwatch.ElapsedMilliseconds;
  23870. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  23871. }
  23872. catch (Exception ex)
  23873. {
  23874. jw.Code = 400;
  23875. jw.Msg = ex.Message;
  23876. }
  23877. return Ok(jw);
  23878. }
  23879. }
  23880. }