GroupsController.cs 926 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833
  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.HSSF.UserModel;
  8. using NPOI.SS.UserModel;
  9. using NPOI.SS.Util;
  10. using NPOI.XSSF.UserModel;
  11. using OASystem.API.Middlewares;
  12. using OASystem.API.OAMethodLib;
  13. using OASystem.API.OAMethodLib.APNs;
  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.QiYeWeChatAPI.AppNotice;
  19. using OASystem.Domain.AesEncryption;
  20. using OASystem.Domain.Dtos.CRM;
  21. using OASystem.Domain.Dtos.FileDto;
  22. using OASystem.Domain.Dtos.Financial;
  23. using OASystem.Domain.Dtos.Groups;
  24. using OASystem.Domain.Entities.Customer;
  25. using OASystem.Domain.Entities.Financial;
  26. using OASystem.Domain.Entities.Groups;
  27. using OASystem.Domain.ViewModels.Financial;
  28. using OASystem.Domain.ViewModels.Groups;
  29. using OASystem.Infrastructure.Repositories.CRM;
  30. using OASystem.Infrastructure.Repositories.Financial;
  31. using OASystem.Infrastructure.Repositories.Groups;
  32. using Quartz.Util;
  33. using SqlSugar.Extensions;
  34. using System.Collections;
  35. using System.Data;
  36. using System.Diagnostics;
  37. using System.Globalization;
  38. using System.IO.Compression;
  39. using static OASystem.API.OAMethodLib.JWTHelper;
  40. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  41. using Bookmark = Aspose.Words.Bookmark;
  42. using Cell = Aspose.Words.Tables.Cell;
  43. using Table = Aspose.Words.Tables.Table;
  44. namespace OASystem.API.Controllers
  45. {
  46. /// <summary>
  47. /// 团组相关
  48. /// </summary>
  49. //[Authorize]
  50. [Route("api/[controller]/[action]")]
  51. public class GroupsController : ControllerBase
  52. {
  53. private readonly ILogger<GroupsController> _logger;
  54. private readonly GrpScheduleRepository _grpScheduleRep;
  55. private readonly IMapper _mapper;
  56. private readonly DelegationInfoRepository _groupRepository;
  57. private readonly TaskAssignmentRepository _taskAssignmentRep;
  58. private readonly AirTicketResRepository _airTicketResRep;
  59. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  60. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  61. private readonly DelegationEnDataRepository _delegationEnDataRep;
  62. private readonly DelegationVisaRepository _delegationVisaRep;
  63. private readonly VisaPriceRepository _visaPriceRep;
  64. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  65. private readonly HotelPriceRepository _hotelPriceRep;
  66. private readonly CustomersRepository _customersRep;
  67. private readonly MessageRepository _message;
  68. private readonly SqlSugarClient _sqlSugar;
  69. private readonly TourClientListRepository _tourClientListRep;
  70. private readonly TeamRateRepository _teamRateRep;
  71. #region 成本相关
  72. private readonly CheckBoxsRepository _checkBoxs;
  73. private readonly GroupCostRepository _GroupCostRepository;
  74. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  75. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  76. #endregion
  77. private readonly SetDataRepository _setDataRep;
  78. private string url;
  79. private string path;
  80. private readonly EnterExitCostRepository _enterExitCostRep;
  81. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  82. private readonly UsersRepository _usersRep;
  83. private readonly IJuHeApiService _juHeApi;
  84. private readonly InvertedListRepository _invertedListRep;
  85. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  86. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  87. private readonly ThreeCodeRepository _threeCodeRepository;
  88. private readonly HotelInquiryRepository _hotelInquiryRep;
  89. private readonly FeeAuditRepository _feeAuditRep;
  90. private readonly VisaCommissionRepository _visaCommissionRep;
  91. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  92. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  93. private readonly List<CurrencyInfo> _currencyInit;
  94. private readonly List<int> _portTypeData;
  95. private readonly TableOperationRecordRepository _tableorRep;
  96. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  97. /// <summary>
  98. /// 构造函数
  99. /// </summary>
  100. /// <param name="logger"></param>
  101. /// <param name="mapper"></param>
  102. /// <param name="hubContext"></param>
  103. /// <param name="sqlSugar"></param>
  104. /// <param name="grpScheduleRep"></param>
  105. /// <param name="groupRepository"></param>
  106. /// <param name="taskAssignmentRep"></param>
  107. /// <param name="airTicketResRep"></param>
  108. /// <param name="decreasePaymentsRep"></param>
  109. /// <param name="InvitationOfficialActivitiesRep"></param>
  110. /// <param name="delegationEnDataRep"></param>
  111. /// <param name="enterExitCostRep"></param>
  112. /// <param name="delegationVisaRep"></param>
  113. /// <param name="message"></param>
  114. /// <param name="visaPriceRep"></param>
  115. /// <param name="carTouristGuideGroundRep"></param>
  116. /// <param name="checkBoxs"></param>
  117. /// <param name="GroupCostRepository"></param>
  118. /// <param name="CostTypeHotelNumberRepository"></param>
  119. /// <param name="GroupCostParameterRepository"></param>
  120. /// <param name="hotelPriceRep"></param>
  121. /// <param name="customersRep"></param>
  122. /// <param name="setDataRep"></param>
  123. /// <param name="tourClientListRep"></param>
  124. /// <param name="teamRateRep"></param>
  125. /// <param name="usersRep"></param>
  126. /// <param name="juHeApi"></param>
  127. /// <param name="invertedListRep"></param>
  128. /// <param name="visaFeeInfoRep"></param>
  129. /// <param name="ticketBlackCodeRep"></param>
  130. /// <param name="hotelInquiryRep"></param>
  131. /// <param name="threeCodeRepository"></param>
  132. /// <param name="feeAuditRep"></param>
  133. /// <param name="visaCommissionRep"></param>
  134. /// <param name="ffrRep"></param>
  135. /// <param name="opinionaireRep"></param>
  136. /// <param name="tableorRep"></param>
  137. public GroupsController(
  138. ILogger<GroupsController> logger,
  139. IMapper mapper,
  140. IHubContext<ChatHub, IChatClient> hubContext,
  141. SqlSugarClient sqlSugar,
  142. GrpScheduleRepository grpScheduleRep,
  143. DelegationInfoRepository groupRepository,
  144. TaskAssignmentRepository taskAssignmentRep,
  145. AirTicketResRepository airTicketResRep,
  146. DecreasePaymentsRepository decreasePaymentsRep,
  147. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  148. DelegationEnDataRepository delegationEnDataRep,
  149. EnterExitCostRepository enterExitCostRep,
  150. DelegationVisaRepository delegationVisaRep,
  151. MessageRepository message,
  152. VisaPriceRepository visaPriceRep,
  153. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  154. CheckBoxsRepository checkBoxs,
  155. GroupCostRepository GroupCostRepository,
  156. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  157. GroupCostParameterRepository GroupCostParameterRepository,
  158. HotelPriceRepository hotelPriceRep,
  159. CustomersRepository customersRep,
  160. SetDataRepository setDataRep,
  161. TourClientListRepository tourClientListRep,
  162. TeamRateRepository teamRateRep,
  163. UsersRepository usersRep, IJuHeApiService juHeApi,
  164. InvertedListRepository invertedListRep,
  165. VisaFeeInfoRepository visaFeeInfoRep,
  166. TicketBlackCodeRepository ticketBlackCodeRep,
  167. HotelInquiryRepository hotelInquiryRep,
  168. ThreeCodeRepository threeCodeRepository,
  169. FeeAuditRepository feeAuditRep,
  170. VisaCommissionRepository visaCommissionRep,
  171. ForeignReceivablesRepository ffrRep,
  172. OpinionaireRepository opinionaireRep,
  173. TableOperationRecordRepository tableorRep,
  174. EnterExitCostDraftRepository enterExitCostDraftRep
  175. )
  176. {
  177. _logger = logger;
  178. _mapper = mapper;
  179. _grpScheduleRep = grpScheduleRep;
  180. _groupRepository = groupRepository;
  181. _taskAssignmentRep = taskAssignmentRep;
  182. _airTicketResRep = airTicketResRep;
  183. _sqlSugar = sqlSugar;
  184. url = AppSettingsHelper.Get("ExcelBaseUrl");
  185. path = AppSettingsHelper.Get("ExcelBasePath");
  186. if (!System.IO.Directory.Exists(path))
  187. {
  188. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  189. }
  190. _decreasePaymentsRep = decreasePaymentsRep;
  191. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  192. _delegationEnDataRep = delegationEnDataRep;
  193. _enterExitCostRep = enterExitCostRep;
  194. _delegationVisaRep = delegationVisaRep;
  195. _message = message;
  196. _visaPriceRep = visaPriceRep;
  197. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  198. _checkBoxs = checkBoxs;
  199. _GroupCostRepository = GroupCostRepository;
  200. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  201. _GroupCostParameterRepository = GroupCostParameterRepository;
  202. _hotelPriceRep = hotelPriceRep;
  203. _customersRep = customersRep;
  204. _setDataRep = setDataRep;
  205. _tourClientListRep = tourClientListRep;
  206. _teamRateRep = teamRateRep;
  207. _hubContext = hubContext;
  208. _usersRep = usersRep;
  209. _juHeApi = juHeApi;
  210. _invertedListRep = invertedListRep;
  211. _visaFeeInfoRep = visaFeeInfoRep;
  212. _ticketBlackCodeRep = ticketBlackCodeRep;
  213. _hotelInquiryRep = hotelInquiryRep;
  214. _threeCodeRepository = threeCodeRepository;
  215. _feeAuditRep = feeAuditRep;
  216. _visaCommissionRep = visaCommissionRep;
  217. _ffrRep = ffrRep;
  218. _opinionaireRep = opinionaireRep;
  219. _currencyInit = new List<CurrencyInfo>()
  220. {
  221. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  222. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  223. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  224. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  225. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  226. };
  227. _portTypeData = new List<int>() { 2, 3 };
  228. _tableorRep = tableorRep;
  229. _enterExitCostDraftRep = enterExitCostDraftRep;
  230. }
  231. #region 流程管控
  232. /// <summary>
  233. /// 获取团组流程管控信息
  234. /// </summary>
  235. /// <param name="paras">参数Json字符串</param>
  236. /// <returns></returns>
  237. [HttpPost]
  238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  239. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  240. {
  241. if (string.IsNullOrEmpty(_jsonDto.Paras))
  242. {
  243. return Ok(JsonView(false, "参数为空"));
  244. }
  245. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  246. if (_ScheduleDto != null)
  247. {
  248. if (_ScheduleDto.SearchType == 2)//获取列表
  249. {
  250. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  251. return Ok(JsonView(_grpScheduleViewList));
  252. }
  253. else//获取对象
  254. {
  255. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  256. if (_grpScheduleView != null)
  257. {
  258. return Ok(JsonView(_grpScheduleView));
  259. }
  260. }
  261. }
  262. else
  263. {
  264. return Ok(JsonView(false, "参数反序列化失败"));
  265. }
  266. return Ok(JsonView(false, "暂无数据!"));
  267. }
  268. /// <summary>
  269. /// 修改团组流程管控详细表数据
  270. /// </summary>
  271. /// <param name="paras"></param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  275. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  276. {
  277. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  278. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  279. .SetColumns(it => it.Duty == _detail.Duty)
  280. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  281. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  282. .SetColumns(it => it.JobContent == _detail.JobContent)
  283. .SetColumns(it => it.Remark == _detail.Remark)
  284. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  285. .Where(s => s.Id == dto.Id)
  286. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  287. .ExecuteCommandAsync();
  288. if (result > 0)
  289. {
  290. return Ok(JsonView(true, "保存成功!"));
  291. }
  292. return Ok(JsonView(false, "保存失败!"));
  293. }
  294. /// <summary>
  295. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  296. /// </summary>
  297. /// <param name="dto"></param>
  298. /// <returns></returns>
  299. [HttpPost]
  300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  301. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  302. {
  303. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  304. _detail.IsDel = 1;
  305. _detail.DeleteUserId = dto.Duty;
  306. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  307. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  308. .SetColumns(it => it.IsDel == _detail.IsDel)
  309. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  310. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  311. .Where(it => it.Id == dto.Id)
  312. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  313. //.WhereColumns(s => s.Id == dto.Id)
  314. .ExecuteCommandAsync();
  315. if (result > 0)
  316. {
  317. return Ok(JsonView(true, "删除成功!"));
  318. }
  319. return Ok(JsonView(false, "删除失败!"));
  320. }
  321. /// <summary>
  322. /// 增加团组流程管控详细表数据
  323. /// </summary>
  324. /// <param name="dto"></param>
  325. /// <returns></returns>
  326. [HttpPost]
  327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  328. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  329. {
  330. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  331. if (DateTime.Now < _detail.ExpectBeginDt)
  332. {
  333. _detail.StepStatus = 0;
  334. }
  335. else
  336. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  337. _detail.StepStatus = 1;
  338. }
  339. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  340. if (result > 0)
  341. {
  342. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  343. return Ok(JsonView(true, "添加成功!", _result));
  344. }
  345. return Ok(JsonView(false, "添加失败!"));
  346. }
  347. #endregion
  348. #region 团组基本信息
  349. /// <summary>
  350. /// 接团信息列表
  351. /// </summary>
  352. /// <param name="dto">团组列表请求dto</param>
  353. /// <returns></returns>
  354. [HttpPost]
  355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  356. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  357. {
  358. var groupData = await _groupRepository.GetGroupList(dto);
  359. if (groupData.Code != 0)
  360. {
  361. return Ok(JsonView(false, groupData.Msg));
  362. }
  363. return Ok(JsonView(groupData.Data));
  364. }
  365. /// <summary>
  366. /// 分页查询团组列表
  367. /// </summary>
  368. /// <param name="dto"></param>
  369. /// <returns></returns>
  370. [HttpPost]
  371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  372. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  373. {
  374. var watch = new Stopwatch();
  375. watch.Start();
  376. RefAsync<int> total = 0;
  377. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  378. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  379. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  380. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  381. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  382. .Distinct()
  383. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  384. watch.Stop();
  385. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  386. }
  387. /// <summary>
  388. /// 接团信息列表 Page
  389. /// </summary>
  390. /// <param name="dto">团组列表请求dto</param>
  391. /// <returns></returns>
  392. [HttpPost]
  393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  394. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  395. {
  396. #region 参数验证
  397. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  398. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  399. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  400. #region 页面操作权限验证
  401. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  402. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  403. #endregion
  404. #endregion
  405. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  406. {
  407. string sqlWhere = string.Empty;
  408. if (dto.IsSure == 0) //未完成
  409. {
  410. sqlWhere += string.Format(@" And IsSure = 0");
  411. }
  412. else if (dto.IsSure == 1) //已完成
  413. {
  414. sqlWhere += string.Format(@" And IsSure = 1");
  415. }
  416. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  417. {
  418. string tj = dto.SearchCriteria;
  419. 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}%')",
  420. tj, tj, tj, tj, tj);
  421. }
  422. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  423. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  424. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  425. JietuanOperator,IsSure,CreateTime,IsBid
  426. From (
  427. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  428. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  429. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  430. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  431. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  432. From Grp_DelegationInfo gdi
  433. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  434. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  435. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  436. Where gdi.IsDel = 0 {0}
  437. ) temp", sqlWhere);
  438. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  439. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  440. #region 处理所属部门
  441. /*
  442. * 1.sq 和 gyy 等显示 市场部
  443. * 2.王鸽和主管及张总还有管理员号统一国交部
  444. * 2-1. 4 管理员 ,21 张海麟
  445. */
  446. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  447. List<int> userIds1 = new List<int>() { 4, 21 };
  448. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  449. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  450. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  451. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  452. .ToList();
  453. foreach (var item in _DelegationList)
  454. {
  455. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  456. }
  457. #endregion
  458. var _view = new
  459. {
  460. PageFuncAuth = pageFunAuthView,
  461. Data = _DelegationList
  462. };
  463. return Ok(JsonView(true, "查询成功!", _view, total));
  464. }
  465. else
  466. {
  467. return Ok(JsonView(false, "查询失败"));
  468. }
  469. }
  470. /// <summary>
  471. /// 团组列表
  472. /// </summary>
  473. /// <returns></returns>
  474. [HttpPost]
  475. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  476. {
  477. #region 参数验证
  478. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  479. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  480. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  481. #region 页面操作权限验证
  482. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  483. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  484. #endregion
  485. #endregion
  486. if (dto.PortType != 1 && dto.PortType != 2)
  487. {
  488. return Ok(JsonView(false, "查询失败!"));
  489. }
  490. string orderbyStr = "order by gdi.CreateTime Desc";
  491. string sqlWhere = string.Empty;
  492. if (dto.IsSure == 0) //未完成
  493. {
  494. sqlWhere += string.Format(@" And IsSure = 0");
  495. }
  496. else if (dto.IsSure == 1) //已完成
  497. {
  498. sqlWhere += string.Format(@" And IsSure = 1");
  499. }
  500. //团组类型
  501. if (dto.TeamDid > 0)
  502. {
  503. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  504. }
  505. //团组名称
  506. if (!string.IsNullOrEmpty(dto.TeamName))
  507. {
  508. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  509. }
  510. //客户名称
  511. if (!string.IsNullOrEmpty(dto.ClientName))
  512. {
  513. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  514. }
  515. //客户单位
  516. if (!string.IsNullOrEmpty(dto.ClientUnit))
  517. {
  518. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  519. }
  520. //出访时间
  521. if (!string.IsNullOrEmpty(dto.visitDataTime))
  522. {
  523. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  524. orderbyStr = "order by gdi.VisitDate";
  525. }
  526. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  527. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  528. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  529. JietuanOperator,IsSure,CreateTime
  530. From (
  531. Select row_number() over({0}) as Row_Number,
  532. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  533. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  534. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  535. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  536. From Grp_DelegationInfo gdi
  537. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  538. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  539. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  540. Where gdi.IsDel = 0 {1}
  541. ) temp ", orderbyStr, sqlWhere);
  542. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  543. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  544. #region 处理所属部门
  545. /*
  546. * 1.sq 和 gyy 等显示 市场部
  547. * 2.王鸽和主管及张总还有管理员号统一国交部
  548. * 2-1. 4 管理员 ,21 张海麟
  549. */
  550. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  551. List<int> userIds1 = new List<int>() { 4, 21 };
  552. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  553. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  554. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  555. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  556. .ToList();
  557. foreach (var item in _DelegationList)
  558. {
  559. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  560. }
  561. #endregion
  562. var _view = new
  563. {
  564. PageFuncAuth = pageFunAuthView,
  565. Data = _DelegationList
  566. };
  567. return Ok(JsonView(true, "查询成功!", _view, total));
  568. }
  569. /// <summary>
  570. /// 接团信息详情
  571. /// </summary>
  572. /// <param name="dto">团组info请求dto</param>
  573. /// <returns></returns>
  574. [HttpPost]
  575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  576. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  577. {
  578. var groupData = await _groupRepository.GetGroupInfo(dto);
  579. if (groupData.Code != 0)
  580. {
  581. return Ok(JsonView(false, groupData.Msg));
  582. }
  583. return Ok(JsonView(groupData.Data));
  584. }
  585. /// <summary>
  586. /// 接团信息 编辑添加
  587. /// 基础信息数据源
  588. /// </summary>
  589. /// <param name="dto"></param>
  590. /// <returns></returns>
  591. [HttpPost]
  592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  593. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  594. {
  595. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  596. if (groupData.Code != 0)
  597. {
  598. return Ok(JsonView(false, groupData.Msg));
  599. }
  600. return Ok(JsonView(groupData.Data));
  601. }
  602. /// <summary>
  603. /// 接团信息 操作(增改)
  604. /// </summary>
  605. /// <param name="dto"></param>
  606. /// <returns></returns>
  607. [HttpPost]
  608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  609. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  610. {
  611. // 创建 Stopwatch 实例
  612. Stopwatch stopwatch = Stopwatch.StartNew();
  613. decimal ffrPrice = 0.00M;
  614. DateTime? visitDt = null;
  615. if (dto.Status == 2)
  616. {
  617. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  618. if (groupInfo != null)
  619. {
  620. ffrPrice = groupInfo.PaymentMoney;
  621. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  622. }
  623. }
  624. var groupData = await _groupRepository.GroupOperation(dto);
  625. if (groupData.Code != 0)
  626. {
  627. return Ok(JsonView(false, groupData.Msg));
  628. }
  629. int diId = 0;
  630. try
  631. {
  632. //添加时 默认加入团组汇率
  633. if (dto.Status == 1) //添加
  634. {
  635. diId = groupData.Data;
  636. //添加默认币种
  637. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  638. //默认分配权限
  639. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  640. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  641. var _managerIds = new List<int>() { 22, 32, 21 };
  642. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  643. if (userIds.Count > 0)
  644. {
  645. userIds.Add(208);
  646. //创建团组管控
  647. GroupStepForDelegation.CreateWorkStep(diId);
  648. //发送消息
  649. string groupName = dto.TeamName;
  650. string createGroupUser = string.Empty;
  651. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  652. if (userInfo != null) createGroupUser = userInfo.CnName;
  653. string title = $"系统通知";
  654. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  655. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  656. }
  657. //默认创建倒推表
  658. await _invertedListRep._Create(dto.UserId, diId);
  659. }
  660. else if (dto.Status == 2)
  661. {
  662. diId = dto.Id;
  663. }
  664. #region 签证人员团组时间通知
  665. #region 计算出访起止时间
  666. var startTime = new DateTime();
  667. var endTime = new DateTime();
  668. if (DateTime.TryParse(dto.VisitDate, out startTime))
  669. {
  670. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  671. }
  672. #endregion
  673. #endregion
  674. #region 团组操作默认添加/修改收款账单
  675. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  676. {
  677. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  678. .Where(x => x.IsDel == 0 &&
  679. x.Diid == diId &&
  680. x.Remark.Equals("预付款")
  681. )
  682. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  683. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  684. .FirstAsync();
  685. ffrInfo = new Fin_ForeignReceivables()
  686. {
  687. Diid = diId,
  688. PriceName = dto.ClientUnit,
  689. Price = dto.PaymentMoney,
  690. Count = 1,
  691. Unit = $"元",
  692. ItemSumPrice = dto.PaymentMoney,
  693. Rate = 1.0000M,
  694. Currency = 836,
  695. AddingWay = 0,
  696. CreateUserId = dto.UserId,
  697. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  698. Remark = $"预付款"
  699. };
  700. if (ffrInfo == null) //Add
  701. {
  702. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  703. }
  704. else //修改
  705. {
  706. await _sqlSugar.Updateable(ffrInfo)
  707. .UpdateColumns(x => new
  708. {
  709. x.PriceName,
  710. x.Price,
  711. x.ItemSumPrice,
  712. x.CreateTime,
  713. x.CreateUserId
  714. })
  715. .WhereColumns(x => x.Id)
  716. .ExecuteCommandAsync();
  717. }
  718. }
  719. #endregion
  720. if (diId > 0)
  721. {
  722. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  723. }
  724. // 停止计时
  725. stopwatch.Stop();
  726. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  727. }
  728. catch (Exception ex)
  729. {
  730. // 停止计时
  731. stopwatch.Stop();
  732. Logs("[response]" + JsonConvert.SerializeObject(dto));
  733. Logs(ex.Message);
  734. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  735. }
  736. // 停止计时
  737. stopwatch.Stop();
  738. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  739. }
  740. /// <summary>
  741. /// 接团流程操作(增改)
  742. /// 安卓端使用 建团时添加客户名单
  743. /// </summary>
  744. /// <param name="dto"></param>
  745. /// <returns></returns>
  746. [HttpPost]
  747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  748. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  749. {
  750. #region 参数验证
  751. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  752. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  753. #region 页面操作权限验证
  754. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  755. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  756. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  757. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  758. #endregion
  759. #endregion
  760. try
  761. {
  762. //_sqlSugar.BeginTran();
  763. decimal ffrPrice = 0.00M;
  764. DateTime? visitDt = null;
  765. if (dto.Status == 2)
  766. {
  767. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  768. if (groupInfo != null)
  769. {
  770. ffrPrice = groupInfo.PaymentMoney;
  771. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  772. }
  773. }
  774. var _dto = new GroupOperationDto();
  775. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  776. var groupData = await _groupRepository.GroupOperation(_dto);
  777. if (groupData.Code != 0)
  778. {
  779. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  780. }
  781. int diId = 0;
  782. //添加时 默认加入团组汇率
  783. if (dto.Status == 1) //添加
  784. {
  785. diId = groupData.Data;
  786. //添加默认币种
  787. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  788. //默认分配权限
  789. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  790. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  791. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  792. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  793. if (userIds.Count > 0)
  794. {
  795. userIds.Add(208);
  796. //创建团组管控
  797. GroupStepForDelegation.CreateWorkStep(diId);
  798. //发送消息
  799. string groupName = dto.TeamName;
  800. string createGroupUser = string.Empty;
  801. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  802. if (userInfo != null) createGroupUser = userInfo.CnName;
  803. string title = $"系统通知";
  804. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  805. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  806. }
  807. #region 应用推送
  808. try
  809. {
  810. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  811. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  812. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  813. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  814. {
  815. List<string> userList = new List<string>() { users.QiyeChatUserId };
  816. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  817. }
  818. }
  819. catch (Exception ex)
  820. {
  821. }
  822. #endregion
  823. //默认创建倒推表
  824. await _invertedListRep._Create(dto.UserId, diId);
  825. }
  826. if (dto.Status == 2)
  827. {
  828. diId = dto.Id;
  829. if (diId == 0)
  830. {
  831. //_sqlSugar.RollbackTran();
  832. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  833. }
  834. }
  835. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  836. if (viewData.Code != 0)
  837. {
  838. //_sqlSugar.RollbackTran();
  839. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  840. }
  841. #region 团组操作默认添加/修改收款账单
  842. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  843. {
  844. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  845. .Where(x => x.IsDel == 0 &&
  846. x.Diid == diId &&
  847. x.Remark.Equals("预付款")
  848. )
  849. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  850. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  851. .FirstAsync();
  852. ffrInfo = new Fin_ForeignReceivables()
  853. {
  854. Diid = diId,
  855. PriceName = dto.ClientUnit,
  856. Price = dto.PaymentMoney,
  857. Count = 1,
  858. Unit = $"元",
  859. ItemSumPrice = dto.PaymentMoney,
  860. Rate = 1.0000M,
  861. Currency = 836,
  862. AddingWay = 0,
  863. CreateUserId = dto.UserId,
  864. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  865. Remark = $"预付款"
  866. };
  867. if (ffrInfo == null) //Add
  868. {
  869. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  870. }
  871. else //修改
  872. {
  873. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  874. .UpdateColumns(x => new
  875. {
  876. x.PriceName,
  877. x.Price,
  878. x.ItemSumPrice,
  879. x.CreateTime,
  880. x.CreateUserId
  881. })
  882. .WhereColumns(x => x.Id)
  883. .ExecuteCommandAsync();
  884. }
  885. }
  886. #endregion
  887. #region 签证人员团组时间通知
  888. #region 计算出访起止时间
  889. var startTime = new DateTime();
  890. var endTime = new DateTime();
  891. if (DateTime.TryParse(dto.VisitDate, out startTime))
  892. {
  893. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  894. }
  895. #endregion
  896. if (diId > 0)
  897. {
  898. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  899. }
  900. #endregion
  901. //_sqlSugar.CommitTran();
  902. return Ok(JsonView(true, "添加成功"));
  903. }
  904. catch (Exception ex)
  905. {
  906. _sqlSugar.RollbackTran();
  907. return Ok(JsonView(false, ex.Message));
  908. }
  909. }
  910. /// <summary>
  911. /// 接团流程操作(增改)
  912. /// 安卓端使用 建团时添加客户名单
  913. /// </summary>
  914. /// <param name="dto"></param>
  915. /// <returns></returns>
  916. [HttpPost]
  917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  918. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  919. {
  920. #region 参数验证
  921. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  922. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  923. #region 页面操作权限验证
  924. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  925. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  926. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  927. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  928. #endregion
  929. #endregion
  930. _sqlSugar.BeginTran();
  931. decimal ffrPrice = 0.00M;
  932. DateTime? visitDt = null;
  933. if (dto.Status == 2)
  934. {
  935. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  936. if (groupInfo != null)
  937. {
  938. ffrPrice = groupInfo.PaymentMoney;
  939. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  940. }
  941. }
  942. var _dto = new GroupOperationDto();
  943. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  944. var groupData = await _groupRepository.GroupOperation(_dto);
  945. if (groupData.Code != 0)
  946. {
  947. _sqlSugar.RollbackTran();
  948. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  949. }
  950. try
  951. {
  952. int diId = 0;
  953. //添加时 默认加入团组汇率
  954. if (dto.Status == 1) //添加
  955. {
  956. diId = groupData.Data;
  957. //添加默认币种
  958. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  959. //默认分配权限
  960. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  961. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  962. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  963. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  964. if (userIds.Count > 0)
  965. {
  966. userIds.Add(208);
  967. //创建团组管控
  968. GroupStepForDelegation.CreateWorkStep(diId);
  969. //发送消息
  970. string groupName = dto.TeamName;
  971. string createGroupUser = string.Empty;
  972. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  973. if (userInfo != null) createGroupUser = userInfo.CnName;
  974. string title = $"系统通知";
  975. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  976. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  977. }
  978. #region 应用推送
  979. try
  980. {
  981. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  982. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  983. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  984. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  985. {
  986. List<string> userList = new List<string>() { users.QiyeChatUserId };
  987. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  988. }
  989. }
  990. catch (Exception ex)
  991. {
  992. _sqlSugar.CommitTran();
  993. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  994. }
  995. #endregion
  996. //默认创建倒推表
  997. await _invertedListRep._Create(dto.UserId, diId);
  998. }
  999. else if (dto.Status == 2)
  1000. {
  1001. diId = dto.Id;
  1002. if (diId == 0)
  1003. {
  1004. _sqlSugar.RollbackTran();
  1005. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1006. }
  1007. }
  1008. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1009. if (viewData.Code != 0)
  1010. {
  1011. _sqlSugar.RollbackTran();
  1012. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1013. }
  1014. #region 团组操作默认添加/修改收款账单
  1015. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1016. {
  1017. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1018. .Where(x => x.IsDel == 0 &&
  1019. x.Diid == diId &&
  1020. x.Remark.Equals("预付款")
  1021. )
  1022. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1023. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1024. .FirstAsync();
  1025. ffrInfo = new Fin_ForeignReceivables()
  1026. {
  1027. Diid = diId,
  1028. PriceName = dto.ClientUnit,
  1029. Price = dto.PaymentMoney,
  1030. Count = 1,
  1031. Unit = $"元",
  1032. ItemSumPrice = dto.PaymentMoney,
  1033. Rate = 1.0000M,
  1034. Currency = 836,
  1035. AddingWay = 0,
  1036. CreateUserId = dto.UserId,
  1037. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1038. Remark = $"预付款"
  1039. };
  1040. if (ffrInfo == null) //Add
  1041. {
  1042. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1043. }
  1044. else //修改
  1045. {
  1046. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1047. .UpdateColumns(x => new
  1048. {
  1049. x.PriceName,
  1050. x.Price,
  1051. x.ItemSumPrice,
  1052. x.CreateTime,
  1053. x.CreateUserId
  1054. })
  1055. .WhereColumns(x => x.Id)
  1056. .ExecuteCommandAsync();
  1057. }
  1058. }
  1059. #endregion
  1060. #region 签证人员团组时间通知
  1061. #region 计算出访起止时间
  1062. var startTime = new DateTime();
  1063. var endTime = new DateTime();
  1064. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1065. {
  1066. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1067. }
  1068. #endregion
  1069. if (diId > 0)
  1070. {
  1071. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1072. }
  1073. #endregion
  1074. _sqlSugar.CommitTran();
  1075. return Ok(JsonView(true));
  1076. }
  1077. catch (Exception ex)
  1078. {
  1079. _sqlSugar.RollbackTran();
  1080. return Ok(JsonView(false, ex.Message));
  1081. }
  1082. }
  1083. /// <summary>
  1084. /// 接团信息 操作(删除)
  1085. /// </summary>
  1086. /// <param name="dto"></param>
  1087. /// <returns></returns>
  1088. [HttpPost]
  1089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1090. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1091. {
  1092. var diId = dto.Id;
  1093. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  1094. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1095. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1096. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1097. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1098. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1099. #endregion
  1100. var groupData = await _groupRepository.GroupDel(dto);
  1101. if (groupData.Code != 0)
  1102. {
  1103. return Ok(JsonView(false, groupData.Msg));
  1104. }
  1105. return Ok(JsonView(true));
  1106. }
  1107. /// <summary>
  1108. /// 获取团组销售报价号
  1109. /// 团组添加时 使用
  1110. /// </summary>
  1111. /// <returns></returns>
  1112. [HttpPost]
  1113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1114. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1115. {
  1116. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1117. if (groupData.Code != 0)
  1118. {
  1119. return Ok(JsonView(false, groupData.Msg));
  1120. }
  1121. object salesQuoteNo = new
  1122. {
  1123. SalesQuoteNo = groupData.Data
  1124. };
  1125. return Ok(JsonView(salesQuoteNo));
  1126. }
  1127. /// <summary>
  1128. /// 设置确认出团
  1129. /// </summary>
  1130. /// <param name="dto"></param>
  1131. /// <returns></returns>
  1132. [HttpPost]
  1133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1134. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1135. {
  1136. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1137. if (groupData.Code != 0)
  1138. {
  1139. return Ok(JsonView(false, groupData.Msg));
  1140. }
  1141. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1142. #region OA消息推送
  1143. try
  1144. {
  1145. string groupName = groupInfo.TeamName;
  1146. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1147. string title = $"系统通知";
  1148. string content = $"团组[{groupName}]已确认出团!";
  1149. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1150. }
  1151. catch (Exception ex)
  1152. {
  1153. }
  1154. #endregion
  1155. #region 应用推送
  1156. try
  1157. {
  1158. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1159. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1160. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1161. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1162. {
  1163. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1164. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1165. }
  1166. }
  1167. catch (Exception ex)
  1168. {
  1169. }
  1170. #endregion
  1171. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1172. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1173. }
  1174. /// <summary>
  1175. /// 获取团组名称data And 签证国别Data
  1176. /// </summary>
  1177. /// <param name="dto"></param>
  1178. /// <returns></returns>
  1179. [HttpPost]
  1180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1181. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1182. {
  1183. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1184. if (groupData.Code != 0)
  1185. {
  1186. return Ok(JsonView(false, groupData.Msg));
  1187. }
  1188. return Ok(JsonView(groupData.Data));
  1189. }
  1190. /// <summary>
  1191. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1192. /// </summary>
  1193. /// <returns></returns>
  1194. [HttpPost]
  1195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1196. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1197. {
  1198. try
  1199. {
  1200. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1201. if (groupData.Code != 0)
  1202. {
  1203. return Ok(JsonView(false, groupData.Msg));
  1204. }
  1205. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1206. }
  1207. catch (Exception ex)
  1208. {
  1209. return Ok(JsonView(false, "程序错误!"));
  1210. throw;
  1211. }
  1212. }
  1213. /// <summary>
  1214. /// 团组清单 Excel
  1215. /// </summary>
  1216. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1217. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1218. /// <returns></returns>
  1219. [HttpGet]
  1220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1221. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1222. {
  1223. DateTime _beginDt, _endDt;
  1224. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1225. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1226. if (!beginBool && !endBool)
  1227. {
  1228. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1229. }
  1230. string sql = string.Format(@"
  1231. SELECT
  1232. ROW_NUMBER,
  1233. Id,
  1234. SalesQuoteNo,
  1235. TourCode,
  1236. TeamTypeId,
  1237. TeamType,
  1238. TeamLevId,
  1239. TeamLev,
  1240. TeamName,
  1241. ClientName,
  1242. ClientUnit,
  1243. VisitDate,
  1244. VisitDays,
  1245. VisitPNumber,
  1246. JietuanOperatorId,
  1247. JietuanOperator,
  1248. IsSure,
  1249. CreateUserName,
  1250. IsBid
  1251. FROM
  1252. (
  1253. SELECT
  1254. ROW_NUMBER() OVER(
  1255. ORDER BY
  1256. gdi.CreateTime Desc
  1257. ) AS ROW_NUMBER,
  1258. gdi.Id,
  1259. SalesQuoteNo,
  1260. TourCode,
  1261. ssd.Id TeamTypeId,
  1262. ssd.Name TeamType,
  1263. ssd1.Id TeamLevId,
  1264. ssd1.Name TeamLev,
  1265. TeamName,
  1266. ClientName,
  1267. ClientUnit,
  1268. VisitDate,
  1269. VisitDays,
  1270. VisitPNumber,
  1271. JietuanOperator JietuanOperatorId,
  1272. su.CnName JietuanOperator,
  1273. IsSure,
  1274. gdi.CreateTime,
  1275. su1.CnName As CreateUserName,
  1276. gdi.IsBid
  1277. FROM
  1278. Grp_DelegationInfo gdi
  1279. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1280. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1281. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1282. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1283. WHERE
  1284. gdi.IsDel = 0
  1285. AND gdi.IsBid = 0
  1286. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1287. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1288. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1289. #region 处理所属部门
  1290. /*
  1291. * 1.sq 和 gyy 等显示 市场部
  1292. * 2.王鸽和主管及张总还有管理员号统一国交部
  1293. * 2-1. 4 管理员 ,21 张海麟
  1294. */
  1295. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1296. List<int> userIds1 = new List<int>() { 4, 21 };
  1297. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1298. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1299. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1300. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1301. .ToListAsync();
  1302. var droupIds = groupList.Select(it => it.Id).ToList();
  1303. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1304. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1305. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1306. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1307. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1308. {
  1309. DiId = tcl.DiId,
  1310. LastName = dc.LastName,
  1311. FirstName = dc.FirstName,
  1312. Sex = dc.Sex,
  1313. Birthday = dc.BirthDay,
  1314. Company = cc.CompanyFullName,
  1315. Job = dc.Job,
  1316. CreateTime = tcl.CreateTime,
  1317. })
  1318. .ToList();
  1319. foreach (var item in groupList)
  1320. {
  1321. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1322. string groupFirstName = "";
  1323. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1324. if (currDatas.Any())
  1325. {
  1326. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1327. }
  1328. item.GroupFirst = groupFirstName;
  1329. }
  1330. #endregion
  1331. #region Excel
  1332. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1333. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1334. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1335. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1336. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1337. //载入模板
  1338. WorkbookDesigner designer = new WorkbookDesigner();
  1339. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1340. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1341. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1342. dt.TableName = "GroupList";
  1343. designer.SetDataSource(dt);
  1344. designer.Process();
  1345. if (!Directory.Exists(savePath))
  1346. {
  1347. Directory.CreateDirectory(savePath);
  1348. }
  1349. string serverPath = $"{savePath}{fileName}";
  1350. designer.Workbook.Save(serverPath);
  1351. string rst = $"{servicePath}{ftpPath}{fileName}";
  1352. #endregion
  1353. return Ok(JsonView(true, "操作成功!", rst));
  1354. }
  1355. #endregion
  1356. #region 团组&签证
  1357. /// <summary>
  1358. /// 根据团组Id获取签证客户信息List
  1359. /// </summary>
  1360. /// <param name="dto">请求dto</param>
  1361. /// <returns></returns>
  1362. [HttpPost]
  1363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1364. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1365. {
  1366. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1367. if (groupData.Code != 0)
  1368. {
  1369. return Ok(JsonView(false, groupData.Msg));
  1370. }
  1371. return Ok(JsonView(groupData.Data));
  1372. }
  1373. /// <summary>
  1374. /// IOS获取团组签证拍照上传进度01(团组列表)
  1375. /// </summary>
  1376. /// <param name="dto">请求dto</param>
  1377. /// <returns></returns>
  1378. [HttpPost]
  1379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1380. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1381. {
  1382. if (dto == null)
  1383. {
  1384. return Ok(JsonView(false, "参数为空"));
  1385. }
  1386. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1387. return Ok(JsonView(visaList));
  1388. }
  1389. /// <summary>
  1390. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1391. /// </summary>
  1392. /// <returns></returns>
  1393. [HttpPost]
  1394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1395. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1396. {
  1397. if (dto == null)
  1398. {
  1399. return Ok(JsonView(false, "请求错误:"));
  1400. }
  1401. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1402. return Ok(JsonView(list));
  1403. }
  1404. /// <summary>
  1405. /// IOS获取团组签证拍照上传进度03(相册)
  1406. /// </summary>
  1407. /// <returns></returns>
  1408. [HttpPost]
  1409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1410. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1411. {
  1412. if (dto == null)
  1413. {
  1414. return Ok(JsonView(false, "请求错误:"));
  1415. }
  1416. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1417. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1418. list.ForEach(s => s.url = url);
  1419. return Ok(JsonView(list));
  1420. }
  1421. /// <summary>
  1422. /// IOS获取团组签证拍照上传进度04(图片上传)
  1423. /// </summary>
  1424. /// <param name="dto"></param>
  1425. /// <returns></returns>
  1426. [HttpPost]
  1427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1428. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1429. {
  1430. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1431. //if (!string.IsNullOrEmpty(result))
  1432. //{
  1433. //}
  1434. //else {
  1435. // return Ok(JsonView(false, "上传失败"));
  1436. //}
  1437. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1438. int sucNum = 0;
  1439. try
  1440. {
  1441. foreach (var item in dto.base64DataList)
  1442. {
  1443. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1444. string result = decodeBase64ToImage(item, imageName);
  1445. if (!string.IsNullOrEmpty(result))
  1446. {
  1447. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1448. pic.CreateUserId = dto.CreateUserId;
  1449. pic.PicName = imageName;
  1450. pic.PicPath = result;
  1451. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1452. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1453. if (insertResult > 0)
  1454. {
  1455. sucNum++;
  1456. }
  1457. }
  1458. }
  1459. }
  1460. catch (Exception ex)
  1461. {
  1462. return Ok(JsonView(false, ex.Message));
  1463. }
  1464. string msg = string.Format(@"成功上传{0}张", sucNum);
  1465. return Ok(JsonView(true, msg));
  1466. }
  1467. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1468. {
  1469. string filename = "";//声明一个string类型的相对路径
  1470. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1471. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1472. try//会有异常抛出,try,catch一下
  1473. {
  1474. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1475. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1476. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1477. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1478. //文件名称
  1479. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1480. //上传的文件的路径
  1481. string filePath = "";
  1482. if (!Directory.Exists(fileDir))
  1483. {
  1484. Directory.CreateDirectory(fileDir);
  1485. }
  1486. //上传的文件的路径
  1487. filePath = fileDir + filename;
  1488. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1489. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1490. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1491. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1492. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1493. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1494. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1495. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1496. bitmap.Dispose();
  1497. }
  1498. catch (Exception e)
  1499. {
  1500. string massage = e.Message;
  1501. Logs("IOS图片上传Error:" + massage);
  1502. //filename = e.Message;
  1503. }
  1504. return filename;//返回相对路径
  1505. }
  1506. /// <summary>
  1507. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1508. /// </summary>
  1509. /// <param name="dto"></param>
  1510. /// <returns></returns>
  1511. [HttpPost]
  1512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1513. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1514. {
  1515. if (dto == null)
  1516. {
  1517. return Ok(JsonView(false, "请求错误:"));
  1518. }
  1519. string msg = "参数错误";
  1520. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1521. {
  1522. try
  1523. {
  1524. //_delegationVisaRep.BeginTran();
  1525. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1526. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1527. .Where(s => s.Id == dto.visaProgressCustomerId)
  1528. .ExecuteCommandAsync();
  1529. if (updCount > 0 && dto.publishCode == 1)
  1530. {
  1531. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1532. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1533. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1534. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1535. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1536. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1537. if (groupData == null)
  1538. {
  1539. _delegationVisaRep.RollbackTran();
  1540. }
  1541. string title = string.Format(@"[签证进度更新]");
  1542. string content = string.Format(@"测试文本");
  1543. bool rst = await _message.AddMsg(new MessageDto()
  1544. {
  1545. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1546. IssuerId = dto.publisher,
  1547. Title = title,
  1548. Content = content,
  1549. ReleaseTime = DateTime.Now,
  1550. UIdList = new List<int> {
  1551. 234
  1552. }
  1553. });
  1554. if (rst)
  1555. {
  1556. return Ok(JsonView(true, "发送通知成功"));
  1557. }
  1558. }
  1559. //_delegationVisaRep.CommitTran();
  1560. }
  1561. catch (Exception)
  1562. {
  1563. //_delegationVisaRep.RollbackTran();
  1564. }
  1565. }
  1566. return Ok(JsonView(true, msg));
  1567. }
  1568. #endregion
  1569. #region 团组任务分配
  1570. /// <summary>
  1571. /// 团组任务分配初始化
  1572. /// </summary>
  1573. /// <param name="dto"></param>
  1574. /// <returns></returns>
  1575. [HttpPost]
  1576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1577. public async Task<IActionResult> GetTaskAssignmen()
  1578. {
  1579. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1580. if (groupData.Code != 0)
  1581. {
  1582. return Ok(JsonView(false, groupData.Msg));
  1583. }
  1584. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1585. }
  1586. /// <summary>
  1587. /// 团组任务分配查询
  1588. /// </summary>
  1589. /// <param name="dto"></param>
  1590. /// <returns></returns>
  1591. [HttpPost]
  1592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1593. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1594. {
  1595. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1596. if (groupData.Code != 0)
  1597. {
  1598. return Ok(JsonView(false, groupData.Msg));
  1599. }
  1600. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1601. }
  1602. /// <summary>
  1603. /// 团组任务分配操作
  1604. /// </summary>
  1605. /// <param name="dto"></param>
  1606. /// <returns></returns>
  1607. [HttpPost]
  1608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1609. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1610. {
  1611. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1612. if (groupData.Code != 0)
  1613. {
  1614. return Ok(JsonView(false, groupData.Msg));
  1615. }
  1616. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1617. }
  1618. /// <summary>
  1619. /// 团组任务分配
  1620. /// 批量分配
  1621. /// 查询团组
  1622. /// </summary>
  1623. /// <param name="dto"></param>
  1624. /// <returns></returns>
  1625. [HttpPost]
  1626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1627. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1628. {
  1629. //参数验证
  1630. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1631. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1632. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1633. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1634. }
  1635. /// <summary>
  1636. /// 团组任务分配
  1637. /// 批量分配
  1638. /// </summary>
  1639. /// <param name="dto"></param>
  1640. /// <returns></returns>
  1641. [HttpPost]
  1642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1643. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1644. {
  1645. //参数验证
  1646. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1647. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1648. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1649. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1650. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1651. }
  1652. #endregion
  1653. #region 团组费用审核
  1654. /// <summary>
  1655. /// 费用审核
  1656. /// 团组列表 Page
  1657. /// </summary>
  1658. /// <param name="_dto">团组列表请求dto</param>
  1659. /// <returns></returns>
  1660. [HttpPost]
  1661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1662. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1663. {
  1664. #region 参数验证
  1665. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1666. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1667. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1668. #region 页面操作权限验证
  1669. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1670. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1671. #endregion
  1672. #endregion
  1673. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1674. {
  1675. string sqlWhere = string.Empty;
  1676. if (_dto.IsSure == 0) //未完成
  1677. {
  1678. sqlWhere += string.Format(@" And IsSure = 0");
  1679. }
  1680. else if (_dto.IsSure == 1) //已完成
  1681. {
  1682. sqlWhere += string.Format(@" And IsSure = 1");
  1683. }
  1684. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1685. {
  1686. string tj = _dto.SearchCriteria;
  1687. 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}%')",
  1688. tj, tj, tj, tj, tj);
  1689. }
  1690. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1691. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1692. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1693. From (
  1694. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1695. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1696. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1697. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1698. From Grp_DelegationInfo gdi
  1699. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1700. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1701. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1702. Where gdi.IsDel = 0 {0}
  1703. ) temp ", sqlWhere);
  1704. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1705. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1706. var _view = new
  1707. {
  1708. PageFuncAuth = pageFunAuthView,
  1709. Data = _DelegationList
  1710. };
  1711. return Ok(JsonView(true, "查询成功!", _view, total));
  1712. }
  1713. else
  1714. {
  1715. return Ok(JsonView(false, "查询失败"));
  1716. }
  1717. }
  1718. /// <summary>
  1719. /// 获取团组费用审核
  1720. /// </summary>
  1721. /// <param name="paras">参数Json字符串</param>
  1722. /// <returns></returns>
  1723. [HttpPost]
  1724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1725. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1726. {
  1727. try
  1728. {
  1729. #region 参数验证
  1730. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1731. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1732. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1733. #region 页面操作权限验证
  1734. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1735. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1736. #endregion
  1737. #endregion
  1738. var _view = new Grp_CreditCardPaymentView();
  1739. var clientNameList = getSimplClientList(_dto.DiId);
  1740. #region 费用清单
  1741. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1742. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1743. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1744. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1745. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1746. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1747. /*
  1748. * 76://酒店预订
  1749. */
  1750. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1751. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1752. /*
  1753. * 79://车/导游地接
  1754. */
  1755. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1756. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1757. /*
  1758. * 80: //签证
  1759. */
  1760. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1761. /*
  1762. *81: //邀请/公务活动
  1763. */
  1764. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1765. /*
  1766. * 82: //团组客户保险
  1767. */
  1768. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1769. /*
  1770. * Lable = 85 机票预订
  1771. */
  1772. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1773. /*
  1774. * 85 机票预定
  1775. */
  1776. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1777. /*
  1778. * 98 其他款项
  1779. */
  1780. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1781. /*
  1782. * 285:收款退还
  1783. */
  1784. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1785. /*
  1786. * 1015: //超支费用
  1787. */
  1788. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1789. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1790. /*
  1791. * 币种信息
  1792. */
  1793. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1794. /*
  1795. * 车/导游地接 费用类型
  1796. */
  1797. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1798. /*
  1799. * 车/导游地接 费用类型
  1800. */
  1801. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1802. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1803. /*
  1804. * 用户信息
  1805. */
  1806. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1807. /*
  1808. * 费用模块
  1809. */
  1810. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1811. string priceModule = string.Empty;
  1812. if (sdPriceName != null)
  1813. {
  1814. priceModule = sdPriceName.Name;
  1815. }
  1816. /*
  1817. * 成本信息
  1818. */
  1819. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1820. decimal _groupRate = 0.0000M;
  1821. string _groupCurrencyCode = "-";
  1822. if (groupCost != null)
  1823. {
  1824. _groupRate = groupCost.Rate;
  1825. if (int.TryParse(groupCost.Currency, out int _currency))
  1826. {
  1827. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1828. }
  1829. else _groupCurrencyCode = groupCost.Currency;
  1830. }
  1831. string costContentSql = $"Select * From Grp_GroupCost";
  1832. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1833. //处理日期为空的天数
  1834. for (int i = 0; i < groupCostDetails.Count; i++)
  1835. if (i != 0)
  1836. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1837. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1838. /*
  1839. * 处理详情数据
  1840. */
  1841. foreach (var entity in entityList)
  1842. {
  1843. var _detail = new Grp_CreditCardPaymentDetailView();
  1844. _detail.Id = entity.Id;
  1845. _detail.PriceName = priceModule;
  1846. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1847. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1848. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1849. //处理金额
  1850. if (entity.CTable == 1015)
  1851. {
  1852. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1853. if (czInfo != null)
  1854. {
  1855. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1856. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1857. }
  1858. }
  1859. /*
  1860. * 应付款金额
  1861. */
  1862. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1863. string PaymentCurrency_WaitPay = "Unknown";
  1864. string hotelCurrncyCode = "Unknown";
  1865. string hotelCurrncyName = "Unknown";
  1866. if (sdPaymentCurrency_WaitPay != null)
  1867. {
  1868. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1869. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1870. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1871. if (hotelCurrncyCode.Equals("CNY"))
  1872. {
  1873. entity.DayRate = 1.0000M;
  1874. }
  1875. }
  1876. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1877. /*
  1878. * 此次付款金额
  1879. */
  1880. decimal CurrPayStr = 0.00M,
  1881. OriginalCurrPay = 0.00M;
  1882. if (entity.PayPercentage == 0)
  1883. {
  1884. if (entity.PayThenMoney != 0)
  1885. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1886. }
  1887. else
  1888. {
  1889. if (entity.PayMoney != 0)
  1890. {
  1891. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1892. }
  1893. }
  1894. //if (_dto.Label == 79)
  1895. //{
  1896. // string original = string.Empty;
  1897. // if (hotelCurrncyCode.Equals("CNY"))
  1898. // {
  1899. // OriginalCurrPay = CurrPayStr;
  1900. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1901. // }
  1902. // else
  1903. // {
  1904. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1905. // //760 EUR(7600.00 CNY)
  1906. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1907. // }
  1908. //}
  1909. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1910. string original = string.Empty;
  1911. if (hotelCurrncyCode.Equals("CNY"))
  1912. {
  1913. OriginalCurrPay = CurrPayStr;
  1914. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1915. }
  1916. else
  1917. {
  1918. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1919. //760 EUR(7600.00 CNY)
  1920. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1921. }
  1922. /*
  1923. * 剩余尾款
  1924. */
  1925. decimal BalanceStr = 0;
  1926. if (CurrPayStr != 0)
  1927. {
  1928. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1929. BalanceStr = 0;
  1930. else
  1931. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1932. }
  1933. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1934. /*
  1935. * Bus名称
  1936. */
  1937. _detail.BusName = "待增加";
  1938. /*
  1939. *费用所属
  1940. */
  1941. switch (entity.CTable)
  1942. {
  1943. case 76://酒店预订
  1944. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1945. if (hotelReservations != null)
  1946. {
  1947. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1948. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1949. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1950. string roomFeeStr = "", roomFeestr1 = "";
  1951. //是否比较房型价格
  1952. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1953. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1954. roomFeeStr += $"<br/>";
  1955. var roomTotal = 0.00M;
  1956. if (hotelReservations.SingleRoomPrice > 0)
  1957. {
  1958. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1959. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1960. __isSingle = true;
  1961. roomTotal += fee;
  1962. }
  1963. if (hotelReservations.DoubleRoomPrice > 0)
  1964. {
  1965. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1966. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1967. __isDouble = true;
  1968. roomTotal += fee;
  1969. }
  1970. if (hotelReservations.SuiteRoomPrice > 0)
  1971. {
  1972. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1973. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1974. __isSuite = true;
  1975. roomTotal += fee;
  1976. }
  1977. if (hotelReservations.OtherRoomPrice > 0)
  1978. {
  1979. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1980. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1981. __isOther = true;
  1982. roomTotal += fee;
  1983. }
  1984. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  1985. else roomFeeStr += " 0.00 * 0";
  1986. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1987. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1988. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1989. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1990. /*
  1991. * 费用类型
  1992. * 1:房费
  1993. * 2:早餐
  1994. * 3:地税
  1995. * 4:城市税
  1996. * </summary>
  1997. */
  1998. //地税
  1999. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2000. if (governmentRentData != null)
  2001. {
  2002. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2003. governmentRentFee = governmentRentData.Price;
  2004. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2005. if (governmentRentCurrData != null)
  2006. {
  2007. governmentRentCode = governmentRentCurrData.Name;
  2008. governmentRentName = $"({governmentRentCurrData.Remark})";
  2009. }
  2010. }
  2011. //城市税
  2012. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2013. if (cityTaxData != null)
  2014. {
  2015. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2016. cityTaxFee = cityTaxData.Price;
  2017. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2018. if (cityTaxCurrData != null)
  2019. {
  2020. cityTaxCode = cityTaxCurrData.Name;
  2021. cityTaxName = $"({cityTaxCurrData.Remark})";
  2022. }
  2023. }
  2024. //酒店早餐
  2025. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2026. if (breakfastData != null)
  2027. {
  2028. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2029. breakfastFee = breakfastData.Price;
  2030. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2031. if (breakfastCurrData != null)
  2032. {
  2033. breakfastCode = breakfastCurrData.Name;
  2034. breakfastName = $"({breakfastCurrData.Remark})";
  2035. }
  2036. }
  2037. //房间费用
  2038. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2039. if (roomData != null)
  2040. {
  2041. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2042. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2043. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2044. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2045. roomFee = roomData.Price;
  2046. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2047. if (roomCurrData != null)
  2048. {
  2049. roomCode = roomCurrData.Name;
  2050. roomName = $"({roomCurrData.Remark})";
  2051. }
  2052. }
  2053. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2054. string hotelCostStr = "";
  2055. decimal hotelCsotTotal = 0.00M;
  2056. if (groupCost != null)
  2057. {
  2058. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2059. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2060. }
  2061. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2062. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2063. string hotelCost_day = "";
  2064. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2065. foreach (var item in hotelCostDetails1)
  2066. {
  2067. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2068. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2069. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2070. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2071. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2072. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2073. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2074. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2075. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2076. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2077. hotelCost_day += @$"<br/>";
  2078. }
  2079. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2080. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2081. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2082. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2083. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2084. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2085. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2086. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2087. $"房间说明: {hotelReservations.Remark} <br/>" +
  2088. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2089. $"{hotelBreakfastStr}" +
  2090. $"{hotelGovernmentRentStr}" +
  2091. $"{hotelCityTaxStr}";
  2092. _detail.PriceNameContent = hotelReservations.HotelName;
  2093. }
  2094. break;
  2095. case 79://车/导游地接
  2096. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2097. if (touristGuideGroundReservations != null)
  2098. {
  2099. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2100. {
  2101. _detail.BusName = touristGuideGroundReservations.BusName;
  2102. }
  2103. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2104. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2105. //if (isInt)
  2106. //{
  2107. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2108. // if (cityInfo != null)
  2109. // {
  2110. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2111. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2112. // if (carFeeItem != null)
  2113. // {
  2114. // nameContent += $@"({carFeeItem.Name})";
  2115. // }
  2116. // _detail.PriceNameContent = nameContent;
  2117. // }
  2118. //}
  2119. //else
  2120. //{
  2121. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2122. //}
  2123. var touristGuideGroundReservationsContents =
  2124. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2125. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2126. foreach (var item in touristGuideGroundReservationsContents)
  2127. {
  2128. string typeName = "Unknown";
  2129. string carCurrencyCode = "Unknown";
  2130. string carCurrencyName = "Unknown";
  2131. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2132. if (carTypeData != null) typeName = carTypeData.Name;
  2133. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2134. if (currencyData != null)
  2135. {
  2136. carCurrencyCode = currencyData.Name;
  2137. carCurrencyName = currencyData.Remark;
  2138. }
  2139. //op、成本 币种是否一致
  2140. bool IsCurrencyAgreement = false;
  2141. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2142. string opCostStr = string.Empty;
  2143. decimal opCostTypePrice = 0.00M;
  2144. #region 处理成本各项费用
  2145. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2146. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2147. if (opCost.Count > 0)
  2148. {
  2149. switch (item.SId)
  2150. {
  2151. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2152. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2153. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2154. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2155. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2156. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2157. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2158. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2159. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2160. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2161. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2162. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2163. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2164. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2165. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2166. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2167. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2168. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2169. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2170. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2171. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2172. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2173. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2174. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2175. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2176. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2177. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2178. }
  2179. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2180. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2181. }
  2182. #endregion
  2183. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2184. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2185. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2186. $"{opTypeStr} {opCostStr}<br/>" +
  2187. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2188. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2189. }
  2190. _detail.PriceMsgContent = priceMsg;
  2191. }
  2192. break;
  2193. case 80: //签证
  2194. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2195. if (visaInfo != null)
  2196. {
  2197. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2198. _detail.PriceNameContent = visaInfo.VisaDescription;
  2199. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2200. }
  2201. break;
  2202. case 81: //邀请/公务活动
  2203. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2204. if (_ioa != null)
  2205. {
  2206. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2207. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2208. sendCurrName = "Unknown", //快递费用币种 Name
  2209. sendCurrCode = "Unknown", //快递费用币种 Code
  2210. eventsCurrName = "Unknown", //公务活动费币种 Name
  2211. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2212. translateCurrName = "Unknown", //公务翻译费 Name
  2213. translateCurrCode = "Unknown"; //公务翻译费 Code
  2214. #region 处理费用币种
  2215. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2216. if (inviteCurrData != null)
  2217. {
  2218. inviteCurrName = inviteCurrData.Remark;
  2219. inviteCurrCode = inviteCurrData.Name;
  2220. }
  2221. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2222. if (sendCurrData != null)
  2223. {
  2224. sendCurrName = sendCurrData.Remark;
  2225. sendCurrCode = sendCurrData.Name;
  2226. }
  2227. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2228. if (eventsCurrData != null)
  2229. {
  2230. eventsCurrName = eventsCurrData.Remark;
  2231. eventsCurrCode = eventsCurrData.Name;
  2232. }
  2233. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2234. if (translateCurrData != null)
  2235. {
  2236. translateCurrName = translateCurrData.Remark;
  2237. translateCurrCode = translateCurrData.Name;
  2238. }
  2239. #endregion
  2240. _detail.PriceNameContent = _ioa.InviterArea;
  2241. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2242. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2243. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2244. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2245. $@"备注:" + _ioa.Remark + "<br/>";
  2246. }
  2247. break;
  2248. case 82: //团组客户保险
  2249. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2250. if (customers != null)
  2251. {
  2252. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2253. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2254. }
  2255. break;
  2256. case 85: //机票预订
  2257. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2258. if (jpRes != null)
  2259. {
  2260. string FlightsDescription = jpRes.FlightsDescription;
  2261. string PriceDescription = jpRes.PriceDescription;
  2262. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2263. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2264. }
  2265. break;
  2266. case 98://其他款项
  2267. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2268. if (gdpRes != null)
  2269. {
  2270. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2271. _detail.PriceNameContent = gdpRes.PriceName;
  2272. }
  2273. break;
  2274. case 285://收款退还
  2275. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2276. if (refundAndOtherMoney != null)
  2277. {
  2278. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2279. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2280. }
  2281. break;
  2282. case 751://酒店早餐
  2283. break;
  2284. case 1015://超支费用
  2285. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2286. if (groupExtraCost != null)
  2287. {
  2288. _detail.PriceNameContent = groupExtraCost.PriceName;
  2289. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2290. }
  2291. break;
  2292. default:
  2293. break;
  2294. }
  2295. /*
  2296. * 申请人
  2297. */
  2298. string operatorName = " - ";
  2299. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2300. if (_opUser != null)
  2301. {
  2302. operatorName = _opUser.CnName;
  2303. }
  2304. _detail.OperatorName = operatorName;
  2305. /*
  2306. * 审核人
  2307. */
  2308. string auditOperatorName = "Unknown";
  2309. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2310. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2311. else
  2312. {
  2313. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2314. if (_adUser != null)
  2315. {
  2316. auditOperatorName = _adUser.CnName;
  2317. }
  2318. }
  2319. _detail.AuditOperatorName = auditOperatorName;
  2320. /*
  2321. * 超预算比例
  2322. */
  2323. string overBudgetStr = "";
  2324. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2325. else if (entity.ExceedBudget == 0)
  2326. {
  2327. if (entity.CTable == 76 || entity.CTable == 79)
  2328. {
  2329. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2330. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2331. }
  2332. else
  2333. {
  2334. overBudgetStr = "未超预算";
  2335. }
  2336. }
  2337. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2338. _detail.OverBudget = overBudgetStr;
  2339. decimal auditFee = 0.00M; //已审核金额 人名币
  2340. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2341. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2342. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2343. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2344. {
  2345. auditedFeeOriginal = entity.PayMoney;
  2346. auditFee = CurrPayStr;
  2347. }
  2348. else if (entity.IsAuditGM == 0)
  2349. {
  2350. unAuditFeeCNY = CurrPayStr;
  2351. unAuditFeeOriginal = OriginalCurrPay;
  2352. OriginalCurrPay = 0.00M;
  2353. }
  2354. /*
  2355. * 费用总计
  2356. */
  2357. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2358. {
  2359. CurrencyId = entity.PaymentCurrency,
  2360. CurrencyName = PaymentCurrency_WaitPay,
  2361. AmountPayable = entity.PayMoney,
  2362. ThisPayment = OriginalCurrPay,
  2363. BalancePayment = BalanceStr,
  2364. AuditedFunds = auditFee,
  2365. AuditedFundsOriginal = auditedFeeOriginal,
  2366. UnAuditFundsCNY = unAuditFeeCNY,
  2367. UnAuditFundsOriginal = unAuditFeeOriginal
  2368. });
  2369. _detail.IsAuditGM = entity.IsAuditGM;
  2370. detailList.Add(_detail);
  2371. }
  2372. #endregion
  2373. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2374. /*
  2375. * 下方描述处理
  2376. */
  2377. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2378. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2379. if (ccpCurrencyPrice != null)
  2380. {
  2381. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2382. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2383. }
  2384. else
  2385. {
  2386. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2387. }
  2388. string amountPayableStr = string.Format(@"应付款总金额: ");
  2389. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2390. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2391. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2392. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2393. foreach (var item in nonDuplicat)
  2394. {
  2395. var currencyName = item.CurrencyName;
  2396. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2397. if (strs.Count > 0)
  2398. {
  2399. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2400. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2401. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2402. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2403. //单独处理此次付款金额
  2404. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2405. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2406. //单独处理已审核费用
  2407. //if (item.CurrencyId == 836) //人民币
  2408. //{
  2409. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2410. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2411. //}
  2412. //else
  2413. //{
  2414. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2415. //}
  2416. if (currencyName.Equals("CNY"))
  2417. {
  2418. //已审核费用
  2419. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2420. //未审核费用
  2421. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2422. }
  2423. else
  2424. {
  2425. //已审核费用
  2426. 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"));
  2427. //未审核费用
  2428. 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"));
  2429. }
  2430. }
  2431. }
  2432. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2433. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2434. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2435. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2436. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2437. var _view1 = new
  2438. {
  2439. PageFuncAuth = pageFunAuthView,
  2440. Data = _view
  2441. };
  2442. return Ok(JsonView(_view1));
  2443. }
  2444. catch (Exception ex)
  2445. {
  2446. return Ok(JsonView(false, ex.Message));
  2447. }
  2448. }
  2449. /// <summary>
  2450. /// 费用审核
  2451. /// 修改团组费用审核状态
  2452. /// </summary>
  2453. /// <param name="_dto">参数Json字符串</param>
  2454. /// <returns></returns>
  2455. [HttpPost]
  2456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2457. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2458. {
  2459. #region 参数验证
  2460. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2461. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2462. #endregion
  2463. #region 页面操作权限验证
  2464. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2465. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2466. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2467. #endregion
  2468. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2469. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2470. DateTime dtNow = DateTime.Now;
  2471. _groupRepository.BeginTran();
  2472. int rst = 0;
  2473. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2474. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2475. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2476. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2477. List<dynamic> msgDatas = new List<dynamic>();
  2478. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2479. foreach (var item in idList)
  2480. {
  2481. int CreditId = int.Parse(item);
  2482. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2483. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2484. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2485. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2486. .Where(s => s.Id == CreditId)
  2487. .ExecuteCommandAsync();
  2488. if (result < 1)
  2489. {
  2490. rst = -1;
  2491. _groupRepository.RollbackTran();
  2492. return Ok(JsonView(false, "操作失败并回滚!"));
  2493. }
  2494. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2495. if (creditData != null)
  2496. {
  2497. #region 应用通知配置
  2498. try
  2499. {
  2500. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2501. }
  2502. catch (Exception ex)
  2503. {
  2504. }
  2505. #endregion
  2506. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2507. string groupNameStr = string.Empty;
  2508. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2509. if (groupData != null) groupNameStr = groupData.TeamName;
  2510. string creditTypeStr = string.Empty;
  2511. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2512. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2513. string creditCurrency = string.Empty;
  2514. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2515. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2516. if (creditCurrency.Equals("CNY"))
  2517. {
  2518. creditData.DayRate = 1.0000M;
  2519. }
  2520. if (creditData.PayPercentage == 0.00M)
  2521. {
  2522. creditData.PayPercentage = 100M;
  2523. }
  2524. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2525. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2526. string msgContent = "";
  2527. if (creditCurrency.Equals("CNY"))
  2528. {
  2529. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2530. }
  2531. else
  2532. {
  2533. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2534. }
  2535. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2536. }
  2537. }
  2538. if (rst == 0)
  2539. {
  2540. _groupRepository.CommitTran();
  2541. foreach (var item in msgDatas)
  2542. {
  2543. //发送消息
  2544. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2545. }
  2546. #region 应用推送
  2547. try
  2548. {
  2549. foreach (var ccpId in dic_ccp_user.Keys)
  2550. {
  2551. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2552. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2553. }
  2554. }
  2555. catch (Exception)
  2556. {
  2557. }
  2558. #endregion
  2559. return Ok(JsonView(true, "操作成功!"));
  2560. }
  2561. return Ok(JsonView(false, "操作失败!"));
  2562. }
  2563. #endregion
  2564. #region 机票费用录入
  2565. /// <summary>
  2566. /// 机票录入当前登录人可操作团组
  2567. /// </summary>
  2568. /// <param name="dto"></param>
  2569. /// <returns></returns>
  2570. [HttpPost]
  2571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2572. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2573. {
  2574. try
  2575. {
  2576. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2577. if (groupData.Code != 0)
  2578. {
  2579. return Ok(JsonView(false, groupData.Msg));
  2580. }
  2581. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2582. }
  2583. catch (Exception ex)
  2584. {
  2585. return Ok(JsonView(false, "程序错误!"));
  2586. throw;
  2587. }
  2588. }
  2589. /// <summary>
  2590. /// 机票费用录入列表
  2591. /// </summary>
  2592. /// <param name="dto"></param>
  2593. /// <returns></returns>
  2594. [HttpPost]
  2595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2596. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2597. {
  2598. try
  2599. {
  2600. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2601. if (groupData.Code != 0)
  2602. {
  2603. return Ok(JsonView(false, groupData.Msg));
  2604. }
  2605. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2606. }
  2607. catch (Exception ex)
  2608. {
  2609. return Ok(JsonView(false, ex.Message));
  2610. throw;
  2611. }
  2612. }
  2613. /// <summary>
  2614. /// 根据id查询费用录入信息
  2615. /// </summary>
  2616. /// <param name="dto"></param>
  2617. /// <returns></returns>
  2618. [HttpPost]
  2619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2620. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2621. {
  2622. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2623. if (groupData.Code != 0)
  2624. {
  2625. return Ok(JsonView(false, groupData.Msg));
  2626. }
  2627. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2628. }
  2629. /// <summary>
  2630. /// 机票费用录入操作(Status:1.新增,2.修改)
  2631. /// </summary>
  2632. /// <param name="dto"></param>
  2633. /// <returns></returns>
  2634. [HttpPost]
  2635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2636. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2637. {
  2638. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2639. if (groupData.Code != 0)
  2640. {
  2641. return Ok(JsonView(false, groupData.Msg));
  2642. }
  2643. #region 应用推送
  2644. try
  2645. {
  2646. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2647. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2648. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2649. //2024-10-21 新增LZ UID
  2650. var userIds = new List<int>() { 21 };
  2651. string title = $"系统通知";
  2652. string content = "";
  2653. var diId = dto.AirTicketResOpData.DiId;
  2654. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2655. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2656. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2657. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2658. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2659. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2660. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2661. }
  2662. catch (Exception ex)
  2663. {
  2664. }
  2665. #endregion
  2666. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2667. }
  2668. /// <summary>
  2669. /// 根据舱位类型查询接团客户名单信息
  2670. /// </summary>
  2671. /// <param name="dto"></param>
  2672. /// <returns></returns>
  2673. [HttpPost]
  2674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2675. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2676. {
  2677. try
  2678. {
  2679. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2680. if (crm_Groups.Count != 0)
  2681. {
  2682. List<dynamic> Customer = new List<dynamic>();
  2683. foreach (var item in crm_Groups)
  2684. {
  2685. var data = new
  2686. {
  2687. Id = item.Id,
  2688. Pinyin = item.Pinyin,
  2689. Name = item.LastName + item.FirstName
  2690. };
  2691. Customer.Add(data);
  2692. }
  2693. return Ok(JsonView(true, "查询成功!", Customer));
  2694. }
  2695. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2696. }
  2697. catch (Exception ex)
  2698. {
  2699. return Ok(JsonView(false, "程序错误!"));
  2700. throw;
  2701. }
  2702. }
  2703. /// <summary>
  2704. /// 根据团号获取客户信息
  2705. /// </summary>
  2706. /// <param name="dto"></param>
  2707. /// <returns></returns>
  2708. [HttpPost]
  2709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2710. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2711. {
  2712. var jw = JsonView(false);
  2713. if (dto.DIID < 1)
  2714. {
  2715. jw.Msg += "请输入正确的diid";
  2716. return Ok(jw);
  2717. }
  2718. var arr = getSimplClientList(dto.DIID);
  2719. jw = JsonView(true, "获取成功!", arr);
  2720. return Ok(jw);
  2721. }
  2722. private List<SimplClientInfo> getSimplClientList(int diId)
  2723. {
  2724. 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);
  2725. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2726. foreach (var item in arr)
  2727. {
  2728. EncryptionProcessor.DecryptProperties(item);
  2729. }
  2730. return arr;
  2731. }
  2732. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2733. {
  2734. string result = origin;
  2735. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2736. {
  2737. string[] temparr = origin.Split(',');
  2738. string fistrStr = temparr[0];
  2739. int count = temparr.Count();
  2740. int tempId;
  2741. bool success = int.TryParse(fistrStr, out tempId);
  2742. if (success)
  2743. {
  2744. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2745. if (tempInfo != null)
  2746. {
  2747. if (count > 1)
  2748. {
  2749. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2750. }
  2751. else
  2752. {
  2753. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2754. }
  2755. }
  2756. }
  2757. }
  2758. return result;
  2759. }
  2760. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2761. {
  2762. string result = origin;
  2763. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2764. {
  2765. string[] temparr = origin.Split(',');
  2766. result = "";
  2767. foreach (var item in temparr)
  2768. {
  2769. int tempId;
  2770. bool success = int.TryParse(item, out tempId);
  2771. if (success)
  2772. {
  2773. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2774. if (tempInfo != null)
  2775. {
  2776. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2777. }
  2778. }
  2779. }
  2780. }
  2781. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2782. return result;
  2783. }
  2784. /// <summary>
  2785. /// 机票费用录入,删除
  2786. /// </summary>
  2787. /// <param name="dto"></param>
  2788. /// <returns></returns>
  2789. [HttpPost]
  2790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2791. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2792. {
  2793. try
  2794. {
  2795. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2796. if (res)
  2797. {
  2798. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2799. {
  2800. IsDel = 1,
  2801. DeleteUserId = dto.DeleteUserId,
  2802. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2803. }).ExecuteCommandAsync();
  2804. return Ok(JsonView(true, "删除成功!"));
  2805. }
  2806. return Ok(JsonView(false, "删除失败!"));
  2807. }
  2808. catch (Exception ex)
  2809. {
  2810. return Ok(JsonView(false, "程序错误!"));
  2811. throw;
  2812. }
  2813. }
  2814. /// <summary>
  2815. /// 导出机票录入报表
  2816. /// </summary>
  2817. /// <param name="dto"></param>
  2818. /// <returns></returns>
  2819. [HttpPost]
  2820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2821. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2822. {
  2823. try
  2824. {
  2825. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2826. if (groupData.Code != 0)
  2827. {
  2828. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2829. }
  2830. else
  2831. {
  2832. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2833. if (AirTicketReservations.Count != 0)
  2834. {
  2835. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2836. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2837. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2838. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2839. WorkbookDesigner designer = new WorkbookDesigner();
  2840. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2841. decimal countCost = 0;
  2842. foreach (var item in AirTicketReservations)
  2843. {
  2844. #region 处理客人姓名
  2845. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2846. item.ClientName = clientNames;
  2847. #endregion
  2848. if (item.BankType == "其他")
  2849. {
  2850. item.BankNo = "--";
  2851. }
  2852. else
  2853. {
  2854. if (!string.IsNullOrEmpty(item.BankType))
  2855. {
  2856. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2857. }
  2858. }
  2859. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2860. item.Price = System.Decimal.Round(item.Price, 2);
  2861. countCost += Convert.ToDecimal(item.Price);
  2862. }
  2863. designer.SetDataSource("Export", AirTicketReservations);
  2864. designer.SetDataSource("ExportDiCode", diCode);
  2865. designer.SetDataSource("ExportDiName", diName);
  2866. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2867. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2868. designer.Process();
  2869. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2870. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2871. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2872. return Ok(JsonView(true, "成功", url = rst));
  2873. }
  2874. else
  2875. {
  2876. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2877. }
  2878. }
  2879. }
  2880. catch (Exception ex)
  2881. {
  2882. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2883. throw;
  2884. }
  2885. }
  2886. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2887. /// <summary>
  2888. /// 行程单导出
  2889. /// </summary>
  2890. /// <param name="dto"></param>
  2891. /// <returns></returns>
  2892. [HttpPost]
  2893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2894. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2895. {
  2896. try
  2897. {
  2898. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2899. if (groupData.Code != 0)
  2900. {
  2901. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2902. }
  2903. else
  2904. {
  2905. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2906. if (dto.Language == "CN")
  2907. {
  2908. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2909. DocumentBuilder builder = new DocumentBuilder(doc);
  2910. int tableIndex = 0;//表格索引
  2911. //得到文档中的第一个表格
  2912. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2913. foreach (var item in _AirTicketReservations)
  2914. {
  2915. #region 处理固定数据
  2916. string[] FlightsCode = item.FlightsCode.Split('/');
  2917. if (FlightsCode.Length != 0)
  2918. {
  2919. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2920. if (_AirCompany != null)
  2921. {
  2922. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2923. }
  2924. else
  2925. {
  2926. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2927. }
  2928. }
  2929. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2930. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2931. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2932. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2933. string name = "";
  2934. foreach (string clientName in nameArray)
  2935. {
  2936. if (!name.Contains(clientName))
  2937. {
  2938. name += clientName + ",";
  2939. }
  2940. }
  2941. if (!string.IsNullOrWhiteSpace(name))
  2942. {
  2943. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2944. }
  2945. else
  2946. {
  2947. table.Range.Bookmarks["ClientName"].Text = "--";
  2948. }
  2949. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2950. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2951. table.Range.Bookmarks["JointTicket"].Text = "--";
  2952. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2953. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2954. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2955. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2956. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2957. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2958. #endregion
  2959. #region 循环数据处理
  2960. List<AirInfo> airs = new List<AirInfo>();
  2961. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2962. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2963. for (int i = 0; i < FlightsCode.Length; i++)
  2964. {
  2965. AirInfo air = new AirInfo();
  2966. string[] tempstr = DayArray[i]
  2967. .Replace("\r\n", string.Empty)
  2968. .Replace("\\r\\n", string.Empty)
  2969. .TrimStart().TrimEnd()
  2970. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2971. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2972. string starCity = "";
  2973. if (star_Three != null)
  2974. {
  2975. starCity = star_Three.AirPort;
  2976. }
  2977. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2978. string EndCity = "";
  2979. if (End_Three != null)
  2980. {
  2981. EndCity = End_Three.AirPort;
  2982. }
  2983. air.Destination = starCity + "/" + EndCity;
  2984. air.Flight = FlightsCode[i];
  2985. air.SeatingClass = item.CTypeName;
  2986. string dateTime = tempstr[2];
  2987. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2988. air.FlightDate = DateTemp;
  2989. air.DepartureTime = tempstr[5];
  2990. air.LandingTime = tempstr[6];
  2991. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2992. air.TicketStatus = "--";
  2993. air.Luggage = "--";
  2994. air.DepartureTerminal = "--";
  2995. air.LandingTerminal = "--";
  2996. airs.Add(air);
  2997. }
  2998. int row = 13;
  2999. for (int i = 0; i < airs.Count; i++)
  3000. {
  3001. if (airs.Count > 2)
  3002. {
  3003. for (int j = 0; j < airs.Count - 2; j++)
  3004. {
  3005. var CopyRow = table.Rows[12].Clone(true);
  3006. table.Rows.Add(CopyRow);
  3007. }
  3008. }
  3009. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3010. int index = 0;
  3011. foreach (PropertyInfo property in properties)
  3012. {
  3013. string value = property.GetValue(airs[i]).ToString();
  3014. Cell ishcel0 = table.Rows[row].Cells[index];
  3015. Paragraph p = new Paragraph(doc);
  3016. string s = value;
  3017. p.AppendChild(new Run(doc, s));
  3018. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3019. ishcel0.AppendChild(p);
  3020. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3021. index++;
  3022. }
  3023. row++;
  3024. }
  3025. #endregion
  3026. Paragraph lastParagraph = new Paragraph(doc);
  3027. //第一个表格末尾加段落
  3028. table.ParentNode.InsertAfter(lastParagraph, table);
  3029. //复制第一个表格
  3030. Table cloneTable = (Table)table.Clone(true);
  3031. //在文档末尾段落后面加入复制的表格
  3032. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3033. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3034. {
  3035. int rownewsIndex = 13;
  3036. for (int i = 0; i < 2; i++)
  3037. {
  3038. var CopyRow = table.Rows[12].Clone(true);
  3039. table.Rows.RemoveAt(13);
  3040. table.Rows.Add(CopyRow);
  3041. rownewsIndex++;
  3042. }
  3043. }
  3044. else
  3045. {
  3046. table.Rows.RemoveAt(12);
  3047. }
  3048. cloneTable.Rows.RemoveAt(12);
  3049. }
  3050. if (_AirTicketReservations.Count != 0)
  3051. {
  3052. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3053. if (FlightsCode.Length != 0)
  3054. {
  3055. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3056. if (_AirCompany != null)
  3057. {
  3058. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3059. }
  3060. else
  3061. {
  3062. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3063. }
  3064. }
  3065. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3066. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3067. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3068. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3069. string name = "";
  3070. foreach (string clientName in nameArray)
  3071. {
  3072. if (!name.Contains(clientName))
  3073. {
  3074. name += clientName + ",";
  3075. }
  3076. }
  3077. if (!string.IsNullOrWhiteSpace(name))
  3078. {
  3079. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3080. }
  3081. else
  3082. {
  3083. table.Range.Bookmarks["ClientName"].Text = "--";
  3084. }
  3085. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3086. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3087. table.Range.Bookmarks["JointTicket"].Text = "--";
  3088. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3089. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3090. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3091. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3092. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3093. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3094. }
  3095. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3096. //保存合并后的文档
  3097. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3098. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3099. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3100. return Ok(JsonView(true, "成功!", rst));
  3101. }
  3102. else
  3103. {
  3104. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3105. DocumentBuilder builder = new DocumentBuilder(doc);
  3106. int tableIndex = 0;//表格索引
  3107. //得到文档中的第一个表格
  3108. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3109. List<string> texts = new List<string>();
  3110. foreach (var item in _AirTicketReservations)
  3111. {
  3112. string[] FlightsCode = item.FlightsCode.Split('/');
  3113. if (FlightsCode.Length != 0)
  3114. {
  3115. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3116. if (_AirCompany != null)
  3117. {
  3118. if (!transDic.ContainsKey(_AirCompany.CnName))
  3119. {
  3120. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3121. }
  3122. }
  3123. else
  3124. {
  3125. if (!transDic.ContainsKey("--"))
  3126. {
  3127. transDic.Add("--", "--");
  3128. }
  3129. }
  3130. }
  3131. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3132. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3133. string name = "";
  3134. foreach (string clientName in nameArray)
  3135. {
  3136. name += clientName + ",";
  3137. }
  3138. if (!texts.Contains(name))
  3139. {
  3140. texts.Add(name);
  3141. }
  3142. List<AirInfo> airs = new List<AirInfo>();
  3143. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3144. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3145. for (int i = 0; i < FlightsCode.Length; i++)
  3146. {
  3147. AirInfo air = new AirInfo();
  3148. string[] tempstr = DayArray[i]
  3149. .Replace("\r\n", string.Empty)
  3150. .Replace("\\r\\n", string.Empty)
  3151. .TrimStart().TrimEnd()
  3152. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3153. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3154. if (star_Three != null)
  3155. {
  3156. if (!transDic.ContainsKey(star_Three.AirPort))
  3157. {
  3158. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3159. }
  3160. }
  3161. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3162. if (End_Three != null)
  3163. {
  3164. if (!transDic.ContainsKey(End_Three.AirPort))
  3165. {
  3166. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3167. }
  3168. }
  3169. if (!texts.Contains(item.CTypeName))
  3170. {
  3171. texts.Add(item.CTypeName);
  3172. }
  3173. }
  3174. }
  3175. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3176. if (transData.Count > 0)
  3177. {
  3178. foreach (TranslateResult item in transData)
  3179. {
  3180. if (!transDic.ContainsKey(item.Query))
  3181. {
  3182. transDic.Add(item.Query, item.Translation);
  3183. }
  3184. }
  3185. }
  3186. foreach (var item in _AirTicketReservations)
  3187. {
  3188. #region 处理固定数据
  3189. string[] FlightsCode = item.FlightsCode.Split('/');
  3190. if (FlightsCode.Length != 0)
  3191. {
  3192. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3193. if (_AirCompany != null)
  3194. {
  3195. string str = "--";
  3196. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3197. if (!string.IsNullOrEmpty(translateResult))
  3198. {
  3199. str = translateResult;
  3200. str = _airTicketResRep.Processing(str);
  3201. }
  3202. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3203. }
  3204. else
  3205. {
  3206. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3207. }
  3208. }
  3209. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3210. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3211. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3212. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3213. string names = "";
  3214. foreach (string clientName in nameArray)
  3215. {
  3216. names += clientName + ",";
  3217. }
  3218. if (!string.IsNullOrWhiteSpace(names))
  3219. {
  3220. string str = "--";
  3221. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3222. if (!string.IsNullOrEmpty(translateResult))
  3223. {
  3224. str = translateResult;
  3225. str = _airTicketResRep.Processing(str);
  3226. }
  3227. table.Range.Bookmarks["ClientName"].Text = str;
  3228. }
  3229. else
  3230. {
  3231. table.Range.Bookmarks["ClientName"].Text = "--";
  3232. }
  3233. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3234. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3235. table.Range.Bookmarks["JointTicket"].Text = "--";
  3236. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3237. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3238. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3239. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3240. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3241. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3242. #endregion
  3243. #region 循环数据处理
  3244. List<AirInfo> airs = new List<AirInfo>();
  3245. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3246. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3247. for (int i = 0; i < FlightsCode.Length; i++)
  3248. {
  3249. AirInfo air = new AirInfo();
  3250. string[] tempstr = DayArray[i]
  3251. .Replace("\r\n", string.Empty)
  3252. .Replace("\\r\\n", string.Empty)
  3253. .TrimStart().TrimEnd()
  3254. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3255. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3256. string starCity = "";
  3257. if (star_Three != null)
  3258. {
  3259. string str2 = "--";
  3260. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3261. if (!string.IsNullOrEmpty(translateResult2))
  3262. {
  3263. str2 = translateResult2;
  3264. str2 = _airTicketResRep.Processing(str2);
  3265. }
  3266. starCity = str2;
  3267. }
  3268. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3269. string EndCity = "";
  3270. if (End_Three != null)
  3271. {
  3272. string str1 = "--";
  3273. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3274. if (!string.IsNullOrEmpty(translateResult1))
  3275. {
  3276. str1 = translateResult1;
  3277. str1 = _airTicketResRep.Processing(str1);
  3278. }
  3279. EndCity = str1;
  3280. }
  3281. air.Destination = starCity + "/" + EndCity;
  3282. air.Flight = FlightsCode[i];
  3283. string str = "--";
  3284. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3285. if (!string.IsNullOrEmpty(translateResult))
  3286. {
  3287. str = translateResult;
  3288. str = _airTicketResRep.Processing(str);
  3289. }
  3290. air.SeatingClass = str;
  3291. string dateTime = tempstr[2];
  3292. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3293. air.FlightDate = DateTemp;
  3294. air.DepartureTime = tempstr[5];
  3295. air.LandingTime = tempstr[6];
  3296. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3297. air.TicketStatus = "--";
  3298. air.Luggage = "--";
  3299. air.DepartureTerminal = "--";
  3300. air.LandingTerminal = "--";
  3301. airs.Add(air);
  3302. }
  3303. int row = 13;
  3304. for (int i = 0; i < airs.Count; i++)
  3305. {
  3306. if (airs.Count > 2)
  3307. {
  3308. for (int j = 0; j < airs.Count - 2; j++)
  3309. {
  3310. var CopyRow = table.Rows[12].Clone(true);
  3311. table.Rows.Add(CopyRow);
  3312. }
  3313. }
  3314. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3315. int index = 0;
  3316. foreach (PropertyInfo property in properties)
  3317. {
  3318. string value = property.GetValue(airs[i]).ToString();
  3319. Cell ishcel0 = table.Rows[row].Cells[index];
  3320. Paragraph p = new Paragraph(doc);
  3321. string s = value;
  3322. p.AppendChild(new Run(doc, s));
  3323. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3324. ishcel0.AppendChild(p);
  3325. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3326. //ishcel0.CellFormat.VerticalAlignment=
  3327. index++;
  3328. }
  3329. row++;
  3330. }
  3331. #endregion
  3332. Paragraph lastParagraph = new Paragraph(doc);
  3333. //第一个表格末尾加段落
  3334. table.ParentNode.InsertAfter(lastParagraph, table);
  3335. //复制第一个表格
  3336. Table cloneTable = (Table)table.Clone(true);
  3337. //在文档末尾段落后面加入复制的表格
  3338. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3339. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3340. {
  3341. int rownewsIndex = 13;
  3342. for (int i = 0; i < 2; i++)
  3343. {
  3344. var CopyRow = table.Rows[12].Clone(true);
  3345. table.Rows.RemoveAt(13);
  3346. table.Rows.Add(CopyRow);
  3347. rownewsIndex++;
  3348. }
  3349. }
  3350. else
  3351. {
  3352. table.Rows.RemoveAt(12);
  3353. }
  3354. cloneTable.Rows.RemoveAt(12);
  3355. }
  3356. if (_AirTicketReservations.Count != 0)
  3357. {
  3358. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3359. if (FlightsCode.Length != 0)
  3360. {
  3361. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3362. if (_AirCompany != null)
  3363. {
  3364. string str = "--";
  3365. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3366. if (!string.IsNullOrEmpty(translateResult))
  3367. {
  3368. str = translateResult;
  3369. str = _airTicketResRep.Processing(str);
  3370. }
  3371. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3372. }
  3373. else
  3374. {
  3375. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3376. }
  3377. }
  3378. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3379. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3380. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3381. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3382. string names = "";
  3383. foreach (string clientName in nameArray)
  3384. {
  3385. names += clientName + ",";
  3386. }
  3387. if (!string.IsNullOrWhiteSpace(names))
  3388. {
  3389. string str = "--";
  3390. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3391. if (!string.IsNullOrEmpty(translateResult))
  3392. {
  3393. str = translateResult;
  3394. str = _airTicketResRep.Processing(str);
  3395. }
  3396. table.Range.Bookmarks["ClientName"].Text = str;
  3397. }
  3398. else
  3399. {
  3400. table.Range.Bookmarks["ClientName"].Text = "--";
  3401. }
  3402. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3403. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3404. table.Range.Bookmarks["JointTicket"].Text = "--";
  3405. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3406. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3407. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3408. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3409. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3410. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3411. }
  3412. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3413. //保存合并后的文档
  3414. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3415. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3416. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3417. return Ok(JsonView(true, "成功!", rst));
  3418. }
  3419. }
  3420. }
  3421. catch (Exception ex)
  3422. {
  3423. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3424. throw;
  3425. }
  3426. }
  3427. #endregion
  3428. #region 团组增减款项 --> 其他款项
  3429. /// <summary>
  3430. /// 团组增减款项下拉框绑定
  3431. /// </summary>
  3432. /// <param name="dto"></param>
  3433. /// <returns></returns>
  3434. [HttpPost]
  3435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3436. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3437. {
  3438. #region 参数验证
  3439. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3440. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3441. #endregion
  3442. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3443. }
  3444. /// <summary>
  3445. /// 根据团组Id查询团组增减款项
  3446. /// </summary>
  3447. /// <param name="dto"></param>
  3448. /// <returns></returns>
  3449. [HttpPost]
  3450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3451. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3452. {
  3453. #region 参数验证
  3454. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3455. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3456. #endregion
  3457. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3458. }
  3459. /// <summary>
  3460. /// 团组增减款项操作(Status:1.新增,2.修改)
  3461. /// </summary>
  3462. /// <param name="dto"></param>
  3463. /// <returns></returns>
  3464. [HttpPost]
  3465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3466. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3467. {
  3468. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3469. if (groupData.Code != 200)
  3470. {
  3471. return Ok(JsonView(false, groupData.Msg));
  3472. }
  3473. #region 应用推送
  3474. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3475. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3476. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3477. //自动审核
  3478. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3479. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3480. //2024-10-21 新增LZ UID
  3481. var userIds = new List<int>() { 21 };
  3482. string title = $"系统通知";
  3483. string content = "";
  3484. var diId = dto.DiId;
  3485. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3486. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3487. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3488. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3489. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3490. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3491. #endregion
  3492. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3493. }
  3494. /// <summary>
  3495. /// 团组增减款项操作 删除
  3496. /// </summary>
  3497. /// <param name="dto"></param>
  3498. /// <returns></returns>
  3499. [HttpPost]
  3500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3501. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3502. {
  3503. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3504. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3505. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3506. if (res.Code == 0)
  3507. {
  3508. return Ok(JsonView(true, "删除成功!"));
  3509. }
  3510. return Ok(JsonView(false, "删除失败!"));
  3511. }
  3512. /// <summary>
  3513. /// 根据团组增减款项Id查询
  3514. /// </summary>
  3515. /// <param name="dto"></param>
  3516. /// <returns></returns>
  3517. [HttpPost]
  3518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3519. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3520. {
  3521. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3522. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3523. }
  3524. /// <summary>
  3525. /// 查询供应商名称
  3526. /// </summary>
  3527. /// <param name="dto"></param>
  3528. /// <returns></returns>
  3529. [HttpPost]
  3530. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3531. {
  3532. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3533. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3534. ?? new List<Grp_DecreasePayments>();
  3535. dbResult = dbResult.Distinct(new
  3536. ProductComparer()).ToList();
  3537. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3538. {
  3539. x.Id,
  3540. x.SupplierAddress,
  3541. x.SupplierArea,
  3542. x.SupplierContact,
  3543. x.SupplierContactNumber,
  3544. x.SupplierEmail,
  3545. x.SupplierName,
  3546. x.SupplierSocialAccount,
  3547. x.SupplierTypeId,
  3548. }).ToList());
  3549. return Ok(jw);
  3550. }
  3551. /// <summary>
  3552. /// 团组增减款项 OTA匹配
  3553. /// </summary>
  3554. /// <param name="file"></param>
  3555. /// <returns></returns>
  3556. [HttpPost]
  3557. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3558. {
  3559. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3560. string fileName = file.FileName;
  3561. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3562. {
  3563. return Ok(JsonView(false, "请上传Excel文件!"));
  3564. }
  3565. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3566. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3567. if (!Directory.Exists(path))
  3568. {
  3569. Directory.CreateDirectory(path);
  3570. }
  3571. var filePath = @$"{path}/{fileName}";
  3572. //保存文件
  3573. using (FileStream fs = System.IO.File.Create(filePath))
  3574. {
  3575. file.CopyTo(fs);
  3576. fs.Flush();
  3577. }
  3578. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3579. //读取ExcelFile
  3580. DataTable dt = ConvertExcelToDataTable(filePath);
  3581. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3582. dt.TableName = "TB";
  3583. //修改table列名
  3584. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3585. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3586. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3587. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3588. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3589. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3590. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3591. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3592. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3593. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3594. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3595. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3596. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3597. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3598. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3599. var otaOrderNos = new List<string>();
  3600. foreach (DataRow item in dt.Rows)
  3601. {
  3602. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3603. }
  3604. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3605. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3606. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3607. .Select((dp, di) => new
  3608. {
  3609. dp.PriceName,
  3610. dp.OTAOrderNo,
  3611. dp.FeeTotal,
  3612. di.TeamName,
  3613. })
  3614. .ToListAsync();
  3615. foreach (DataRow item in dt.Rows)
  3616. {
  3617. var otaOrderNo = item["OTAOrderNo"].ToString();
  3618. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3619. if (oaData == null) continue;
  3620. item["GroupName"] = oaData.TeamName;
  3621. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3622. }
  3623. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3624. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3625. List<DataTable> datas = new List<DataTable>();
  3626. datas.Add(dt);
  3627. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3628. return Ok(JsonView(true, "操作成功", new { url = url }));
  3629. }
  3630. #region
  3631. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3632. {
  3633. // 创建Workbook对象
  3634. Workbook workbook = new Workbook(excelFilePath);
  3635. // 获取第一个工作表
  3636. Worksheet worksheet = workbook.Worksheets[0];
  3637. // 将工作表转换为DataTable
  3638. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3639. return dataTable;
  3640. }
  3641. #endregion
  3642. #endregion
  3643. #region 文件上传、删除
  3644. /// <summary>
  3645. /// region 文件上传 可以带参数
  3646. /// </summary>
  3647. /// <param name="file"></param>
  3648. /// <returns></returns>
  3649. [HttpPost]
  3650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3651. public async Task<IActionResult> UploadProject(IFormFile file)
  3652. {
  3653. //var TypeName = Request.Headers["TypeName"].ToString();
  3654. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3655. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3656. ////文件名称
  3657. //string projectFileName = file.FileName;
  3658. ////上传的文件的路径
  3659. //string filePath = $"{fileDir}/{projectFileName}";
  3660. //if (TypeName == "A")//A代表团组增减款项
  3661. //{
  3662. // filePath = fileDir + $@"\团组增减款项相关文件";
  3663. // if (!Directory.Exists(filePath))
  3664. // {
  3665. // Directory.CreateDirectory(filePath);
  3666. // }
  3667. // //上传的文件的路径
  3668. // filePath += $@"\{projectFileName}";
  3669. //}
  3670. //else if (TypeName == "B")//B代表商邀相关文件
  3671. //{
  3672. // //上传的文件的路径
  3673. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3674. // if (!Directory.Exists(filePath))
  3675. // {
  3676. // Directory.CreateDirectory(filePath);
  3677. // }
  3678. // //上传的文件的路径
  3679. // filePath = $@"\{projectFileName}";
  3680. //}
  3681. //try
  3682. //{
  3683. // using (FileStream fs = System.IO.File.Create(filePath))
  3684. // {
  3685. // file.CopyTo(fs);
  3686. // fs.Flush();
  3687. // }
  3688. //}
  3689. //catch (Exception ex)
  3690. //{
  3691. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3692. //}
  3693. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3694. try
  3695. {
  3696. var TypeName = Request.Headers["TypeName"].ToString();
  3697. if (file != null)
  3698. {
  3699. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3700. //文件名称
  3701. string projectFileName = file.FileName;
  3702. //上传的文件的路径
  3703. string filePath = $"{fileDir}/{projectFileName}";
  3704. if (TypeName == "A")//A代表团组增减款项
  3705. {
  3706. if (!Directory.Exists(fileDir))
  3707. {
  3708. Directory.CreateDirectory(fileDir);
  3709. }
  3710. //上传的文件的路径
  3711. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3712. }
  3713. else if (TypeName == "B")//B代表商邀相关文件
  3714. {
  3715. if (!Directory.Exists(fileDir))
  3716. {
  3717. Directory.CreateDirectory(fileDir);
  3718. }
  3719. //上传的文件的路径
  3720. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3721. }
  3722. using (FileStream fs = System.IO.File.Create(filePath))
  3723. {
  3724. file.CopyTo(fs);
  3725. fs.Flush();
  3726. }
  3727. return Ok(JsonView(true, "上传成功!", projectFileName));
  3728. }
  3729. else
  3730. {
  3731. return Ok(JsonView(false, "上传失败!"));
  3732. }
  3733. }
  3734. catch (Exception ex)
  3735. {
  3736. return Ok(JsonView(false, "程序错误!"));
  3737. }
  3738. }
  3739. /// <summary>
  3740. /// 删除指定文件
  3741. /// </summary>
  3742. /// <param name="dto"></param>
  3743. /// <returns></returns>
  3744. [HttpPost]
  3745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3746. public async Task<IActionResult> DelFile(DelFileDto dto)
  3747. {
  3748. try
  3749. {
  3750. var TypeName = Request.Headers["TypeName"].ToString();
  3751. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3752. string filePath = "";
  3753. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3754. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3755. int id = 0;
  3756. if (TypeName == "A")
  3757. {
  3758. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3759. // 删除该文件
  3760. System.IO.File.Delete(filePath);
  3761. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3762. .Where(a => a.Id == dto.Id)
  3763. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3764. .ExecuteCommandAsync();
  3765. }
  3766. else if (TypeName == "B")
  3767. {
  3768. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3769. // 删除该文件
  3770. System.IO.File.Delete(filePath);
  3771. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3772. if (info != null)
  3773. {
  3774. string[] files = new string[] { };
  3775. if (!string.IsNullOrEmpty(info.Attachment))
  3776. {
  3777. try
  3778. {
  3779. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3780. }
  3781. catch (Exception)
  3782. {
  3783. files = new List<string>() { info.Attachment }.ToArray();
  3784. }
  3785. }
  3786. if (files.Length > 0)
  3787. {
  3788. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3789. string filePath2 = string.Empty;
  3790. if (files1.Length > 0)
  3791. {
  3792. filePath2 = JsonConvert.SerializeObject(files1);
  3793. }
  3794. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3795. .Where(a => a.Id == dto.Id)
  3796. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3797. .ExecuteCommandAsync();
  3798. }
  3799. }
  3800. }
  3801. if (id != 0)
  3802. {
  3803. return Ok(JsonView(true, "成功!"));
  3804. }
  3805. else
  3806. {
  3807. return Ok(JsonView(false, "失败!"));
  3808. }
  3809. }
  3810. catch (Exception ex)
  3811. {
  3812. return Ok(JsonView(false, "程序错误!"));
  3813. throw;
  3814. }
  3815. }
  3816. /// <summary>
  3817. /// 文件上传多个文件 可以带参数
  3818. /// </summary>
  3819. /// <param name="file"></param>
  3820. /// <returns></returns>
  3821. [HttpPost]
  3822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3823. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3824. {
  3825. try
  3826. {
  3827. var TypeName = Request.Headers["TypeName"].ToString();
  3828. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3829. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3830. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3831. var filePahts = new List<string>();
  3832. foreach (var file in files)
  3833. {
  3834. //文件名称
  3835. string projectFileName = file.FileName;
  3836. //上传的文件的路径
  3837. string filePath = $"{fileDir}/{projectFileName}";
  3838. if (TypeName == "A")//A代表团组增减款项
  3839. {
  3840. if (!Directory.Exists(fileDir))
  3841. {
  3842. Directory.CreateDirectory(fileDir);
  3843. }
  3844. //上传的文件的路径
  3845. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3846. }
  3847. else if (TypeName == "B")//B代表商邀相关文件
  3848. {
  3849. if (!Directory.Exists(fileDir))
  3850. {
  3851. Directory.CreateDirectory(fileDir);
  3852. }
  3853. //上传的文件的路径
  3854. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3855. }
  3856. using (FileStream fs = System.IO.File.Create(filePath))
  3857. {
  3858. file.CopyTo(fs);
  3859. fs.Flush();
  3860. }
  3861. filePahts.Add(projectFileName);
  3862. }
  3863. return Ok(JsonView(true, "上传成功!", filePahts));
  3864. }
  3865. catch (Exception ex)
  3866. {
  3867. return Ok(JsonView(false, "程序错误!"));
  3868. }
  3869. }
  3870. #endregion
  3871. #region 商邀费用录入
  3872. /// <summary>
  3873. /// 根据团组Id查询商邀费用列表
  3874. /// </summary>
  3875. /// <param name="dto"></param>
  3876. /// <returns></returns>
  3877. [HttpPost]
  3878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3879. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3880. {
  3881. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3882. if (groupData.Code != 0)
  3883. {
  3884. return Ok(JsonView(false, groupData.Msg));
  3885. }
  3886. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3887. }
  3888. /// <summary>
  3889. /// 商邀费用列表
  3890. /// 下载文件
  3891. /// </summary>
  3892. /// <param name="dto"></param>
  3893. /// <returns></returns>
  3894. [HttpGet("{id}")]
  3895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3896. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3897. {
  3898. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3899. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3900. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3901. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3902. var filePaths = new List<string>();
  3903. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3904. try
  3905. {
  3906. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3907. }
  3908. catch (Exception ex)
  3909. {
  3910. filePaths.Add(info.Attachment);
  3911. }
  3912. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3913. for (int i = 0; i < filePaths.Count; i++)
  3914. {
  3915. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3916. }
  3917. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3918. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3919. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3920. {
  3921. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3922. {
  3923. foreach (string filePath in filePaths)
  3924. {
  3925. if (System.IO.File.Exists(filePath))
  3926. {
  3927. // 获取文件名
  3928. string fileName = Path.GetFileName(filePath);
  3929. // 将文件添加到ZIP归档中
  3930. zipArchive.CreateEntryFromFile(filePath, fileName);
  3931. }
  3932. }
  3933. }
  3934. }
  3935. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3936. }
  3937. /// <summary>
  3938. /// 商邀费用 Info Page 基础数据源
  3939. /// </summary>
  3940. /// <param name="dto"></param>
  3941. /// <returns></returns>
  3942. [HttpPost]
  3943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3944. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3945. {
  3946. try
  3947. {
  3948. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3949. if (groupData.Code != 0)
  3950. {
  3951. return Ok(JsonView(false, groupData.Msg));
  3952. }
  3953. return Ok(JsonView(true, "操作成功", groupData.Data));
  3954. }
  3955. catch (Exception ex)
  3956. {
  3957. return Ok(JsonView(false, ex.Message));
  3958. throw;
  3959. }
  3960. }
  3961. /// <summary>
  3962. /// 根据商邀费用ID查询C表和商邀费用数据
  3963. /// </summary>
  3964. /// <param name="dto"></param>
  3965. /// <returns></returns>
  3966. [HttpPost]
  3967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3968. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3969. {
  3970. try
  3971. {
  3972. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3973. if (groupData.Code != 0)
  3974. {
  3975. return Ok(JsonView(false, groupData.Msg));
  3976. }
  3977. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3978. }
  3979. catch (Exception ex)
  3980. {
  3981. return Ok(JsonView(false, ex.Message));
  3982. throw;
  3983. }
  3984. }
  3985. /// <summary>
  3986. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3987. /// </summary>
  3988. /// <param name="dto"></param>
  3989. /// <returns></returns>
  3990. [HttpPost]
  3991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3992. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3993. {
  3994. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3995. if (groupData.Code != 0)
  3996. {
  3997. return Ok(JsonView(false, groupData.Msg));
  3998. }
  3999. #region 应用推送
  4000. try
  4001. {
  4002. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4003. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4004. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4005. //2024-10-21 新增LZ UID
  4006. var userIds = new List<int>() { 21 };
  4007. string title = $"系统通知";
  4008. string content = "";
  4009. var diId = dto.DiId;
  4010. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4011. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4012. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4013. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4014. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4015. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4016. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4017. }
  4018. catch (Exception ex)
  4019. {
  4020. }
  4021. #endregion
  4022. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4023. }
  4024. /// <summary>
  4025. /// 商邀删除
  4026. /// </summary>
  4027. /// <param name="dto"></param>
  4028. /// <returns></returns>
  4029. [HttpPost]
  4030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4031. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4032. {
  4033. try
  4034. {
  4035. _sqlSugar.BeginTran();
  4036. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4037. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4038. {
  4039. IsDel = 1,
  4040. DeleteUserId = dto.DeleteUserId,
  4041. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4042. })
  4043. .Where(it => it.Id == dto.Id)
  4044. .ExecuteCommand();
  4045. if (res1 > 0)
  4046. {
  4047. int _diId = 0;
  4048. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4049. if (_ioaInfo != null)
  4050. {
  4051. _diId = _ioaInfo.DiId;
  4052. }
  4053. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4054. .SetColumns(a => new Grp_CreditCardPayment()
  4055. {
  4056. IsDel = 1,
  4057. DeleteUserId = dto.DeleteUserId,
  4058. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4059. })
  4060. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4061. .ExecuteCommand();
  4062. if (res2 > 0)
  4063. {
  4064. _sqlSugar.CommitTran();
  4065. return Ok(JsonView(true, "删除成功!"));
  4066. }
  4067. }
  4068. _sqlSugar.RollbackTran();
  4069. return Ok(JsonView(false, "删除失败"));
  4070. }
  4071. catch (Exception ex)
  4072. {
  4073. _sqlSugar.RollbackTran();
  4074. return Ok(JsonView(false, ex.Message));
  4075. }
  4076. }
  4077. /// <summary>
  4078. /// 团组模块文件上传
  4079. /// </summary>
  4080. /// <param name="dto"></param>
  4081. /// <returns></returns>
  4082. [HttpPost]
  4083. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4084. {
  4085. var jw = JsonView(false);
  4086. long M = 1024 * 1024;
  4087. if (dto.Files == null || dto.Files.Count == 0)
  4088. {
  4089. jw.Msg = "无文件信息!";
  4090. return Ok(jw);
  4091. }
  4092. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4093. {
  4094. jw.Msg = "文件大小超过20M!";
  4095. return Ok(jw);
  4096. }
  4097. //var nameSp = dto.File.FileName.Split(".");
  4098. //if (nameSp.Length < 2)
  4099. //{
  4100. // jw.Msg = "拓展名称有误!";
  4101. // return Ok(jw);
  4102. //}
  4103. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4104. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4105. //{
  4106. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4107. // return Ok(jw);
  4108. //}
  4109. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4110. if (Ctable == null)
  4111. {
  4112. jw.Msg = "Ctable指向有误!";
  4113. return Ok(jw);
  4114. }
  4115. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4116. if (groupInfo == null)
  4117. {
  4118. jw.Msg = "团组信息不存在!";
  4119. return Ok(jw);
  4120. }
  4121. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4122. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4123. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4124. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4125. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4126. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4127. try
  4128. {
  4129. if (!Directory.Exists(fileBase))
  4130. {
  4131. Directory.CreateDirectory(fileBase);
  4132. }
  4133. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4134. foreach (var fileStream in dto.Files)
  4135. {
  4136. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4137. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4138. {
  4139. Cid = dto.Cid,
  4140. CreateTime = DateTime.Now,
  4141. CreateUserId = dto.Userid,
  4142. Ctable = dto.Ctable,
  4143. Diid = dto.Diid,
  4144. IsDel = 0,
  4145. FilePath = saveFilePath,
  4146. FileName = fileStream.FileName
  4147. };
  4148. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4149. {
  4150. fileStream.CopyTo(fs);
  4151. fs.Flush();
  4152. }
  4153. saveArr.Add(file);
  4154. }
  4155. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4156. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4157. jw = JsonView(true, "保存成功!", new
  4158. {
  4159. count = addResult,
  4160. filesName = saveArr.Select(x => x.FileName)
  4161. });
  4162. }
  4163. catch (Exception ex)
  4164. {
  4165. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4166. {
  4167. count = 0,
  4168. filesName = new string[0],
  4169. });
  4170. }
  4171. return Ok(jw);
  4172. }
  4173. /// <summary>
  4174. /// 查询各模块已保存文件
  4175. /// </summary>
  4176. /// <param name="dto"></param>
  4177. /// <returns></returns>
  4178. [HttpPost]
  4179. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4180. {
  4181. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4182. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4183. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4184. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4185. {
  4186. expression = Expressionable.Create<Grp_GroupModelFile>()
  4187. .And(x => visaIds.Contains(x.CreateUserId));
  4188. }
  4189. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4190. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4191. .Where(expression.ToExpression())
  4192. .ToList();
  4193. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4194. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4195. {
  4196. x.FileName,
  4197. x.Id,
  4198. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4199. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4200. })));
  4201. }
  4202. /// <summary>
  4203. /// 下载该团组下的所有文件
  4204. /// </summary>
  4205. /// <param name="dto"></param>
  4206. /// <returns></returns>
  4207. [HttpPost]
  4208. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4209. {
  4210. var jw = JsonView(false);
  4211. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4212. if (groupInfo == null)
  4213. {
  4214. jw.Msg = "团组信息不存在!";
  4215. return Ok(jw);
  4216. }
  4217. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4218. var isModule = Convert.ToBoolean(dto.isModule);
  4219. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4220. IOOperatorHelper io = new IOOperatorHelper();
  4221. if (isModule)
  4222. {
  4223. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4224. foreach (var moduleArr in moduleGroup)
  4225. {
  4226. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4227. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4228. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4229. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4230. foreach (var item in moduleArr)
  4231. {
  4232. if (System.IO.File.Exists(item.FilePath))
  4233. {
  4234. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4235. {
  4236. byte[] bytes = new byte[fileStream.Length];
  4237. fileStream.Read(bytes, 0, bytes.Length);
  4238. fileStream.Close();
  4239. Stream stream = new MemoryStream(bytes);
  4240. chiZips.Add(item.FileName, stream);
  4241. }
  4242. }
  4243. }
  4244. if (chiZips.Count > 0)
  4245. {
  4246. var byts = io.ConvertZipStream(chiZips);
  4247. Stream stream = new MemoryStream(byts);
  4248. Zips.Add(key.Name + "_.zip", stream);
  4249. }
  4250. }
  4251. }
  4252. else
  4253. {
  4254. foreach (var item in dbQuery)
  4255. {
  4256. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4257. {
  4258. byte[] bytes = new byte[fileStream.Length];
  4259. fileStream.Read(bytes, 0, bytes.Length);
  4260. fileStream.Close();
  4261. Stream stream = new MemoryStream(bytes);
  4262. while (Zips.Keys.Contains(item.FileName))
  4263. {
  4264. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4265. }
  4266. Zips.Add(item.FileName, stream);
  4267. }
  4268. }
  4269. }
  4270. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4271. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4272. if (Zips.Count > 0)
  4273. {
  4274. var byts = io.ConvertZipStream(Zips);
  4275. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4276. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4277. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4278. }
  4279. else
  4280. {
  4281. jw.Msg = "暂无生成文件!";
  4282. }
  4283. return Ok(jw);
  4284. }
  4285. /// <summary>
  4286. /// 下载该团组下此模块的所有文件
  4287. /// </summary>
  4288. /// <param name="dto"></param>
  4289. /// <returns></returns>
  4290. [HttpPost]
  4291. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4292. {
  4293. var jw = JsonView(false);
  4294. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4295. if (groupInfo == null)
  4296. {
  4297. jw.Msg = "团组信息不存在!";
  4298. return Ok(jw);
  4299. }
  4300. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4301. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4302. && x.IsDel == 0);
  4303. if (key == null)
  4304. {
  4305. jw.Msg = "Ctable指向错误!";
  4306. return Ok(jw);
  4307. }
  4308. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4309. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4310. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4311. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4312. IOOperatorHelper io = new IOOperatorHelper();
  4313. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4314. foreach (var item in dbQuery)
  4315. {
  4316. if (System.IO.File.Exists(item.FilePath))
  4317. {
  4318. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4319. {
  4320. byte[] bytes = new byte[fileStream.Length];
  4321. fileStream.Read(bytes, 0, bytes.Length);
  4322. fileStream.Close();
  4323. Stream stream = new MemoryStream(bytes);
  4324. while (Zips.Keys.Contains(item.FileName))
  4325. {
  4326. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4327. }
  4328. Zips.Add(item.FileName, stream);
  4329. }
  4330. }
  4331. }
  4332. if (Zips.Count > 0)
  4333. {
  4334. var byts = io.ConvertZipStream(Zips);
  4335. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4336. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4337. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4338. }
  4339. else
  4340. {
  4341. jw.Msg = "暂无生成文件!";
  4342. }
  4343. return Ok(jw);
  4344. }
  4345. /// <summary>
  4346. /// 删除该团组下的指定文件
  4347. /// </summary>
  4348. /// <param name="dto"></param>
  4349. /// <returns></returns>
  4350. [HttpPost]
  4351. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4352. {
  4353. var jw = JsonView(false);
  4354. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4355. if (sing == null)
  4356. {
  4357. jw.Msg = "暂无";
  4358. return Ok(jw);
  4359. }
  4360. if (System.IO.File.Exists(sing.FilePath))
  4361. {
  4362. try
  4363. {
  4364. System.IO.File.Delete(sing.FilePath);
  4365. }
  4366. catch (Exception ex)
  4367. {
  4368. jw.Msg = "删除失败!" + ex.Message;
  4369. return Ok(jw);
  4370. }
  4371. }
  4372. sing.IsDel = 1;
  4373. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4374. sing.DeleteUserId = dto.UserId;
  4375. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4376. jw = JsonView(true, "删除成功!");
  4377. return Ok(jw);
  4378. }
  4379. #endregion
  4380. #region 团组英文资料
  4381. /// <summary>
  4382. /// 查询团组英文所有资料
  4383. /// </summary>
  4384. /// <param name="dto"></param>
  4385. /// <returns></returns>
  4386. [HttpPost]
  4387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4388. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4389. {
  4390. try
  4391. {
  4392. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4393. if (groupData.Code != 0)
  4394. {
  4395. return Ok(JsonView(false, groupData.Msg));
  4396. }
  4397. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4398. }
  4399. catch (Exception ex)
  4400. {
  4401. return Ok(JsonView(false, "程序错误!"));
  4402. throw;
  4403. }
  4404. }
  4405. /// <summary>
  4406. /// 团组英文资料操作(Status:1.新增,2.修改)
  4407. /// </summary>
  4408. /// <param name="dto"></param>
  4409. /// <returns></returns>
  4410. [HttpPost]
  4411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4412. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4413. {
  4414. try
  4415. {
  4416. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4417. if (groupData.Code != 0)
  4418. {
  4419. return Ok(JsonView(false, groupData.Msg));
  4420. }
  4421. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4422. }
  4423. catch (Exception ex)
  4424. {
  4425. return Ok(JsonView(false, "程序错误!"));
  4426. throw;
  4427. }
  4428. }
  4429. /// <summary>
  4430. /// 团组英文资料Id查询数据
  4431. /// </summary>
  4432. /// <param name="dto"></param>
  4433. /// <returns></returns>
  4434. [HttpPost]
  4435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4436. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4437. {
  4438. try
  4439. {
  4440. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4441. if (_DelegationEnData != null)
  4442. {
  4443. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4444. }
  4445. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4446. }
  4447. catch (Exception ex)
  4448. {
  4449. return Ok(JsonView(false, "程序错误!"));
  4450. throw;
  4451. }
  4452. }
  4453. /// <summary>
  4454. /// 团组英文资料删除
  4455. /// </summary>
  4456. /// <param name="dto"></param>
  4457. /// <returns></returns>
  4458. [HttpPost]
  4459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4460. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4461. {
  4462. try
  4463. {
  4464. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4465. if (!res)
  4466. {
  4467. return Ok(JsonView(false, "删除失败"));
  4468. }
  4469. return Ok(JsonView(true, "删除成功!"));
  4470. }
  4471. catch (Exception ex)
  4472. {
  4473. return Ok(JsonView(false, "程序错误!"));
  4474. throw;
  4475. }
  4476. }
  4477. #endregion
  4478. #region 导出邀请函
  4479. /// <summary>
  4480. /// 导出邀请函页面初始化
  4481. /// </summary>
  4482. /// <param name="dto"></param>
  4483. /// <returns></returns>
  4484. [HttpPost]
  4485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4486. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4487. {
  4488. try
  4489. {
  4490. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4491. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4492. if (dto.DiId == 0)
  4493. {
  4494. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4495. }
  4496. else
  4497. {
  4498. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4499. }
  4500. return Ok(JsonView(true, "查询成功!", new
  4501. {
  4502. deleClient = crm_Deles,
  4503. delegations = grp_Delegations
  4504. }));
  4505. }
  4506. catch (Exception ex)
  4507. {
  4508. return Ok(JsonView(false, "程序错误!"));
  4509. throw;
  4510. }
  4511. }
  4512. /// <summary>
  4513. /// 导出邀请函
  4514. /// </summary>
  4515. /// <param name="dto"></param>
  4516. /// <returns></returns>
  4517. [HttpPost]
  4518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4519. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4520. {
  4521. #region 参数验证
  4522. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4523. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4524. #endregion
  4525. try
  4526. {
  4527. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4528. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4529. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4530. From Grp_TourClientList tcl
  4531. Left Join
  4532. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4533. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4534. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4535. From Crm_DeleClient dc
  4536. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4537. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4538. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4539. Where dc.IsDel = 0) temp
  4540. On temp.DcId =tcl.ClientId
  4541. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4542. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4543. List<string> texts = new List<string>();
  4544. if (datas.Count != 0)
  4545. {
  4546. foreach (TourClientListDetailsView item in datas)
  4547. {
  4548. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4549. {
  4550. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4551. }
  4552. else
  4553. {
  4554. string name = item.LastName + item.FirstName;
  4555. texts.Add(name);
  4556. }
  4557. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4558. {
  4559. if (!transDic.ContainsKey(item.Job))
  4560. {
  4561. texts.Add(item.Job);
  4562. }
  4563. }
  4564. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4565. {
  4566. texts.Add(item.CompanyFullName);
  4567. }
  4568. }
  4569. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4570. if (transData.Count > 0)
  4571. {
  4572. foreach (TranslateResult item in transData)
  4573. {
  4574. if (!transDic.ContainsKey(item.Query))
  4575. {
  4576. transDic.Add(item.Query, item.Translation);
  4577. }
  4578. }
  4579. }
  4580. List<GuestList> list = new List<GuestList>();
  4581. foreach (TourClientListDetailsView dele in datas)
  4582. {
  4583. GuestList guestList = new GuestList();
  4584. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4585. {
  4586. guestList.Name = dele.Pinyin;
  4587. }
  4588. else
  4589. {
  4590. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4591. guestList.Name = Name;
  4592. }
  4593. if (dele.Sex == 0)
  4594. {
  4595. guestList.Sex = "Male";
  4596. }
  4597. else if (dele.Sex == 1)
  4598. {
  4599. guestList.Sex = "Female";
  4600. }
  4601. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4602. if (!string.IsNullOrEmpty(dele.Job))
  4603. {
  4604. guestList.Job = dele.Job;
  4605. }
  4606. list.Add(guestList);
  4607. }
  4608. //载入模板
  4609. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4610. DocumentBuilder builder = new DocumentBuilder(doc);
  4611. //获取word里所有表格
  4612. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4613. //获取所填表格的序数
  4614. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4615. var rowStart = tableOne.Rows[0]; //获取第1行
  4616. //循环赋值
  4617. for (int i = 0; i < list.Count; i++)
  4618. {
  4619. builder.MoveToCell(0, i + 1, 0, 0);
  4620. builder.Write(list[i].Name.ToString());
  4621. builder.MoveToCell(0, i + 1, 1, 0);
  4622. builder.Write(list[i].Sex.ToString());
  4623. builder.MoveToCell(0, i + 1, 2, 0);
  4624. builder.Write(list[i].DOB.ToString());
  4625. builder.MoveToCell(0, i + 1, 3, 0);
  4626. builder.Write(list[i].Job.ToString());
  4627. }
  4628. //删除多余行
  4629. while (tableOne.Rows.Count > list.Count + 1)
  4630. {
  4631. tableOne.Rows.RemoveAt(list.Count + 1);
  4632. }
  4633. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4634. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4635. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4636. doc.Save(filePath);
  4637. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4638. return Ok(JsonView(true, "操作成功!", Url));
  4639. }
  4640. else
  4641. {
  4642. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4643. }
  4644. }
  4645. catch (Exception ex)
  4646. {
  4647. return Ok(JsonView(false, ex.Message));
  4648. throw;
  4649. }
  4650. }
  4651. #endregion
  4652. #region 团组经理模块 出入境费用
  4653. /// <summary>
  4654. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4655. /// </summary>
  4656. /// <returns></returns>
  4657. [HttpPost]
  4658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4659. public async Task<IActionResult> SetDayAndCostAreaChange()
  4660. {
  4661. try
  4662. {
  4663. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4664. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4665. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4666. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4667. foreach (var item in unite) //处理交集数据
  4668. {
  4669. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4670. }
  4671. foreach (var item in merge) //处理差集数据
  4672. {
  4673. int nationalTravelFeeId = 0;
  4674. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4675. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4676. else
  4677. {
  4678. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4679. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4680. }
  4681. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4682. }
  4683. //只更新dayAndCost 的 nationalTravelFeeId;
  4684. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4685. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4686. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4687. }
  4688. catch (Exception ex)
  4689. {
  4690. return Ok(JsonView(false, ex.Message));
  4691. throw;
  4692. }
  4693. }
  4694. /// <summary>
  4695. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4696. /// </summary>
  4697. /// <returns></returns>
  4698. [HttpPost]
  4699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4700. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4701. {
  4702. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4703. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4704. //SetDataInfoView
  4705. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4706. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4707. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4708. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4709. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4710. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4711. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4712. //默认币种显示
  4713. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4714. {
  4715. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4716. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4717. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4718. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4719. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4720. };
  4721. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4722. if (_currencyRate.Count > 0)
  4723. {
  4724. foreach (var item in _currencyInfos)
  4725. {
  4726. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4727. if (rateInfo != null)
  4728. {
  4729. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4730. rate1 *= 1.035M;
  4731. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4732. }
  4733. }
  4734. }
  4735. var gj_jobPostIds = new List<int>() { 22, 32 };
  4736. var viewPermissionData = await _sqlSugar.Queryable<Sys_Users>()
  4737. .Where(x => x.IsDel == 0 && ((x.DepId == 7 && gj_jobPostIds.Contains(x.JobPostId)) || x.DepId == 6))
  4738. .Select(x => new { x.Id, Name = x.CnName })
  4739. .ToListAsync();
  4740. return Ok(JsonView(true, "查询成功!", new
  4741. {
  4742. GroupNameData = groupNameData.Data,
  4743. CurrencyData = _CurrencyData,
  4744. WordTypeData = _WordTypeData,
  4745. ExcelTypeData = _ExcelTypeData,
  4746. CurrencyInit = _currencyInfos,
  4747. ViewPermissionData = viewPermissionData
  4748. }));
  4749. }
  4750. /// <summary>
  4751. /// 团组模块 - 出入境费用
  4752. /// 实时汇率 tips
  4753. /// 签证费用 tips
  4754. /// 机票费用 tips
  4755. /// </summary>
  4756. /// <returns></returns>
  4757. [HttpPost]
  4758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4759. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4760. {
  4761. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4762. //默认币种显示
  4763. var _currencyInfos = _currencyInit;
  4764. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4765. List<dynamic> reteInfos = new List<dynamic>();
  4766. if (_currencyRate.Count > 0)
  4767. {
  4768. foreach (var item in _currencyInfos)
  4769. {
  4770. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4771. if (rateInfo != null)
  4772. {
  4773. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4774. decimal rate1 = item.Rate;
  4775. rate1 *= 1.03M;
  4776. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4777. reteInfos.Add(new
  4778. {
  4779. currCode = item.CurrencyCode,
  4780. currName = item.CurrencyName,
  4781. rate = rate2,
  4782. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4783. });
  4784. }
  4785. }
  4786. }
  4787. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4788. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4789. return Ok(JsonView(true, "查询成功!", new
  4790. {
  4791. //GroupNameData = groupNameData.Data,
  4792. visaData = visaData.Data,
  4793. airData = airData.Data,
  4794. reteInfos = reteInfos
  4795. }));
  4796. }
  4797. /// <summary>
  4798. /// 团组模块 - 出入境费用 - Info
  4799. /// </summary>
  4800. /// <returns></returns>
  4801. [HttpPost]
  4802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4803. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4804. {
  4805. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4806. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4807. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4808. }
  4809. /// <summary>
  4810. /// 团组模块 - 出入境费用 - 设置view权限
  4811. /// </summary>
  4812. /// <returns></returns>
  4813. [HttpPost]
  4814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4815. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4816. {
  4817. if (dto.CurrUserId < 1) return Ok(JsonView(false,MsgTips.UserId));
  4818. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4819. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4820. var permissions = new List<Grp_EnterExitCostPermission>();
  4821. foreach (var userId in dto.UserIds)
  4822. {
  4823. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = dto.CurrUserId, CreateUserId = userId });
  4824. }
  4825. if (permissions.Any())
  4826. {
  4827. _sqlSugar.BeginTran();
  4828. try
  4829. {
  4830. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4831. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4832. if (result < 1)
  4833. {
  4834. _sqlSugar.RollbackTran();
  4835. return Ok(JsonView(false));
  4836. }
  4837. }
  4838. catch (Exception ex)
  4839. {
  4840. _sqlSugar.RollbackTran();
  4841. return Ok(JsonView(false, ex.Message));
  4842. }
  4843. _sqlSugar.CommitTran();
  4844. return Ok(JsonView(true));
  4845. }
  4846. return Ok(JsonView(false));
  4847. }
  4848. /// <summary>
  4849. /// 团组模块 - 出入境费用 - Add And Update
  4850. /// </summary>
  4851. /// <returns></returns>
  4852. [HttpPost]
  4853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4854. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4855. {
  4856. try
  4857. {
  4858. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4859. if (dto.DayOtherPriceData.Any())
  4860. {
  4861. var inserList = dto.DayOtherPriceData
  4862. .Where(x => x.Id == 0)
  4863. .Select(x => new Grp_DayOtherPrice
  4864. {
  4865. Cost = x.Cost,
  4866. Id = x.Id,
  4867. CreateTime = DateTime.Now,
  4868. CreateUserId = dto.UserId,
  4869. Currency = x.Currency,
  4870. Diid = x.DiId,
  4871. Index = x.Index,
  4872. IsDel = 0,
  4873. SetDataId = x.SetDataId,
  4874. SubTotal = x.SubTotal,
  4875. Remark = x.Remark
  4876. })
  4877. .ToList();
  4878. var updateList = dto.DayOtherPriceData
  4879. .Where(x => x.Id != 0)
  4880. .Select(x => new Grp_DayOtherPrice
  4881. {
  4882. Cost = x.Cost,
  4883. Id = x.Id,
  4884. CreateTime = DateTime.Now,
  4885. CreateUserId = dto.UserId,
  4886. Currency = x.Currency,
  4887. Diid = x.DiId,
  4888. Index = x.Index,
  4889. IsDel = 0,
  4890. SetDataId = x.SetDataId,
  4891. SubTotal = x.SubTotal,
  4892. Remark = x.Remark
  4893. })
  4894. .ToList();
  4895. //添加
  4896. _sqlSugar.BeginTran();
  4897. if (inserList.Any())
  4898. {
  4899. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4900. }
  4901. if (updateList.Any())
  4902. {
  4903. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4904. }
  4905. _sqlSugar.CommitTran();
  4906. }
  4907. if (data.Code != 0)
  4908. {
  4909. return Ok(JsonView(false, data.Msg));
  4910. }
  4911. //生成默认文件pdf并且通知人员
  4912. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4913. {
  4914. DiId = dto.DiId,
  4915. ExportType = 1,
  4916. SubTypeId = 1005
  4917. }, "pdf");
  4918. //发送通知
  4919. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4920. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4921. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4922. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4923. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4924. //汇率信息记录
  4925. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4926. return Ok(JsonView(true, data.Msg, data.Data));
  4927. }
  4928. catch (Exception ex)
  4929. {
  4930. return Ok(JsonView(false, ex.Message));
  4931. }
  4932. }
  4933. /// <summary>
  4934. /// 团组模块 - 出入境费用 - Confirm 费用
  4935. /// </summary>
  4936. /// <returns></returns>
  4937. [HttpPost]
  4938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4939. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4940. {
  4941. //TODO:测试完毕需把对应的用户ID更改
  4942. //1、数据表添加字段
  4943. //2、更改字段接口()
  4944. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4945. //3、确认成功 给财务发送消息
  4946. if (_view.Code == 200)
  4947. {
  4948. if (dto.Type == 1)
  4949. {
  4950. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4951. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4952. }
  4953. }
  4954. return Ok(_view);
  4955. }
  4956. /// <summary>
  4957. /// 团组模块 - 出入境费用 - File downlaod
  4958. /// </summary>
  4959. /// <param name="dto"></param>
  4960. /// <returns></returns>
  4961. [HttpPost]
  4962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4963. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4964. {
  4965. try
  4966. {
  4967. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4968. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4969. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4970. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4971. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4972. 3 团组成员名单 1 团组成员名单", ""));
  4973. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4974. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4975. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4976. //数据源
  4977. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4978. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4979. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4980. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4981. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4982. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4983. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4984. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4985. .Select((x, a, b) => new
  4986. {
  4987. x.Index,
  4988. itemName = a.Name,
  4989. CurrencyStr = b.Name,
  4990. x.Cost,
  4991. x.SubTotal,
  4992. x.Remark
  4993. })
  4994. .OrderBy((x) => x.Index)
  4995. .ToList(); //其他款项费用
  4996. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4997. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4998. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4999. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5000. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5001. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5002. .Select((tcl, dc, cc) => new ClientInfo
  5003. {
  5004. LastName = dc.LastName,
  5005. FirstName = dc.FirstName,
  5006. Sex = dc.Sex,
  5007. Birthday = dc.BirthDay,
  5008. Company = cc.CompanyFullName,
  5009. Job = dc.Job
  5010. })
  5011. .ToList();
  5012. foreach (var item in DeleClientList)
  5013. {
  5014. EncryptionProcessor.DecryptProperties(item);
  5015. }
  5016. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5017. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5018. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5019. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5020. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5021. if (dto.ExportType == 1) //明细表
  5022. {
  5023. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5024. {
  5025. //获取模板
  5026. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5027. //载入模板
  5028. Document doc = new Document(tempPath);
  5029. DocumentBuilder builder = new DocumentBuilder(doc);
  5030. //利用键值对存放数据
  5031. Dictionary<string, string> dic = new Dictionary<string, string>();
  5032. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5033. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5034. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5035. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5036. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5037. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5038. //境内费用(其他费用)
  5039. if (_EnterExitCosts.ChoiceOne == 1)
  5040. {
  5041. string row1_1 = "";
  5042. if (_EnterExitCosts.Visa > 0)
  5043. {
  5044. //insidePayTotal += _EnterExitCosts.Visa;
  5045. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5046. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5047. {
  5048. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5049. }
  5050. }
  5051. string row1_2 = "";
  5052. if (_EnterExitCosts.YiMiao > 0)
  5053. {
  5054. //insidePayTotal += _EnterExitCosts.YiMiao;
  5055. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5056. }
  5057. if (_EnterExitCosts.HeSuan > 0)
  5058. {
  5059. //insidePayTotal += _EnterExitCosts.HeSuan;
  5060. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5061. }
  5062. if (_EnterExitCosts.Service > 0)
  5063. {
  5064. //insidePayTotal += _EnterExitCosts.Service;
  5065. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5066. }
  5067. string row1_3 = "";
  5068. if (_EnterExitCosts.Safe > 0)
  5069. {
  5070. //insidePayTotal += _EnterExitCosts.Safe;
  5071. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5072. }
  5073. if (_EnterExitCosts.Ticket > 0)
  5074. {
  5075. //insidePayTotal += _EnterExitCosts.Ticket;
  5076. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5077. }
  5078. string row1 = "";
  5079. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5080. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5081. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5082. row1 += $"备注:{_EnterExitCosts.Remark}";
  5083. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5084. dic.Add("Row1Str", row1);
  5085. }
  5086. string airTotalStr = string.Empty,
  5087. airPriceStr = string.Empty;
  5088. //经济舱
  5089. if (_EnterExitCosts.SumJJC == 1)
  5090. {
  5091. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5092. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5093. }
  5094. //公务舱
  5095. if (_EnterExitCosts.SumGWC == 1)
  5096. {
  5097. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5098. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5099. }
  5100. //头等舱
  5101. if (_EnterExitCosts.SumTDC == 1)
  5102. {
  5103. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5104. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5105. }
  5106. string twoItemRemark = "备注:";
  5107. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  5108. {
  5109. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  5110. }
  5111. dic.Add("AirTotalStr", airTotalStr);
  5112. dic.Add("AirPriceStr", airPriceStr);
  5113. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5114. dic.Add("TwoItemRemark", twoItemRemark);
  5115. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5116. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5117. int table1Row = 0,
  5118. table2Row = 0,
  5119. table3Row = 0,
  5120. table4Row = 0,
  5121. table5Row = 0;
  5122. //住宿费
  5123. if (_EnterExitCosts.ChoiceThree == 1)
  5124. {
  5125. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5126. table1Row = dac1.Count;
  5127. #region 填充word表格内容
  5128. for (int i = 0; i < dac1.Count; i++)
  5129. {
  5130. Grp_DayAndCost dac = dac1[i];
  5131. if (dac == null) continue;
  5132. builder.MoveToCell(0, i, 0, 0);
  5133. builder.Write("第" + dac.Days.ToString() + "晚:");
  5134. builder.MoveToCell(0, i, 1, 0);
  5135. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5136. //builder.Write(dac.Place == null ? "" : dac.Place);
  5137. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5138. builder.MoveToCell(0, i, 2, 0);
  5139. builder.Write("费用标准:");
  5140. string curr = "";
  5141. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5142. if (currData != null)
  5143. {
  5144. curr = currData.Name;
  5145. }
  5146. builder.MoveToCell(0, i, 3, 0);
  5147. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5148. builder.MoveToCell(0, i, 4, 0);
  5149. builder.Write("费用小计:");
  5150. builder.MoveToCell(0, i, 5, 0);
  5151. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5152. }
  5153. #endregion
  5154. }
  5155. else dic.Add("SubZS", "0.00");
  5156. //删除多余行
  5157. while (table1.Rows.Count > table1Row)
  5158. {
  5159. table1.Rows.RemoveAt(table1Row);
  5160. }
  5161. //伙食费
  5162. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5163. if (_EnterExitCosts.ChoiceFour == 1)
  5164. {
  5165. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5166. table2Row = dac2.Count;
  5167. #region 填充word表格内容
  5168. for (int i = 0; i < dac2.Count; i++)
  5169. {
  5170. Grp_DayAndCost dac = dac2[i];
  5171. if (dac == null) continue;
  5172. builder.MoveToCell(1, i, 0, 0);
  5173. builder.Write("第" + dac.Days.ToString() + "天:");
  5174. builder.MoveToCell(1, i, 1, 0);
  5175. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5176. builder.MoveToCell(1, i, 2, 0);
  5177. builder.Write("费用标准:");
  5178. string curr = "";
  5179. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5180. if (currData != null)
  5181. {
  5182. curr = currData.Name;
  5183. }
  5184. builder.MoveToCell(1, i, 3, 0);
  5185. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5186. builder.MoveToCell(1, i, 4, 0);
  5187. builder.Write("费用小计:");
  5188. builder.MoveToCell(1, i, 5, 0);
  5189. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5190. }
  5191. #endregion
  5192. }
  5193. else dic.Add("SubHS", "0.00");
  5194. //删除多余行
  5195. while (table2.Rows.Count > table2Row)
  5196. {
  5197. table2.Rows.RemoveAt(table2Row);
  5198. }
  5199. //公杂费
  5200. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5201. if (_EnterExitCosts.ChoiceFive == 1)
  5202. {
  5203. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5204. table3Row = dac3.Count;
  5205. #region 填充word表格内容
  5206. for (int i = 0; i < dac3.Count; i++)
  5207. {
  5208. Grp_DayAndCost dac = dac3[i];
  5209. if (dac == null) continue;
  5210. builder.MoveToCell(2, i, 0, 0);
  5211. builder.Write("第" + dac.Days.ToString() + "天:");
  5212. builder.MoveToCell(2, i, 1, 0);
  5213. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5214. builder.MoveToCell(2, i, 2, 0);
  5215. builder.Write("费用标准:");
  5216. string curr = "";
  5217. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5218. if (currData != null)
  5219. {
  5220. curr = currData.Name;
  5221. }
  5222. builder.MoveToCell(2, i, 3, 0);
  5223. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5224. builder.MoveToCell(2, i, 4, 0);
  5225. builder.Write("费用小计:");
  5226. builder.MoveToCell(2, i, 5, 0);
  5227. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5228. }
  5229. //删除多余行
  5230. while (table3.Rows.Count > table3Row)
  5231. {
  5232. table3.Rows.RemoveAt(table3Row);
  5233. }
  5234. #endregion
  5235. }
  5236. else dic.Add("SubGZF", "0.00");
  5237. //删除多余行
  5238. while (table3.Rows.Count > table3Row)
  5239. {
  5240. table3.Rows.RemoveAt(table3Row);
  5241. }
  5242. //培训费
  5243. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5244. if (_EnterExitCosts.ChoiceSix == 1)
  5245. {
  5246. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5247. dic.Add("SubPX", pxStr);
  5248. table4Row = dac4.Count;
  5249. #region 填充word表格内容
  5250. for (int i = 0; i < dac4.Count; i++)
  5251. {
  5252. Grp_DayAndCost dac = dac4[i];
  5253. if (dac == null) continue;
  5254. builder.MoveToCell(3, i, 0, 0);
  5255. builder.Write("第" + dac.Days.ToString() + "天:");
  5256. builder.MoveToCell(3, i, 1, 0);
  5257. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5258. builder.MoveToCell(3, i, 2, 0);
  5259. builder.Write("费用标准:");
  5260. string curr = "";
  5261. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5262. if (currData != null)
  5263. {
  5264. curr = currData.Name;
  5265. }
  5266. builder.MoveToCell(3, i, 3, 0);
  5267. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5268. builder.MoveToCell(3, i, 4, 0);
  5269. builder.Write("费用小计:");
  5270. builder.MoveToCell(3, i, 5, 0);
  5271. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5272. }
  5273. #endregion
  5274. }
  5275. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5276. //删除多余行
  5277. while (table4.Rows.Count > table4Row)
  5278. {
  5279. table4.Rows.RemoveAt(table4Row);
  5280. }
  5281. //其他费用
  5282. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5283. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5284. {
  5285. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5286. dic.Add("titleQi", qtStr);
  5287. table5Row = dac5.Count;
  5288. #region 填充word表格内容
  5289. for (int i = 0; i < dac5.Count; i++)
  5290. {
  5291. var dac = dac5[i];
  5292. if (dac == null) continue;
  5293. builder.MoveToCell(4, i, 0, 0);
  5294. builder.Write("第" + dac.Index.ToString() + "项:");
  5295. builder.MoveToCell(4, i, 1, 0);
  5296. builder.Write(dac.itemName);
  5297. builder.MoveToCell(4, i, 2, 0);
  5298. builder.Write("费用标准:");
  5299. builder.MoveToCell(4, i, 3, 0);
  5300. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5301. builder.MoveToCell(4, i, 4, 0);
  5302. builder.Write("费用小计:");
  5303. builder.MoveToCell(4, i, 5, 0);
  5304. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5305. builder.MoveToCell(4, i, 6, 0);
  5306. builder.Write("备注:");
  5307. builder.MoveToCell(4, i, 7, 0);
  5308. builder.Write(dac.Remark);
  5309. }
  5310. #endregion
  5311. }
  5312. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5313. //删除多余行
  5314. while (table5.Rows.Count > table5Row)
  5315. {
  5316. table5.Rows.RemoveAt(table5Row);
  5317. }
  5318. //加上其他费用
  5319. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5320. decimal subJJC = 0.00M,
  5321. subGWC = 0.00M,
  5322. subTDC = 0.00M;
  5323. //经济舱
  5324. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5325. //公务舱
  5326. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5327. //头等舱
  5328. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5329. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5330. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5331. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5332. #region 填充word模板书签内容
  5333. foreach (var key in dic.Keys)
  5334. {
  5335. Bookmark bookmark = doc.Range.Bookmarks[key];
  5336. if (bookmark != null)
  5337. {
  5338. builder.MoveToBookmark(key);
  5339. builder.Write(dic[key]);
  5340. }
  5341. }
  5342. #endregion
  5343. //文件名
  5344. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5345. AsposeHelper.removewatermark_v2180();
  5346. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5347. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5348. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5349. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5350. }
  5351. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5352. {
  5353. //获取模板
  5354. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5355. //载入模板
  5356. Document doc = new Document(tempPath);
  5357. DocumentBuilder builder = new DocumentBuilder(doc);
  5358. Dictionary<string, string> dic = new Dictionary<string, string>();
  5359. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5360. {
  5361. List<string> list = new List<string>();
  5362. try
  5363. {
  5364. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5365. foreach (var item in spilitArr)
  5366. {
  5367. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5368. var depCode = spDotandEmpty[2].Substring(0, 3);
  5369. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5370. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5371. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5372. list.Add(depName);
  5373. list.Add(arrName);
  5374. }
  5375. list = list.Distinct().ToList();
  5376. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5377. }
  5378. catch (Exception)
  5379. {
  5380. dic.Add("ReturnCode", "行程录入不正确!");
  5381. }
  5382. }
  5383. else
  5384. {
  5385. dic.Add("ReturnCode", "未录入行程!");
  5386. }
  5387. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5388. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5389. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5390. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5391. {
  5392. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5393. dic.Add("Day", sp.Days.ToString());
  5394. }
  5395. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5396. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5397. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5398. //dic.Add("Names", Names);
  5399. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5400. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5401. decimal dac1totalPrice = 0.00M;
  5402. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5403. foreach (var dac in dac1)
  5404. {
  5405. if (dac.SubTotal == 0.00M)
  5406. {
  5407. continue;
  5408. }
  5409. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5410. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5411. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5412. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5413. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5414. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5415. builder.Write(currency);//币种
  5416. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5417. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5418. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5419. builder.Write("");//人数
  5420. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5421. builder.Write("");//天数
  5422. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5423. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5424. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5425. decimal rate = 0.00M;
  5426. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5427. builder.Write(rate.ToString("#0.0000"));//汇率
  5428. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5429. decimal rbmPrice = dac.SubTotal;
  5430. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5431. accommodationStartIndex++;
  5432. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5433. }
  5434. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5435. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5436. {
  5437. table1.Rows.RemoveAt(i - 1);
  5438. foodandotherStartIndex--;
  5439. }
  5440. if (dac2.Count == dac3.Count)//国家 币种 金额
  5441. {
  5442. for (int i = 0; i < dac2.Count; i++)
  5443. {
  5444. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5445. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5446. }
  5447. }
  5448. decimal dac2totalPrice = 0.00M;
  5449. foreach (var dac in dac2)
  5450. {
  5451. if (dac.SubTotal == 0)
  5452. {
  5453. continue;
  5454. }
  5455. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5456. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5457. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5458. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5459. builder.Write(currency);//币种
  5460. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5461. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5462. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5463. builder.Write("");//人数
  5464. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5465. builder.Write("");//天数
  5466. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5467. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5468. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5469. decimal rate = 0.00M;
  5470. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5471. builder.Write(rate.ToString("#0.0000"));//汇率
  5472. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5473. decimal rbmPrice = dac.SubTotal;
  5474. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5475. foodandotherStartIndex++;
  5476. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5477. }
  5478. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5479. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5480. {
  5481. table1.Rows.RemoveAt(i - 1);
  5482. }
  5483. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5484. string otherFeeStr = "";
  5485. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5486. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5487. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5488. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5489. foreach (var otherInfo in dac5)
  5490. {
  5491. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5492. }
  5493. #endregion
  5494. if (otherFeeStr.Length > 0)
  5495. {
  5496. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5497. otherFeeStr = $"({otherFeeStr})";
  5498. dic.Add("OtherFeeStr", otherFeeStr);
  5499. }
  5500. //总计
  5501. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5502. //国际旅费
  5503. string outsideAir = string.Empty;
  5504. string allPriceAir = string.Empty;
  5505. if (_EnterExitCosts.SumJJC == 1)
  5506. {
  5507. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5508. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5509. }
  5510. if (_EnterExitCosts.SumGWC == 1)
  5511. {
  5512. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5513. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5514. }
  5515. if (_EnterExitCosts.SumTDC == 1)
  5516. {
  5517. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5518. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5519. }
  5520. dic.Add("InTravelPrice", $"({outsideAir})");
  5521. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5522. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5523. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5524. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5525. foreach (var key in dic.Keys)
  5526. {
  5527. builder.MoveToBookmark(key);
  5528. builder.Write(dic[key]);
  5529. }
  5530. //模板文件名
  5531. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5532. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5533. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5534. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5535. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5536. }
  5537. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5538. {
  5539. //获取模板
  5540. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5541. //载入模板
  5542. WorkbookDesigner designer = new WorkbookDesigner();
  5543. designer.Workbook = new Workbook(tempPath);
  5544. Dictionary<string, string> dic = new Dictionary<string, string>();
  5545. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5546. {
  5547. List<string> list = new List<string>();
  5548. try
  5549. {
  5550. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5551. foreach (var item in spilitArr)
  5552. {
  5553. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5554. var depCode = spDotandEmpty[2].Substring(0, 3);
  5555. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5556. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5557. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5558. list.Add(depName);
  5559. list.Add(arrName);
  5560. }
  5561. list = list.Distinct().ToList();
  5562. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5563. }
  5564. catch (Exception)
  5565. {
  5566. dic.Add("ReturnCode", "行程录入不正确!");
  5567. }
  5568. }
  5569. else
  5570. {
  5571. dic.Add("ReturnCode", "未录入行程!");
  5572. }
  5573. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5574. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5575. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5576. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5577. {
  5578. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5579. dic.Add("Day", sp.Days.ToString());
  5580. }
  5581. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5582. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5583. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5584. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5585. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5586. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5587. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5588. designer.SetDataSource("Name", Names);
  5589. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5590. designer.SetDataSource("Day", dic["Day"] + "天");
  5591. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5592. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5593. int startIndex = 10;
  5594. const int startIndexcopy = 10;
  5595. if (dac2.Count == dac3.Count)//国家 币种 金额
  5596. {
  5597. for (int i = 0; i < dac2.Count; i++)
  5598. {
  5599. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5600. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5601. }
  5602. }
  5603. DataTable dtdac1 = new DataTable();
  5604. List<string> place = new List<string>();
  5605. dtdac1.Columns.AddRange(new DataColumn[] {
  5606. new DataColumn(){ ColumnName = "city"},
  5607. new DataColumn(){ ColumnName = "curr"},
  5608. new DataColumn(){ ColumnName = "criterion"},
  5609. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5610. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5611. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5612. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5613. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5614. });
  5615. DataTable dtdac2 = new DataTable();
  5616. dtdac2.Columns.AddRange(new DataColumn[] {
  5617. new DataColumn(){ ColumnName = "city"},
  5618. new DataColumn(){ ColumnName = "curr"},
  5619. new DataColumn(){ ColumnName = "criterion"},
  5620. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5621. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5622. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5623. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5624. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5625. });
  5626. dtdac1.TableName = "tb1";
  5627. dtdac2.TableName = "tb2";
  5628. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5629. foreach (var item in dac1)
  5630. {
  5631. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5632. if (place.Contains(item.Place))
  5633. {
  5634. continue;
  5635. }
  5636. DataRow row = dtdac1.NewRow();
  5637. row["city"] = item.Place;
  5638. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5639. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5640. row["curr"] = currency;
  5641. row["rate"] = rate.ToString("#0.0000");
  5642. row["criterion"] = item.Cost.ToString("#0.00");
  5643. row["number"] = 1;
  5644. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5645. //row["costRMB"] = rbmPrice;
  5646. dtdac1.Rows.Add(row);
  5647. place.Add(item.Place);
  5648. }
  5649. place = new List<string>();
  5650. foreach (var item in dac2)
  5651. {
  5652. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5653. if (place.Contains(item.Place))
  5654. {
  5655. continue;
  5656. }
  5657. DataRow row = dtdac2.NewRow();
  5658. row["city"] = item.Place;
  5659. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5660. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5661. row["curr"] = currency;
  5662. row["rate"] = rate.ToString("#0.0000");
  5663. row["criterion"] = item.Cost.ToString("#0.00");
  5664. row["number"] = 1;
  5665. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5666. //row["cost"] = item.SubTotal;
  5667. //row["costRMB"] = rbmPrice;
  5668. dtdac2.Rows.Add(row);
  5669. place.Add(item.Place);
  5670. //dac2totalPrice += rbmPrice;
  5671. }
  5672. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5673. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5674. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5675. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5676. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5677. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5678. string cell4Str1 = string.Empty;
  5679. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5680. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5681. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5682. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5683. string cellStr = $" 5.其他费用(";
  5684. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5685. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5686. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5687. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5688. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5689. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5690. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5691. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5692. foreach (var otherInfo in dac5)
  5693. {
  5694. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5695. }
  5696. #endregion
  5697. if (cellStr.Length > 8)
  5698. {
  5699. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5700. }
  5701. cellStr += ")";
  5702. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5703. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5704. decimal pxFee = dac4.Sum(it => it.Cost);
  5705. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5706. string celllastStr1 = "";
  5707. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5708. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5709. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5710. celllastStr1 += $",国际旅费 元";
  5711. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5712. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5713. designer.SetDataSource("cell4Str", cell4Str);
  5714. designer.SetDataSource("cellStr", cellStr);
  5715. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5716. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5717. designer.SetDataSource("celllastStr", celllastStr);
  5718. Workbook wb = designer.Workbook;
  5719. var sheet = wb.Worksheets[0];
  5720. //绑定datatable数据集
  5721. designer.SetDataSource(dtdac1);
  5722. designer.SetDataSource(dtdac2);
  5723. designer.Process();
  5724. var rowStart = dtdac1.Rows.Count;
  5725. while (rowStart > 0)
  5726. {
  5727. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5728. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5729. startIndex++;
  5730. rowStart--;
  5731. }
  5732. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5733. startIndex += 1; //总计行
  5734. rowStart = dtdac2.Rows.Count;
  5735. while (rowStart > 0)
  5736. {
  5737. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5738. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5739. startIndex++;
  5740. rowStart--;
  5741. }
  5742. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5743. wb.CalculateFormula(true);
  5744. //模板文件名
  5745. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5746. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5747. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5748. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5749. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5750. }
  5751. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5752. {
  5753. //获取模板
  5754. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5755. //载入模板
  5756. Document doc = new Document(tempPath);
  5757. DocumentBuilder builder = new DocumentBuilder(doc);
  5758. Dictionary<string, string> dic = new Dictionary<string, string>();
  5759. dic.Add("GroupName", _DelegationInfo.TeamName);
  5760. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5761. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5762. string missionLeaderJob = "";//负责人job
  5763. int groupNumber = 0; //团人数
  5764. if (DeleClientList.Count > 0)
  5765. {
  5766. missionLeader = DeleClientList[0]?.Name ?? "";
  5767. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5768. }
  5769. dic.Add("MissionLeader", missionLeader); //团负责人
  5770. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5771. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5772. #region MyRegion
  5773. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5774. //{
  5775. // List<string> list = new List<string>();
  5776. // try
  5777. // {
  5778. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5779. // foreach (var item in spilitArr)
  5780. // {
  5781. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5782. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5783. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5784. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5785. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5786. // list.Add(depName);
  5787. // list.Add(arrName);
  5788. // }
  5789. // list = list.Distinct().ToList();
  5790. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5791. // }
  5792. // catch (Exception)
  5793. // {
  5794. // dic.Add("ReturnCode", "行程录入不正确!");
  5795. // }
  5796. //}
  5797. //else
  5798. //{
  5799. // dic.Add("ReturnCode", "未录入行程!");
  5800. //}
  5801. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5802. dic.Add("ReturnCode", string.Join("、", countrys));
  5803. #endregion
  5804. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5805. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5806. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5807. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5808. //{
  5809. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5810. // dic.Add("Day", sp.Days.ToString());
  5811. //}
  5812. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5813. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5814. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5815. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5816. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5817. //培训人员名单
  5818. int cultivateRowIndex = 7;
  5819. foreach (var item in DeleClientList)
  5820. {
  5821. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5822. builder.Write(item.Name);
  5823. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5824. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5825. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5826. string birthDay = "";
  5827. if (item.Birthday != null)
  5828. {
  5829. DateTime dt = Convert.ToDateTime(item.Birthday);
  5830. birthDay = $"{dt.Year}.{dt.Month}";
  5831. }
  5832. builder.Write(birthDay);
  5833. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5834. builder.Write(item.Company);
  5835. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5836. builder.Write(item.Job);
  5837. cultivateRowIndex++;
  5838. }
  5839. //删除多余行
  5840. //cultivateRowIndex -= 2;
  5841. int delRows = 10 + 7 - cultivateRowIndex;
  5842. if (delRows > 0)
  5843. {
  5844. for (int i = 0; i < delRows; i++)
  5845. {
  5846. table1.Rows.RemoveAt(cultivateRowIndex);
  5847. //cultivateRowIndex++;
  5848. }
  5849. }
  5850. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5851. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5852. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5853. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5854. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5855. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5856. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5857. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5858. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5859. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5860. //其他费用
  5861. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5862. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5863. //其他费用合计
  5864. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5865. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5866. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5867. //公务舱合计
  5868. //国际旅费
  5869. string outsideJJ = "";
  5870. string allPriceJJ = "";
  5871. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5872. {
  5873. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5874. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5875. }
  5876. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5877. {
  5878. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5879. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5880. }
  5881. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5882. {
  5883. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5884. dic.Add("AirFeeTotal", airFeeTotalStr);
  5885. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5886. dic.Add("FeeTotal", feeTotalStr);
  5887. }
  5888. foreach (var key in dic.Keys)
  5889. {
  5890. builder.MoveToBookmark(key);
  5891. builder.Write(dic[key]);
  5892. }
  5893. //模板文件名
  5894. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5895. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5896. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5897. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5898. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5899. }
  5900. }
  5901. else if (dto.ExportType == 2) //表格
  5902. {
  5903. //利用键值对存放数据
  5904. Dictionary<string, string> dic = new Dictionary<string, string>();
  5905. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5906. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5907. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5908. dic.Add("Day", sp.Days.ToString());
  5909. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5910. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5911. {
  5912. //获取模板
  5913. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5914. //载入模板
  5915. Document doc = new Document(tempPath);
  5916. DocumentBuilder builder = new DocumentBuilder(doc);
  5917. dic.Add("TeamName", _DelegationInfo.TeamName);
  5918. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5919. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5920. string missionLeaderName = "",
  5921. missionLeaderJob = "";
  5922. if (DeleClientList.Count > 0)
  5923. {
  5924. missionLeaderName = DeleClientList[0].Name;
  5925. missionLeaderJob = DeleClientList[0].Job;
  5926. }
  5927. dic.Add("MissionLeaderName", missionLeaderName);
  5928. dic.Add("MissionLeaderJob", missionLeaderJob);
  5929. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5930. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5931. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5932. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5933. int rowCount = 10;//总人数行
  5934. int startRowIndex = 7; //起始行
  5935. for (int i = 0; i < DeleClientList.Count; i++)
  5936. {
  5937. builder.MoveToCell(0, startRowIndex, 0, 0);
  5938. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5939. builder.MoveToCell(0, startRowIndex, 1, 0);
  5940. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5941. builder.Write(sex);//性别
  5942. builder.MoveToCell(0, startRowIndex, 2, 0);
  5943. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5944. builder.MoveToCell(0, startRowIndex, 3, 0);
  5945. builder.Write(DeleClientList[i].Company);//工作单位
  5946. builder.MoveToCell(0, startRowIndex, 4, 0);
  5947. builder.Write(DeleClientList[i].Job);//职务及级别
  5948. builder.MoveToCell(0, startRowIndex, 5, 0);
  5949. builder.Write("");//人员属性
  5950. builder.MoveToCell(0, startRowIndex, 6, 0);
  5951. builder.Write("");//上次出国时间
  5952. startRowIndex++;
  5953. }
  5954. int nullRow = rowCount - DeleClientList.Count;//空行
  5955. for (int i = 0; i < nullRow; i++)
  5956. {
  5957. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5958. }
  5959. foreach (var key in dic.Keys)
  5960. {
  5961. builder.MoveToBookmark(key);
  5962. builder.Write(dic[key]);
  5963. }
  5964. //模板文件名
  5965. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5966. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5967. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5968. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5969. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5970. }
  5971. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5972. {
  5973. //获取模板
  5974. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5975. //载入模板
  5976. Document doc = new Document(tempPath);
  5977. DocumentBuilder builder = new DocumentBuilder(doc);
  5978. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5979. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5980. dic.Add("Names", Names);
  5981. int accommodationRows = 12, foodandotherRows = 12;
  5982. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5983. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5984. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5985. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5986. int accommodationStartIndex = 6;
  5987. decimal dac1totalPrice = 0.00M;
  5988. foreach (var dac in dac1)
  5989. {
  5990. if (dac.SubTotal == 0)
  5991. {
  5992. continue;
  5993. }
  5994. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5995. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5996. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5997. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5998. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5999. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6000. builder.Write(currency);//币种
  6001. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6002. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6003. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6004. builder.Write("");//人数
  6005. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6006. builder.Write("");//天数
  6007. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6008. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6009. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6010. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6011. builder.Write(rate.ToString("#0.0000"));//汇率
  6012. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6013. decimal rbmPrice = rate * dac.SubTotal;
  6014. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6015. accommodationStartIndex++;
  6016. dac1totalPrice += rbmPrice;
  6017. }
  6018. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6019. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6020. builder.Write("小计");
  6021. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6022. builder.Write(dac1totalPrice.ToString("#0.00"));
  6023. accommodationStartIndex++;
  6024. int nullRow = accommodationRows - dac1.Count;
  6025. //删除空行
  6026. //if (nullRow > 0)
  6027. //{
  6028. // int rowIndex = accommodationStartIndex;
  6029. // for (int i = 0; i < nullRow; i++)
  6030. // {
  6031. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6032. // row.Remove();
  6033. // rowIndex++;
  6034. // }
  6035. //}
  6036. if (dac2.Count == dac3.Count)//国家 币种 金额
  6037. {
  6038. for (int i = 0; i < dac2.Count; i++)
  6039. {
  6040. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6041. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6042. }
  6043. }
  6044. int foodandotherStartIndex = 19;//
  6045. decimal dac2totalPrice = 0.00M;
  6046. foreach (var dac in dac2)
  6047. {
  6048. if (dac.SubTotal == 0)
  6049. {
  6050. continue;
  6051. }
  6052. //foodandotherStartIndex = 12;
  6053. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6054. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6055. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6056. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6057. builder.Write(currency);//币种
  6058. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6059. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6060. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6061. builder.Write("");//人数
  6062. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6063. builder.Write("");//天数
  6064. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6065. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6066. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6067. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6068. builder.Write(rate.ToString("#0.0000"));//汇率
  6069. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6070. decimal rbmPrice = rate * dac.SubTotal;
  6071. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6072. foodandotherStartIndex++;
  6073. dac2totalPrice += rbmPrice;
  6074. }
  6075. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6076. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6077. //删除空行
  6078. //if (dac2.Count < foodandotherRows)
  6079. //{
  6080. // while (table2.Rows.Count > dac2.Count)
  6081. // {
  6082. // table2.Rows.RemoveAt(dac2.Count);
  6083. // }
  6084. //}
  6085. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6086. string otherFeeStr = "";
  6087. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6088. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6089. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6090. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6091. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6092. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6093. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6094. foreach (var otherInfo in dac5)
  6095. {
  6096. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6097. }
  6098. #endregion
  6099. if (otherFeeStr.Length > 0)
  6100. {
  6101. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6102. otherFeeStr = $"({otherFeeStr})";
  6103. dic.Add("OtherFeeStr", otherFeeStr);
  6104. }
  6105. foreach (var key in dic.Keys)
  6106. {
  6107. builder.MoveToBookmark(key);
  6108. builder.Write(dic[key]);
  6109. }
  6110. //模板文件名
  6111. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6112. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6113. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6114. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6115. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6116. }
  6117. }
  6118. else if (dto.ExportType == 3)
  6119. {
  6120. if (dto.SubTypeId == 1) //团组成员名单
  6121. {
  6122. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6123. //获取模板
  6124. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6125. //载入模板
  6126. Document doc = new Document(tempPath);
  6127. DocumentBuilder builder = new DocumentBuilder(doc);
  6128. //获取word里所有表格
  6129. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6130. //获取所填表格的序数
  6131. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6132. var rowStart = tableOne.Rows[0]; //获取第1行
  6133. //循环赋值
  6134. for (int i = 0; i < DeleClientList.Count; i++)
  6135. {
  6136. builder.MoveToCell(0, i + 1, 0, 0);
  6137. builder.Write(DeleClientList[i].Name);
  6138. builder.MoveToCell(0, i + 1, 1, 0);
  6139. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6140. builder.Write(sex);
  6141. builder.MoveToCell(0, i + 1, 2, 0);
  6142. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6143. builder.MoveToCell(0, i + 1, 3, 0);
  6144. builder.Write(DeleClientList[i].Company);
  6145. builder.MoveToCell(0, i + 1, 4, 0);
  6146. builder.Write(DeleClientList[i].Job);
  6147. }
  6148. //删除多余行
  6149. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6150. {
  6151. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6152. }
  6153. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6154. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6155. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6156. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6157. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6158. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6159. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6160. }
  6161. }
  6162. return Ok(JsonView(400, "操作失败!", ""));
  6163. }
  6164. catch (Exception ex)
  6165. {
  6166. return Ok(JsonView(400, ex.Message, ""));
  6167. }
  6168. }
  6169. /// <summary>
  6170. /// 获取三公费用标准city
  6171. /// </summary>
  6172. /// <param name="placeData"></param>
  6173. /// <param name="nationalTravelFeeId"></param>
  6174. /// <returns></returns>
  6175. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6176. {
  6177. string _city = string.Empty;
  6178. if (placeData.Count < 1) return _city;
  6179. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6180. if (data == null) return _city;
  6181. string country = data.Country;
  6182. string city = data.City;
  6183. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6184. else _city = city;
  6185. return _city;
  6186. }
  6187. /// <summary>
  6188. /// 团组模块 - 出入境费用 - 明细表导出
  6189. /// </summary>
  6190. /// <returns></returns>
  6191. [HttpPost]
  6192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6193. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6194. {
  6195. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6196. if (data.Code != 0)
  6197. {
  6198. return Ok(JsonView(false, data.Msg));
  6199. }
  6200. return Ok(JsonView(true, data.Msg, data.Data));
  6201. }
  6202. /// <summary>
  6203. /// 团组模块 - 出入境费用 - 一键清空
  6204. /// </summary>
  6205. /// <returns></returns>
  6206. [HttpPost]
  6207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6208. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6209. {
  6210. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6211. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6212. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6213. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6214. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6215. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6216. .SetColumns(x => new Grp_DayOtherPrice
  6217. {
  6218. IsDel = 1,
  6219. DeleteUserId = dto.UserId,
  6220. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6221. })
  6222. .ExecuteCommandAsync();
  6223. if (_view.Code == 0)
  6224. {
  6225. return Ok(JsonView(true, "操作成功"));
  6226. }
  6227. return Ok(JsonView(false, "操作失败"));
  6228. }
  6229. /// <summary>
  6230. /// 团组模块 - 出入境费用 - 子项删除
  6231. /// </summary>
  6232. /// <returns></returns>
  6233. [HttpPost]
  6234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6235. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6236. {
  6237. try
  6238. {
  6239. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6240. if (data.Code != 0)
  6241. {
  6242. return Ok(JsonView(false, data.Msg));
  6243. }
  6244. return Ok(JsonView(true, "操作成功!", data.Data));
  6245. }
  6246. catch (Exception ex)
  6247. {
  6248. return Ok(JsonView(false, ex.Message));
  6249. }
  6250. }
  6251. /// <summary>
  6252. /// 删除三公其他费用
  6253. /// </summary>
  6254. /// <param name="dto"></param>
  6255. /// <returns></returns>
  6256. [HttpPost]
  6257. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6258. {
  6259. var jw = JsonView(false,"删除失败!");
  6260. var data = new Grp_DayOtherPrice()
  6261. {
  6262. Id = dto.Id,
  6263. IsDel = 1,
  6264. DeleteUserId = dto.DeleteUserId,
  6265. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6266. };
  6267. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6268. if (del > 0)
  6269. {
  6270. jw.Code = 200;
  6271. jw.Msg = "删除成功!";
  6272. }
  6273. return Ok(jw);
  6274. }
  6275. /// <summary>
  6276. /// 团组模块 - 出入境国家费用标准 List
  6277. /// </summary>
  6278. /// <returns></returns>
  6279. [HttpPost]
  6280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6281. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6282. {
  6283. try
  6284. {
  6285. Stopwatch sw = new Stopwatch();
  6286. sw.Start();
  6287. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6288. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6289. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6290. Where gntf.Isdel = 0");
  6291. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6292. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6293. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6294. //foreach (var item in nationalTravel)
  6295. //{
  6296. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6297. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6298. // if (otherData != null)
  6299. // {
  6300. // cityData.Remove(otherData);
  6301. // cityData.Add(otherData);
  6302. // }
  6303. // nationalTravelFeeData1.Add(new
  6304. // {
  6305. // Country = item.Country,
  6306. // CityData = cityData
  6307. // });
  6308. //}
  6309. sw.Stop();
  6310. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6311. }
  6312. catch (Exception ex)
  6313. {
  6314. return Ok(JsonView(false, ex.Message));
  6315. throw;
  6316. }
  6317. }
  6318. /// <summary>
  6319. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6320. /// </summary>
  6321. /// <returns></returns>
  6322. [HttpPost]
  6323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6324. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6325. {
  6326. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6327. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6328. List<string> countryData = new List<string>();
  6329. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6330. countryData = countryData.Distinct().ToList();
  6331. List<dynamic> dataSource = new List<dynamic>();
  6332. foreach (var item in countryData)
  6333. {
  6334. List<string> cityData1 = new List<string>();
  6335. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6336. var countryData2 = new
  6337. {
  6338. CountryName = item,
  6339. CityData = cityData1
  6340. };
  6341. dataSource.Add(countryData2);
  6342. }
  6343. return Ok(JsonView(true, "查询成功!", dataSource));
  6344. }
  6345. /// <summary>
  6346. /// 团组模块 - 出入境国家费用标准 Page List
  6347. /// </summary>
  6348. /// <returns></returns>
  6349. [HttpPost]
  6350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6351. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6352. {
  6353. int portId = dto.PortType;
  6354. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6355. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6356. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6357. string whereSql = string.Empty;
  6358. if (!string.IsNullOrEmpty(dto.Country))
  6359. {
  6360. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6361. }
  6362. if (!string.IsNullOrEmpty(dto.City))
  6363. {
  6364. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6365. }
  6366. string pageSql = string.Format(@"Select * From (
  6367. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6368. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6369. From Grp_NationalTravelFee gntf
  6370. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6371. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6372. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6373. RefAsync<int> total = 0;
  6374. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6375. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6376. }
  6377. /// <summary>
  6378. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6379. /// </summary>
  6380. /// <returns></returns>
  6381. [HttpPost]
  6382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6383. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6384. {
  6385. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6386. int portId = dto.PortType;
  6387. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6388. string whereSql = string.Empty;
  6389. if (!string.IsNullOrEmpty(dto.Country))
  6390. {
  6391. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6392. }
  6393. if (!string.IsNullOrEmpty(dto.City))
  6394. {
  6395. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6396. }
  6397. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6398. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6399. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6400. From Grp_NationalTravelFee gntf
  6401. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6402. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6403. Where gntf.Isdel = 0 {0} ", whereSql);
  6404. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6405. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6406. }
  6407. /// <summary>
  6408. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6409. /// </summary>
  6410. /// <returns></returns>
  6411. [HttpPost]
  6412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6413. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6414. {
  6415. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6416. if (data.Code != 0)
  6417. {
  6418. return Ok(JsonView(false, data.Msg));
  6419. }
  6420. return Ok(JsonView(true, "操作成功!", data.Data));
  6421. }
  6422. /// <summary>
  6423. /// 团组模块 - 出入境国家费用标准 - Del
  6424. /// </summary>
  6425. /// <returns></returns>
  6426. [HttpPost]
  6427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6428. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6429. {
  6430. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6431. {
  6432. Id = dto.Id,
  6433. DeleteUserId = dto.DeleteUserId,
  6434. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6435. IsDel = 1
  6436. };
  6437. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6438. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6439. .WhereColumns(it => new { it.Id })
  6440. .ExecuteCommandAsync();
  6441. if (delStatus <= 0)
  6442. {
  6443. return Ok(JsonView(false, "删除失败!"));
  6444. }
  6445. return Ok(JsonView(true, "操作成功!"));
  6446. }
  6447. /// <summary>
  6448. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6449. /// 注:Get 请求Headers 加 Token
  6450. /// </summary>
  6451. /// <param name="groupId"></param>
  6452. /// <returns></returns>
  6453. [HttpGet("{groupId}")]
  6454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6455. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6456. {
  6457. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6458. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6459. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6460. data.ForEach(x =>
  6461. {
  6462. x.CreateUserId = _currUserInfo.UserId;
  6463. });
  6464. if (data.Any())
  6465. {
  6466. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6467. if (add > 0)
  6468. {
  6469. return Ok(JsonView(true, "操作成功!"));
  6470. }
  6471. }
  6472. return Ok(JsonView(false, "未操作!"));
  6473. }
  6474. #endregion
  6475. #region 团组经理模块 出入境费用-草稿
  6476. /// <summary>
  6477. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6478. /// </summary>
  6479. /// <returns></returns>
  6480. [HttpPost]
  6481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6482. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6483. {
  6484. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6485. .Where(x => x.IsDel == 0)
  6486. .OrderByDescending(x => x.CreateTime)
  6487. .Select(x => new { x.Id, x.DraftName })
  6488. .ToListAsync();
  6489. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6490. //SetDataInfoView
  6491. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6492. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6493. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6494. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6495. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6496. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6497. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6498. //默认币种显示
  6499. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6500. {
  6501. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6502. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6503. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6504. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6505. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6506. };
  6507. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6508. if (_currencyRate.Count > 0)
  6509. {
  6510. foreach (var item in _currencyInfos)
  6511. {
  6512. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6513. if (rateInfo != null)
  6514. {
  6515. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6516. rate1 *= 1.035M;
  6517. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6518. }
  6519. }
  6520. }
  6521. var gj_jobPostIds = new List<int>() { 22, 32 };
  6522. var viewPermissionData = await _sqlSugar.Queryable<Sys_Users>()
  6523. .Where(x => x.IsDel == 0 && ((x.DepId == 7 && gj_jobPostIds.Contains(x.JobPostId)) || x.DepId == 6))
  6524. .Select(x => new { x.Id, Name = x.CnName })
  6525. .ToListAsync();
  6526. return Ok(JsonView(true, "查询成功!", new
  6527. {
  6528. DraftNameDatas = draftNameDatas,
  6529. CurrencyData = _CurrencyData,
  6530. WordTypeData = _WordTypeData,
  6531. ExcelTypeData = _ExcelTypeData,
  6532. CurrencyInit = _currencyInfos,
  6533. ViewPermissionData = viewPermissionData
  6534. }));
  6535. }
  6536. /// <summary>
  6537. /// 团组模块 - 出入境费用-草稿
  6538. /// 实时汇率 tips
  6539. /// 签证费用 tips
  6540. /// 机票费用 tips
  6541. /// </summary>
  6542. /// <returns></returns>
  6543. [HttpPost]
  6544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6545. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6546. {
  6547. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6548. //默认币种显示
  6549. var _currencyInfos = _currencyInit;
  6550. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6551. List<dynamic> reteInfos = new List<dynamic>();
  6552. if (_currencyRate.Count > 0)
  6553. {
  6554. foreach (var item in _currencyInfos)
  6555. {
  6556. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6557. if (rateInfo != null)
  6558. {
  6559. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6560. decimal rate1 = item.Rate;
  6561. rate1 *= 1.03M;
  6562. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6563. reteInfos.Add(new
  6564. {
  6565. currCode = item.CurrencyCode,
  6566. currName = item.CurrencyName,
  6567. rate = rate2,
  6568. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6569. });
  6570. }
  6571. }
  6572. }
  6573. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6574. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6575. return Ok(JsonView(true, "查询成功!", new
  6576. {
  6577. //GroupNameData = groupNameData.Data,
  6578. //visaData = visaData.Data,
  6579. //airData = airData.Data,
  6580. reteInfos = reteInfos
  6581. }));
  6582. }
  6583. /// <summary>
  6584. /// 团组模块 - 出入境费用-草稿 - Info
  6585. /// </summary>
  6586. /// <returns></returns>
  6587. [HttpPost]
  6588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6589. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6590. {
  6591. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6592. }
  6593. /// <summary>
  6594. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6595. /// </summary>
  6596. /// <returns></returns>
  6597. [HttpPost]
  6598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6599. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6600. {
  6601. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6602. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6603. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6604. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6605. foreach (var userId in dto.UserIds)
  6606. {
  6607. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = userId });
  6608. }
  6609. if (permissions.Any())
  6610. {
  6611. _sqlSugar.BeginTran();
  6612. try
  6613. {
  6614. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6615. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6616. if (result < 1)
  6617. {
  6618. _sqlSugar.RollbackTran();
  6619. return Ok(JsonView(false));
  6620. }
  6621. }
  6622. catch (Exception ex)
  6623. {
  6624. _sqlSugar.RollbackTran();
  6625. return Ok(JsonView(false, ex.Message));
  6626. }
  6627. _sqlSugar.CommitTran();
  6628. return Ok(JsonView(true));
  6629. }
  6630. return Ok(JsonView(false));
  6631. }
  6632. /// <summary>
  6633. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6634. /// </summary>
  6635. /// <returns></returns>
  6636. [HttpPost]
  6637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6638. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6639. {
  6640. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6641. if (data.Code != 0)
  6642. {
  6643. return Ok(JsonView(false, data.Msg));
  6644. }
  6645. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6646. //汇率信息记录
  6647. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6648. return Ok(JsonView(true, data.Msg, data.Data));
  6649. }
  6650. /// <summary>
  6651. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6652. /// </summary>
  6653. /// <param name="dto"></param>
  6654. /// <returns></returns>
  6655. [HttpPost]
  6656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6657. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6658. {
  6659. try
  6660. {
  6661. var id = dto.Id;
  6662. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6663. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6664. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6665. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6666. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6667. 3 团组成员名单 1 团组成员名单", ""));
  6668. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6669. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6670. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6671. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6672. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6673. //数据源
  6674. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6675. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6676. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6677. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6678. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6679. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6680. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6681. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6682. .Select((x, a, b) => new
  6683. {
  6684. x.Index,
  6685. itemName = a.Name,
  6686. CurrencyStr = b.Name,
  6687. x.Cost,
  6688. x.SubTotal,
  6689. x.Remark
  6690. })
  6691. .OrderBy((x) => x.Index)
  6692. .ToList(); //其他款项费用
  6693. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6694. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6695. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6696. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6697. if (dto.ExportType == 1) //明细表
  6698. {
  6699. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6700. {
  6701. //获取模板
  6702. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6703. //载入模板
  6704. Document doc = new Document(tempPath);
  6705. DocumentBuilder builder = new DocumentBuilder(doc);
  6706. //利用键值对存放数据
  6707. Dictionary<string, string> dic = new Dictionary<string, string>();
  6708. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6709. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6710. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6711. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6712. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6713. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6714. //境内费用(其他费用)
  6715. if (_EnterExitCosts.ChoiceOne == 1)
  6716. {
  6717. string row1_1 = "";
  6718. if (_EnterExitCosts.Visa > 0)
  6719. {
  6720. //insidePayTotal += _EnterExitCosts.Visa;
  6721. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6722. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6723. {
  6724. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6725. }
  6726. }
  6727. string row1_2 = "";
  6728. if (_EnterExitCosts.YiMiao > 0)
  6729. {
  6730. //insidePayTotal += _EnterExitCosts.YiMiao;
  6731. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6732. }
  6733. if (_EnterExitCosts.HeSuan > 0)
  6734. {
  6735. //insidePayTotal += _EnterExitCosts.HeSuan;
  6736. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6737. }
  6738. if (_EnterExitCosts.Service > 0)
  6739. {
  6740. //insidePayTotal += _EnterExitCosts.Service;
  6741. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6742. }
  6743. string row1_3 = "";
  6744. if (_EnterExitCosts.Safe > 0)
  6745. {
  6746. //insidePayTotal += _EnterExitCosts.Safe;
  6747. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6748. }
  6749. if (_EnterExitCosts.Ticket > 0)
  6750. {
  6751. //insidePayTotal += _EnterExitCosts.Ticket;
  6752. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6753. }
  6754. string row1 = "";
  6755. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6756. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6757. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6758. row1 += $"备注:{_EnterExitCosts.Remark}";
  6759. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6760. dic.Add("Row1Str", row1);
  6761. }
  6762. string airTotalStr = string.Empty,
  6763. airPriceStr = string.Empty;
  6764. //经济舱
  6765. if (_EnterExitCosts.SumJJC == 1)
  6766. {
  6767. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6768. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6769. }
  6770. //公务舱
  6771. if (_EnterExitCosts.SumGWC == 1)
  6772. {
  6773. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6774. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6775. }
  6776. //头等舱
  6777. if (_EnterExitCosts.SumTDC == 1)
  6778. {
  6779. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6780. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6781. }
  6782. string twoItemRemark = "备注:";
  6783. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  6784. {
  6785. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  6786. }
  6787. dic.Add("AirTotalStr", airTotalStr);
  6788. dic.Add("AirPriceStr", airPriceStr);
  6789. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6790. dic.Add("TwoItemRemark", twoItemRemark);
  6791. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6792. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6793. int table1Row = 0,
  6794. table2Row = 0,
  6795. table3Row = 0,
  6796. table4Row = 0,
  6797. table5Row = 0;
  6798. //住宿费
  6799. if (_EnterExitCosts.ChoiceThree == 1)
  6800. {
  6801. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6802. table1Row = dac1.Count;
  6803. #region 填充word表格内容
  6804. for (int i = 0; i < dac1.Count; i++)
  6805. {
  6806. var dac = dac1[i];
  6807. if (dac == null) continue;
  6808. builder.MoveToCell(0, i, 0, 0);
  6809. builder.Write("第" + dac.Days.ToString() + "晚:");
  6810. builder.MoveToCell(0, i, 1, 0);
  6811. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6812. //builder.Write(dac.Place == null ? "" : dac.Place);
  6813. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6814. builder.MoveToCell(0, i, 2, 0);
  6815. builder.Write("费用标准:");
  6816. string curr = "";
  6817. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6818. if (currData != null)
  6819. {
  6820. curr = currData.Name;
  6821. }
  6822. builder.MoveToCell(0, i, 3, 0);
  6823. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6824. builder.MoveToCell(0, i, 4, 0);
  6825. builder.Write("费用小计:");
  6826. builder.MoveToCell(0, i, 5, 0);
  6827. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6828. }
  6829. #endregion
  6830. }
  6831. else dic.Add("SubZS", "0.00");
  6832. //删除多余行
  6833. while (table1.Rows.Count > table1Row)
  6834. {
  6835. table1.Rows.RemoveAt(table1Row);
  6836. }
  6837. //伙食费
  6838. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6839. if (_EnterExitCosts.ChoiceFour == 1)
  6840. {
  6841. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6842. table2Row = dac2.Count;
  6843. #region 填充word表格内容
  6844. for (int i = 0; i < dac2.Count; i++)
  6845. {
  6846. var dac = dac2[i];
  6847. if (dac == null) continue;
  6848. builder.MoveToCell(1, i, 0, 0);
  6849. builder.Write("第" + dac.Days.ToString() + "天:");
  6850. builder.MoveToCell(1, i, 1, 0);
  6851. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6852. builder.MoveToCell(1, i, 2, 0);
  6853. builder.Write("费用标准:");
  6854. string curr = "";
  6855. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6856. if (currData != null)
  6857. {
  6858. curr = currData.Name;
  6859. }
  6860. builder.MoveToCell(1, i, 3, 0);
  6861. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6862. builder.MoveToCell(1, i, 4, 0);
  6863. builder.Write("费用小计:");
  6864. builder.MoveToCell(1, i, 5, 0);
  6865. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6866. }
  6867. #endregion
  6868. }
  6869. else dic.Add("SubHS", "0.00");
  6870. //删除多余行
  6871. while (table2.Rows.Count > table2Row)
  6872. {
  6873. table2.Rows.RemoveAt(table2Row);
  6874. }
  6875. //公杂费
  6876. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6877. if (_EnterExitCosts.ChoiceFive == 1)
  6878. {
  6879. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6880. table3Row = dac3.Count;
  6881. #region 填充word表格内容
  6882. for (int i = 0; i < dac3.Count; i++)
  6883. {
  6884. var dac = dac3[i];
  6885. if (dac == null) continue;
  6886. builder.MoveToCell(2, i, 0, 0);
  6887. builder.Write("第" + dac.Days.ToString() + "天:");
  6888. builder.MoveToCell(2, i, 1, 0);
  6889. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6890. builder.MoveToCell(2, i, 2, 0);
  6891. builder.Write("费用标准:");
  6892. string curr = "";
  6893. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6894. if (currData != null)
  6895. {
  6896. curr = currData.Name;
  6897. }
  6898. builder.MoveToCell(2, i, 3, 0);
  6899. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6900. builder.MoveToCell(2, i, 4, 0);
  6901. builder.Write("费用小计:");
  6902. builder.MoveToCell(2, i, 5, 0);
  6903. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6904. }
  6905. //删除多余行
  6906. while (table3.Rows.Count > table3Row)
  6907. {
  6908. table3.Rows.RemoveAt(table3Row);
  6909. }
  6910. #endregion
  6911. }
  6912. else dic.Add("SubGZF", "0.00");
  6913. //删除多余行
  6914. while (table3.Rows.Count > table3Row)
  6915. {
  6916. table3.Rows.RemoveAt(table3Row);
  6917. }
  6918. //培训费
  6919. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6920. if (_EnterExitCosts.ChoiceSix == 1)
  6921. {
  6922. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6923. dic.Add("SubPX", pxStr);
  6924. table4Row = dac4.Count;
  6925. #region 填充word表格内容
  6926. for (int i = 0; i < dac4.Count; i++)
  6927. {
  6928. var dac = dac4[i];
  6929. if (dac == null) continue;
  6930. builder.MoveToCell(3, i, 0, 0);
  6931. builder.Write("第" + dac.Days.ToString() + "天:");
  6932. builder.MoveToCell(3, i, 1, 0);
  6933. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6934. builder.MoveToCell(3, i, 2, 0);
  6935. builder.Write("费用标准:");
  6936. string curr = "";
  6937. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6938. if (currData != null)
  6939. {
  6940. curr = currData.Name;
  6941. }
  6942. builder.MoveToCell(3, i, 3, 0);
  6943. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6944. builder.MoveToCell(3, i, 4, 0);
  6945. builder.Write("费用小计:");
  6946. builder.MoveToCell(3, i, 5, 0);
  6947. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6948. }
  6949. #endregion
  6950. }
  6951. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6952. //删除多余行
  6953. while (table4.Rows.Count > table4Row)
  6954. {
  6955. table4.Rows.RemoveAt(table4Row);
  6956. }
  6957. //其他费用
  6958. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6959. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6960. {
  6961. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6962. dic.Add("titleQi", qtStr);
  6963. table5Row = dac5.Count;
  6964. #region 填充word表格内容
  6965. for (int i = 0; i < dac5.Count; i++)
  6966. {
  6967. var dac = dac5[i];
  6968. if (dac == null) continue;
  6969. builder.MoveToCell(4, i, 0, 0);
  6970. builder.Write("第" + dac.Index.ToString() + "项:");
  6971. builder.MoveToCell(4, i, 1, 0);
  6972. builder.Write(dac.itemName);
  6973. builder.MoveToCell(4, i, 2, 0);
  6974. builder.Write("费用标准:");
  6975. builder.MoveToCell(4, i, 3, 0);
  6976. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6977. builder.MoveToCell(4, i, 4, 0);
  6978. builder.Write("费用小计:");
  6979. builder.MoveToCell(4, i, 5, 0);
  6980. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6981. builder.MoveToCell(4, i, 6, 0);
  6982. builder.Write("备注:");
  6983. builder.MoveToCell(4, i, 7, 0);
  6984. builder.Write(dac.Remark);
  6985. }
  6986. #endregion
  6987. }
  6988. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6989. //删除多余行
  6990. while (table5.Rows.Count > table5Row)
  6991. {
  6992. table5.Rows.RemoveAt(table5Row);
  6993. }
  6994. //加上其他费用
  6995. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6996. decimal subJJC = 0.00M,
  6997. subGWC = 0.00M,
  6998. subTDC = 0.00M;
  6999. //经济舱
  7000. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7001. //公务舱
  7002. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7003. //头等舱
  7004. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7005. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7006. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7007. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7008. #region 填充word模板书签内容
  7009. foreach (var key in dic.Keys)
  7010. {
  7011. Bookmark bookmark = doc.Range.Bookmarks[key];
  7012. if (bookmark != null)
  7013. {
  7014. builder.MoveToBookmark(key);
  7015. builder.Write(dic[key]);
  7016. }
  7017. }
  7018. #endregion
  7019. //文件名
  7020. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7021. strFileName = CommonFun.ValidFileName(strFileName);
  7022. AsposeHelper.removewatermark_v2180();
  7023. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7024. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7025. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7026. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7027. }
  7028. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7029. {
  7030. //获取模板
  7031. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7032. //载入模板
  7033. Document doc = new Document(tempPath);
  7034. DocumentBuilder builder = new DocumentBuilder(doc);
  7035. Dictionary<string, string> dic = new Dictionary<string, string>();
  7036. string returnCodeLabel = string.Empty;
  7037. if (nationalTravelFeeData.Any())
  7038. {
  7039. List<string> list = new List<string>();
  7040. foreach (var item in nationalTravelFeeData)
  7041. {
  7042. list.Add($"{item.Country}({item.City})");
  7043. }
  7044. list = list.Distinct().ToList();
  7045. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7046. }
  7047. var countryLabel = string.Empty;
  7048. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7049. if (countryData.Any())
  7050. {
  7051. countryLabel = string.Join("、", countryData);
  7052. }
  7053. dic.Add("ReturnCodeAir", returnCodeLabel);
  7054. dic.Add("VisitStartDate", "-");
  7055. dic.Add("VisitEndDate", "-");
  7056. dic.Add("Day", "-");
  7057. dic.Add("VisitCountry", countryLabel);
  7058. dic.Add("ClientUnit", "-");
  7059. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7060. //dic.Add("Names", Names);
  7061. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7062. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7063. decimal dac1totalPrice = 0.00M;
  7064. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7065. foreach (var dac in dac1)
  7066. {
  7067. if (dac.SubTotal == 0.00M)
  7068. {
  7069. continue;
  7070. }
  7071. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7072. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7073. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7074. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7075. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7076. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7077. builder.Write(currency);//币种
  7078. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7079. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7080. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7081. builder.Write("");//人数
  7082. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7083. builder.Write("");//天数
  7084. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7085. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7086. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7087. decimal rate = 0.00M;
  7088. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7089. builder.Write(rate.ToString("#0.0000"));//汇率
  7090. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7091. decimal rbmPrice = dac.SubTotal;
  7092. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7093. accommodationStartIndex++;
  7094. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7095. }
  7096. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7097. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7098. {
  7099. table1.Rows.RemoveAt(i - 1);
  7100. foodandotherStartIndex--;
  7101. }
  7102. if (dac2.Count == dac3.Count)//国家 币种 金额
  7103. {
  7104. for (int i = 0; i < dac2.Count; i++)
  7105. {
  7106. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7107. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7108. }
  7109. }
  7110. decimal dac2totalPrice = 0.00M;
  7111. foreach (var dac in dac2)
  7112. {
  7113. if (dac.SubTotal == 0)
  7114. {
  7115. continue;
  7116. }
  7117. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7118. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7119. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7120. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7121. builder.Write(currency);//币种
  7122. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7123. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7124. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7125. builder.Write("");//人数
  7126. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7127. builder.Write("");//天数
  7128. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7129. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7130. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7131. decimal rate = 0.00M;
  7132. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7133. builder.Write(rate.ToString("#0.0000"));//汇率
  7134. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7135. decimal rbmPrice = dac.SubTotal;
  7136. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7137. foodandotherStartIndex++;
  7138. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7139. }
  7140. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7141. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7142. {
  7143. table1.Rows.RemoveAt(i - 1);
  7144. }
  7145. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7146. string otherFeeStr = "";
  7147. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7148. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7149. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7150. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7151. foreach (var otherInfo in dac5)
  7152. {
  7153. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7154. }
  7155. #endregion
  7156. if (otherFeeStr.Length > 0)
  7157. {
  7158. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7159. otherFeeStr = $"({otherFeeStr})";
  7160. dic.Add("OtherFeeStr", otherFeeStr);
  7161. }
  7162. //总计
  7163. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7164. //国际旅费
  7165. string outsideAir = string.Empty;
  7166. string allPriceAir = string.Empty;
  7167. if (_EnterExitCosts.SumJJC == 1)
  7168. {
  7169. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7170. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7171. }
  7172. if (_EnterExitCosts.SumGWC == 1)
  7173. {
  7174. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7175. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7176. }
  7177. if (_EnterExitCosts.SumTDC == 1)
  7178. {
  7179. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7180. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7181. }
  7182. dic.Add("InTravelPrice", $"({outsideAir})");
  7183. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7184. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7185. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7186. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7187. foreach (var key in dic.Keys)
  7188. {
  7189. builder.MoveToBookmark(key);
  7190. builder.Write(dic[key]);
  7191. }
  7192. //模板文件名
  7193. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7194. strFileName = CommonFun.ValidFileName(strFileName);
  7195. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7196. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7197. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7198. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7199. }
  7200. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7201. {
  7202. //获取模板
  7203. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7204. //载入模板
  7205. WorkbookDesigner designer = new WorkbookDesigner();
  7206. designer.Workbook = new Workbook(tempPath);
  7207. Dictionary<string, string> dic = new Dictionary<string, string>();
  7208. string returnCodeLabel = string.Empty;
  7209. if (nationalTravelFeeData.Any())
  7210. {
  7211. List<string> list = new List<string>();
  7212. foreach (var item in nationalTravelFeeData)
  7213. {
  7214. list.Add($"{item.Country}({item.City})");
  7215. }
  7216. list = list.Distinct().ToList();
  7217. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7218. }
  7219. var countryLabel = string.Empty;
  7220. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7221. if (countryData.Any())
  7222. {
  7223. countryLabel = string.Join("、", countryData);
  7224. }
  7225. dic.Add("ReturnCodeAir", returnCodeLabel);
  7226. dic.Add("VisitStartDate", "-");
  7227. dic.Add("VisitEndDate", "-");
  7228. dic.Add("Day", "0");
  7229. dic.Add("VisitCountry", countryLabel);
  7230. dic.Add("ClientUnit", "-");
  7231. designer.SetDataSource("ClientUnit", "-");
  7232. designer.SetDataSource("VisitCountry", countryLabel);
  7233. designer.SetDataSource("Group", "-");
  7234. designer.SetDataSource("ClientUnitTitle", "-");
  7235. designer.SetDataSource("Name", "-");
  7236. designer.SetDataSource("VisitStartDate", "-" );
  7237. designer.SetDataSource("Day", "0");
  7238. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7239. designer.SetDataSource("ReturnCodeAir", "-");
  7240. int startIndex = 10;
  7241. const int startIndexcopy = 10;
  7242. if (dac2.Count == dac3.Count)//国家 币种 金额
  7243. {
  7244. for (int i = 0; i < dac2.Count; i++)
  7245. {
  7246. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7247. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7248. }
  7249. }
  7250. DataTable dtdac1 = new DataTable();
  7251. List<string> place = new List<string>();
  7252. dtdac1.Columns.AddRange(new DataColumn[] {
  7253. new DataColumn(){ ColumnName = "city"},
  7254. new DataColumn(){ ColumnName = "curr"},
  7255. new DataColumn(){ ColumnName = "criterion"},
  7256. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7257. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7258. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7259. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7260. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7261. });
  7262. DataTable dtdac2 = new DataTable();
  7263. dtdac2.Columns.AddRange(new DataColumn[] {
  7264. new DataColumn(){ ColumnName = "city"},
  7265. new DataColumn(){ ColumnName = "curr"},
  7266. new DataColumn(){ ColumnName = "criterion"},
  7267. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7268. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7269. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7270. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7271. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7272. });
  7273. dtdac1.TableName = "tb1";
  7274. dtdac2.TableName = "tb2";
  7275. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7276. foreach (var item in dac1)
  7277. {
  7278. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7279. if (place.Contains(item.Place))
  7280. {
  7281. continue;
  7282. }
  7283. DataRow row = dtdac1.NewRow();
  7284. row["city"] = item.Place;
  7285. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7286. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7287. row["curr"] = currency;
  7288. row["rate"] = rate.ToString("#0.0000");
  7289. row["criterion"] = item.Cost.ToString("#0.00");
  7290. row["number"] = 1;
  7291. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7292. //row["costRMB"] = rbmPrice;
  7293. dtdac1.Rows.Add(row);
  7294. place.Add(item.Place);
  7295. }
  7296. place = new List<string>();
  7297. foreach (var item in dac2)
  7298. {
  7299. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7300. if (place.Contains(item.Place))
  7301. {
  7302. continue;
  7303. }
  7304. DataRow row = dtdac2.NewRow();
  7305. row["city"] = item.Place;
  7306. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7307. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7308. row["curr"] = currency;
  7309. row["rate"] = rate.ToString("#0.0000");
  7310. row["criterion"] = item.Cost.ToString("#0.00");
  7311. row["number"] = 1;
  7312. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7313. //row["cost"] = item.SubTotal;
  7314. //row["costRMB"] = rbmPrice;
  7315. dtdac2.Rows.Add(row);
  7316. place.Add(item.Place);
  7317. //dac2totalPrice += rbmPrice;
  7318. }
  7319. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7320. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7321. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7322. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7323. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7324. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7325. string cell4Str1 = string.Empty;
  7326. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7327. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7328. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7329. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7330. string cellStr = $" 5.其他费用(";
  7331. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7332. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7333. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7334. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7335. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7336. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7337. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7338. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7339. foreach (var otherInfo in dac5)
  7340. {
  7341. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7342. }
  7343. #endregion
  7344. if (cellStr.Length > 8)
  7345. {
  7346. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7347. }
  7348. cellStr += ")";
  7349. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7350. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7351. decimal pxFee = dac4.Sum(it => it.Cost);
  7352. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7353. string celllastStr1 = "";
  7354. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7355. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7356. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7357. celllastStr1 += $",国际旅费 元";
  7358. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7359. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7360. designer.SetDataSource("cell4Str", cell4Str);
  7361. designer.SetDataSource("cellStr", cellStr);
  7362. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7363. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7364. designer.SetDataSource("celllastStr", celllastStr);
  7365. Workbook wb = designer.Workbook;
  7366. var sheet = wb.Worksheets[0];
  7367. //绑定datatable数据集
  7368. designer.SetDataSource(dtdac1);
  7369. designer.SetDataSource(dtdac2);
  7370. designer.Process();
  7371. var rowStart = dtdac1.Rows.Count;
  7372. while (rowStart > 0)
  7373. {
  7374. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7375. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7376. startIndex++;
  7377. rowStart--;
  7378. }
  7379. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7380. startIndex += 1; //总计行
  7381. rowStart = dtdac2.Rows.Count;
  7382. while (rowStart > 0)
  7383. {
  7384. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7385. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7386. startIndex++;
  7387. rowStart--;
  7388. }
  7389. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7390. wb.CalculateFormula(true);
  7391. //模板文件名
  7392. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7393. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7394. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7395. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7396. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7397. }
  7398. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7399. {
  7400. //获取模板
  7401. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7402. //载入模板
  7403. Document doc = new Document(tempPath);
  7404. DocumentBuilder builder = new DocumentBuilder(doc);
  7405. Dictionary<string, string> dic = new Dictionary<string, string>();
  7406. dic.Add("GroupName", "-");
  7407. dic.Add("ClientUnit", "-");
  7408. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7409. string missionLeaderJob = "";//负责人job
  7410. int groupNumber = 0; //团人数
  7411. dic.Add("MissionLeader", "-"); //团负责人
  7412. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7413. dic.Add("GroupNumber", "0"); //团人数
  7414. dic.Add("Day", "0");
  7415. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7416. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7417. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7418. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7419. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7420. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7421. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7422. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7423. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7424. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7425. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7426. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7427. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7428. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7429. //其他费用
  7430. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7431. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7432. //其他费用合计
  7433. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7434. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7435. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7436. //公务舱合计
  7437. //国际旅费
  7438. string outsideJJ = "";
  7439. string allPriceJJ = "";
  7440. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7441. {
  7442. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7443. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7444. }
  7445. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7446. {
  7447. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7448. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7449. }
  7450. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7451. {
  7452. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7453. dic.Add("AirFeeTotal", airFeeTotalStr);
  7454. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7455. dic.Add("FeeTotal", feeTotalStr);
  7456. }
  7457. foreach (var key in dic.Keys)
  7458. {
  7459. builder.MoveToBookmark(key);
  7460. builder.Write(dic[key]);
  7461. }
  7462. //模板文件名
  7463. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7464. strFileName = CommonFun.ValidFileName(strFileName);
  7465. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7466. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7467. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7468. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7469. }
  7470. }
  7471. else if (dto.ExportType == 2) //表格
  7472. {
  7473. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7474. }
  7475. else if (dto.ExportType == 3)
  7476. {
  7477. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7478. }
  7479. return Ok(JsonView(400, "只可导出明细表!", ""));
  7480. }
  7481. catch (Exception ex)
  7482. {
  7483. return Ok(JsonView(400, ex.Message, ""));
  7484. }
  7485. }
  7486. /// <summary>
  7487. /// 获取三公费用标准city
  7488. /// </summary>
  7489. /// <param name="placeData"></param>
  7490. /// <param name="nationalTravelFeeId"></param>
  7491. /// <returns></returns>
  7492. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7493. {
  7494. string _city = string.Empty;
  7495. if (!placeData.Any()) return _city;
  7496. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7497. if (data == null) return _city;
  7498. string country = data.Country;
  7499. string city = data.City;
  7500. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7501. else _city = city;
  7502. return _city;
  7503. }
  7504. /// <summary>
  7505. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7506. /// </summary>
  7507. /// <returns></returns>
  7508. [HttpPost]
  7509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7510. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7511. {
  7512. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7513. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7514. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7515. if (_view.Code == 0)
  7516. {
  7517. return Ok(JsonView(true, "操作成功"));
  7518. }
  7519. return Ok(JsonView(false, "操作失败"));
  7520. }
  7521. /// <summary>
  7522. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7523. /// </summary>
  7524. /// <returns></returns>
  7525. [HttpPost]
  7526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7527. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7528. {
  7529. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7530. if (data.Code != 0)
  7531. {
  7532. return Ok(JsonView(false, data.Msg));
  7533. }
  7534. return Ok(JsonView(true, "操作成功!", data.Data));
  7535. }
  7536. /// <summary>
  7537. /// 三公其他费用草稿 删除
  7538. /// </summary>
  7539. /// <param name="dto"></param>
  7540. /// <returns></returns>
  7541. [HttpPost]
  7542. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7543. {
  7544. var jw = JsonView(false, "删除失败!");
  7545. var data = new Grp_DayOtherPriceDraft()
  7546. {
  7547. Id = dto.Id,
  7548. IsDel = 1,
  7549. DeleteUserId = dto.DeleteUserId,
  7550. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7551. };
  7552. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7553. if (del > 0)
  7554. {
  7555. jw.Code = 200;
  7556. jw.Msg = "删除成功!";
  7557. }
  7558. return Ok(jw);
  7559. }
  7560. /// <summary>
  7561. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7562. /// </summary>
  7563. /// <param name="dto"></param>
  7564. /// <returns></returns>
  7565. [HttpPost]
  7566. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7567. {
  7568. var jw = JsonView(false);
  7569. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7570. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
  7571. jw.Code = StatusCodes.Status200OK;
  7572. jw.Msg = "操作成功!";
  7573. jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
  7574. return Ok(jw);
  7575. }
  7576. /// <summary>
  7577. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7578. /// </summary>
  7579. /// <param name="dto"></param>
  7580. /// <returns></returns>
  7581. [HttpPost]
  7582. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7583. {
  7584. int userId = dto.UserId,
  7585. portId = dto.PortType,
  7586. groupId = dto.GroupId,
  7587. draftId = dto.DraftId;
  7588. _portTypeData.Add(1);
  7589. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7590. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7591. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7592. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7593. _sqlSugar.BeginTran();
  7594. try
  7595. {
  7596. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7597. if (draftDatas == null)
  7598. {
  7599. _sqlSugar.RollbackTran();
  7600. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7601. }
  7602. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7603. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7604. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7605. newExterData.DiId = groupId;
  7606. newExterData.CreateUserId = userId;
  7607. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7608. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7609. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7610. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7611. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7612. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7613. //数据如果存在执行删除
  7614. if (enterExitCostInfo != null)
  7615. {
  7616. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7617. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7618. .Where(x => x.Id == enterExitCostInfo.Id)
  7619. .ExecuteCommand();
  7620. _sqlSugar.Updateable<Grp_DayAndCost>()
  7621. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7622. .Where(x => x.DiId == groupId)
  7623. .ExecuteCommand();
  7624. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7625. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7626. .Where(x => x.Diid == groupId)
  7627. .ExecuteCommand();
  7628. }
  7629. //执行insert
  7630. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7631. if (insertId < 1)
  7632. {
  7633. _sqlSugar.RollbackTran();
  7634. return Ok(JsonView(false, "草稿数据导入失败!"));
  7635. }
  7636. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7637. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7638. _sqlSugar.CommitTran();
  7639. //执行操作之后
  7640. //生成默认文件pdf并且通知人员
  7641. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7642. {
  7643. DiId = groupId,
  7644. ExportType = 1,
  7645. SubTypeId = 1005
  7646. }, "pdf");
  7647. //发送通知
  7648. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7649. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7650. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7651. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7652. //汇率信息记录
  7653. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7654. return Ok(JsonView(true));
  7655. }
  7656. catch (Exception ex)
  7657. {
  7658. _sqlSugar.RollbackTran();
  7659. return Ok(JsonView(false,ex.Message));
  7660. }
  7661. }
  7662. #endregion
  7663. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7664. /// <summary>
  7665. /// 获取币种基础数据(含逻辑处理)
  7666. /// </summary>
  7667. /// <returns></returns>
  7668. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7669. {
  7670. //默认币种显示
  7671. var _currencyInfos = _currencyInit;
  7672. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7673. if (_currencyRate.Count > 0)
  7674. {
  7675. foreach (var item in _currencyInfos)
  7676. {
  7677. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7678. if (rateInfo != null)
  7679. {
  7680. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7681. rate1 *= 1.035M;
  7682. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7683. }
  7684. }
  7685. }
  7686. return _currencyInfos;
  7687. }
  7688. /// <summary>
  7689. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7690. /// </summary>
  7691. /// <returns></returns>
  7692. [HttpPost]
  7693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7694. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7695. {
  7696. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7697. //SetDataInfoView
  7698. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7699. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7700. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7701. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7702. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7703. //默认币种显示
  7704. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7705. return Ok(JsonView(true, "查询成功!", new
  7706. {
  7707. WordTypeData = _WordTypeData,
  7708. ExcelTypeData = _ExcelTypeData,
  7709. CurrencyInit = _currencyInfos
  7710. }));
  7711. }
  7712. /// <summary>
  7713. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7714. /// </summary>
  7715. /// <returns></returns>
  7716. [HttpPost]
  7717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7718. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7719. {
  7720. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7721. RefAsync<int> total = 0;
  7722. int diId = 0;
  7723. var status = int.TryParse(dto.GroupName, out diId);
  7724. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  7725. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  7726. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7727. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  7728. .Select(x => new
  7729. {
  7730. Id = x.Id,
  7731. GroupName = x.TeamName
  7732. })
  7733. .OrderByDescending(x => x.Id)
  7734. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7735. return Ok(JsonView(true, "查询成功!", data, total));
  7736. }
  7737. /// <summary>
  7738. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7739. /// </summary>
  7740. /// <returns></returns>
  7741. [HttpPost]
  7742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7743. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7744. {
  7745. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7746. RefAsync<int> total = 0;
  7747. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7748. .Where(x => x.IsDel == 0 && x.STid == 66)
  7749. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7750. .Select(x => new
  7751. {
  7752. id = x.Id,
  7753. name = x.Name,
  7754. remark = x.Remark,
  7755. })
  7756. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7757. return Ok(JsonView(true, "查询成功!", data, total));
  7758. }
  7759. /// <summary>
  7760. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7761. /// </summary>
  7762. /// <returns></returns>
  7763. [HttpPost]
  7764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7765. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7766. {
  7767. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7768. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7769. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7770. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7771. var groupOtherRateData = groupRateData.TeamRates;
  7772. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7773. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7774. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7775. groupOtherRateData = groupOtherRateData
  7776. .Select(x => new TeamRateDescAddCurrencyIdView {
  7777. CurrencyId = x.CurrencyId,
  7778. CurrencyName = x.CurrencyName,
  7779. CurrencyCode = x.CurrencyCode,
  7780. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7781. }).ToList();
  7782. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7783. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7784. }
  7785. /// <summary>
  7786. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7787. /// </summary>
  7788. /// <returns></returns>
  7789. [HttpPost]
  7790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7791. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7792. {
  7793. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7794. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7795. var tipsData = new List<int>() {1,2,3 };
  7796. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7797. if (dto.TipsType == 1)
  7798. {
  7799. //默认币种显示
  7800. var _currencyInfos = _currencyInit;
  7801. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7802. List<dynamic> reteInfos = new List<dynamic>();
  7803. if (_currencyRate.Count > 0)
  7804. {
  7805. foreach (var item in _currencyInfos)
  7806. {
  7807. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7808. if (rateInfo != null)
  7809. {
  7810. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7811. decimal rate1 = item.Rate;
  7812. rate1 *= 1.03M;
  7813. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7814. reteInfos.Add(new
  7815. {
  7816. currCode = item.CurrencyCode,
  7817. currName = item.CurrencyName,
  7818. rate = rate2,
  7819. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7820. });
  7821. }
  7822. }
  7823. }
  7824. return Ok(JsonView(true, "查询成功!", reteInfos));
  7825. }
  7826. else if (dto.TipsType == 2)
  7827. {
  7828. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7829. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7830. }
  7831. else if (dto.TipsType == 3)
  7832. {
  7833. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7834. return Ok(JsonView(true, "查询成功!", airData.Data));
  7835. }
  7836. return Ok(JsonView(false));
  7837. }
  7838. /// <summary>
  7839. /// 团组模块 - 出入境国家费用标准-移动端 List
  7840. /// </summary>
  7841. /// <returns></returns>
  7842. [HttpPost]
  7843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7844. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7845. {
  7846. Stopwatch sw = new Stopwatch();
  7847. sw.Start();
  7848. RefAsync<int> total = 0;
  7849. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7850. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7851. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7852. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7853. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7854. .Select((ntf, sd, u) => new
  7855. {
  7856. Id = ntf.Id,
  7857. Area = $"{ntf.Country}-{ntf.City}",
  7858. Currency = ntf.Currency,
  7859. CurrencyCode = sd.Name,
  7860. CurrencyName = sd.Remark,
  7861. RoomCost = ntf.RoomCost,
  7862. FoodCost = ntf.FoodCost,
  7863. PublicCost = ntf.PublicCost,
  7864. LastUpdateUserId = ntf.LastUpdateUserId,
  7865. LastUpdateUserName = u.CnName,
  7866. LastUpdateTime = ntf.LastUpdateTime,
  7867. })
  7868. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7869. sw.Stop();
  7870. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  7871. }
  7872. /// <summary>
  7873. /// 团组模块 - 出入境费用-移动端 - Info
  7874. /// </summary>
  7875. /// <returns></returns>
  7876. [HttpPost]
  7877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7878. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7879. {
  7880. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7881. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7882. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7883. return Ok(data);
  7884. }
  7885. /// <summary>
  7886. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7887. /// </summary>
  7888. /// <returns></returns>
  7889. [HttpPost]
  7890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7891. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  7892. {
  7893. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7894. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7895. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7896. var mobileInfo = new EnterExitCostMobileParentInfoView();
  7897. mobileInfo.DiId = dto.DiId;
  7898. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  7899. if (eecInfo == null) return Ok(mobileInfo);
  7900. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  7901. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  7902. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7903. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7904. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  7905. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7906. {
  7907. SubId = dac.Id,
  7908. DiId = dac.DiId,
  7909. Type = dac.Type,
  7910. Days = dac.Days,
  7911. NationalTravelFeeId = dac.NationalTravelFeeId,
  7912. Arae = $"{ntf.Country}-{ntf.City}",
  7913. Cost = dac.Cost,
  7914. Currency = dac.Currency,
  7915. CurrencyName = sd.Name,
  7916. SubTotal = dac.SubTotal,
  7917. })
  7918. .ToList();
  7919. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  7920. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  7921. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  7922. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  7923. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  7924. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  7925. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  7926. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  7927. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  7928. //其他款项
  7929. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7930. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  7931. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  7932. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  7933. .OrderBy((dop, sd1, sd2) => dop.Index)
  7934. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  7935. {
  7936. SubId = dop.Id,
  7937. DiId = dop.Diid,
  7938. Index = dop.Index,
  7939. SetDataId = dop.SetDataId,
  7940. SetDataName = sd1.Name,
  7941. Cost = dop.Cost,
  7942. Currency = dop.Currency,
  7943. CurrencyName = sd2.Remark,
  7944. SubTotal = dop.SubTotal,
  7945. Remark = dop.Remark,
  7946. })
  7947. .ToArray();
  7948. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  7949. return Ok(mobileInfo);
  7950. }
  7951. /// <summary>
  7952. /// 团组模块 - 出入境费用-移动端 - SubInfo
  7953. /// </summary>
  7954. /// <returns></returns>
  7955. [HttpPost]
  7956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7957. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  7958. {
  7959. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7960. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7961. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  7962. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  7963. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7964. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  7965. var subType = dto.SubType;
  7966. if (subType == 1) //1:境内费用
  7967. {
  7968. var oneData = new ChoiceOneMobileSubInfoView()
  7969. {
  7970. Id = eecInfo.Id,
  7971. ChoiceOne = eecInfo.ChoiceOne,
  7972. ChoiceOneTotalCost = eecInfo.InsidePay,
  7973. Visa = eecInfo.Visa,
  7974. VisaRemark = eecInfo.VisaRemark,
  7975. YiMiao = eecInfo.YiMiao,
  7976. HeSuan = eecInfo.HeSuan,
  7977. Service = eecInfo.Service,
  7978. Ticket = eecInfo.Ticket,
  7979. Safe = eecInfo.Safe,
  7980. FirstItemRemark = eecInfo.FirstItemRemark
  7981. };
  7982. return Ok(JsonView(oneData));
  7983. }
  7984. else if (subType == 2) //2:国际旅费
  7985. {
  7986. var twoData = new ChoiceTwoMobileSubInfoView() {
  7987. Id = eecInfo.Id,
  7988. ChoiceTwoJJ = eecInfo.SumJJC,
  7989. OutsideJJPay = eecInfo.OutsideJJPay,
  7990. ChoiceTwoGW = eecInfo.SumGWC,
  7991. OutsideGWPay = eecInfo.OutsideGWPay,
  7992. ChoiceTwoTD = eecInfo.SumTDC,
  7993. OutsideTDPay = eecInfo.OutsideTDPay,
  7994. AirJJ = eecInfo.AirJJ,
  7995. AirGW = eecInfo.AirGW,
  7996. AirTD = eecInfo.AirTD,
  7997. CityTranffic = eecInfo.CityTranffic,
  7998. TwoItemRemark = eecInfo.TwoItemRemark
  7999. };
  8000. return Ok(JsonView(twoData));
  8001. }
  8002. else if (subType == 3) //3:住宿费
  8003. {
  8004. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8005. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8006. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8007. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8008. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8009. {
  8010. SubId = dac.Id,
  8011. DiId = dac.DiId,
  8012. Type = dac.Type,
  8013. Days = dac.Days,
  8014. NationalTravelFeeId = dac.NationalTravelFeeId,
  8015. Arae = $"{ntf.Country}-{ntf.City}",
  8016. Cost = dac.Cost,
  8017. Currency = dac.Currency,
  8018. CurrencyName = sd.Name,
  8019. SubTotal = dac.SubTotal,
  8020. })
  8021. .ToArray();
  8022. var data = new ChoiceMobileSubInfo3To6View() {
  8023. ParentId = eecInfo.Id,
  8024. Choice = eecInfo.ChoiceThree,
  8025. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8026. Details = dayAndCostDatas
  8027. };
  8028. return Ok(JsonView(data));
  8029. }
  8030. else if (subType == 4) //4:伙食费
  8031. {
  8032. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8033. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8034. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8035. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8036. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8037. {
  8038. SubId = dac.Id,
  8039. DiId = dac.DiId,
  8040. Type = dac.Type,
  8041. Days = dac.Days,
  8042. NationalTravelFeeId = dac.NationalTravelFeeId,
  8043. Arae = $"{ntf.Country}-{ntf.City}",
  8044. Cost = dac.Cost,
  8045. Currency = dac.Currency,
  8046. CurrencyName = sd.Name,
  8047. SubTotal = dac.SubTotal,
  8048. })
  8049. .ToArray();
  8050. var data = new ChoiceMobileSubInfo3To6View()
  8051. {
  8052. ParentId = eecInfo.Id,
  8053. Choice = eecInfo.ChoiceFour,
  8054. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8055. Details = dayAndCostDatas
  8056. };
  8057. return Ok(JsonView(data));
  8058. }
  8059. else if (subType == 5) //5:公杂费
  8060. {
  8061. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8062. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8063. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8064. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8065. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8066. {
  8067. SubId = dac.Id,
  8068. DiId = dac.DiId,
  8069. Type = dac.Type,
  8070. Days = dac.Days,
  8071. NationalTravelFeeId = dac.NationalTravelFeeId,
  8072. Arae = $"{ntf.Country}-{ntf.City}",
  8073. Cost = dac.Cost,
  8074. Currency = dac.Currency,
  8075. CurrencyName = sd.Name,
  8076. SubTotal = dac.SubTotal,
  8077. })
  8078. .ToArray();
  8079. var data = new ChoiceMobileSubInfo3To6View()
  8080. {
  8081. ParentId = eecInfo.Id,
  8082. Choice = eecInfo.ChoiceFive,
  8083. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8084. Details = dayAndCostDatas
  8085. };
  8086. return Ok(JsonView(data));
  8087. }
  8088. else if (subType == 6) //6:培训费
  8089. {
  8090. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8091. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8092. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8093. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8094. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8095. {
  8096. SubId = dac.Id,
  8097. DiId = dac.DiId,
  8098. Type = dac.Type,
  8099. Days = dac.Days,
  8100. NationalTravelFeeId = dac.NationalTravelFeeId,
  8101. Arae = $"{ntf.Country}-{ntf.City}",
  8102. Cost = dac.Cost,
  8103. Currency = dac.Currency,
  8104. CurrencyName = sd.Name,
  8105. SubTotal = dac.SubTotal,
  8106. })
  8107. .ToArray();
  8108. var data = new ChoiceMobileSubInfo3To6View()
  8109. {
  8110. ParentId = eecInfo.Id,
  8111. Choice = eecInfo.ChoiceSix,
  8112. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8113. Details = dayAndCostDatas
  8114. };
  8115. return Ok(JsonView(data));
  8116. }
  8117. else if (subType == 7) //7:其他
  8118. {
  8119. //其他款项
  8120. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8121. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8122. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8123. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8124. .OrderBy((dop, sd1, sd2) => dop.Index)
  8125. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8126. {
  8127. SubId = dop.Id,
  8128. DiId = dop.Diid,
  8129. Index = dop.Index,
  8130. SetDataId = dop.SetDataId,
  8131. SetDataName = sd1.Name,
  8132. Cost = dop.Cost,
  8133. Currency = dop.Currency,
  8134. CurrencyName = sd2.Name,
  8135. SubTotal = dop.SubTotal,
  8136. Remark = dop.Remark,
  8137. })
  8138. .ToArray();
  8139. var data = new ChoiceSevenMobileSubInfoView()
  8140. {
  8141. ParentId = eecInfo.Id,
  8142. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8143. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8144. Details = otherData
  8145. };
  8146. return Ok(JsonView(data));
  8147. }
  8148. return Ok(JsonView(false));
  8149. }
  8150. #region op
  8151. /// <summary>
  8152. /// 移动端更新费用消息通知
  8153. /// </summary>
  8154. /// <param name="diid"></param>
  8155. /// <param name="id"></param>
  8156. /// <param name="currUserId"></param>
  8157. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  8158. {
  8159. try
  8160. {
  8161. ////生成默认文件pdf并且通知人员
  8162. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8163. //{
  8164. // DiId = diid,
  8165. // ExportType = 1,
  8166. // SubTypeId = 1005
  8167. //}, "pdf");
  8168. ////发送通知
  8169. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8170. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8171. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8172. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8173. ////汇率信息记录
  8174. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8175. }
  8176. catch (Exception ex)
  8177. {
  8178. //记录日志
  8179. throw;
  8180. }
  8181. }
  8182. /// <summary>
  8183. /// 验证出入境费用数据是否存在
  8184. /// 不存在添加
  8185. /// </summary>
  8186. /// <param name="diId"></param>
  8187. /// <param name="currUserId"></param>
  8188. /// <returns></returns>
  8189. /// <exception cref="CustomException"></exception>
  8190. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  8191. {
  8192. var parentId = 0;
  8193. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8194. if (info != null) parentId = info.Id;
  8195. else
  8196. {
  8197. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8198. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8199. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8200. parentId = addId;
  8201. }
  8202. return parentId;
  8203. }
  8204. /// <summary>
  8205. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8206. /// </summary>
  8207. /// <returns></returns>
  8208. [HttpPost]
  8209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8210. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8211. {
  8212. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8213. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8214. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8215. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8216. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8217. int id = dto.Id;
  8218. if (id <= 0) //add
  8219. {
  8220. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8221. if (add < 1) return Ok(JsonView(false));
  8222. id = add;
  8223. }
  8224. else //update
  8225. {
  8226. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8227. if (upd < 1) return Ok(JsonView(false));
  8228. }
  8229. #region 汇率变更时更改币种相关费用
  8230. var opDayCosts = new List<Grp_DayAndCost>();
  8231. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8232. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8233. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8234. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  8235. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8236. .Select((dac, sd) => new {
  8237. dac.Id,
  8238. dac.DiId,
  8239. CurrencyCode = sd.Name,
  8240. dac.Cost
  8241. })
  8242. .ToList();
  8243. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8244. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8245. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8246. .Select((dop, sd) => new {
  8247. dop.Id,
  8248. dop.Diid,
  8249. CurrencyCode = sd.Name,
  8250. dop.Cost
  8251. })
  8252. .ToList();
  8253. if (dayCosts.Count > 0)
  8254. {
  8255. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8256. foreach (var dc in new_dayCosts)
  8257. {
  8258. var thisCurrency = dc.Key.ToUpper();
  8259. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8260. if (thisRate == 0.00M) continue;
  8261. foreach (var dcSub in dc)
  8262. {
  8263. opDayCosts.Add(new Grp_DayAndCost() {
  8264. Id = dcSub.Id,
  8265. DiId = dcSub.DiId,
  8266. Cost = dcSub.Cost,
  8267. SubTotal = dcSub.Cost * thisRate,
  8268. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8269. });
  8270. }
  8271. }
  8272. if (opDayCosts.Count > 0)
  8273. {
  8274. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8275. }
  8276. }
  8277. if (dayOtherCosts.Count > 0)
  8278. {
  8279. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8280. foreach (var dc in new_dayOtherCosts)
  8281. {
  8282. var thisCurrency = dc.Key.ToUpper();
  8283. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8284. if (thisRate == 0.00M) continue;
  8285. foreach (var dcSub in dc)
  8286. {
  8287. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8288. {
  8289. Id = dcSub.Id,
  8290. Diid = dcSub.Diid,
  8291. Cost = dcSub.Cost,
  8292. SubTotal = dcSub.Cost * thisRate,
  8293. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8294. });
  8295. }
  8296. }
  8297. if (opDayOtherCosts.Count > 0)
  8298. {
  8299. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8300. }
  8301. }
  8302. #endregion
  8303. //消息通知
  8304. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  8305. //汇率信息记录
  8306. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8307. return Ok(JsonView(new { parentId = id }));
  8308. }
  8309. /// <summary>
  8310. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8311. /// </summary>
  8312. /// <returns></returns>
  8313. [HttpPost]
  8314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8315. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8316. {
  8317. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8318. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8319. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8320. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8321. int id = dto.Id;
  8322. if (id <= 0) //add
  8323. {
  8324. checkboxInfo.CreateUserId = dto.CurrUserId;
  8325. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8326. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8327. if (add < 1) return Ok(JsonView(false));
  8328. }
  8329. else //update
  8330. {
  8331. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8332. .UpdateColumns(x => new {
  8333. x.ChoiceOne,
  8334. x.ChoiceTwo,
  8335. x.SumJJC,
  8336. x.SumGWC,
  8337. x.SumTDC,
  8338. x.ChoiceThree,
  8339. x.ChoiceFour,
  8340. x.ChoiceFive,
  8341. x.ChoiceSix,
  8342. x.OtherExpenses_Checked
  8343. })
  8344. .Where(x => x.Id == id)
  8345. .ExecuteCommandAsync();
  8346. if (upd < 1) return Ok(JsonView(false));
  8347. }
  8348. return Ok(JsonView(new { parentId = id }));
  8349. }
  8350. /// <summary>
  8351. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8352. /// </summary>
  8353. /// <returns></returns>
  8354. [HttpPost]
  8355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8356. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8357. {
  8358. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  8359. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8360. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8361. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8362. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8363. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8364. var checkboxInfo = new Grp_EnterExitCost() {
  8365. Id = id,
  8366. DiId = diId,
  8367. CreateUserId = currUserId
  8368. };
  8369. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8370. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8371. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8372. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8373. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8374. if (id <= 0) //add
  8375. {
  8376. checkboxInfo.CreateUserId = dto.CurrUserId;
  8377. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8378. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8379. if (add < 1) return Ok(JsonView(false));
  8380. }
  8381. else //update
  8382. {
  8383. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8384. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8385. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8386. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8387. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8388. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8389. .Where(x => x.Id == id)
  8390. .ExecuteCommandAsync();
  8391. if (upd < 1) return Ok(JsonView(false));
  8392. }
  8393. return Ok(JsonView(new { parentId = id }));
  8394. }
  8395. /// <summary>
  8396. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8397. /// </summary>
  8398. /// <returns></returns>
  8399. [HttpPost]
  8400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8401. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8402. {
  8403. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8404. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8405. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8406. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8407. info.FirstItemRemark = dto.FirstItemRemark;
  8408. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8409. int id = dto.Id;
  8410. if (id <= 0) //add
  8411. {
  8412. info.CreateUserId = dto.CurrUserId;
  8413. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8414. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8415. if (add < 1) return Ok(JsonView(false));
  8416. id = add;
  8417. }
  8418. else //update
  8419. {
  8420. var upd = await _sqlSugar.Updateable(info)
  8421. .UpdateColumns(x => new {
  8422. x.ChoiceOne,
  8423. x.InsidePay,
  8424. x.VisaRemark,
  8425. x.Visa,
  8426. x.Service,
  8427. x.Safe,
  8428. x.Ticket,
  8429. x.HeSuan,
  8430. x.YiMiao,
  8431. x.FirstItemRemark
  8432. })
  8433. .Where(x => x.Id == id)
  8434. .ExecuteCommandAsync();
  8435. if (upd < 1) return Ok(JsonView(false));
  8436. }
  8437. //消息通知
  8438. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8439. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8440. }
  8441. /// <summary>
  8442. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8443. /// </summary>
  8444. /// <returns></returns>
  8445. [HttpPost]
  8446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8447. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8448. {
  8449. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8450. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8451. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8452. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8453. info.OutsideJJPay = dto.OutsideJJPay;
  8454. info.OutsideGWPay = dto.OutsideGWPay;
  8455. info.OutsideTDPay = dto.OutsideTDPay;
  8456. info.AirJJ = dto.AirJJ;
  8457. info.AirGW = dto.AirGW;
  8458. info.AirTD = dto.AirTD;
  8459. info.CityTranffic = dto.CityTranffic;
  8460. info.TwoItemRemark = dto.TwoItemRemark;
  8461. info.SumJJC = dto.ChoiceTwoJJ;
  8462. info.SumGWC = dto.ChoiceTwoGW;
  8463. info.SumTDC = dto.ChoiceTwoTD;
  8464. int id = dto.Id;
  8465. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8466. if (id <= 0) //add
  8467. {
  8468. info.CreateUserId = dto.CurrUserId;
  8469. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8470. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8471. if (addId <= 0) return Ok(JsonView(false));
  8472. id = addId;
  8473. }
  8474. else //update
  8475. {
  8476. var upd = await _sqlSugar.Updateable(info)
  8477. .UpdateColumns(x => new {
  8478. x.SumJJC,
  8479. x.OutsideJJPay,
  8480. x.SumGWC,
  8481. x.OutsideGWPay,
  8482. x.SumTDC,
  8483. x.OutsideTDPay,
  8484. x.AirJJ,
  8485. x.AirGW,
  8486. x.AirTD,
  8487. x.CityTranffic,
  8488. x.TwoItemRemark
  8489. })
  8490. .Where(x => x.Id == id)
  8491. .ExecuteCommandAsync();
  8492. if (upd <1) return Ok(JsonView(false));
  8493. }
  8494. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8495. gwcItemTotal = info.AirGW + info.CityTranffic;
  8496. tdcItemTotal = info.AirTD + info.CityTranffic;
  8497. //消息通知
  8498. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8499. return Ok(JsonView(new
  8500. {
  8501. parentId = id,
  8502. choiceTwoJJ = dto.ChoiceTwoJJ,
  8503. jjcItemTotal = jjcItemTotal,
  8504. choiceTwoGW = dto.ChoiceTwoGW,
  8505. gwcItemTotal = gwcItemTotal,
  8506. choiceTwoTD = dto.ChoiceTwoTD,
  8507. tdcItemTotal = tdcItemTotal
  8508. }));
  8509. }
  8510. /// <summary>
  8511. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8512. /// </summary>
  8513. /// <returns></returns>
  8514. [HttpPost]
  8515. [ApiExplorerSettings(IgnoreApi = true)]
  8516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8517. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8518. {
  8519. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8520. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8521. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8522. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8523. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8524. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8525. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8526. var infos = infos1.Select(x => new Grp_DayAndCost
  8527. {
  8528. Id = x.Id,
  8529. DiId = dto.DiId,
  8530. Type = dto.FeeType,
  8531. Days = x.Days,
  8532. NationalTravelFeeId = x.NationalTravelFeeId,
  8533. Cost = x.Cost,
  8534. Currency = x.Currency,
  8535. SubTotal = x.SubTotal,
  8536. CreateUserId = dto.CurrUserId
  8537. })
  8538. .ToList();
  8539. var adds = infos.Where(x => x.Id <= 0).ToList();
  8540. var upds = infos.Where(x => x.Id > 0).ToList();
  8541. if (adds.Count > 0)
  8542. {
  8543. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8544. if (add < 1) return Ok(JsonView(false));
  8545. }
  8546. if (upds.Count > 0)
  8547. {
  8548. var upd = await _sqlSugar.Updateable(adds)
  8549. .UpdateColumns(x => new
  8550. {
  8551. x.Days,
  8552. x.NationalTravelFeeId,
  8553. x.Cost,
  8554. x.Currency,
  8555. x.SubTotal
  8556. })
  8557. .WhereColumns(x => new { x.Id })
  8558. .ExecuteCommandAsync();
  8559. if (upd < 1) return Ok(JsonView(false));
  8560. }
  8561. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8562. //消息通知
  8563. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8564. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8565. return Ok(JsonView(new { itemTotal = itemTotal }));
  8566. }
  8567. /// <summary>
  8568. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8569. /// </summary>
  8570. /// <returns></returns>
  8571. [HttpPost]
  8572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8573. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8574. {
  8575. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8576. int subId = dto.SubId, feeType = dto.FeeType;
  8577. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8578. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8579. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8580. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8581. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8582. subInfo.Id = subId;
  8583. subInfo.DiId = dto.DiId;
  8584. if (feeType == 3) subInfo.Type = 1;
  8585. else if (feeType == 4) subInfo.Type = 2;
  8586. else if (feeType == 5) subInfo.Type = 3;
  8587. else if (feeType == 6) subInfo.Type = 4;
  8588. subInfo.CreateUserId = dto.CurrUserId;
  8589. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8590. if (parentId < 1) return Ok(JsonView(false));
  8591. //子表op
  8592. if (subId < 1)
  8593. {
  8594. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8595. if (subAdd < 1) return Ok(JsonView(false));
  8596. }
  8597. else
  8598. {
  8599. var subUpd = await _sqlSugar.Updateable(subInfo)
  8600. .UpdateColumns(x => new
  8601. {
  8602. x.Days,
  8603. x.NationalTravelFeeId,
  8604. x.Cost,
  8605. x.Currency,
  8606. x.SubTotal
  8607. })
  8608. .WhereColumns(x => new { x.Id })
  8609. .ExecuteCommandAsync();
  8610. if (subUpd < 1) return Ok(JsonView(false));
  8611. }
  8612. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8613. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8614. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8615. }
  8616. /// <summary>
  8617. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8618. /// </summary>
  8619. /// <returns></returns>
  8620. [HttpPost]
  8621. [ApiExplorerSettings(IgnoreApi = true)]
  8622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8623. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8624. {
  8625. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8626. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8627. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8628. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8629. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8630. {
  8631. Id = x.Id,
  8632. Diid = dto.DiId,
  8633. SetDataId = x.SetDataId,
  8634. Index = x.Index,
  8635. Cost = x.Cost,
  8636. Currency = x.Currency,
  8637. SubTotal = x.SubTotal,
  8638. CreateUserId = dto.CurrUserId,
  8639. Remark = x.Remark
  8640. }).ToList();
  8641. var adds = infos.Where(x => x.Id <= 0).ToList();
  8642. var upds = infos.Where(x => x.Id > 0).ToList();
  8643. if (adds.Count > 0)
  8644. {
  8645. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8646. if (add < 1) return Ok(JsonView(false));
  8647. }
  8648. if (upds.Count > 0)
  8649. {
  8650. var upd = await _sqlSugar.Updateable(adds)
  8651. .UpdateColumns(x => new
  8652. {
  8653. x.Index,
  8654. x.SetDataId,
  8655. x.Cost,
  8656. x.Currency,
  8657. x.SubTotal,
  8658. x.Remark
  8659. })
  8660. .WhereColumns(x => new { x.Id })
  8661. .ExecuteCommandAsync();
  8662. if (upd < 1) return Ok(JsonView(false));
  8663. }
  8664. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8665. //消息通知
  8666. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8667. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8668. return Ok(JsonView(new { itemTotal = itemTotal }));
  8669. }
  8670. /// <summary>
  8671. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8672. /// </summary>
  8673. /// <returns></returns>
  8674. [HttpPost]
  8675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8676. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8677. {
  8678. int subId = dto.SubId;
  8679. int diId = dto.Diid;
  8680. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8681. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8682. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8683. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8684. subInfo.Id = subId;
  8685. subInfo.Diid = dto.Diid;
  8686. subInfo.CreateUserId = dto.CurrUserId;
  8687. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8688. if (parentId < 1) return Ok(JsonView(false));
  8689. #region 子表op
  8690. if (subId < 1)//add
  8691. {
  8692. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8693. if (subAdd < 1) return Ok(JsonView(false));
  8694. }
  8695. else //upd
  8696. {
  8697. var subUpd = await _sqlSugar.Updateable(subInfo)
  8698. .UpdateColumns(x => new
  8699. {
  8700. x.Index,
  8701. x.SetDataId,
  8702. x.Cost,
  8703. x.Currency,
  8704. x.SubTotal,
  8705. x.Remark
  8706. })
  8707. .WhereColumns(x => new { x.Id })
  8708. .ExecuteCommandAsync();
  8709. if (subUpd < 1) return Ok(JsonView(false));
  8710. }
  8711. #endregion
  8712. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8713. //消息通知
  8714. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8715. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8716. }
  8717. /// <summary>
  8718. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8719. /// </summary>
  8720. /// <returns></returns>
  8721. [HttpPost]
  8722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8723. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8724. {
  8725. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8726. if (data.Code != 0)
  8727. {
  8728. return Ok(JsonView(false, data.Msg));
  8729. }
  8730. return Ok(JsonView(true, "操作成功!", data.Data));
  8731. }
  8732. /// <summary>
  8733. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8734. /// </summary>
  8735. /// <param name="dto"></param>
  8736. /// <returns></returns>
  8737. [HttpPost]
  8738. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8739. {
  8740. var data = new Grp_DayOtherPrice()
  8741. {
  8742. Id = dto.Id,
  8743. IsDel = 1,
  8744. DeleteUserId = dto.DeleteUserId,
  8745. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8746. };
  8747. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8748. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  8749. return Ok(JsonView(false,"删除失败!"));
  8750. }
  8751. #endregion
  8752. #endregion
  8753. #region 签证费用录入
  8754. /// <summary>
  8755. /// 根据diid查询签证费用列表
  8756. /// </summary>
  8757. /// <param name="dto"></param>
  8758. /// <returns></returns>
  8759. [HttpPost]
  8760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8761. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  8762. {
  8763. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  8764. if (groupData.Code != 0)
  8765. {
  8766. return Ok(JsonView(false, groupData.Msg));
  8767. }
  8768. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8769. }
  8770. /// <summary>
  8771. /// 根据签证费用Id查询单条数据及c表数据
  8772. /// </summary>
  8773. /// <param name="dto"></param>
  8774. /// <returns></returns>
  8775. [HttpPost]
  8776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8777. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  8778. {
  8779. Result groupData = await _visaPriceRep.PostVisaById(dto);
  8780. if (groupData.Code != 0)
  8781. {
  8782. return Ok(JsonView(false, groupData.Msg));
  8783. }
  8784. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8785. }
  8786. /// <summary>
  8787. /// 签证费用删除
  8788. /// </summary>
  8789. /// <param name="dto"></param>
  8790. /// <returns></returns>
  8791. [HttpPost]
  8792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8793. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  8794. {
  8795. _sqlSugar.BeginTran();
  8796. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  8797. if (!res)
  8798. {
  8799. _sqlSugar.RollbackTran();
  8800. return Ok(JsonView(false, "删除失败"));
  8801. }
  8802. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  8803. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  8804. .SetColumns(a => new Grp_CreditCardPayment()
  8805. {
  8806. IsDel = 1,
  8807. DeleteUserId = dto.DeleteUserId,
  8808. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8809. })
  8810. .ExecuteCommand();
  8811. if (resSub < 1)
  8812. {
  8813. _sqlSugar.RollbackTran();
  8814. return Ok(JsonView(false, "删除失败"));
  8815. }
  8816. _sqlSugar.CommitTran();
  8817. return Ok(JsonView(true, "删除成功!"));
  8818. }
  8819. /// <summary>
  8820. /// 签证费用录入下拉框初始化
  8821. /// </summary>
  8822. /// <returns></returns>
  8823. [HttpPost]
  8824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8825. public async Task<IActionResult> VisaPriceAddSelect()
  8826. {
  8827. //支付方式
  8828. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  8829. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  8830. //币种
  8831. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  8832. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  8833. //乘客类型
  8834. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  8835. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  8836. //卡类型
  8837. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  8838. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  8839. //代办费类型
  8840. var agencyFeeTypeData = new List<dynamic>() {
  8841. new { id = 0 , Text = "未选择" },
  8842. new { id = 1 , Text = "小公务" },
  8843. new { id = 2 , Text = "大公务" },
  8844. };
  8845. //签证费用标准国家Data
  8846. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  8847. var data = new
  8848. {
  8849. Payment = _Payment,
  8850. CurrencyList = _CurrencyList,
  8851. PassengerType = _PassengerType,
  8852. BankCard = _BankCard,
  8853. AgencyFeeType = agencyFeeTypeData,
  8854. CountryFeeData = visaCountryFeeData
  8855. };
  8856. return Ok(JsonView(true, "查询成功!", data));
  8857. }
  8858. /// <summary>
  8859. /// 签证费用录入操作(Status:1.新增,2.修改)
  8860. /// </summary>
  8861. /// <param name="dto"></param>
  8862. /// <returns></returns>
  8863. [HttpPost]
  8864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8865. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  8866. {
  8867. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  8868. if (groupData.Code != 0)
  8869. {
  8870. return Ok(JsonView(false, groupData.Msg));
  8871. }
  8872. #region 应用推送
  8873. try
  8874. {
  8875. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  8876. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  8877. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8878. //2024-10-21 新增LZ UID
  8879. var userIds = new List<int>() { 21 };
  8880. string title = $"系统通知";
  8881. string content = "";
  8882. var diId = dto.DiId;
  8883. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  8884. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  8885. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8886. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8887. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  8888. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  8889. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  8890. }
  8891. catch (Exception ex)
  8892. {
  8893. }
  8894. #endregion
  8895. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8896. }
  8897. #endregion
  8898. #region 签证提成录入
  8899. /// <summary>
  8900. /// 签证提成录入
  8901. /// 基础数据
  8902. /// </summary>
  8903. /// <param name="_dto"></param>
  8904. /// <returns></returns>
  8905. [HttpGet]
  8906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8907. public async Task<IActionResult> VisaCommissionInit()
  8908. {
  8909. return Ok(await _visaCommissionRep.Init());
  8910. }
  8911. /// <summary>
  8912. /// 签证提成录入
  8913. /// Item
  8914. /// </summary>
  8915. /// <param name="_dto"></param>
  8916. /// <returns></returns>
  8917. [HttpPost]
  8918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8919. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  8920. {
  8921. var validator = new VisaCommissionItemDtoValidator();
  8922. var validatorRes = await validator.ValidateAsync(_dto);
  8923. if (!validatorRes.IsValid)
  8924. {
  8925. StringBuilder sb = new StringBuilder();
  8926. foreach (var item in validatorRes.Errors)
  8927. {
  8928. sb.AppendLine(item.ErrorMessage);
  8929. }
  8930. return Ok(JsonView(false, sb.ToString()));
  8931. }
  8932. return Ok(await _visaCommissionRep.Item(_dto));
  8933. }
  8934. /// <summary>
  8935. /// 签证提成录入
  8936. /// Save
  8937. /// </summary>
  8938. /// <param name="_dto"></param>
  8939. /// <returns></returns>
  8940. [HttpPost]
  8941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8942. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  8943. {
  8944. //参数验证
  8945. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  8946. foreach (var item in _dto.Items)
  8947. {
  8948. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  8949. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  8950. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  8951. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  8952. }
  8953. return Ok(await _visaCommissionRep.Save(_dto));
  8954. }
  8955. /// <summary>
  8956. /// 签证提成录入
  8957. /// Create
  8958. /// </summary>
  8959. /// <param name="_dto"></param>
  8960. /// <returns></returns>
  8961. [HttpPost]
  8962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8963. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  8964. {
  8965. var validator = new VisaCommissionCreateDtoValidator();
  8966. var validatorRes = await validator.ValidateAsync(_dto);
  8967. if (!validatorRes.IsValid)
  8968. {
  8969. StringBuilder sb = new StringBuilder();
  8970. foreach (var item in validatorRes.Errors)
  8971. {
  8972. sb.AppendLine(item.ErrorMessage);
  8973. }
  8974. return Ok(JsonView(false, sb.ToString()));
  8975. }
  8976. return Ok(await _visaCommissionRep.Create(_dto));
  8977. }
  8978. /// <summary>
  8979. /// 签证提成录入
  8980. /// Put(编辑)
  8981. /// </summary>
  8982. /// <param name="id"></param>
  8983. /// <param name="_dto"></param>
  8984. /// <returns></returns>
  8985. [HttpPut]
  8986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8987. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  8988. {
  8989. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  8990. var validator = new VisaCommissionCreateDtoValidator();
  8991. var validatorRes = await validator.ValidateAsync(_dto);
  8992. if (!validatorRes.IsValid)
  8993. {
  8994. StringBuilder sb = new StringBuilder();
  8995. foreach (var item in validatorRes.Errors)
  8996. {
  8997. sb.AppendLine(item.ErrorMessage);
  8998. }
  8999. return Ok(JsonView(false, sb.ToString()));
  9000. }
  9001. return Ok(await _visaCommissionRep.Edit(id, _dto));
  9002. }
  9003. /// <summary>
  9004. /// 签证提成录入
  9005. /// Del
  9006. /// </summary>
  9007. /// <param name="id"></param>
  9008. /// <param name="currUserId"></param>
  9009. /// <returns></returns>
  9010. [HttpPost]
  9011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9012. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  9013. {
  9014. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  9015. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  9016. return Ok(await _visaCommissionRep.Del(id, currUserId));
  9017. }
  9018. #endregion
  9019. #region op费用录入
  9020. /// <summary>
  9021. /// 根据diid查询op费用列表
  9022. /// </summary>
  9023. /// <param name="dto"></param>
  9024. /// <returns></returns>
  9025. [HttpPost]
  9026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9027. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  9028. {
  9029. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  9030. if (groupData.Code != 0)
  9031. {
  9032. return Ok(JsonView(false, groupData.Msg));
  9033. }
  9034. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9035. }
  9036. /// <summary>
  9037. /// 根据op费用Id查询单条数据及c表数据
  9038. /// </summary>
  9039. /// <param name="dto"></param>
  9040. /// <returns></returns>
  9041. [HttpPost]
  9042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9043. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  9044. {
  9045. try
  9046. {
  9047. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  9048. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  9049. var data = new
  9050. {
  9051. CarTouristGuideGround = _groupData,
  9052. CreditCardPayment = _creditCardPayment
  9053. };
  9054. return Ok(JsonView(true, "查询成功!", data));
  9055. }
  9056. catch (Exception ex)
  9057. {
  9058. return Ok(JsonView(false, "程序错误!"));
  9059. }
  9060. }
  9061. /// <summary>
  9062. /// op费用删除
  9063. /// </summary>
  9064. /// <param name="dto"></param>
  9065. /// <returns></returns>
  9066. [HttpPost]
  9067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9068. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  9069. {
  9070. try
  9071. {
  9072. _sqlSugar.BeginTran();
  9073. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  9074. if (!res)
  9075. {
  9076. return Ok(JsonView(false, "删除失败"));
  9077. }
  9078. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  9079. {
  9080. IsDel = 1,
  9081. DeleteUserId = dto.DeleteUserId,
  9082. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9083. }).ExecuteCommandAsync();
  9084. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  9085. {
  9086. IsDel = 1,
  9087. DeleteUserId = dto.DeleteUserId,
  9088. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9089. }).ExecuteCommandAsync();
  9090. #region 删除超支相关数据
  9091. //删除导入的超支数据
  9092. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  9093. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  9094. {
  9095. IsDel = 1,
  9096. DeleteUserId = dto.DeleteUserId,
  9097. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9098. }).ExecuteCommand();
  9099. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  9100. {
  9101. IsDel = 1,
  9102. DeleteUserId = dto.DeleteUserId,
  9103. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9104. }).ExecuteCommand();
  9105. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  9106. {
  9107. IsDel = 1,
  9108. DeleteUserId = dto.DeleteUserId,
  9109. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9110. }).ExecuteCommand();
  9111. #endregion
  9112. _sqlSugar.CommitTran();
  9113. return Ok(JsonView(true, "删除成功!"));
  9114. }
  9115. catch (Exception ex)
  9116. {
  9117. _sqlSugar.RollbackTran();
  9118. return Ok(JsonView(false, "程序错误!" + ex.Message));
  9119. }
  9120. }
  9121. /// <summary>
  9122. /// op费用录入操作(Status:1.新增,2.修改)
  9123. /// </summary>
  9124. /// <param name="dto"></param>
  9125. /// <returns></returns>
  9126. [HttpPost]
  9127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9128. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  9129. {
  9130. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  9131. if (groupData.Code != 0)
  9132. {
  9133. return Ok(JsonView(false, groupData.Msg));
  9134. }
  9135. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9136. }
  9137. /// <summary>
  9138. /// 填写费用详细页面初始化绑定
  9139. /// </summary>
  9140. /// <param name="dto"></param>
  9141. /// <returns></returns>
  9142. [HttpPost]
  9143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9144. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  9145. {
  9146. try
  9147. {
  9148. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  9149. if (groupData.Code != 0)
  9150. {
  9151. return Ok(JsonView(false, groupData.Msg));
  9152. }
  9153. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9154. }
  9155. catch (Exception ex)
  9156. {
  9157. return Ok(JsonView(false, ex.Message));
  9158. }
  9159. }
  9160. /// <summary>
  9161. /// 根据op费用Id查询详细数据
  9162. /// </summary>
  9163. /// <param name="dto"></param>
  9164. /// <returns></returns>
  9165. [HttpPost]
  9166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9167. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  9168. {
  9169. try
  9170. {
  9171. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  9172. if (groupData.Code != 0)
  9173. {
  9174. return Ok(JsonView(false, groupData.Msg));
  9175. }
  9176. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9177. }
  9178. catch (Exception ex)
  9179. {
  9180. return Ok(JsonView(false, ex.Message));
  9181. }
  9182. }
  9183. /// <summary>
  9184. /// OP费用录入填写详情
  9185. /// </summary>
  9186. /// <param name="dto"></param>
  9187. /// <returns></returns>
  9188. [HttpPost]
  9189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9190. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  9191. {
  9192. try
  9193. {
  9194. #region 参数校验
  9195. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  9196. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  9197. if (di == null) return Ok(JsonView(false, "团组错误!"));
  9198. #endregion
  9199. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  9200. if (groupData.Code != 0)
  9201. {
  9202. return Ok(JsonView(false, groupData.Msg));
  9203. }
  9204. //自动审核
  9205. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  9206. #region 应用推送
  9207. try
  9208. {
  9209. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9210. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9211. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9212. //2024-10-21 新增LZ UID
  9213. var userIds = new List<int>() { 21 };
  9214. string title = $"系统通知";
  9215. var diId = dto.DiId;
  9216. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9217. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9218. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  9219. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9220. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  9221. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  9222. }
  9223. catch (Exception ex)
  9224. {
  9225. }
  9226. #endregion
  9227. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9228. }
  9229. catch (Exception ex)
  9230. {
  9231. return Ok(JsonView(false, ex.Message));
  9232. }
  9233. }
  9234. /// <summary>
  9235. /// 获取三公详细所有城市
  9236. /// </summary>
  9237. /// <returns></returns>
  9238. [HttpGet]
  9239. public IActionResult OpCarCityResult()
  9240. {
  9241. var jw = JsonView(false);
  9242. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  9243. {
  9244. x.Id,
  9245. x.Country,
  9246. x.City,
  9247. }).ToList();
  9248. if (data.Count > 0)
  9249. {
  9250. jw = JsonView(true, "获取成功!", data);
  9251. }
  9252. else
  9253. {
  9254. jw.Msg = "城市数据为空!";
  9255. jw.Data = new string[0];
  9256. }
  9257. return Ok(jw);
  9258. }
  9259. /// <summary>
  9260. /// 导出地接费用明细
  9261. /// </summary>
  9262. /// <param name="dto"></param>
  9263. /// <returns></returns>
  9264. [HttpPost]
  9265. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  9266. {
  9267. var jw = JsonView(false);
  9268. if (dto.Diid < 1)
  9269. {
  9270. jw.Msg = "请输入正确的diid!";
  9271. return Ok(jw);
  9272. }
  9273. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  9274. if (group == null)
  9275. {
  9276. jw.Msg = "未找到团组信息!";
  9277. return Ok(jw);
  9278. }
  9279. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  9280. if (localGuideArr.Count == 0)
  9281. {
  9282. jw.Msg = "该团组暂无地接信息!";
  9283. return Ok(jw);
  9284. }
  9285. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  9286. var overspendSoure = new Dictionary<int, int>
  9287. {
  9288. { 91, 982 }, //车
  9289. { 92 , 1059} ,//导游
  9290. { 994 , 1073}, //翻译
  9291. { 988 , 1074 }, //早餐
  9292. { 93 , 1075 }, //午餐
  9293. { 989 , 1076 }, //晚餐
  9294. };
  9295. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  9296. foreach (var groupArr in localGroup)
  9297. {
  9298. var keyValue = groupArr.Key;
  9299. if (int.TryParse(keyValue, out int cityid))
  9300. {
  9301. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  9302. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  9303. }
  9304. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  9305. foreach (var item in groupArr)
  9306. {
  9307. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  9308. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  9309. new Grp_CarTouristGuideGroundReservationsContentExtend
  9310. {
  9311. Count = a.Count,
  9312. CreateTime = a.CreateTime,
  9313. CreateUserId = a.CreateUserId,
  9314. CTGGRId = a.CTGGRId,
  9315. Currency = a.Currency,
  9316. DatePrice = a.DatePrice,
  9317. DeleteTime = a.DeleteTime,
  9318. DeleteUserId = a.DeleteUserId,
  9319. DiId = a.DiId,
  9320. Id = a.Id,
  9321. IsDel = a.IsDel,
  9322. Price = a.Price,
  9323. PriceContent = a.PriceContent,
  9324. Remark = a.Remark,
  9325. SId = a.SId,
  9326. SidName = b.Name,
  9327. Units = a.Units,
  9328. }
  9329. ).ToList();
  9330. if (content.Count > 0)
  9331. {
  9332. contentArr.Add(content);
  9333. }
  9334. }
  9335. //open excel
  9336. //set excel
  9337. //save excel
  9338. try
  9339. {
  9340. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  9341. IWorkbook workbook;
  9342. if (Path.GetExtension(filePath).ToLower() == ".xls")
  9343. {
  9344. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  9345. }
  9346. else
  9347. {
  9348. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  9349. }
  9350. ISheet sheet = workbook.GetSheetAt(0);
  9351. var rowStartIndex = 2;
  9352. var clounmCount = 10;
  9353. var initStyleRow = sheet.GetRow(2);
  9354. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  9355. //var overspendArrDetail =
  9356. var existsId = new List<CarCompare>();
  9357. var lastElem = arr.Last();
  9358. var thisSid = -1;
  9359. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  9360. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  9361. {
  9362. Name = "未知币种!",
  9363. Remark = "未知币种!",
  9364. };
  9365. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  9366. Action cloneRowFn = () =>
  9367. {
  9368. rowStartIndex++;
  9369. var cloneRow = sheet.CreateRow(rowStartIndex);
  9370. // 复制样式
  9371. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  9372. {
  9373. ICell sourceCell = initStyleRow.GetCell(i);
  9374. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  9375. // 确保单元格存在样式
  9376. if (sourceCell.CellStyle != null)
  9377. {
  9378. targetCell.CellStyle = sourceCell.CellStyle;
  9379. }
  9380. }
  9381. };
  9382. var mergeRow = () =>
  9383. {
  9384. for (int i = 2; i < sheet.LastRowNum; i++)
  9385. {
  9386. var row = sheet.GetRow(i);
  9387. var cellFirst = row.GetCell(0);
  9388. var thisIndex = i + 1;
  9389. while (thisIndex < sheet.LastRowNum)
  9390. {
  9391. var nextRow = sheet.GetRow(thisIndex);
  9392. var nextCellFirst = nextRow.GetCell(0);
  9393. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  9394. {
  9395. thisIndex++;
  9396. }
  9397. else
  9398. {
  9399. break;
  9400. }
  9401. }
  9402. thisIndex--;
  9403. if (thisIndex != i)
  9404. {
  9405. //合并row
  9406. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9407. i, // 起始行索引(0-based)
  9408. thisIndex, // 结束行索引(0-based)
  9409. 0, // 起始列索引(0-based)
  9410. 0 // 结束列索引(0-based)
  9411. );
  9412. sheet.AddMergedRegion(cellRangeAddress);
  9413. i = thisIndex;
  9414. }
  9415. }
  9416. };
  9417. var chaoshiNumber = 0;
  9418. var totalNumber = 0.00M;
  9419. string lastStr = "";
  9420. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  9421. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  9422. {
  9423. b.IsAuditGM,
  9424. x.Id,
  9425. x.Area,
  9426. b.PayPercentage,
  9427. b.PayMoney,
  9428. }).ToList();
  9429. string yesPayment = "", noPayment = "";
  9430. foreach (var item in queryCarArrByCityAndDiid)
  9431. {
  9432. if (item.IsAuditGM == 1)
  9433. {
  9434. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  9435. }
  9436. else
  9437. {
  9438. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  9439. }
  9440. }
  9441. lastStr = yesPayment + noPayment;
  9442. foreach (var item in arr)
  9443. {
  9444. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  9445. {
  9446. if (thisSid != item.SId)
  9447. {
  9448. if (thisSid == -1)
  9449. {
  9450. thisSid = item.SId;
  9451. }
  9452. else
  9453. {
  9454. //合并小计行
  9455. //创建合并区域的实例
  9456. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9457. rowStartIndex, // 起始行索引(0-based)
  9458. rowStartIndex, // 结束行索引(0-based)
  9459. 0, // 起始列索引(0-based)
  9460. 3 // 结束列索引(0-based)
  9461. );
  9462. sheet.AddMergedRegion(cellRangeAddress);
  9463. var CellStyle = workbook.CreateCellStyle();
  9464. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9465. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  9466. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  9467. for (int i = 0; i <= clounmCount; i++)
  9468. {
  9469. if (i > 6)
  9470. {
  9471. var CellStyle1 = workbook.CreateCellStyle();
  9472. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9473. IFont Font = workbook.CreateFont(); // 创建字体
  9474. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  9475. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9476. CellStyle1.SetFont(Font);
  9477. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  9478. }
  9479. else
  9480. {
  9481. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  9482. }
  9483. }
  9484. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  9485. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  9486. //超时合计
  9487. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  9488. //超时数
  9489. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  9490. //超时合计费用
  9491. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  9492. thisSid = item.SId;
  9493. cloneRowFn();
  9494. chaoshiNumber = 0;
  9495. totalNumber = 0;
  9496. }
  9497. }
  9498. IRow row = sheet.GetRow(rowStartIndex);
  9499. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9500. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  9501. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  9502. if (isOpenOverspendSoure)
  9503. {
  9504. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9505. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  9506. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  9507. }
  9508. for (int i = 0; i <= clounmCount; i++)
  9509. {
  9510. var cell = row.GetCell(i);
  9511. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  9512. if (cell == null)
  9513. {
  9514. cell = row.CreateCell(i);
  9515. }
  9516. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  9517. fontRed.CloneStyleFrom(cell.CellStyle);
  9518. IFont Font = workbook.CreateFont(); // 创建字体
  9519. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  9520. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9521. fontRed.SetFont(Font);
  9522. byte[] rgb = new byte[3] { 255, 242, 204 };
  9523. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  9524. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  9525. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  9526. if (workbook is XSSFWorkbook)
  9527. {
  9528. BackgroundColor255_242_204.FillForegroundColor = 0;
  9529. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  9530. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  9531. }
  9532. else
  9533. {
  9534. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  9535. }
  9536. if (i == 1 || i > 6)
  9537. {
  9538. if (i > 6)
  9539. {
  9540. fontRed.FillForegroundColor = 0;
  9541. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  9542. fontRed.FillPattern = FillPattern.SolidForeground;
  9543. }
  9544. cell.CellStyle = fontRed;
  9545. }
  9546. if (i > 2 && i < 7)
  9547. {
  9548. cell.CellStyle = BackgroundColor255_242_204;
  9549. }
  9550. cell.SetCellValue(setCellValue); //写入单元格
  9551. }
  9552. if (overspendSoure.ContainsKey(thisSid))
  9553. {
  9554. var overspendId = overspendSoure[thisSid];
  9555. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9556. }
  9557. cloneRowFn();
  9558. existsId.Add(new CarCompare
  9559. {
  9560. DataPrice = item.DatePrice.ObjToDate(),
  9561. Sid = item.SId
  9562. });
  9563. }
  9564. if (item.Equals(lastElem))
  9565. {
  9566. //合并小计行
  9567. //创建合并区域的实例
  9568. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9569. rowStartIndex, // 起始行索引(0-based)
  9570. rowStartIndex, // 结束行索引(0-based)
  9571. 0, // 起始列索引(0-based)
  9572. 3 // 结束列索引(0-based)
  9573. );
  9574. sheet.AddMergedRegion(cellRangeAddress);
  9575. var CellStyle = workbook.CreateCellStyle();
  9576. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9577. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  9578. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  9579. for (int i = 0; i <= clounmCount; i++)
  9580. {
  9581. if (i > 6)
  9582. {
  9583. var CellStyle1 = workbook.CreateCellStyle();
  9584. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9585. IFont Font = workbook.CreateFont(); // 创建字体
  9586. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  9587. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9588. CellStyle1.SetFont(Font);
  9589. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  9590. }
  9591. else
  9592. {
  9593. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  9594. }
  9595. }
  9596. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  9597. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  9598. //超时合计
  9599. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  9600. //超时数
  9601. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  9602. //超时合计费用
  9603. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  9604. cloneRowFn();
  9605. // 创建合并区域的实例
  9606. cellRangeAddress = new CellRangeAddress(
  9607. rowStartIndex, // 起始行索引(0-based)
  9608. rowStartIndex, // 结束行索引(0-based)
  9609. 0, // 起始列索引(0-based)
  9610. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  9611. );
  9612. // 添加合并区域
  9613. sheet.AddMergedRegion(cellRangeAddress);
  9614. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  9615. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  9616. }
  9617. }
  9618. mergeRow();
  9619. // 保存修改后的Excel文件到新文件
  9620. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  9621. // new FileStream(newFilePath, FileMode.CreateNew)
  9622. using (var stream = new MemoryStream())
  9623. {
  9624. workbook.Write(stream, true);
  9625. stream.Flush();
  9626. stream.Seek(0, SeekOrigin.Begin);
  9627. MemoryStream memoryStream = new MemoryStream();
  9628. stream.CopyTo(memoryStream);
  9629. memoryStream.Seek(0, SeekOrigin.Begin);
  9630. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  9631. }
  9632. workbook.Close();
  9633. workbook.Dispose();
  9634. }
  9635. catch (Exception ex)
  9636. {
  9637. jw.Msg = "出现异常!" + ex.Message;
  9638. return Ok(jw);
  9639. }
  9640. }
  9641. if (Zips.Count > 0)
  9642. {
  9643. IOOperatorHelper io = new IOOperatorHelper();
  9644. var byts = io.ConvertZipStream(Zips);
  9645. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  9646. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  9647. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  9648. }
  9649. else
  9650. {
  9651. jw.Msg = "暂无生成文件!";
  9652. }
  9653. return Ok(jw);
  9654. }
  9655. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  9656. {
  9657. string outStr = string.Empty;
  9658. switch (i)
  9659. {
  9660. case 0:
  9661. outStr = arr[0].SidName;
  9662. break;
  9663. case 1:
  9664. outStr = arr[0].DataPriceStr;
  9665. break;
  9666. case 2:
  9667. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  9668. break;
  9669. case 4:
  9670. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  9671. break;
  9672. case 7:
  9673. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9674. {
  9675. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  9676. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  9677. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  9678. }
  9679. break;
  9680. case 8:
  9681. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9682. {
  9683. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  9684. }
  9685. break;
  9686. case 9:
  9687. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9688. {
  9689. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  9690. }
  9691. break;
  9692. case 10:
  9693. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9694. {
  9695. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  9696. }
  9697. break;
  9698. }
  9699. return outStr;
  9700. }
  9701. #region OP行程单
  9702. /// <summary>
  9703. /// OP行程单初始化
  9704. /// </summary>
  9705. /// <param name="dto"></param>
  9706. /// <returns></returns>
  9707. [HttpPost]
  9708. public IActionResult InitOpTravel(InitOpTravelDto dto)
  9709. {
  9710. var jw = JsonView(false);
  9711. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  9712. var group = groupList.First();
  9713. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  9714. if (group == null)
  9715. {
  9716. jw.Msg = "暂无团组!";
  9717. return Ok(jw);
  9718. }
  9719. group = groupList.Find(x => x.Id == diid);
  9720. if (group == null)
  9721. {
  9722. jw.Msg = "请输入正确的团组ID!";
  9723. return Ok(jw);
  9724. }
  9725. string city = string.Empty;
  9726. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  9727. if (blackCode.Count > 0)
  9728. {
  9729. var black = blackCode.First();
  9730. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  9731. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  9732. if (blackSp.Length > 0)
  9733. {
  9734. try
  9735. {
  9736. var cityArrCode = new List<string>(20);
  9737. foreach (var item in blackSp)
  9738. {
  9739. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  9740. var IndexSelect = itemSp[2];
  9741. var cityArrCodeLength = cityArrCode.Count - 1;
  9742. var startCity = IndexSelect.Substring(0, 3);
  9743. if (cityArrCodeLength > 0)
  9744. {
  9745. var arrEndCity = cityArrCode[cityArrCodeLength];
  9746. if (arrEndCity != startCity)
  9747. {
  9748. cityArrCode.Add(startCity.ToUpper());
  9749. }
  9750. }
  9751. else
  9752. {
  9753. cityArrCode.Add(startCity.ToUpper());
  9754. }
  9755. var endCity = IndexSelect.Substring(3, 3);
  9756. cityArrCode.Add(endCity.ToUpper());
  9757. }
  9758. var cityThree = string.Empty;
  9759. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  9760. cityThree = cityThree.TrimEnd(',');
  9761. if (string.IsNullOrWhiteSpace(cityThree))
  9762. {
  9763. throw new
  9764. Exception("error");
  9765. }
  9766. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  9767. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  9768. foreach (var item in cityArrCode)
  9769. {
  9770. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  9771. if (find != null)
  9772. {
  9773. city += find.City + "/";
  9774. }
  9775. else
  9776. {
  9777. city += item + "三字码未收入/";
  9778. }
  9779. }
  9780. city = city.TrimEnd('/');
  9781. }
  9782. catch (Exception e)
  9783. {
  9784. city = "黑屏代码格式不正确!";
  9785. }
  9786. }
  9787. }
  9788. else
  9789. {
  9790. city = "未录入黑屏代码";
  9791. }
  9792. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  9793. {
  9794. Date = x.Date,
  9795. Days = x.Days,
  9796. Diffgroup = x.Diffgroup,
  9797. Diid = x.Diid,
  9798. Traffic_First = x.Traffic_First,
  9799. Traffic_Second = x.Traffic_Second,
  9800. Trip = x.Trip,
  9801. WeekDay = x.WeekDay,
  9802. Id = x.Id
  9803. }).ToList();
  9804. jw.Data = new
  9805. {
  9806. groupList = groupList.Select(x => new
  9807. {
  9808. x.Id,
  9809. x.TeamName,
  9810. x.TourCode
  9811. }).ToList(),
  9812. groupInfo = new
  9813. {
  9814. group.VisitDays,
  9815. group.TourCode,
  9816. group.VisitPNumber,
  9817. group.TeamName,
  9818. city
  9819. },
  9820. OpTravelList
  9821. };
  9822. jw.Code = 200;
  9823. jw.Msg = "操作成功!";
  9824. return Ok(jw);
  9825. }
  9826. /// <summary>
  9827. /// 删除团组行程单
  9828. /// </summary>
  9829. /// <returns></returns>
  9830. [HttpPost]
  9831. public IActionResult DelTravel(DelOpTravelDto dto)
  9832. {
  9833. var jw = JsonView(false);
  9834. if (dto.UserId <= 0 || dto.Diid <= 0)
  9835. {
  9836. jw.Msg = "请输入正确的参数!";
  9837. return Ok(jw);
  9838. }
  9839. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  9840. .SetColumns(x => new Grp_TravelList
  9841. {
  9842. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9843. DeleteUserId = dto.UserId,
  9844. IsDel = 1,
  9845. }).ExecuteCommand();
  9846. jw = JsonView(true);
  9847. return Ok(jw);
  9848. }
  9849. /// <summary>
  9850. /// 行程单保存
  9851. /// </summary>
  9852. /// <returns></returns>
  9853. [HttpPost]
  9854. public IActionResult TravelSave(TravelSaveDto dto)
  9855. {
  9856. var jw = JsonView(false);
  9857. if (dto.Arr.Count > 0)
  9858. {
  9859. try
  9860. {
  9861. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  9862. .Where(x => dto.Arr.Select(x=>x.Id).Contains(x.Id))
  9863. .ToList();
  9864. _sqlSugar.BeginTran();
  9865. foreach (var item in dto.Arr)
  9866. {
  9867. if (item.Id == 0)
  9868. {
  9869. throw new Exception("请传入正确的Id");
  9870. }
  9871. //比较上一次的差异
  9872. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  9873. if (findTravel != null)
  9874. {
  9875. item.Trip = item.Trip.Replace("[++]", string.Empty);
  9876. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  9877. item.Trip = CheckStr(findTravel.Trip,item.Trip);
  9878. }
  9879. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  9880. .SetColumns(x => new Grp_TravelList
  9881. {
  9882. Trip = item.Trip
  9883. }).ExecuteCommand();
  9884. }
  9885. _sqlSugar.CommitTran();
  9886. jw = JsonView(true);
  9887. }
  9888. catch (Exception ex)
  9889. {
  9890. _sqlSugar.RollbackTran();
  9891. jw.Msg = "程序异常!" + ex.Message;
  9892. }
  9893. }
  9894. else
  9895. {
  9896. jw.Msg = "请传入正确的参数!";
  9897. }
  9898. return Ok(jw);
  9899. }
  9900. private string CheckStr(string original, string changed)
  9901. {
  9902. // 创建diff_match_patch对象
  9903. var dmp = new diff_match_patch();
  9904. // 计算差异
  9905. List<Diff> diffs = dmp.diff_main(original, changed);
  9906. // 清理和合并差异
  9907. dmp.diff_cleanupSemantic(diffs);
  9908. // 使用StringBuilder构建最终的字符串
  9909. StringBuilder finalString = new StringBuilder();
  9910. // 输出差异结果,并构建变动后的字符串
  9911. foreach (Diff diff in diffs)
  9912. {
  9913. switch (diff.operation)
  9914. {
  9915. case Operation.EQUAL:
  9916. // 相等的部分,直接添加到最终字符串
  9917. finalString.Append(diff.text);
  9918. break;
  9919. case Operation.INSERT:
  9920. // 插入的部分,添加标记并添加到最终字符串
  9921. finalString.Append("[++]" + diff.text + "[++]");
  9922. break;
  9923. case Operation.DELETE:
  9924. // 删除的部分,不添加到最终字符串
  9925. //finalString.Append("[++]" + diff.text + "[++]");
  9926. break;
  9927. }
  9928. }
  9929. // 输出变动后的字符串
  9930. return finalString.ToString();
  9931. }
  9932. private class tagContent
  9933. {
  9934. public DateTime Date { get; set; }
  9935. public string StartTag { get; set; }
  9936. public string EndTag { get; set; }
  9937. public string Content { get; set; }
  9938. public static int tagLength { get { return 3; } }
  9939. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  9940. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  9941. public bool IsFinally { get; set; }
  9942. }
  9943. private List<string> ExtractContentBetweenTags(string input, string tag)
  9944. {
  9945. List<string> results = new List<string>();
  9946. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  9947. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  9948. MatchCollection matches = Regex.Matches(input, pattern);
  9949. foreach (System.Text.RegularExpressions.Match match in matches)
  9950. {
  9951. // 提取匹配的内容(在两个标记之间的部分)
  9952. results.Add(match.Groups[1].Value);
  9953. }
  9954. return results;
  9955. }
  9956. /// <summary>
  9957. /// 导出行程单
  9958. /// </summary>
  9959. /// <param name="dto"></param>
  9960. /// <returns></returns>
  9961. [HttpPost]
  9962. public IActionResult ExportTravel(ExportTravelDto dto)
  9963. {
  9964. var jw = JsonView(false);
  9965. jw.Data = "";
  9966. int diid = 0;
  9967. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  9968. if (Find == null)
  9969. {
  9970. jw.Msg = "请选择正确的团组!";
  9971. return Ok(jw);
  9972. }
  9973. else
  9974. {
  9975. diid = Find.Id;
  9976. }
  9977. //数据源
  9978. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  9979. DataTable dtBlack = null;
  9980. try
  9981. {
  9982. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  9983. }
  9984. catch (Exception)
  9985. {
  9986. jw.Msg = "机票黑屏代码有误!";
  9987. return Ok(jw);
  9988. }
  9989. string CityStr = string.Empty;
  9990. if (dtBlack.Rows.Count == 0)
  9991. {
  9992. jw.Msg = "机票黑屏代码有误!";
  9993. return Ok(jw);
  9994. }
  9995. else
  9996. {
  9997. foreach (DataRow row in dtBlack.Rows)
  9998. {
  9999. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  10000. {
  10001. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  10002. return Ok(jw);
  10003. }
  10004. }
  10005. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  10006. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  10007. }
  10008. // 指定的文字
  10009. var targetTextDic = new Dictionary<string, List<string>>();
  10010. //创建数据源Table
  10011. DataTable dtSource = new DataTable();
  10012. dtSource.Columns.Add("Days", typeof(string));
  10013. dtSource.Columns.Add("Date", typeof(string));
  10014. dtSource.Columns.Add("Week", typeof(string));
  10015. dtSource.Columns.Add("Traffic", typeof(string));
  10016. dtSource.Columns.Add("Trip", typeof(string));
  10017. //获取数据,放到datatable
  10018. foreach (var item in _travelList)
  10019. {
  10020. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  10021. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  10022. .Replace(tagContent.TagFormat.Item2, string.Empty)
  10023. .Replace("[++]", string.Empty);
  10024. DataRow dr = dtSource.NewRow();
  10025. dr["Days"] = item.Days;
  10026. dr["Date"] = item.Date;
  10027. dr["Week"] = item.WeekDay;
  10028. dr["Traffic"] = item.Traffic_First
  10029. + "\r\n"
  10030. + item.Traffic_Second;
  10031. dr["Trip"] = item.Trip;
  10032. dtSource.Rows.Add(dr);
  10033. }
  10034. Dictionary<string, string> dic = new Dictionary<string, string>();
  10035. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  10036. dic.Add("City", CityStr);
  10037. dic.Add("Days", Find.VisitDays.ToString());
  10038. dic.Add("DeleCode", Find.TourCode);
  10039. dic.Add("Pnum", Find.VisitPNumber.ToString());
  10040. //模板路径
  10041. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  10042. //载入模板
  10043. Document doc = null;
  10044. DocumentBuilder builder = null;
  10045. try
  10046. {
  10047. //载入模板
  10048. doc = new Document(tempPath);
  10049. builder = new DocumentBuilder(doc);
  10050. }
  10051. catch (Exception)
  10052. {
  10053. jw.Msg = "模板位置不存在!";
  10054. return Ok(jw);
  10055. }
  10056. foreach (var key in dic.Keys)
  10057. {
  10058. Bookmark bookmark = doc.Range.Bookmarks[key];
  10059. if (bookmark != null)
  10060. {
  10061. builder.MoveToBookmark(key);
  10062. builder.Write(dic[key]);
  10063. }
  10064. }
  10065. //获取word里所有表格
  10066. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10067. //获取所填表格的序数
  10068. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10069. try
  10070. {
  10071. //循环赋值
  10072. for (int i = 0; i < dtSource.Rows.Count; i++)
  10073. {
  10074. builder.MoveToCell(0, i + 1, 0, 0);
  10075. builder.Write(dtSource.Rows[i]["Days"].ToString());
  10076. builder.MoveToCell(0, i + 1, 1, 0);
  10077. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  10078. builder.MoveToCell(0, i + 1, 2, 0);
  10079. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  10080. var trip = dtSource.Rows[i]["Trip"].ToString();
  10081. builder.MoveToCell(0, i + 1, 3, 0);
  10082. builder.Write(trip);
  10083. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  10084. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  10085. // 获取特定索引的段落
  10086. Paragraph paragraph = (Paragraph)paragraphs[0];
  10087. Run run = paragraph.Runs[0];
  10088. Aspose.Words.Font font = run.Font;
  10089. font.Name = "黑体";
  10090. //设置双休红色
  10091. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  10092. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  10093. paragraph = (Paragraph)paragraphs[1];
  10094. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  10095. {
  10096. run = paragraph.Runs[0];
  10097. font = run.Font;
  10098. font.Color = Color.Red;
  10099. }
  10100. }
  10101. }
  10102. catch (Exception ex)
  10103. {
  10104. }
  10105. //删除多余行
  10106. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  10107. {
  10108. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  10109. }
  10110. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  10111. if (!Directory.Exists(savePath))
  10112. {
  10113. try
  10114. {
  10115. Directory.CreateDirectory(savePath);
  10116. }
  10117. catch
  10118. {
  10119. }
  10120. }
  10121. string path = savePath + Find.TeamName + "出访日程";
  10122. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  10123. try
  10124. {
  10125. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  10126. string postfix = ".docx";
  10127. if (dto.IsPDF == 1)
  10128. {
  10129. saveFormat = Aspose.Words.SaveFormat.Pdf;
  10130. postfix = ".pdf";
  10131. }
  10132. doc.Save(path + postfix, saveFormat);
  10133. jw = JsonView(true, "导出成功", ftpPath + postfix);
  10134. }
  10135. catch (Exception)
  10136. {
  10137. jw = JsonView(false);
  10138. }
  10139. return Ok(jw);
  10140. }
  10141. /// <summary>
  10142. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  10143. /// </summary>
  10144. /// <param name="num"></param>
  10145. /// <returns></returns>
  10146. string GetNum(string num)
  10147. {
  10148. string str = "";
  10149. switch (num)
  10150. {
  10151. case "1":
  10152. str = "一";
  10153. break;
  10154. case "2":
  10155. str = "二";
  10156. break;
  10157. case "3":
  10158. str = "三";
  10159. break;
  10160. case "4":
  10161. str = "四";
  10162. break;
  10163. case "5":
  10164. str = "五";
  10165. break;
  10166. case "6":
  10167. str = "六";
  10168. break;
  10169. case "7":
  10170. str = "七";
  10171. break;
  10172. case "8":
  10173. str = "八";
  10174. break;
  10175. case "9":
  10176. str = "九";
  10177. break;
  10178. case "10":
  10179. str = "十";
  10180. break;
  10181. case "11":
  10182. str = "十一";
  10183. break;
  10184. case "12":
  10185. str = "十二";
  10186. break;
  10187. case "一":
  10188. str = "1";
  10189. break;
  10190. case "二":
  10191. str = "2";
  10192. break;
  10193. case "三":
  10194. str = "3";
  10195. break;
  10196. case "四":
  10197. str = "4";
  10198. break;
  10199. case "五":
  10200. str = "5";
  10201. break;
  10202. case "六":
  10203. str = "6";
  10204. break;
  10205. case "七":
  10206. str = "7";
  10207. break;
  10208. case "八":
  10209. str = "8";
  10210. break;
  10211. case "九":
  10212. str = "9";
  10213. break;
  10214. case "十":
  10215. str = "10";
  10216. break;
  10217. case "十一":
  10218. str = "11";
  10219. break;
  10220. case "十二":
  10221. str = "12";
  10222. break;
  10223. }
  10224. return str;
  10225. }
  10226. #endregion
  10227. #endregion
  10228. #region 团组成本
  10229. /// <summary>
  10230. /// 团组成本数据初始化
  10231. /// </summary>
  10232. /// <param name="dto"></param>
  10233. /// <returns></returns>
  10234. [HttpPost]
  10235. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  10236. {
  10237. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  10238. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  10239. WHEN COUNT(*) >= 0 THEN 'True'
  10240. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  10241. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  10242. ").ToList(); //团组列表
  10243. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  10244. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  10245. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  10246. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  10247. if (groupinfoValue != null)
  10248. {
  10249. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  10250. var spArr = new string[1] { countryArr };
  10251. if (countryArr.Contains("|"))
  10252. {
  10253. spArr = countryArr.Split("|");
  10254. }
  10255. else if (countryArr.Contains("、"))
  10256. {
  10257. spArr = countryArr.Split("、");
  10258. }
  10259. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  10260. {
  10261. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  10262. if (dbQueryCountry != null)
  10263. {
  10264. visaCountryInfoArr.Add(dbQueryCountry);
  10265. }
  10266. }
  10267. }
  10268. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  10269. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  10270. var create = _GroupCostRepository.
  10271. CreateGroupCostByBlackCode(dto.Diid);
  10272. if (groupCost.Count == 0 && create.Code == 0)
  10273. {
  10274. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  10275. }
  10276. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  10277. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  10278. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  10279. groupCostMap = groupCostMap.Select(x =>
  10280. {
  10281. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  10282. {
  10283. x.Date = dataForamt.ToString("yyyy-MM-dd");
  10284. }
  10285. return x;
  10286. }).ToList();
  10287. //GroupCostParameter.Add(new
  10288. // Grp_GroupCostParameter());
  10289. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  10290. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  10291. return Ok(JsonView(new
  10292. {
  10293. groupList,
  10294. groupInfo,
  10295. groupChecks,
  10296. groupCost = groupCostMap,
  10297. hotelNumber,
  10298. GroupCostParameter = GroupCostParameterMap,
  10299. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  10300. {
  10301. x.VisaCountry,
  10302. x.VisaPrice,
  10303. x.Id,
  10304. }).ToList(),
  10305. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  10306. blackCodeIsTrue = create.Code == 0 ? true : false,
  10307. hotelIsTrue = hotelIsTrue,
  10308. }));
  10309. }
  10310. /// <summary>
  10311. /// 团组成本信息保存
  10312. /// </summary>
  10313. /// <param name="dto"></param>
  10314. /// <returns></returns>
  10315. [HttpPost]
  10316. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  10317. {
  10318. if (dto.Diid <= 0 || dto.Userid <= 0)
  10319. {
  10320. return Ok(JsonView(false));
  10321. }
  10322. JsonView jw = null;
  10323. bool isTrue = false;
  10324. #region 复制团组成本
  10325. //if (dto.Diid == 2581)
  10326. //{
  10327. // dto.Diid = 2599;
  10328. // dto.CheckBoxs.ForEach(x =>
  10329. // {
  10330. // x.Diid = 2599;
  10331. // });
  10332. // dto.GroupCosts.ForEach(x =>
  10333. // {
  10334. // x.Diid = 2599;
  10335. // });
  10336. // dto.CostTypeHotelNumbers.ForEach(x =>
  10337. // {
  10338. // x.Diid = 2599;
  10339. // });
  10340. // dto.GroupCostParameters.ForEach(x =>
  10341. // {
  10342. // x.DiId = 2599;
  10343. // });
  10344. //}
  10345. #endregion
  10346. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  10347. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  10348. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  10349. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  10350. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  10351. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  10352. try
  10353. {
  10354. _sqlSugar.BeginTran();
  10355. isTrue = await _GroupCostRepository.
  10356. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  10357. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  10358. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  10359. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  10360. _sqlSugar.CommitTran();
  10361. jw = JsonView(true, "保存成功!", isTrue);
  10362. }
  10363. catch (Exception)
  10364. {
  10365. _sqlSugar.RollbackTran();
  10366. jw = JsonView(false);
  10367. }
  10368. return Ok(jw);
  10369. }
  10370. /// <summary>
  10371. /// 司兼导数据
  10372. /// </summary>
  10373. /// <param name="dto"></param>
  10374. /// <returns></returns>
  10375. [HttpPost]
  10376. public IActionResult GetCarGuides(CarGuidesDto dto)
  10377. {
  10378. JsonView jw = null;
  10379. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  10380. jw = JsonView(true, "获取成功!", Data);
  10381. return Ok(jw);
  10382. }
  10383. /// <summary>
  10384. /// 导游数据
  10385. /// </summary>
  10386. /// <param name="dto"></param>
  10387. /// <returns></returns>
  10388. [HttpPost]
  10389. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  10390. {
  10391. JsonView jw = null;
  10392. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  10393. // 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
  10394. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  10395. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  10396. jw = JsonView(true, "获取成功!", Data);
  10397. return Ok(jw);
  10398. }
  10399. /// <summary>
  10400. /// 成本车数据
  10401. /// </summary>
  10402. /// <param name="dto"></param>
  10403. /// <returns></returns>
  10404. [HttpPost]
  10405. public IActionResult GetCarInfo(CarGuidesDto dto)
  10406. {
  10407. JsonView jw = null;
  10408. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  10409. jw = JsonView(true, "获取成功!", Data);
  10410. return Ok(jw);
  10411. }
  10412. /// <summary>
  10413. /// 景点数据
  10414. /// </summary>
  10415. /// <param name="dto"></param>
  10416. /// <returns></returns>
  10417. [HttpPost]
  10418. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  10419. {
  10420. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  10421. return Ok(JsonView(true, "获取成功!", Data));
  10422. }
  10423. /// <summary>
  10424. /// 成本通知
  10425. /// </summary>
  10426. /// <param name="dto"></param>
  10427. /// <returns></returns>
  10428. [HttpPost]
  10429. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  10430. {
  10431. if (dto.Diid < 0)
  10432. {
  10433. return Ok(JsonView(false));
  10434. }
  10435. JsonView jw = null;
  10436. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  10437. if (GroupCostParameter != null)
  10438. {
  10439. int IsShare = 0;
  10440. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  10441. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  10442. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  10443. string msg = string.Empty;
  10444. if (isTrue)
  10445. {
  10446. if (IsShare == 0)
  10447. {
  10448. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  10449. }
  10450. else
  10451. {
  10452. #region 企微通知对应岗位用户
  10453. try
  10454. {
  10455. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  10456. }
  10457. catch (Exception ex)
  10458. {
  10459. }
  10460. #endregion
  10461. msg = "通知成功,其他模块操作人员可见此成本信息!";
  10462. }
  10463. jw = JsonView(isTrue, msg, new { IsShare });
  10464. }
  10465. else
  10466. {
  10467. msg = "修改失败!";
  10468. jw = JsonView(isTrue, msg);
  10469. }
  10470. }
  10471. else
  10472. {
  10473. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  10474. }
  10475. return Ok(jw);
  10476. }
  10477. /// <summary>
  10478. /// 导出报价单
  10479. /// </summary>
  10480. /// <param name="dto"></param>
  10481. /// <returns></returns>
  10482. [HttpPost]
  10483. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  10484. {
  10485. if (dto.Diid == 0)
  10486. {
  10487. return Ok(JsonView(false, "请传递团组id"));
  10488. }
  10489. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10490. if (deleInfo.Code != 0)
  10491. {
  10492. return Ok(JsonView(false, "团组信息查询失败!"));
  10493. }
  10494. var di = deleInfo.Data as DelegationInfoWebView;
  10495. if (di != null)
  10496. {
  10497. di.TeamName = di.TeamName.Replace("|", "、");
  10498. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  10499. //文件名
  10500. string strFileName = di.TeamName + "-收款账单.doc";
  10501. //获取模板
  10502. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  10503. //载入模板
  10504. Document doc = new Document(tmppath);
  10505. decimal TotalPrice = 0.00M;
  10506. string itemStr = string.Empty;
  10507. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  10508. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  10509. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  10510. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  10511. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  10512. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  10513. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  10514. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  10515. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  10516. foreach (var cost in groupCostType)
  10517. {
  10518. var List = cost.ToList();
  10519. if (cost.Key == "A")
  10520. {
  10521. foreach (var ListItem in List)
  10522. {
  10523. if (ListItem.number > 0)
  10524. {
  10525. if (ListItem.code.Contains("TBR"))
  10526. {
  10527. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10528. }
  10529. else
  10530. {
  10531. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10532. }
  10533. TotalPrice += (ListItem.number * ListItem.price);
  10534. }
  10535. }
  10536. }
  10537. else
  10538. {
  10539. itemStr = itemStr.Insert(0, "A段\r\n");
  10540. itemStr += "B段\r\n";
  10541. foreach (var ListItem in List)
  10542. {
  10543. if (ListItem.number > 0)
  10544. {
  10545. if (ListItem.code.Contains("TBR"))
  10546. {
  10547. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10548. }
  10549. else
  10550. {
  10551. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10552. }
  10553. TotalPrice += (ListItem.number * ListItem.price);
  10554. }
  10555. }
  10556. }
  10557. }
  10558. #region 替换Word模板书签内容
  10559. Dictionary<string, string> marks = new Dictionary<string, string>();
  10560. marks.Add("To", di.ClientUnit);//付款方
  10561. marks.Add("ToTel", di.TellPhone);//付款方电话
  10562. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  10563. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  10564. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  10565. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  10566. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  10567. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  10568. marks.Add("PayItemContent", itemStr);//详细信息
  10569. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  10570. #endregion
  10571. ////注
  10572. //if (doc.Range.Bookmarks["Attention"] != null)
  10573. //{
  10574. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  10575. // mark.Text = frList[0].Attention;
  10576. //}
  10577. foreach (var item in marks.Keys)
  10578. {
  10579. if (doc.Range.Bookmarks[item] != null)
  10580. {
  10581. Bookmark mark = doc.Range.Bookmarks[item];
  10582. mark.Text = marks[item];
  10583. }
  10584. }
  10585. byte[] bytes = null;
  10586. using (MemoryStream stream = new MemoryStream())
  10587. {
  10588. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10589. bytes = stream.ToArray();
  10590. }
  10591. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  10592. return Ok(JsonView(true, "", new
  10593. {
  10594. Data = bytes,
  10595. strFileName,
  10596. }));
  10597. }
  10598. else
  10599. {
  10600. return Ok(JsonView(false, "团组信息不存在!"));
  10601. }
  10602. }
  10603. /// <summary>
  10604. /// 导出团组成本
  10605. /// </summary>
  10606. /// <param name="dto"></param>
  10607. /// <returns></returns>
  10608. [HttpPost]
  10609. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  10610. {
  10611. var jw = JsonView(false);
  10612. if (dto.Diid == 0)
  10613. {
  10614. return Ok(JsonView(false, "请传递团组id"));
  10615. }
  10616. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10617. if (deleInfo.Code != 0)
  10618. {
  10619. return Ok(JsonView(false, "团组信息查询失败!"));
  10620. }
  10621. var di = deleInfo.Data as DelegationInfoWebView;
  10622. if (di == null)
  10623. {
  10624. return Ok(JsonView(false, "团组信息查询失败!"));
  10625. }
  10626. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  10627. WorkbookDesigner designer = new WorkbookDesigner();
  10628. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  10629. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  10630. for (int i = 0; i < List_GC.Count; i++)
  10631. {
  10632. GroupCost_Excel gc = new GroupCost_Excel();
  10633. gc.Id = List_GC[i].Id;
  10634. gc.Diid = List_GC[i].Diid.ToString();
  10635. gc.DAY = List_GC[i].DAY;
  10636. string week = "";
  10637. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  10638. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  10639. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  10640. gc.ITIN = List_GC[i].ITIN;
  10641. gc.CarType = List_GC[i].CarType;
  10642. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  10643. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  10644. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  10645. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  10646. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  10647. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  10648. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  10649. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  10650. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  10651. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  10652. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  10653. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  10654. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  10655. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  10656. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  10657. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  10658. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  10659. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  10660. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  10661. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  10662. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  10663. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  10664. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  10665. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  10666. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  10667. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  10668. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  10669. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  10670. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  10671. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  10672. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  10673. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  10674. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  10675. List_GC1.Add(gc);
  10676. }
  10677. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  10678. dt.TableName = "TB";
  10679. //报表标题等不用dt的值
  10680. designer.SetDataSource("TeamName", dto.title.TeamName);
  10681. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  10682. designer.SetDataSource("Tax", dto.title.Tax);
  10683. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  10684. designer.SetDataSource("Currency", dto.title.Currency);
  10685. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  10686. designer.SetDataSource("Rate", dto.title.Rate);
  10687. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  10688. var Aparams = hotels.Find(x => x.Type == "Default");
  10689. if (Aparams == null)
  10690. {
  10691. return Ok(jw);
  10692. }
  10693. //酒店数量
  10694. var txtSGRNumber = Aparams.SGR.ToString();
  10695. var txtTBRNumber = Aparams.TBR.ToString();
  10696. var txtJSESNumber = Aparams.JSES.ToString();
  10697. var txtSUITENumbe = Aparams.SUITE.ToString();
  10698. if (dto.costType == "B")
  10699. {
  10700. Aparams = hotels.Find(x => x.Type == "A");
  10701. var Bparams = hotels.Find(x => x.Type == "B");
  10702. if (Aparams == null || Bparams == null)
  10703. {
  10704. return Ok(jw);
  10705. }
  10706. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  10707. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  10708. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  10709. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  10710. }
  10711. designer.SetDataSource("SGRNumber", txtSGRNumber);
  10712. designer.SetDataSource("TBRNumber", txtTBRNumber);
  10713. designer.SetDataSource("JSESNumber", txtJSESNumber);
  10714. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  10715. var ws = designer.Workbook.Worksheets[0];
  10716. int Row = List_GC.Count;
  10717. int startIndex = 11;
  10718. int HideRows = 0;
  10719. List<int> hideRowsList = new List<int>();
  10720. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  10721. #region A段left数据
  10722. var left = dto.leftInfo.Find(x => x.Type == "A");
  10723. if (left == null)
  10724. {
  10725. return Ok(jw);
  10726. }
  10727. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  10728. if (leftBindData != null)
  10729. {
  10730. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  10731. designer.SetDataSource("VisaRS", leftBindData.rs);
  10732. designer.SetDataSource("VisaXS", leftBindData.xs);
  10733. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10734. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10735. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10736. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10737. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10738. }
  10739. else
  10740. {
  10741. hideRowsList.Add(Row + startIndex + HideRows);
  10742. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10743. }
  10744. HideRows += 2;
  10745. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  10746. if (leftBindData != null)
  10747. {
  10748. designer.SetDataSource("BXDRCB", leftBindData.cb);
  10749. designer.SetDataSource("BXRS", leftBindData.rs);
  10750. designer.SetDataSource("BXXS", leftBindData.xs);
  10751. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10752. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10753. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10754. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10755. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10756. }
  10757. else
  10758. {
  10759. hideRowsList.Add(Row + startIndex + HideRows);
  10760. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10761. }
  10762. HideRows += 2;
  10763. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  10764. if (leftBindData != null)
  10765. {
  10766. designer.SetDataSource("HSDRCB", leftBindData.cb);
  10767. designer.SetDataSource("HSRS", leftBindData.rs);
  10768. designer.SetDataSource("HSXS", leftBindData.xs);
  10769. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10770. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10771. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10772. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10773. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10774. }
  10775. else
  10776. {
  10777. hideRowsList.Add(Row + startIndex + HideRows);
  10778. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10779. }
  10780. HideRows += 2;
  10781. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  10782. if (leftBindData != null)
  10783. {
  10784. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  10785. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  10786. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  10787. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10788. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10789. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10790. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10791. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10792. }
  10793. else
  10794. {
  10795. hideRowsList.Add(Row + startIndex + HideRows);
  10796. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10797. }
  10798. HideRows += 2;
  10799. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  10800. if (leftBindData != null)
  10801. {
  10802. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  10803. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  10804. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  10805. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10806. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10807. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10808. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10809. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10810. }
  10811. else
  10812. {
  10813. hideRowsList.Add(Row + startIndex + HideRows);
  10814. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10815. }
  10816. HideRows += 2;
  10817. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  10818. if (leftBindData != null)
  10819. {
  10820. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  10821. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  10822. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  10823. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10824. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10825. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10826. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10827. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10828. }
  10829. else
  10830. {
  10831. hideRowsList.Add(Row + startIndex + HideRows);
  10832. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10833. }
  10834. HideRows += 2;
  10835. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  10836. if (leftBindData != null)
  10837. {
  10838. ////TBR
  10839. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  10840. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  10841. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  10842. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10843. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10844. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10845. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10846. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10847. }
  10848. else
  10849. {
  10850. hideRowsList.Add(Row + startIndex + HideRows);
  10851. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10852. }
  10853. HideRows += 2;
  10854. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  10855. if (leftBindData != null)
  10856. {
  10857. ////SGR
  10858. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  10859. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  10860. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  10861. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10862. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10863. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10864. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10865. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10866. }
  10867. else
  10868. {
  10869. hideRowsList.Add(Row + startIndex + HideRows);
  10870. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10871. }
  10872. HideRows += 2;
  10873. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  10874. if (leftBindData != null)
  10875. {
  10876. ////JS/ES
  10877. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  10878. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  10879. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  10880. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10881. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10882. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10883. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10884. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10885. }
  10886. else
  10887. {
  10888. hideRowsList.Add(Row + startIndex + HideRows);
  10889. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10890. }
  10891. HideRows += 2;
  10892. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  10893. if (leftBindData != null)
  10894. {
  10895. ////SUITE
  10896. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  10897. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  10898. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  10899. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10900. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10901. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10902. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10903. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10904. }
  10905. else
  10906. {
  10907. hideRowsList.Add(Row + startIndex + HideRows);
  10908. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10909. }
  10910. HideRows += 2;
  10911. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  10912. if (leftBindData != null)
  10913. {
  10914. designer.SetDataSource("DJDRCB", leftBindData.cb);
  10915. designer.SetDataSource("DJRS", leftBindData.rs);
  10916. designer.SetDataSource("DJXS", leftBindData.xs);
  10917. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10918. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10919. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10920. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10921. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10922. }
  10923. else
  10924. {
  10925. hideRowsList.Add(Row + startIndex + HideRows);
  10926. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10927. }
  10928. HideRows += 2;
  10929. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  10930. if (leftBindData != null)
  10931. {
  10932. designer.SetDataSource("HCPCB", leftBindData.cb);
  10933. designer.SetDataSource("HCPRS", leftBindData.rs);
  10934. designer.SetDataSource("HCPXS", leftBindData.xs);
  10935. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10936. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10937. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10938. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10939. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10940. }
  10941. else
  10942. {
  10943. hideRowsList.Add(Row + startIndex + HideRows);
  10944. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10945. }
  10946. HideRows += 2;
  10947. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  10948. if (leftBindData != null)
  10949. {
  10950. designer.SetDataSource("CPCB", leftBindData.cb);
  10951. designer.SetDataSource("CPRS", leftBindData.rs);
  10952. designer.SetDataSource("CPXS", leftBindData.xs);
  10953. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10954. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10955. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10956. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10957. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10958. }
  10959. else
  10960. {
  10961. hideRowsList.Add(Row + startIndex + HideRows);
  10962. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10963. }
  10964. HideRows += 2;
  10965. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  10966. if (leftBindData != null)
  10967. {
  10968. designer.SetDataSource("GWDRCD", leftBindData.cb);
  10969. designer.SetDataSource("GWRS", leftBindData.rs);
  10970. designer.SetDataSource("GWXS", leftBindData.xs);
  10971. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10972. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10973. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10974. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10975. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10976. }
  10977. else
  10978. {
  10979. hideRowsList.Add(Row + startIndex + HideRows);
  10980. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10981. }
  10982. HideRows += 2;
  10983. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  10984. if (leftBindData != null)
  10985. {
  10986. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  10987. designer.SetDataSource("LYJRS", leftBindData.rs);
  10988. designer.SetDataSource("LYJXS", leftBindData.xs);
  10989. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10990. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10991. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10992. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10993. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10994. }
  10995. else
  10996. {
  10997. hideRowsList.Add(Row + startIndex + HideRows);
  10998. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10999. }
  11000. #endregion
  11001. #region A段Right信息
  11002. var right = dto.rightInfo.Find(x => x.Type == "A");
  11003. if (right == null)
  11004. {
  11005. return Ok(jw);
  11006. }
  11007. HideRows += 4;
  11008. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  11009. if (rightBindData != null)
  11010. {
  11011. //经济舱 + 双人间 TBR
  11012. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  11013. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  11014. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11015. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  11016. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11017. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11018. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11019. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11020. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11021. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11022. }
  11023. else
  11024. {
  11025. hideRowsList.Add(Row + startIndex + HideRows);
  11026. }
  11027. HideRows += 2;
  11028. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  11029. if (rightBindData != null)
  11030. {
  11031. //经济舱 + 单人间 SGR
  11032. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  11033. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  11034. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11035. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  11036. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11037. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11038. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11039. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11040. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11041. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11042. }
  11043. else
  11044. {
  11045. hideRowsList.Add(Row + startIndex + HideRows);
  11046. }
  11047. HideRows += 2;
  11048. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  11049. if (rightBindData != null)
  11050. {
  11051. //公务舱 + 单人间 SGR
  11052. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  11053. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  11054. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11055. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  11056. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11057. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11058. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11059. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11060. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11061. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11062. }
  11063. else
  11064. {
  11065. hideRowsList.Add(Row + startIndex + HideRows);
  11066. }
  11067. HideRows += 2;
  11068. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  11069. if (rightBindData != null)
  11070. {
  11071. //公务舱 + 小套房 JSES
  11072. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  11073. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  11074. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11075. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  11076. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11077. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11078. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11079. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11080. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11081. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11082. }
  11083. else
  11084. {
  11085. hideRowsList.Add(Row + startIndex + HideRows);
  11086. }
  11087. HideRows += 2;
  11088. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  11089. if (rightBindData != null)
  11090. {
  11091. //公务舱 + 小套房 JSES
  11092. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  11093. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  11094. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11095. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  11096. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11097. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11098. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11099. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11100. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11101. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11102. }
  11103. else
  11104. {
  11105. hideRowsList.Add(Row + startIndex + HideRows);
  11106. }
  11107. HideRows += 2;
  11108. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  11109. if (rightBindData != null)
  11110. {
  11111. //经济舱 + 大套房
  11112. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  11113. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  11114. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11115. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  11116. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11117. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11118. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11119. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11120. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11121. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11122. }
  11123. else
  11124. {
  11125. hideRowsList.Add(Row + startIndex + HideRows);
  11126. }
  11127. HideRows += 2;
  11128. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  11129. if (rightBindData != null)
  11130. {
  11131. //头等舱 + 小套房 JSES
  11132. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  11133. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  11134. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11135. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  11136. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11137. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11138. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11139. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11140. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11141. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11142. }
  11143. else
  11144. {
  11145. hideRowsList.Add(Row + startIndex + HideRows);
  11146. }
  11147. HideRows += 2;
  11148. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  11149. if (rightBindData != null)
  11150. {
  11151. //头等舱 + 大套房
  11152. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  11153. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  11154. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11155. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  11156. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11157. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11158. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11159. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11160. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11161. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11162. }
  11163. else
  11164. {
  11165. hideRowsList.Add(Row + startIndex + HideRows);
  11166. }
  11167. #endregion
  11168. #region B段标题清空
  11169. designer.SetDataSource("CostBDRCB", "");
  11170. designer.SetDataSource("CostBRS", "");
  11171. designer.SetDataSource("CostBXS", "");
  11172. designer.SetDataSource("CostBZCB", "");
  11173. designer.SetDataSource("CostBDRBJ", "");
  11174. designer.SetDataSource("CostBZBJ", "");
  11175. designer.SetDataSource("CostBDRLR", "");
  11176. designer.SetDataSource("CostBZLR", "");
  11177. designer.SetDataSource("CostBDRCBOM", "");
  11178. designer.SetDataSource("CostBRSOM", "");
  11179. designer.SetDataSource("CostBZCBOM", "");
  11180. designer.SetDataSource("CostBDRBJOM", "");
  11181. designer.SetDataSource("CostBZBJOM", "");
  11182. designer.SetDataSource("CostBDRLROM", "");
  11183. designer.SetDataSource("CostBZLROM", "");
  11184. #endregion
  11185. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  11186. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  11187. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  11188. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  11189. designer.SetDataSource("DJName", "地接(CNY)");
  11190. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  11191. designer.SetDataSource("CPName", "地接-船票(CNY)");
  11192. designer.SetDataSource("GWName", "公务(CNY)");
  11193. designer.SetDataSource("YQHName", "邀请函(CNY)");
  11194. designer.SetDataSource("LYJName", "零用金(CNY)");
  11195. designer.SetDataSource("HSName", "核酸检测(CNY)");
  11196. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  11197. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  11198. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  11199. designer.SetDataSource("BXName", "保险(CNY)");
  11200. designer.SetDataSource("VisaName", "签证(CNY)");
  11201. #region B段基本数据
  11202. if (dto.costType == "B")
  11203. {
  11204. left = dto.leftInfo.Find(x => x.Type == "B");
  11205. if (left == null)
  11206. {
  11207. return Ok(jw);
  11208. }
  11209. #region B段left数据
  11210. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  11211. if (leftBindData != null)
  11212. {
  11213. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  11214. designer.SetDataSource("BHSRS", leftBindData.rs);
  11215. designer.SetDataSource("BHSXS", leftBindData.xs);
  11216. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11217. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11218. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11219. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11220. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11221. }
  11222. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  11223. if (leftBindData != null)
  11224. {
  11225. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  11226. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  11227. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  11228. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11229. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11230. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11231. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11232. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11233. }
  11234. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  11235. if (leftBindData != null)
  11236. {
  11237. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  11238. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  11239. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  11240. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11241. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11242. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11243. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11244. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11245. }
  11246. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  11247. if (leftBindData != null)
  11248. {
  11249. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  11250. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  11251. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  11252. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11253. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11254. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11255. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11256. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11257. }
  11258. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  11259. if (leftBindData != null)
  11260. {
  11261. designer.SetDataSource("BHCPCB", leftBindData.cb);
  11262. designer.SetDataSource("BHCPRS", leftBindData.rs);
  11263. designer.SetDataSource("BHCPXS", leftBindData.xs);
  11264. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11265. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11266. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11267. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11268. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11269. }
  11270. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  11271. if (leftBindData != null)
  11272. {
  11273. designer.SetDataSource("BCPCB", leftBindData.cb);
  11274. designer.SetDataSource("BCPRS", leftBindData.rs);
  11275. designer.SetDataSource("BCPXS", leftBindData.xs);
  11276. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11277. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11278. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11279. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11280. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11281. }
  11282. //TBR
  11283. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  11284. if (leftBindData != null)
  11285. {
  11286. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  11287. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  11288. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  11289. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11290. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11291. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11292. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11293. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11294. }
  11295. //SGR
  11296. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  11297. if (leftBindData != null)
  11298. {
  11299. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  11300. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  11301. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  11302. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11303. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11304. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11305. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11306. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11307. }
  11308. //JS/ES
  11309. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  11310. if (leftBindData != null)
  11311. {
  11312. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  11313. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  11314. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  11315. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11316. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11317. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11318. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11319. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11320. }
  11321. //SUITE
  11322. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  11323. if (leftBindData != null)
  11324. {
  11325. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  11326. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  11327. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  11328. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11329. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11330. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11331. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11332. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11333. }
  11334. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  11335. if (leftBindData != null)
  11336. {
  11337. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  11338. designer.SetDataSource("BDJRS", leftBindData.rs);
  11339. designer.SetDataSource("BDJXS", leftBindData.xs);
  11340. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11341. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11342. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11343. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11344. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11345. }
  11346. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  11347. if (leftBindData != null)
  11348. {
  11349. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  11350. designer.SetDataSource("BGWRS", leftBindData.rs);
  11351. designer.SetDataSource("BGWXS", leftBindData.xs);
  11352. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11353. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11354. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11355. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11356. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11357. }
  11358. #region 优化方案
  11359. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  11360. //excelBind.Add("零用金", new {
  11361. //cb="",
  11362. //rs="",
  11363. //xs ="",
  11364. //zcb = "",
  11365. //});
  11366. #endregion
  11367. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  11368. if (leftBindData != null)
  11369. {
  11370. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  11371. designer.SetDataSource("BLYJRS", leftBindData.rs);
  11372. designer.SetDataSource("BLYJXS", leftBindData.xs);
  11373. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11374. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11375. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11376. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11377. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11378. }
  11379. #endregion
  11380. #region B段Right信息
  11381. right = dto.rightInfo.Find(x => x.Type == "B");
  11382. if (right == null)
  11383. {
  11384. return Ok(jw);
  11385. }
  11386. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  11387. if (rightBindData != null)
  11388. {
  11389. //经济舱 + 双人间 TBR
  11390. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  11391. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  11392. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11393. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  11394. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11395. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11396. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11397. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11398. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11399. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11400. }
  11401. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  11402. if (rightBindData != null)
  11403. {
  11404. //经济舱 + 单人间 SGR
  11405. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  11406. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  11407. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11408. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  11409. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11410. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11411. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11412. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11413. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11414. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11415. }
  11416. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  11417. if (rightBindData != null)
  11418. {
  11419. //公务舱 + 单人间 SGR
  11420. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  11421. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  11422. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11423. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  11424. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11425. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11426. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11427. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11428. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11429. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11430. }
  11431. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  11432. if (rightBindData != null)
  11433. {
  11434. //公务舱 + 小套房 JSES
  11435. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  11436. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  11437. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11438. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  11439. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11440. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11441. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11442. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11443. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11444. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11445. }
  11446. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  11447. if (rightBindData != null)
  11448. {
  11449. //公务舱 + 小套房 JSES
  11450. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  11451. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  11452. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11453. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  11454. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11455. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11456. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11457. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11458. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11459. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11460. }
  11461. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  11462. if (rightBindData != null)
  11463. {
  11464. //经济舱 + 大套房
  11465. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  11466. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  11467. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11468. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  11469. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11470. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11471. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11472. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11473. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11474. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11475. }
  11476. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  11477. if (rightBindData != null)
  11478. {
  11479. //头等舱 + 小套房 JSES
  11480. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  11481. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  11482. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11483. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  11484. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11485. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11486. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11487. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11488. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11489. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11490. }
  11491. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  11492. if (rightBindData != null)
  11493. {
  11494. //头等舱 + 大套房
  11495. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  11496. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  11497. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11498. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  11499. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11500. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11501. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11502. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11503. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11504. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11505. }
  11506. #endregion
  11507. #region 标题
  11508. designer.SetDataSource("CostBDRCB", "单人成本");
  11509. designer.SetDataSource("CostBRS", "人数");
  11510. designer.SetDataSource("CostBXS", "系数");
  11511. designer.SetDataSource("CostBZCB", "总成本");
  11512. designer.SetDataSource("CostBDRBJ", "单人报价");
  11513. designer.SetDataSource("CostBZBJ", "总报价");
  11514. designer.SetDataSource("CostBDRLR", "单人利润");
  11515. designer.SetDataSource("CostBZLR", "总利润");
  11516. designer.SetDataSource("CostBDRCBOM", "单人成本");
  11517. designer.SetDataSource("CostBRSOM", "人数");
  11518. designer.SetDataSource("CostBZCBOM", "总成本");
  11519. designer.SetDataSource("CostBDRBJOM", "单人报价");
  11520. designer.SetDataSource("CostBZBJOM", "总报价");
  11521. designer.SetDataSource("CostBDRLROM", "单人利润");
  11522. designer.SetDataSource("CostBZLROM", "总利润");
  11523. #endregion
  11524. }
  11525. #endregion
  11526. designer.SetDataSource("TzZCB2", TzZCB2);
  11527. designer.SetDataSource("TzZBJ2", TzZBJ2);
  11528. designer.SetDataSource("TzZLR2", TzZLR2);
  11529. string[] dataSourceKeys = new string[]
  11530. {
  11531. "VF",
  11532. "TGS",
  11533. "TGOF",
  11534. "TGM",
  11535. "TGA",
  11536. "TGTF",
  11537. "TGEF",
  11538. "CFM",
  11539. "CFOF",
  11540. "B",
  11541. "L",
  11542. "D",
  11543. "TBR",
  11544. "SGR",
  11545. "JSES",
  11546. "Suite",
  11547. "TV",
  11548. "1L",
  11549. "IF",
  11550. "EF",
  11551. "BRF",
  11552. "TE",
  11553. "TGT",
  11554. "DRVT",
  11555. "PC",
  11556. "TLF",
  11557. "ECT"
  11558. };
  11559. foreach (var item in dataSourceKeys)
  11560. {
  11561. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  11562. if (find != null)
  11563. {
  11564. designer.SetDataSource(item, find.text);
  11565. }
  11566. else
  11567. {
  11568. designer.SetDataSource(item, 0);
  11569. }
  11570. }
  11571. designer.SetDataSource(dt);
  11572. //根据数据源处理生成报表内容
  11573. designer.Process();
  11574. designer.Workbook.Worksheets[0].Name = "清单";
  11575. Worksheet sheet = designer.Workbook.Worksheets[0];
  11576. foreach (var Rowindex in hideRowsList)
  11577. {
  11578. ws.Cells.HideRows(Rowindex, 2);
  11579. }
  11580. byte[] bytes = null;
  11581. string strFileName = di.TeamName + "-团组-成本.xls";
  11582. using (MemoryStream stream = new MemoryStream())
  11583. {
  11584. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  11585. bytes = stream.ToArray();
  11586. }
  11587. return Ok(JsonView(true, "", new
  11588. {
  11589. Data = bytes,
  11590. strFileName,
  11591. }));
  11592. }
  11593. /// <summary>
  11594. /// 导出客户报表
  11595. /// </summary>
  11596. /// <returns></returns>
  11597. [HttpPost]
  11598. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  11599. {
  11600. var jw = JsonView(false);
  11601. if (dto.Diid == 0)
  11602. {
  11603. return Ok(JsonView(false, "请传递团组id"));
  11604. }
  11605. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11606. if (deleInfo.Code != 0)
  11607. {
  11608. return Ok(JsonView(false, "团组信息查询失败!"));
  11609. }
  11610. var di = deleInfo.Data as DelegationInfoWebView;
  11611. if (di == null)
  11612. {
  11613. return Ok(JsonView(false, "团组信息查询失败!"));
  11614. }
  11615. //文件名
  11616. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  11617. //获取模板
  11618. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  11619. //载入模板
  11620. Document doc = new Document(tmppath);
  11621. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  11622. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  11623. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  11624. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  11625. var AParameter = ParameterList.Find(x => x.CostType == "A");
  11626. var BParameter = ParameterList.Find(x => x.CostType == "B");
  11627. if (AParameter == null)
  11628. {
  11629. return Ok(JsonView(false, "系数不存在!"));
  11630. }
  11631. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  11632. , TzAirDesc, TzZCost;
  11633. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  11634. = TzAirDesc = TzZCost = string.Empty;
  11635. TzNumber = AParameter.CostTypenumber.ToString();
  11636. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  11637. CarGuides1 = dto.CarGuides1;
  11638. Meal = dto.Meal;
  11639. SubsidizedMeals = dto.SubsidizedMeals;
  11640. NightRepair = dto.NightRepair;
  11641. AttractionsTickets = dto.AttractionsTickets;
  11642. MiscellaneousFees = dto.MiscellaneousFees;
  11643. ATip = dto.ATip;
  11644. TzHotelDesc = "";
  11645. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  11646. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  11647. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  11648. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  11649. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  11650. TzAirDesc = "";
  11651. TzZCost = dto.TzZCost;
  11652. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  11653. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  11654. var index = 1;
  11655. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  11656. foreach (var item in TzHotelDescArr)
  11657. {
  11658. if (AinfoArr != null)
  11659. {
  11660. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11661. if (Ainfo != null)
  11662. {
  11663. if (int.Parse(Ainfo.rs) <= 0)
  11664. {
  11665. continue;
  11666. }
  11667. var hotelText = string.Empty;
  11668. switch (item)
  11669. {
  11670. case "SGR":
  11671. hotelText = "单人间";
  11672. break;
  11673. case "JSES":
  11674. hotelText = "小套房";
  11675. break;
  11676. case "SUITE":
  11677. hotelText = "套房";
  11678. break;
  11679. case "TBR":
  11680. hotelText = "双人间";
  11681. break;
  11682. }
  11683. if (item != "TBR")
  11684. {
  11685. 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";
  11686. }
  11687. else
  11688. {
  11689. 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";
  11690. }
  11691. index++;
  11692. }
  11693. }
  11694. }
  11695. index = 1;
  11696. foreach (var item in TzAirDescArr)
  11697. {
  11698. if (AinfoArr != null)
  11699. {
  11700. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11701. if (Ainfo != null)
  11702. {
  11703. if (int.Parse(Ainfo.rs) <= 0)
  11704. {
  11705. continue;
  11706. }
  11707. 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";
  11708. index++;
  11709. }
  11710. }
  11711. }
  11712. if (dto.costType == "B")
  11713. {
  11714. if (BParameter == null)
  11715. {
  11716. return Ok(JsonView(false, "B段系数不存在!"));
  11717. }
  11718. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  11719. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  11720. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  11721. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  11722. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  11723. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  11724. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  11725. foreach (var item in TzHotelDescArr)
  11726. {
  11727. if (AinfoArr != null)
  11728. {
  11729. TzHotelDesc += "B段信息 \r\n";
  11730. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11731. if (Ainfo != null)
  11732. {
  11733. if (int.Parse(Ainfo.rs) <= 0)
  11734. {
  11735. continue;
  11736. }
  11737. var hotelText = string.Empty;
  11738. switch (item)
  11739. {
  11740. case "SGR":
  11741. hotelText = "单人间";
  11742. break;
  11743. case "JSES":
  11744. hotelText = "小套房";
  11745. break;
  11746. case "SUITE":
  11747. hotelText = "套房";
  11748. break;
  11749. case "TBR":
  11750. hotelText = "双人间";
  11751. break;
  11752. }
  11753. if (item != "TBR")
  11754. {
  11755. 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";
  11756. }
  11757. else
  11758. {
  11759. 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";
  11760. }
  11761. index++;
  11762. }
  11763. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  11764. }
  11765. }
  11766. index = 1;
  11767. foreach (var item in TzAirDescArr)
  11768. {
  11769. if (AinfoArr != null)
  11770. {
  11771. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11772. if (Ainfo != null)
  11773. {
  11774. if (int.Parse(Ainfo.rs) <= 0)
  11775. {
  11776. continue;
  11777. }
  11778. 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";
  11779. index++;
  11780. }
  11781. }
  11782. }
  11783. }
  11784. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  11785. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  11786. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  11787. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  11788. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  11789. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  11790. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  11791. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  11792. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  11793. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  11794. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  11795. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  11796. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  11797. DickeyValue.Add("Visa", Visa); // 签证单人报价
  11798. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  11799. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  11800. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  11801. DickeyValue.Add("TzZCost", TzZCost);
  11802. foreach (var key in DickeyValue.Keys)
  11803. {
  11804. if (doc.Range.Bookmarks[key] != null)
  11805. {
  11806. Bookmark mark = doc.Range.Bookmarks[key];
  11807. mark.Text = DickeyValue[key];
  11808. }
  11809. }
  11810. byte[] bytes = null;
  11811. string strFileName = di.TeamName + "-客户报价.doc";
  11812. using (MemoryStream stream = new MemoryStream())
  11813. {
  11814. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  11815. bytes = stream.ToArray();
  11816. }
  11817. return Ok(JsonView(true, "", new
  11818. {
  11819. Data = bytes,
  11820. strFileName,
  11821. }));
  11822. }
  11823. /// <summary>
  11824. /// 团组成本 各模块(酒店,地接,机票)成本提示
  11825. /// </summary>
  11826. /// <param name="dto"></param>
  11827. /// <returns></returns>
  11828. [HttpPost]
  11829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11830. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  11831. {
  11832. try
  11833. {
  11834. #region 参数验证
  11835. if (dto.DiId < 0)
  11836. {
  11837. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  11838. }
  11839. List<int> cTableIds = new List<int>() {
  11840. 76 ,//酒店预订
  11841. 77 ,//行程
  11842. 79 ,//车/导游地接
  11843. 80 ,//签证
  11844. 81 ,//邀请/公务活
  11845. 82 ,//团组客户保险
  11846. 85 ,//机票预订
  11847. 98 ,//其他款项
  11848. 285 ,//收款退还
  11849. 751 ,//酒店早餐
  11850. 1015 // 超支费用
  11851. };
  11852. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  11853. {
  11854. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  11855. }
  11856. #endregion
  11857. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  11858. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  11859. if (_GroupCostParameters.Count <= 0)
  11860. {
  11861. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  11862. }
  11863. if (_GroupCostParameters[0].IsShare == 0)
  11864. {
  11865. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  11866. }
  11867. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  11868. //处理date为空问题
  11869. if (_GroupCosts.Count > 0)
  11870. {
  11871. for (int i = 0; i < _GroupCosts.Count; i++)
  11872. {
  11873. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  11874. {
  11875. if (i > 0)
  11876. {
  11877. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  11878. }
  11879. }
  11880. }
  11881. }
  11882. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  11883. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  11884. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  11885. string currCode = "";
  11886. #region currCode 验证
  11887. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  11888. if (isInt)
  11889. {
  11890. var currData = currDatas.Find(it => it.Id == intCurrency);
  11891. if (currData != null)
  11892. {
  11893. currCode = currData.Name;
  11894. }
  11895. }
  11896. else
  11897. {
  11898. currCode = _GroupCostParameters[0].Currency.Trim();
  11899. }
  11900. #endregion
  11901. //op,酒店单段模式存储
  11902. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  11903. {
  11904. CurrencyCode = currCode,
  11905. Rate = _GroupCostParameters[0].Rate,
  11906. CostType = _GroupCostParameters[0].CostType,
  11907. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  11908. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  11909. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  11910. };
  11911. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  11912. if (_GroupCostParameters.Count == 2)
  11913. {
  11914. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  11915. }
  11916. foreach (var item in _GroupCostParameters)
  11917. {
  11918. decimal _rate = 1;
  11919. decimal _rate1 = item.Rate;
  11920. decimal _scale = 1;
  11921. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  11922. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  11923. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  11924. //if (userInfo != null)
  11925. //{
  11926. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  11927. // {
  11928. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  11929. // {
  11930. // _scale = 1.00M;
  11931. // }
  11932. // }
  11933. //}
  11934. #endregion
  11935. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  11936. {
  11937. CurrencyCode = currCode,
  11938. Rate = _rate1,
  11939. CostType = item.CostType,
  11940. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  11941. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  11942. CostTypeNumber = item.CostTypenumber
  11943. };
  11944. if (_GroupCostParameters.Count > 1)
  11945. {
  11946. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  11947. }
  11948. else
  11949. {
  11950. modulePromptInfo.CostTypeNumber = item.LYJRS;
  11951. }
  11952. if (dto.CTable == 79)//
  11953. {
  11954. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  11955. modulePromptInfo.TotalCost = item.DJCB;
  11956. }
  11957. List<string> costTypes = new List<string>() { "A", "B" };
  11958. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  11959. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  11960. if (_GroupCostsDuplicates.Count() == 1)
  11961. {
  11962. _GroupCostsTypeData = _GroupCosts;
  11963. }
  11964. else
  11965. {
  11966. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  11967. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  11968. }
  11969. /*
  11970. * 76 酒店预订
  11971. * 77 行程
  11972. * 79 车/导游地接
  11973. * 80 签证
  11974. * 81 邀请/公务活动
  11975. * 82 团组客户保险
  11976. * 85 机票预订
  11977. * 98 其他款项
  11978. * 285 收款退还
  11979. * 751 酒店早餐
  11980. * 1015 超支费用
  11981. */
  11982. switch (dto.CTable)
  11983. {
  11984. case 76: // 酒店预订
  11985. _ModuleSubPromptInfo.AddRange(
  11986. _GroupCostsTypeData.Select(it => new
  11987. {
  11988. it.DAY,
  11989. it.Date,
  11990. it.ACCON,
  11991. it.ITIN,
  11992. it.SGR,
  11993. it.TBR,
  11994. it.JS_ES,
  11995. it.Suite
  11996. })
  11997. );
  11998. break;
  11999. case 79: // 车/导游地接
  12000. _ModuleSubPromptInfo.AddRange(
  12001. _GroupCostsTypeData.Select(it => new
  12002. {
  12003. Date = it.Date, //日期
  12004. CarFee = it.CarCost * _rate * _scale, //车费用
  12005. CarType = it.CarType, //车型
  12006. DriverFee = it.CFS * _rate * _scale, //司机工资
  12007. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  12008. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  12009. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  12010. GuideFee = it.TGS * _rate * _scale, //导游费用
  12011. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  12012. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  12013. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  12014. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  12015. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  12016. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  12017. Breakfast = it.B * _rate * _scale, //早餐费
  12018. Lunch = it.L * _rate * _scale, //午餐费
  12019. Dinner = it.D * _rate * _scale, //晚餐费
  12020. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  12021. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  12022. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  12023. TicketFee = it.EF * _rate * _scale, //门票费
  12024. TicketRemark = it.EFR, //门票费描述
  12025. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  12026. TravelSupplies = it.TE * _rate * _scale, //出行物资
  12027. SpentCash = it.PC * _rate * _scale, //零用金
  12028. LeadersFee = it.TLF * _rate * _scale, //领队费
  12029. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  12030. })
  12031. );
  12032. break;
  12033. case 85: // 机票
  12034. List<dynamic> datas = new List<dynamic>();
  12035. datas.Add(
  12036. new
  12037. {
  12038. AirType = "经济舱",
  12039. AirNum = item.JJCRS,
  12040. AirDRCB = item.JJCCB,
  12041. AirZCB = (item.JJCRS * item.JJCCB)
  12042. }
  12043. );
  12044. datas.Add(
  12045. new
  12046. {
  12047. AirType = "公务舱",
  12048. AirNum = item.GWCRS,
  12049. AirDRCB = item.GWCCB,
  12050. AirZCB = (item.GWCRS * item.GWCCB)
  12051. }
  12052. );
  12053. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  12054. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  12055. modulePromptInfo.Data = new
  12056. {
  12057. airFeeData = datas,
  12058. airInitData = initDatas
  12059. };
  12060. _ModulePromptInfos.Add(modulePromptInfo);
  12061. break;
  12062. default:
  12063. break;
  12064. }
  12065. }
  12066. if (dto.CTable != 85)
  12067. {
  12068. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  12069. _ModulePromptInfos.Add(_ModulePromptInfo);
  12070. }
  12071. _view.ModulePromptInfos = _ModulePromptInfos;
  12072. return Ok(JsonView(true, "操作成功!", _view));
  12073. }
  12074. catch (Exception ex)
  12075. {
  12076. return Ok(JsonView(false, ex.Message));
  12077. }
  12078. }
  12079. /// <summary>
  12080. /// 根据黑屏代码重新生成行程
  12081. /// </summary>
  12082. /// <param name="dto"></param>
  12083. /// <returns></returns>
  12084. [HttpPost]
  12085. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  12086. {
  12087. var jw = JsonView(false);
  12088. var Create = _GroupCostRepository.
  12089. CreateGroupCostByBlackCode(dto.Diid);
  12090. jw.Msg = Create.Msg;
  12091. if (Create.Code == 0)
  12092. {
  12093. jw.Code = 200;
  12094. jw.Data = new
  12095. {
  12096. groupCost = Create.Data,
  12097. blackCodeIsTrue = true
  12098. };
  12099. }
  12100. else
  12101. {
  12102. jw.Code = 400;
  12103. jw.Data = new
  12104. {
  12105. groupCost = Create.Data,
  12106. blackCodeIsTrue = false,
  12107. };
  12108. }
  12109. return Ok(jw);
  12110. }
  12111. /// <summary>
  12112. /// 成本获取OP历史车费用
  12113. /// </summary>
  12114. /// <param name="dto"></param>
  12115. /// <returns></returns>
  12116. [HttpPost]
  12117. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  12118. {
  12119. var jw = JsonView(false);
  12120. try
  12121. {
  12122. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  12123. //获取现有所有车的数据
  12124. if (!dto.Param.IsNullOrWhiteSpace())
  12125. {
  12126. string sql = $@"
  12127. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  12128. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  12129. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  12130. 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
  12131. AND gctggr.ServiceEndTime is not NULL
  12132. ORDER by gctggrc.id DESC
  12133. ";
  12134. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  12135. var numeberResult = await Task.Run(() =>
  12136. {
  12137. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  12138. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  12139. return numberArr;
  12140. });
  12141. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  12142. foreach (var item in numeberResult)
  12143. {
  12144. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  12145. {
  12146. Country = "数据异常!",
  12147. City = string.Empty,
  12148. };
  12149. item.Area = find.Country + " " + find.City;
  12150. }
  12151. dbResult.AddRange(numeberResult);
  12152. if (dto.Param.Contains("、"))
  12153. {
  12154. var sp = dto.Param.Split("、");
  12155. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  12156. .Where(x =>
  12157. {
  12158. return System.Array.Exists(sp, e =>
  12159. {
  12160. bool where = false;
  12161. if (x.Area != null)
  12162. {
  12163. where = x.Area.Contains(e);
  12164. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  12165. {
  12166. return false;
  12167. }
  12168. }
  12169. if (x.PriceName != null && !where)
  12170. {
  12171. where = x.PriceName.Contains(e);
  12172. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  12173. {
  12174. return false;
  12175. }
  12176. }
  12177. return where;
  12178. });
  12179. }).ToList();
  12180. }
  12181. else
  12182. {
  12183. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  12184. .Where(x =>
  12185. {
  12186. bool where = false;
  12187. if (x.Area != null)
  12188. {
  12189. where = x.Area.Contains(dto.Param);
  12190. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  12191. {
  12192. return false;
  12193. }
  12194. }
  12195. if (x.PriceName != null && !where)
  12196. {
  12197. where = x.PriceName.Contains(dto.Param);
  12198. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  12199. {
  12200. return false;
  12201. }
  12202. }
  12203. return where;
  12204. }
  12205. )
  12206. .ToList();
  12207. }
  12208. }
  12209. var view = dbResult.Select(x =>
  12210. {
  12211. decimal dp = 0.00M;
  12212. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  12213. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  12214. if (string.IsNullOrWhiteSpace(x.DatePrice))
  12215. {
  12216. if (startB && endB)
  12217. {
  12218. var timesp = endD.Subtract(startD);
  12219. if ((timesp.Days + 1) != 0)
  12220. {
  12221. dp = x.Price / (timesp.Days + 1);
  12222. }
  12223. }
  12224. }
  12225. else
  12226. {
  12227. dp = x.Price;
  12228. }
  12229. return new
  12230. {
  12231. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  12232. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  12233. x.Area,
  12234. x.id,
  12235. price = x.Price.ToString("F2"),
  12236. x.PriceName,
  12237. x.PriceContent,
  12238. x.TeamName,
  12239. x.DatePrice,
  12240. dayPrice = dp.ToString("F2"),
  12241. };
  12242. }).OrderByDescending(x => x.id).ToList();
  12243. jw = JsonView(true, "获取成功!", view);
  12244. }
  12245. catch (Exception e)
  12246. {
  12247. jw = JsonView(false, e.Message);
  12248. }
  12249. return Ok(jw);
  12250. }
  12251. #endregion
  12252. #region 酒店预订 新 雷怡 2023-12-28 17:45
  12253. /// <summary>
  12254. /// 酒店预订
  12255. /// 酒店费用列表 根据团组Id查询
  12256. /// </summary>
  12257. /// <param name="_dto"></param>
  12258. /// <returns></returns>
  12259. [HttpPost]
  12260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12261. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  12262. {
  12263. #region 参数验证
  12264. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12265. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12266. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12267. #region 团组操作权限验证 76 酒店预定模块
  12268. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12269. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12270. #endregion
  12271. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12272. #region 页面操作权限验证
  12273. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12274. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12275. #endregion
  12276. #endregion
  12277. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  12278. }
  12279. /// <summary>
  12280. /// 酒店预订
  12281. /// 基础数据
  12282. /// </summary>
  12283. /// <param name="_dto"></param>
  12284. /// <returns></returns>
  12285. [HttpPost]
  12286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12287. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  12288. {
  12289. #region 参数验证
  12290. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12291. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12292. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12293. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12294. #region 页面操作权限验证
  12295. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12296. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12297. #endregion
  12298. #region 团组操作权限验证 76 酒店预定模块
  12299. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12300. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12301. #endregion
  12302. #endregion
  12303. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  12304. }
  12305. /// <summary>
  12306. /// 酒店预订
  12307. /// 创建 入住卷号码
  12308. /// </summary>
  12309. /// <param name="_dto"></param>
  12310. /// <returns></returns>
  12311. [HttpPost]
  12312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12313. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  12314. {
  12315. #region 参数验证
  12316. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12317. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12318. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12319. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12320. #region 页面操作权限验证
  12321. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12322. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12323. #endregion
  12324. #region 团组操作权限验证 76 酒店预定模块
  12325. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12326. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12327. #endregion
  12328. #endregion
  12329. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  12330. if (data.Code != 0)
  12331. {
  12332. return Ok(JsonView(false, data.Msg));
  12333. }
  12334. return Ok(JsonView(true, data.Msg, data.Data));
  12335. }
  12336. /// <summary>
  12337. /// 酒店预订
  12338. /// 详情
  12339. /// </summary>
  12340. /// <param name="_dto"></param>
  12341. /// <returns></returns>
  12342. [HttpPost]
  12343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12344. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  12345. {
  12346. #region 参数验证
  12347. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  12348. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12349. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  12350. #region 团组操作权限验证 76 酒店预定模块
  12351. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12352. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12353. #endregion
  12354. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12355. #region 页面操作权限验证
  12356. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12357. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12358. #endregion
  12359. #endregion
  12360. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  12361. }
  12362. /// <summary>
  12363. /// 酒店预订
  12364. /// Add Or Edit
  12365. /// </summary>
  12366. /// <param name="_dto"></param>
  12367. /// <returns></returns>
  12368. [HttpPost]
  12369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12370. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  12371. {
  12372. #region 参数验证
  12373. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12374. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12375. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12376. #region 团组操作权限验证 76 酒店预定模块
  12377. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12378. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12379. #endregion
  12380. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12381. #region 页面操作权限验证
  12382. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12383. if (_dto.Id == 0) // Add
  12384. {
  12385. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  12386. }
  12387. else if (_dto.Id > 1) // Edit
  12388. {
  12389. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  12390. }
  12391. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  12392. #endregion
  12393. #endregion
  12394. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  12395. if (_view.Code != 200)
  12396. {
  12397. return Ok(_view);
  12398. }
  12399. #region 成本无酒店价格数据进入超支
  12400. _sqlSugar.BeginTran();
  12401. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  12402. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  12403. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  12404. for (int i = 0; i < groupCost.Count; i++)
  12405. {
  12406. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  12407. {
  12408. groupCost[i].Date = groupCost[i - 1].Date;
  12409. }
  12410. }
  12411. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  12412. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  12413. List<Fin_GroupExtraCostDto_OP>();
  12414. if (start_Bool && end_Bool)
  12415. {
  12416. while (start_Time < end_Time)
  12417. {
  12418. foreach (var item in groupCost_Grp)
  12419. {
  12420. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  12421. {
  12422. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  12423. {
  12424. extraCostList.Add(new
  12425. Fin_GroupExtraCostDto_OP
  12426. {
  12427. Area = _dto.AreaId,
  12428. coefficient = 1.5M,
  12429. createUser = _dto.UserId,
  12430. currency = _dto.CardPriceCurrency,
  12431. diId = _dto.DiId,
  12432. ManagerConfirm = 0,
  12433. SupervisorConfirm = 0,
  12434. SYsupervisorConfirm = 0,
  12435. editType = 1,
  12436. PortType = 1,
  12437. price = _dto.CardPrice,
  12438. PriceCount = 1,
  12439. priceType = 1027,
  12440. priceDetailType = 1044,
  12441. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  12442. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  12443. });
  12444. }
  12445. }
  12446. }
  12447. start_Time = start_Time.AddDays(1);
  12448. }
  12449. }
  12450. if (extraCostList.Any())
  12451. {
  12452. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  12453. }
  12454. _sqlSugar.CommitTran();
  12455. #endregion
  12456. #region 应用推送
  12457. try
  12458. {
  12459. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  12460. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  12461. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  12462. var diId = _dto.DiId;
  12463. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12464. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12465. #region 操作记录
  12466. var opInfo = new Crm_TableOperationRecord() {
  12467. TableName = "Grp_HotelReservations",
  12468. PortType = _dto.PortType,
  12469. DataId = hotelId,
  12470. CreateUserId = _dto.UserId
  12471. };
  12472. var opStatus = OperationEnum.NoOperation;
  12473. if (_dto.Id<1) //添加操作
  12474. {
  12475. opInfo.OperationItem = OperationEnum.Add;
  12476. }
  12477. else if (_dto.Id > 0)
  12478. {
  12479. opInfo.OperationItem = OperationEnum.Edit;
  12480. }
  12481. string opRemark = string.Empty;
  12482. if (ccpInfo != null)
  12483. {
  12484. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  12485. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  12486. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  12487. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  12488. }
  12489. opInfo.Remark = opRemark;
  12490. await _tableorRep.AddAsync(opInfo);
  12491. #endregion
  12492. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  12493. //2024-10-21 新增LZ UID
  12494. var userIds = new List<int>() { 21 };
  12495. string title = $"费用审核";
  12496. string content = "";
  12497. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12498. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12499. try
  12500. {
  12501. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12502. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  12503. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  12504. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  12505. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  12506. }
  12507. catch (Exception ex )
  12508. {
  12509. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  12510. }
  12511. }
  12512. catch (Exception ex)
  12513. {
  12514. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  12515. }
  12516. try
  12517. {
  12518. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  12519. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  12520. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  12521. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12522. //自动审核
  12523. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  12524. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  12525. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  12526. //2024-10-21 新增LZ UID
  12527. var userIds = new List<int>() { 21 };
  12528. string title = $"系统通知";
  12529. var diId = _dto.DiId;
  12530. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12531. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12532. string content = "";
  12533. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12534. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12535. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12536. }
  12537. catch (Exception ex)
  12538. {
  12539. }
  12540. #endregion
  12541. return Ok(_view);
  12542. }
  12543. /// <summary>
  12544. /// 酒店自动审核测试
  12545. /// Add Or Edit
  12546. /// </summary>
  12547. /// <param name="_dto"></param>
  12548. /// <returns></returns>
  12549. [HttpPost]
  12550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12551. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  12552. {
  12553. #region 应用推送
  12554. try
  12555. {
  12556. //自动审核
  12557. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  12558. }
  12559. catch (Exception ex)
  12560. {
  12561. return Ok(JsonView(false, "操作失败"));
  12562. }
  12563. #endregion
  12564. return Ok(JsonView(false, "操作成功"));
  12565. }
  12566. /// <summary>
  12567. /// 酒店预订
  12568. /// Del
  12569. /// </summary>
  12570. /// <param name="_dto"></param>
  12571. /// <returns></returns>
  12572. [HttpPost]
  12573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12574. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  12575. {
  12576. #region 参数验证
  12577. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12578. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12579. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12580. #region 团组操作权限验证 76 酒店预定模块
  12581. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12582. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12583. #endregion
  12584. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12585. #region 页面操作权限验证
  12586. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12587. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  12588. #endregion
  12589. #endregion
  12590. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  12591. #region 操作记录
  12592. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  12593. {
  12594. TableName = "Grp_HotelReservations",
  12595. PortType = _dto.PortType,
  12596. OperationItem = OperationEnum.Del,
  12597. DataId = _dto.Id,
  12598. CreateUserId = _dto.UserId
  12599. });
  12600. #endregion
  12601. return Ok(data);
  12602. }
  12603. /// <summary>
  12604. /// 酒店预订
  12605. /// 生成VOUCHER
  12606. /// 2024.05.06 之前版本
  12607. /// </summary>
  12608. /// <param name="_dto"></param>
  12609. /// <returns></returns>
  12610. [HttpPost]
  12611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12612. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  12613. {
  12614. try
  12615. {
  12616. #region 参数验证
  12617. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12618. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12619. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12620. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  12621. #region 团组操作权限验证 76 酒店预定模块
  12622. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12623. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12624. #endregion
  12625. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12626. #region 页面操作权限验证
  12627. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12628. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12629. #endregion
  12630. #endregion
  12631. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  12632. //判断数据是否完整
  12633. if (hr != null)
  12634. {
  12635. if (!string.IsNullOrEmpty(hr.DetermineNo))
  12636. {
  12637. string strFileName = "HotelStatement/";
  12638. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  12639. if (dele != null)
  12640. strFileName += dele.TourCode;
  12641. //载入模板
  12642. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  12643. Document doc = new Document(sss);
  12644. DocumentBuilder builder = new DocumentBuilder(doc);
  12645. #region 替换Word模板书签内容
  12646. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  12647. //入住卷预定号码
  12648. if (doc.Range.Bookmarks["VNO"] != null)
  12649. {
  12650. Bookmark mark = doc.Range.Bookmarks["VNO"];
  12651. mark.Text = hr.CheckNumber;
  12652. }
  12653. //酒店时间
  12654. if (doc.Range.Bookmarks["Date"] != null)
  12655. {
  12656. Bookmark mark = doc.Range.Bookmarks["Date"];
  12657. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  12658. }
  12659. //团号
  12660. if (doc.Range.Bookmarks["TNo"] != null)
  12661. {
  12662. Bookmark mark = doc.Range.Bookmarks["TNo"];
  12663. mark.Text = dele.TourCode;
  12664. }
  12665. //预定号码
  12666. if (doc.Range.Bookmarks["BookingId"] != null)
  12667. {
  12668. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  12669. mark.Text = hr.ReservationsNo;
  12670. }
  12671. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  12672. {
  12673. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  12674. mark.Text = hr.DetermineNo;
  12675. }
  12676. //酒店城市
  12677. if (doc.Range.Bookmarks["City"] != null)
  12678. {
  12679. Bookmark mark = doc.Range.Bookmarks["City"];
  12680. mark.Text = hr.City;
  12681. }
  12682. //酒店名称
  12683. if (doc.Range.Bookmarks["HName"] != null)
  12684. {
  12685. Bookmark mark = doc.Range.Bookmarks["HName"];
  12686. mark.Text = hr.HotelName;
  12687. }
  12688. //酒店地址
  12689. if (doc.Range.Bookmarks["Address"] != null)
  12690. {
  12691. Bookmark mark = doc.Range.Bookmarks["Address"];
  12692. mark.Text = hr.HotelAddress;
  12693. }
  12694. //酒店电话
  12695. if (doc.Range.Bookmarks["Tel"] != null)
  12696. {
  12697. Bookmark mark = doc.Range.Bookmarks["Tel"];
  12698. mark.Text = hr.HotelTel;
  12699. }
  12700. //酒店传真
  12701. if (doc.Range.Bookmarks["Fax"] != null)
  12702. {
  12703. Bookmark mark = doc.Range.Bookmarks["Fax"];
  12704. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  12705. {
  12706. mark.Text = hr.HotelFax;
  12707. }
  12708. }
  12709. //入住时间
  12710. if (doc.Range.Bookmarks["CIn"] != null)
  12711. {
  12712. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  12713. Bookmark mark = doc.Range.Bookmarks["CIn"];
  12714. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  12715. }
  12716. //退房时间
  12717. if (doc.Range.Bookmarks["COut"] != null)
  12718. {
  12719. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  12720. Bookmark mark = doc.Range.Bookmarks["COut"];
  12721. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  12722. }
  12723. //客户名称
  12724. if (doc.Range.Bookmarks["GName"] != null)
  12725. {
  12726. string guestName = "";
  12727. string[] clients = new string[] { };
  12728. if (hr.GuestName.Contains(","))
  12729. {
  12730. clients = hr.GuestName.Split(",");
  12731. }
  12732. else
  12733. {
  12734. clients = new string[] { hr.GuestName };
  12735. }
  12736. List<int> clientIds_int = new List<int>();
  12737. if (clients.Length > 0)
  12738. {
  12739. foreach (var item in clients)
  12740. {
  12741. if (item.IsNumeric())
  12742. {
  12743. clientIds_int.Add(int.Parse(item));
  12744. }
  12745. }
  12746. }
  12747. if (clientIds_int.Count > 0)
  12748. {
  12749. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  12750. foreach (var client in _clientDatas)
  12751. {
  12752. //男
  12753. if (client.Sex == 0) guestName += $"Mr.";
  12754. //女
  12755. else if (client.Sex == 1) guestName += $"Ms.";
  12756. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  12757. {
  12758. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  12759. }
  12760. //guestName += $"{client.Pinyin},";
  12761. }
  12762. if (guestName.Length > 0)
  12763. {
  12764. guestName = guestName.Substring(0, guestName.Length - 1);
  12765. }
  12766. }
  12767. else
  12768. {
  12769. guestName = hr.GuestName;
  12770. }
  12771. Bookmark mark = doc.Range.Bookmarks["GName"];
  12772. mark.Text = guestName;
  12773. }
  12774. //房间介绍
  12775. if (doc.Range.Bookmarks["ROOM"] != null)
  12776. {
  12777. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  12778. mark.Text = hr.RoomExplanation;
  12779. }
  12780. //报价描述
  12781. if (doc.Range.Bookmarks["NOTE"] != null)
  12782. {
  12783. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  12784. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  12785. if (ss != null)
  12786. mark.Text = ss.Name;
  12787. }
  12788. //入住时间
  12789. if (doc.Range.Bookmarks["CheckIn"] != null)
  12790. {
  12791. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  12792. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  12793. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  12794. }
  12795. //退房时间
  12796. if (doc.Range.Bookmarks["CheckOut"] != null)
  12797. {
  12798. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  12799. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  12800. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  12801. }
  12802. //日期
  12803. if (doc.Range.Bookmarks["DT"] != null)
  12804. {
  12805. Bookmark mark = doc.Range.Bookmarks["DT"];
  12806. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  12807. }
  12808. //名称
  12809. if (doc.Range.Bookmarks["VName"] != null)
  12810. {
  12811. Bookmark mark = doc.Range.Bookmarks["VName"];
  12812. mark.Text = hr.HotelName;
  12813. }
  12814. //号码
  12815. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  12816. {
  12817. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  12818. mark.Text = hr.CheckNumber;
  12819. }
  12820. #endregion
  12821. strFileName += "VOUCHER.doc";
  12822. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12823. doc.Save(fileDir);
  12824. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12825. return Ok(JsonView(true, "操作成功!", Url));
  12826. }
  12827. else
  12828. {
  12829. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  12830. }
  12831. }
  12832. else
  12833. {
  12834. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  12835. }
  12836. }
  12837. catch (Exception ex)
  12838. {
  12839. return Ok(JsonView(false, ex.Message));
  12840. }
  12841. }
  12842. /// <summary>
  12843. /// 酒店预订
  12844. /// 生成VOUCHER
  12845. /// 2024.05.06 之后版本
  12846. /// </summary>
  12847. /// <param name="_dto"></param>
  12848. /// <returns></returns>
  12849. [HttpPost]
  12850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12851. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  12852. {
  12853. #region 参数验证
  12854. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12855. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12856. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12857. #region 团组操作权限验证 76 酒店预定模块
  12858. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12859. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12860. #endregion
  12861. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12862. #region 页面操作权限验证
  12863. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12864. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12865. #endregion
  12866. #endregion
  12867. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  12868. //判断数据是否完整
  12869. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  12870. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12871. string strFileName = "HotelStatement/";
  12872. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12873. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  12874. #region 数据处理
  12875. List<int> guestIds = new List<int>();
  12876. int index = 0;
  12877. foreach (var item in hrDtas)
  12878. {
  12879. if (item.GuestName.Contains(","))
  12880. {
  12881. string[] guestIdArr = item.GuestName.Split(',');
  12882. foreach (var guestIdStr in guestIdArr)
  12883. {
  12884. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  12885. if (guestBool)
  12886. {
  12887. guestIds.Add(guestId);
  12888. }
  12889. }
  12890. }
  12891. else guestNames += item.GuestName;
  12892. var voucherInfo = new HotelVoucherInfoView()
  12893. {
  12894. HotelName = item.HotelName,
  12895. CheckInDate = item.CheckInDate,
  12896. CheckOutDate = item.CheckOutDate,
  12897. ConfirmationNumber = item.DetermineNo.Trim(),
  12898. RoomType = item.RoomExplanation
  12899. };
  12900. vouchers.Add(voucherInfo);
  12901. }
  12902. if (guestIds.Count > 0)
  12903. {
  12904. guestIds = guestIds.Distinct().ToList();
  12905. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  12906. if (guestDatas.Count > 0)
  12907. {
  12908. guestNames = "";
  12909. foreach (var guest in guestDatas)
  12910. {
  12911. string guestName = "";
  12912. if (guest.Sex == 0) guestName += @"MR.";
  12913. else if (guest.Sex == 1) guestName += @"MS.";
  12914. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  12915. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  12916. guestNames += @$"{guestName.Trim()}、";
  12917. }
  12918. if (guestNames.Length > 0)
  12919. {
  12920. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  12921. }
  12922. }
  12923. }
  12924. #endregion
  12925. //载入模板
  12926. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  12927. Document doc = new Document(sss);
  12928. DocumentBuilder builder = new DocumentBuilder(doc);
  12929. if (doc.Range.Bookmarks["GuestName"] != null)
  12930. {
  12931. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  12932. mark.Text = guestNames;
  12933. }
  12934. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12935. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  12936. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  12937. for (int i = 1; i <= vouchers.Count; i++)
  12938. {
  12939. HotelVoucherInfoView hviv = vouchers[i - 1];
  12940. builder.MoveToCell(0, i, 0, 0);
  12941. builder.Write(hviv.HotelName);
  12942. builder.MoveToCell(0, i, 1, 0);
  12943. builder.Write(hviv.CheckInDate);
  12944. builder.MoveToCell(0, i, 2, 0);
  12945. builder.Write(hviv.CheckOutDate);
  12946. builder.MoveToCell(0, i, 3, 0);
  12947. builder.Write(hviv.RoomType);
  12948. builder.MoveToCell(0, i, 4, 0);
  12949. builder.Write(hviv.ConfirmationNumber);
  12950. }
  12951. //删除多余行
  12952. int currRowIndex = vouchers.Count + 1;
  12953. int delRows = 21 - currRowIndex;
  12954. if (delRows > 0)
  12955. {
  12956. for (int i = 0; i < delRows; i++)
  12957. {
  12958. table.Rows.RemoveAt(currRowIndex);
  12959. //cultivateRowIndex++;
  12960. }
  12961. }
  12962. strFileName += "VOUCHER.docx";
  12963. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12964. doc.Save(fileDir);
  12965. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12966. return Ok(JsonView(true, "操作成功!", Url));
  12967. }
  12968. /// <summary>
  12969. /// 酒店预订
  12970. /// 生成VOUCHER 批量生成
  12971. /// New
  12972. /// </summary>
  12973. /// <param name="_dto"></param>
  12974. /// <returns></returns>
  12975. [HttpPost]
  12976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12977. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  12978. {
  12979. #region 参数验证
  12980. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12981. if (_dto.PageId < 1) _dto.PageId = 28;
  12982. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12983. #region 团组操作权限验证 76 酒店预定模块
  12984. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12985. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12986. #endregion
  12987. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12988. #region 页面操作权限验证
  12989. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12990. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12991. #endregion
  12992. #endregion
  12993. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  12994. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  12995. .OrderBy(x => x.CheckInDate)
  12996. .ToListAsync();
  12997. //判断数据是否完整
  12998. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  12999. string strFileName = "HotelStatement/";
  13000. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  13001. if (dele != null)
  13002. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  13003. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  13004. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  13005. .Where(it => it.IsDel == 0)
  13006. .ToListAsync();
  13007. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  13008. for (int i = 0; i < hrDtas.Count; i++)
  13009. {
  13010. string guestNames = string.Empty;
  13011. List<int> guestIds = new List<int>();
  13012. var item = hrDtas[i];
  13013. //处理客户姓名
  13014. if (item.GuestName.Contains(","))
  13015. {
  13016. string[] guestIdArr = item.GuestName.Split(',');
  13017. foreach (var guestIdStr in guestIdArr)
  13018. if (int.TryParse(guestIdStr, out int guestId))
  13019. guestIds.Add(guestId);
  13020. }
  13021. else
  13022. {
  13023. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  13024. if (guestIdBool)
  13025. {
  13026. guestIds.Add(guestId);
  13027. }
  13028. //NaN
  13029. if (item.GuestName.Contains("NaN"))
  13030. {
  13031. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  13032. }
  13033. }
  13034. if (guestIds.Count > 0)
  13035. {
  13036. guestIds = guestIds.Distinct().ToList();
  13037. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  13038. if (guestDatas1.Count > 0)
  13039. {
  13040. guestNames = "";
  13041. foreach (var guest in guestDatas1)
  13042. {
  13043. string guestName = "";
  13044. if (guest.Sex == 0) guestName += @"MR.";
  13045. else if (guest.Sex == 1) guestName += @"MS.";
  13046. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  13047. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  13048. guestNames += @$"{guestName.Trim()}、";
  13049. }
  13050. if (guestNames.Length > 0)
  13051. {
  13052. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  13053. }
  13054. }
  13055. }
  13056. //if (!string.IsNullOrEmpty(guestNames))
  13057. //{
  13058. hrDtas[i].GuestName = guestNames;
  13059. //}
  13060. }
  13061. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  13062. Document doc = new Document();
  13063. DocumentBuilder builder = new DocumentBuilder(doc);
  13064. try
  13065. {
  13066. builder.MoveToDocumentStart();
  13067. foreach (var item in hrDtas)
  13068. {
  13069. //标题
  13070. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  13071. builder.ParagraphFormat.LineSpacing = 1;
  13072. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13073. builder.ParagraphFormat.Style.Font.Size = 9;
  13074. builder.ParagraphFormat.Style.Font.Bold = true;
  13075. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  13076. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  13077. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  13078. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  13079. builder.ParagraphFormat.LineSpacing = 1;
  13080. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13081. builder.ParagraphFormat.Style.Font.Size = 9;
  13082. builder.ParagraphFormat.Style.Font.Bold = true;
  13083. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  13084. builder.StartTable();
  13085. // 设置边框颜色
  13086. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  13087. //设置边框样式
  13088. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  13089. //表格
  13090. #region 第一行
  13091. builder.InsertCell();
  13092. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13093. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13094. //builder.CellFormat.AllowAutoFit = false;
  13095. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13096. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13097. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13098. builder.CellFormat.WrapText = true; //自动换行
  13099. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13100. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  13101. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13102. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13103. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13104. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13105. builder.Write("TOUR NO:");
  13106. builder.InsertCell();
  13107. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13108. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13109. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13110. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13111. builder.ParagraphFormat.Style.Font.Bold = false;
  13112. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13113. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13114. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13115. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13116. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13117. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13118. builder.Write($"{dele?.TourCode ?? "-"}");
  13119. builder.InsertCell();
  13120. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13121. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13122. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13123. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13124. builder.ParagraphFormat.Style.Font.Bold = false;
  13125. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13126. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13127. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13128. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13129. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13130. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13131. builder.Write($"CITY:");
  13132. builder.InsertCell();
  13133. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13134. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13135. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13136. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13137. builder.ParagraphFormat.Style.Font.Bold = false;
  13138. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13139. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13140. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13141. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13142. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13143. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13144. builder.Write($"{item.City}");
  13145. builder.EndRow();
  13146. #endregion
  13147. #region 第二行
  13148. builder.InsertCell();
  13149. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13150. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13151. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13152. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13153. builder.ParagraphFormat.Style.Font.Bold = false;
  13154. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13155. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13156. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13157. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13158. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13159. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13160. builder.Write("CONFIRMATION NO:");
  13161. builder.InsertCell();
  13162. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13163. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13164. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13165. builder.ParagraphFormat.Style.Font.Bold = false;
  13166. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13167. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13168. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13169. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13170. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13171. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13172. builder.CellFormat.VerticalMerge = CellMerge.None;
  13173. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13174. builder.Write($"{item.DetermineNo}");
  13175. builder.InsertCell();
  13176. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13177. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13178. builder.InsertCell();
  13179. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13180. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13181. builder.EndRow();
  13182. #endregion
  13183. #region 第三行
  13184. builder.InsertCell();
  13185. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13186. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13187. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13188. builder.ParagraphFormat.Style.Font.Bold = false;
  13189. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13190. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13191. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13192. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13193. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13194. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13195. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13196. builder.Write($"HOTEL NAME:");
  13197. builder.InsertCell();
  13198. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13199. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13200. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13201. builder.ParagraphFormat.Style.Font.Bold = false;
  13202. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13203. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13204. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13205. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13206. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13207. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13208. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13209. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13210. builder.Write($"{item.HotelName}");
  13211. builder.InsertCell();
  13212. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13213. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13214. builder.InsertCell();
  13215. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13216. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13217. builder.EndRow();
  13218. #endregion
  13219. #region 第四行
  13220. builder.InsertCell();
  13221. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13222. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13223. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13224. builder.ParagraphFormat.Style.Font.Bold = false;
  13225. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13226. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13227. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13228. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13229. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13230. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13231. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13232. builder.Write($"HOTEL ADDRESS:");
  13233. builder.InsertCell();
  13234. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13235. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13236. builder.ParagraphFormat.Style.Font.Size = 8;
  13237. builder.ParagraphFormat.Style.Font.Bold = false;
  13238. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13239. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13240. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13241. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13242. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13243. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13244. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13245. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13246. builder.Write($"{item.HotelAddress}");
  13247. builder.InsertCell();
  13248. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13249. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13250. builder.InsertCell();
  13251. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13252. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13253. builder.EndRow();
  13254. #endregion
  13255. #region 第五行
  13256. builder.InsertCell();
  13257. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13258. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13259. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13260. builder.ParagraphFormat.Style.Font.Bold = false;
  13261. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13262. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13263. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13264. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13265. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13266. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13267. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13268. builder.Write("TEL:");
  13269. builder.InsertCell();
  13270. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13271. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13272. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13273. builder.ParagraphFormat.Style.Font.Bold = false;
  13274. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13275. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13276. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13277. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13278. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13279. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13280. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13281. builder.Write($"{item.HotelTel}");
  13282. builder.InsertCell();
  13283. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13284. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13285. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13286. builder.ParagraphFormat.Style.Font.Bold = false;
  13287. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13288. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13289. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13290. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13291. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13292. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13293. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13294. builder.Write($"FAX:");
  13295. builder.InsertCell();
  13296. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13297. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13298. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13299. builder.ParagraphFormat.Style.Font.Bold = false;
  13300. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13301. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13302. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13303. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13304. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13305. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13306. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13307. builder.Write($"{item.HotelFax}");
  13308. builder.EndRow();
  13309. #endregion
  13310. #region 第六行
  13311. builder.InsertCell();
  13312. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13313. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13314. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13315. builder.ParagraphFormat.Style.Font.Bold = false;
  13316. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13317. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13318. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13319. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13320. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13321. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13322. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13323. builder.Write("CHECK IN:");
  13324. builder.InsertCell();
  13325. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13326. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13327. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13328. builder.ParagraphFormat.Style.Font.Bold = false;
  13329. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13330. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13331. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13332. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13333. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13334. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13335. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13336. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  13337. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  13338. builder.Write($"{checkInStr}");
  13339. builder.InsertCell();
  13340. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13341. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13342. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13343. builder.ParagraphFormat.Style.Font.Bold = false;
  13344. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13345. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13346. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13347. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13348. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13349. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13350. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13351. builder.Write($"CHECK OUT:");
  13352. builder.InsertCell();
  13353. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13354. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13355. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13356. builder.ParagraphFormat.Style.Font.Bold = false;
  13357. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13358. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13359. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13360. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13361. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13362. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13363. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13364. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  13365. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  13366. builder.Write($"{checkOutStr}");
  13367. builder.EndRow();
  13368. #endregion
  13369. #region 第七行
  13370. builder.InsertCell();
  13371. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13372. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13373. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13374. builder.ParagraphFormat.Style.Font.Bold = false;
  13375. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13376. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13377. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13378. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13379. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13380. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13381. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13382. builder.Write($"GUEST NAME:");
  13383. builder.InsertCell();
  13384. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13385. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13386. builder.ParagraphFormat.Style.Font.Size = 8;
  13387. builder.ParagraphFormat.Style.Font.Bold = false;
  13388. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13389. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13390. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13391. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13392. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13393. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13394. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13395. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13396. builder.Write($"{item.GuestName}");
  13397. builder.InsertCell();
  13398. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13399. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13400. builder.InsertCell();
  13401. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13402. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13403. builder.EndRow();
  13404. #endregion
  13405. #region 第八行
  13406. builder.InsertCell();
  13407. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13408. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13409. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13410. builder.ParagraphFormat.Style.Font.Bold = false;
  13411. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13412. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13413. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13414. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13415. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13416. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13417. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13418. builder.Write($"ROOM TYPE:");
  13419. builder.InsertCell();
  13420. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13421. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13422. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13423. builder.ParagraphFormat.Style.Font.Bold = false;
  13424. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13425. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13426. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13427. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13428. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13429. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13430. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13431. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13432. builder.Write($"{item.RoomExplanation}");
  13433. builder.InsertCell();
  13434. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13435. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13436. builder.InsertCell();
  13437. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13438. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13439. builder.EndRow();
  13440. #endregion
  13441. #region 第九行
  13442. builder.InsertCell();
  13443. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13444. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13445. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13446. builder.ParagraphFormat.Style.Font.Bold = false;
  13447. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13448. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13449. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13450. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13451. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13452. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13453. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13454. builder.Write($"NOTE:");
  13455. builder.InsertCell();
  13456. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13457. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13458. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13459. builder.ParagraphFormat.Style.Font.Bold = false;
  13460. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13461. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13462. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13463. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13464. 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.");
  13465. builder.InsertCell();
  13466. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13467. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13468. builder.InsertCell();
  13469. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13470. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13471. builder.EndRow();
  13472. #endregion
  13473. builder.EndTable();
  13474. //换行
  13475. builder.Writeln("");
  13476. builder.Writeln("");
  13477. }
  13478. #region 获取文档中的所有表格 设置文字自适应
  13479. // 获取文档中的所有表格。
  13480. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13481. {
  13482. // 遍历表格中的所有行。
  13483. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13484. {
  13485. foreach (Cell cell in row.Cells)
  13486. {
  13487. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  13488. cellFormat.Width = 0;
  13489. }
  13490. }
  13491. }
  13492. #endregion
  13493. #region 设置页眉
  13494. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  13495. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  13496. if (System.IO.File.Exists(voucherHeaderPath))
  13497. {
  13498. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  13499. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  13500. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  13501. Shape shape = builder.InsertImage(imageBytes);
  13502. // 调整图片位置
  13503. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  13504. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  13505. shape.Top = 50; // 将图片距离页眉上边缘的距离
  13506. shape.Left = 0; // 将图片距离页面左边缘的距离
  13507. shape.Width = 81; // 设置图片宽度
  13508. shape.Height = 36; // 设置图片高度
  13509. }
  13510. //靠右
  13511. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  13512. //// 设置页脚上下边距
  13513. //builder.PageSetup.HeaderDistance = 42;
  13514. // 添加页眉线
  13515. Aspose.Words.Border borderHeader = null;
  13516. try
  13517. {
  13518. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  13519. }
  13520. catch (Exception e)
  13521. {
  13522. // TODO Auto-generated catch block
  13523. //e.printStackTrace();
  13524. }
  13525. borderHeader.Shadow = true;
  13526. borderHeader.DistanceFromText = 2;
  13527. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  13528. #endregion
  13529. }
  13530. catch (Exception ex)
  13531. {
  13532. }
  13533. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  13534. doc.Save(fileDir);
  13535. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  13536. return Ok(JsonView(true, "操作成功!", Url));
  13537. }
  13538. /// <summary>
  13539. /// 酒店预订
  13540. /// 生成 预定成本 Excel
  13541. /// </summary>
  13542. /// <param name="_dto"></param>
  13543. /// <returns></returns>
  13544. [HttpPost]
  13545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13546. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  13547. {
  13548. #region 参数验证
  13549. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  13550. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  13551. if (!vadalitorRes.IsValid)
  13552. {
  13553. var errors = new StringBuilder();
  13554. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  13555. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  13556. }
  13557. #region 团组操作权限验证 76 酒店预定模块
  13558. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13559. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13560. #endregion
  13561. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13562. #region 页面操作权限验证
  13563. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13564. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13565. #endregion
  13566. #endregion
  13567. decimal _rate = 1.00M;
  13568. string _currency = string.Empty;
  13569. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  13570. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  13571. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  13572. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  13573. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  13574. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  13575. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  13576. if (_GroupCostParameter == null)
  13577. {
  13578. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  13579. bool isIntType = int.TryParse(_currency, out int currId);
  13580. if (isIntType)
  13581. {
  13582. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  13583. }
  13584. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  13585. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  13586. if (currInfo == null)
  13587. {
  13588. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  13589. }
  13590. else _rate = currInfo.Rate;
  13591. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  13592. {
  13593. _rate = _GroupCostParameter.Rate;
  13594. }
  13595. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  13596. string strFileName = "HotelStatement/";
  13597. string guestNames = ""; //格式Mr.xxx Ms.xxx
  13598. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  13599. var rateDatas = new List<dynamic>();
  13600. #region 数据处理
  13601. foreach (var item in hrDtas)
  13602. {
  13603. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  13604. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  13605. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  13606. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  13607. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  13608. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  13609. {
  13610. continue;
  13611. }
  13612. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  13613. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  13614. string singleRoomFeeStr = string.Empty,
  13615. doubleRoomFeeStr = string.Empty,
  13616. suiteRoomFeeStr = string.Empty,
  13617. otherRoomFeeStr = string.Empty,
  13618. payMoneyStr = string.Empty,
  13619. cardPriceStr = string.Empty;
  13620. if (roomCurr.Equals("CNY"))
  13621. {
  13622. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  13623. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13624. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13625. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13626. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13627. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  13628. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  13629. }
  13630. else
  13631. {
  13632. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13633. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13634. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13635. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13636. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  13637. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  13638. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13639. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13640. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13641. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13642. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  13643. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  13644. if (ccpPaymentCurrency.Equals("CNY"))
  13645. {
  13646. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  13647. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  13648. }
  13649. else
  13650. {
  13651. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  13652. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  13653. }
  13654. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  13655. if (hotelcardPriceCurrency.Equals("CNY"))
  13656. {
  13657. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  13658. }
  13659. else
  13660. {
  13661. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  13662. }
  13663. }
  13664. string breakfastPriceStr = string.Empty,
  13665. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  13666. governmentRentStr = string.Empty,
  13667. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  13668. cityTaxStr = string.Empty,
  13669. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  13670. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  13671. if (!string.IsNullOrEmpty(breakfastCurrency1))
  13672. {
  13673. if (breakfastCurrency1.Equals("CNY"))
  13674. {
  13675. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  13676. }
  13677. else
  13678. {
  13679. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  13680. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  13681. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  13682. }
  13683. }
  13684. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  13685. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  13686. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  13687. {
  13688. if (governmentRentCurrency.Equals("CNY"))
  13689. {
  13690. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  13691. }
  13692. else
  13693. {
  13694. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  13695. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  13696. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  13697. }
  13698. }
  13699. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  13700. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  13701. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  13702. {
  13703. if (cityTaxStrCurrency1.Equals("CNY"))
  13704. {
  13705. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  13706. }
  13707. else
  13708. {
  13709. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  13710. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  13711. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  13712. }
  13713. }
  13714. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  13715. int payDId = roomInfo?.PayDId ?? 0;
  13716. pcfds.Add(new HotelReservations_PCFD_View()
  13717. {
  13718. City = item.City,
  13719. HotelName = item.HotelName,
  13720. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  13721. // SingleRoomCount = item.SingleRoomCount,
  13722. SingleRoomPrice = singleRoomFeeStr,
  13723. // DoubleRoomCount = item.DoubleRoomCount,
  13724. DoubleRoomPrice = doubleRoomFeeStr,
  13725. //SuiteRoomCount = item.SuiteRoomCount,
  13726. SuiteRoomPrice = suiteRoomFeeStr,
  13727. OtherRoomPrice = otherRoomFeeStr,
  13728. //OtherRoomCount = item.OtherRoomCount,
  13729. BreakfastPrice = breakfastPriceStr,
  13730. GovernmentRent = governmentRentStr,
  13731. CityTax = cityTaxStr,
  13732. RoomExplanation = item.RoomExplanation,
  13733. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  13734. PayTime = roomInfo?.ConsumptionDate,
  13735. BankNo = roomInfo?.BankNo,
  13736. PayMoney = payMoneyStr,
  13737. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  13738. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  13739. CardPrice = cardPriceStr,
  13740. Remark = ccpInfo.Remark
  13741. });
  13742. }
  13743. #endregion
  13744. //载入模板
  13745. WorkbookDesigner designer = new WorkbookDesigner();
  13746. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  13747. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  13748. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  13749. designer.SetDataSource("TourNo", groupInfo.TourCode);
  13750. var rateDatas1 = rateDatas.Distinct();
  13751. var rateStr = string.Empty;
  13752. foreach (var item in rateDatas1)
  13753. {
  13754. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  13755. }
  13756. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  13757. designer.SetDataSource("Opertor", userInfo.CnName);
  13758. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  13759. dt.TableName = "ViewMyHotelReservations";
  13760. designer.SetDataSource(dt);
  13761. designer.Process();
  13762. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  13763. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  13764. designer.Workbook.Save(serverPath);
  13765. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  13766. #region 删除指定行
  13767. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  13768. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  13769. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  13770. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  13771. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  13772. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  13773. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  13774. cssIndex = dt.Columns["CityTax"].Ordinal,
  13775. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  13776. remarkIndex = dt.Columns["Remark"].Ordinal;
  13777. //删除指定列
  13778. foreach (DataRow item in dt.Rows)
  13779. {
  13780. string singleStr = item["SingleRoomPrice"].ToString();
  13781. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  13782. if (containsDigitButNotZero1) singleDel = false;
  13783. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  13784. string doubleStr = item["DoubleRoomPrice"].ToString();
  13785. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13786. if (containsDigitButNotZero2) doubleDel = false;
  13787. string suiteStr = item["SuiteRoomPrice"].ToString();
  13788. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13789. if (containsDigitButNotZero3) suiteDel = false;
  13790. string otherStr = item["OtherRoomPrice"].ToString();
  13791. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  13792. if (containsDigitButNotZero4) otherDel = false;
  13793. string zcStr = item["BreakfastPrice"].ToString();
  13794. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  13795. if (containsDigitButNotZero5) zcDel = false;
  13796. string dsStr = item["GovernmentRent"].ToString();
  13797. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  13798. if (containsDigitButNotZero6) dsDel = false;
  13799. string cssStr = item["CityTax"].ToString();
  13800. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  13801. if (containsDigitButNotZero7) cssDel = false;
  13802. string cpStr = item["ConsumptionPatterns"].ToString();
  13803. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  13804. string remarkStr = item["Remark"].ToString();
  13805. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  13806. }
  13807. DeleteColumn(serverPath, remarkIndex, remarkDel);
  13808. DeleteColumn(serverPath, cpIndex, cpDel);
  13809. DeleteColumn(serverPath, dsIndex, dsDel);
  13810. DeleteColumn(serverPath, cssIndex, cssDel);
  13811. DeleteColumn(serverPath, zcIndex, zcDel);
  13812. DeleteColumn(serverPath, otherIndex, otherDel);
  13813. DeleteColumn(serverPath, suiteIndex, suiteDel);
  13814. DeleteColumn(serverPath, doubleIndex, doubleDel);
  13815. DeleteColumn(serverPath, singleIndex, singleDel);
  13816. #endregion
  13817. //只保留第一个表格
  13818. DeleteSheet(serverPath);
  13819. return Ok(JsonView(true, "操作成功", url = rst));
  13820. }
  13821. else
  13822. {
  13823. _currency = _GroupCostParameter.Currency;
  13824. bool isIntType = int.TryParse(_currency, out int currId);
  13825. if (isIntType)
  13826. {
  13827. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  13828. }
  13829. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  13830. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  13831. if (currInfo == null)
  13832. {
  13833. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  13834. }
  13835. if (!_currency.ToUpper().Equals("CNY"))
  13836. {
  13837. _rate = _GroupCostParameter.Rate;
  13838. }
  13839. _rate = currInfo.Rate;
  13840. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  13841. string strFileName = "HotelStatement/";
  13842. string guestNames = ""; //格式Mr.xxx Ms.xxx
  13843. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  13844. #region 数据处理
  13845. foreach (var item in hrDtas)
  13846. {
  13847. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  13848. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  13849. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  13850. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  13851. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  13852. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  13853. string singleRoomFeeStr = string.Empty,
  13854. doubleRoomFeeStr = string.Empty,
  13855. suiteRoomFeeStr = string.Empty,
  13856. otherRoomFeeStr = string.Empty,
  13857. payMoneyStr = string.Empty,
  13858. cardPriceStr = string.Empty;
  13859. if (roomCurr.Equals(_currency))
  13860. {
  13861. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  13862. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  13863. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  13864. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  13865. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  13866. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  13867. }
  13868. else
  13869. {
  13870. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13871. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13872. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13873. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13874. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  13875. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  13876. }
  13877. string breakfastPriceStr = string.Empty,
  13878. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  13879. governmentRentStr = string.Empty,
  13880. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  13881. cityTaxStrStr = string.Empty,
  13882. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  13883. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  13884. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  13885. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  13886. int payDId = roomInfo?.PayDId ?? 0;
  13887. pcfds.Add(new HotelReservations_PCFD_View()
  13888. {
  13889. City = item.City,
  13890. HotelName = item.HotelName,
  13891. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  13892. // SingleRoomCount = item.SingleRoomCount,
  13893. SingleRoomPrice = singleRoomFeeStr,
  13894. // DoubleRoomCount = item.DoubleRoomCount,
  13895. DoubleRoomPrice = doubleRoomFeeStr,
  13896. //SuiteRoomCount = item.SuiteRoomCount,
  13897. SuiteRoomPrice = suiteRoomFeeStr,
  13898. OtherRoomPrice = otherRoomFeeStr,
  13899. //OtherRoomCount = item.OtherRoomCount,
  13900. BreakfastPrice = breakfastPriceStr,
  13901. GovernmentRent = governmentRentStr,
  13902. CityTax = cityTaxStrStr,
  13903. RoomExplanation = item.RoomExplanation,
  13904. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  13905. PayTime = roomInfo?.ConsumptionDate,
  13906. BankNo = roomInfo?.BankNo,
  13907. PayMoney = payMoneyStr,
  13908. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  13909. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  13910. CardPrice = cardPriceStr,
  13911. Remark = ccpInfo.Remark
  13912. });
  13913. }
  13914. #endregion
  13915. //载入模板
  13916. WorkbookDesigner designer = new WorkbookDesigner();
  13917. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  13918. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  13919. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  13920. designer.SetDataSource("TourNo", groupInfo.TourCode);
  13921. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  13922. designer.SetDataSource("Opertor", userInfo.CnName);
  13923. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  13924. dt.TableName = "ViewMyHotelReservations";
  13925. designer.SetDataSource(dt);
  13926. designer.Process();
  13927. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  13928. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  13929. designer.Workbook.Save(serverPath);
  13930. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  13931. #region 删除指定行
  13932. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  13933. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  13934. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  13935. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  13936. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  13937. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  13938. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  13939. cssIndex = dt.Columns["CityTax"].Ordinal,
  13940. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  13941. remarkIndex = dt.Columns["Remark"].Ordinal;
  13942. //删除指定列
  13943. foreach (DataRow item in dt.Rows)
  13944. {
  13945. string singleStr = item["SingleRoomPrice"].ToString();
  13946. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  13947. if (containsDigitButNotZero1) singleDel = false;
  13948. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  13949. string doubleStr = item["DoubleRoomPrice"].ToString();
  13950. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13951. if (containsDigitButNotZero2) doubleDel = false;
  13952. string suiteStr = item["SuiteRoomPrice"].ToString();
  13953. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13954. if (containsDigitButNotZero3) suiteDel = false;
  13955. string otherStr = item["OtherRoomPrice"].ToString();
  13956. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  13957. if (containsDigitButNotZero4) otherDel = false;
  13958. string zcStr = item["BreakfastPrice"].ToString();
  13959. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  13960. if (containsDigitButNotZero5) zcDel = false;
  13961. string dsStr = item["GovernmentRent"].ToString();
  13962. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  13963. if (containsDigitButNotZero6) dsDel = false;
  13964. string cssStr = item["CityTax"].ToString();
  13965. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  13966. if (containsDigitButNotZero7) cssDel = false;
  13967. string cpStr = item["ConsumptionPatterns"].ToString();
  13968. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  13969. string remarkStr = item["Remark"].ToString();
  13970. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  13971. }
  13972. DeleteColumn(serverPath, remarkIndex, remarkDel);
  13973. DeleteColumn(serverPath, cpIndex, cpDel);
  13974. DeleteColumn(serverPath, dsIndex, dsDel);
  13975. DeleteColumn(serverPath, cssIndex, cssDel);
  13976. DeleteColumn(serverPath, zcIndex, zcDel);
  13977. DeleteColumn(serverPath, otherIndex, otherDel);
  13978. DeleteColumn(serverPath, suiteIndex, suiteDel);
  13979. DeleteColumn(serverPath, doubleIndex, doubleDel);
  13980. DeleteColumn(serverPath, singleIndex, singleDel);
  13981. #endregion
  13982. //只保留第一个表格
  13983. DeleteSheet(serverPath);
  13984. return Ok(JsonView(true, "操作成功", url = rst));
  13985. }
  13986. return Ok(JsonView(false));
  13987. }
  13988. /// <summary>
  13989. /// 删除指定列
  13990. /// </summary>
  13991. /// <param name="file"></param>
  13992. /// <param name="columnIndex"></param>
  13993. /// <param name="isDel"></param>
  13994. private void DeleteColumn(string file, int columnIndex, bool isDel)
  13995. {
  13996. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  13997. //wb.Save(file);
  13998. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  13999. if (sheet1 != null)
  14000. {
  14001. if (isDel)
  14002. {
  14003. Cells cells = sheet1.Cells;
  14004. cells.DeleteColumn(columnIndex);
  14005. }
  14006. }
  14007. wb.Save(file);
  14008. }
  14009. /// <summary>
  14010. /// 删除sheet
  14011. /// </summary>
  14012. /// <param name="file"></param>
  14013. /// <param name="sheetName"></param>
  14014. private void DeleteSheet(string file, string sheetName = "")
  14015. {
  14016. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  14017. //wb.Save(file);
  14018. List<string> sheets = new List<string>();
  14019. foreach (var item in wb.Worksheets)
  14020. {
  14021. sheets.Add(item.Name);
  14022. }
  14023. if (sheets.Count > 0)
  14024. {
  14025. sheets.RemoveAt(0);//不删除第一个sheet
  14026. foreach (var item in sheets)
  14027. {
  14028. wb.Worksheets.RemoveAt(item);
  14029. }
  14030. }
  14031. wb.Save(file);
  14032. }
  14033. /// <summary>
  14034. /// 酒店预订
  14035. /// 确认单
  14036. /// </summary>
  14037. /// <param name="_dto"></param>
  14038. /// <returns></returns>
  14039. [HttpPost]
  14040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14041. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  14042. {
  14043. try
  14044. {
  14045. #region 参数验证
  14046. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14047. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14048. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14049. #region 团组操作权限验证 76 酒店预定模块
  14050. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14051. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14052. #endregion
  14053. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14054. #region 页面操作权限验证
  14055. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14056. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14057. #endregion
  14058. #endregion
  14059. //团组信息
  14060. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  14061. //酒店数据
  14062. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  14063. if (listhoteldata.Count < 0)
  14064. {
  14065. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  14066. }
  14067. //利datatable存储
  14068. DataTable dt = new DataTable();
  14069. dt.Columns.Add("CheckInDate", typeof(string));
  14070. dt.Columns.Add("City", typeof(string));
  14071. dt.Columns.Add("Hotel", typeof(string));
  14072. dt.Columns.Add("Room", typeof(string));
  14073. for (int i = 0; i < listhoteldata.Count; i++)
  14074. {
  14075. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  14076. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  14077. while (dayStart < dayEnd)
  14078. {
  14079. string temp = "";
  14080. DataRow row = dt.NewRow();
  14081. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  14082. row["City"] = listhoteldata[i].City;
  14083. row["Hotel"] = listhoteldata[i].HotelName;
  14084. if (listhoteldata[i].SingleRoomCount > 0)
  14085. {
  14086. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  14087. }
  14088. if (listhoteldata[i].DoubleRoomCount > 0)
  14089. {
  14090. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  14091. }
  14092. if (listhoteldata[i].SuiteRoomCount > 0)
  14093. {
  14094. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  14095. }
  14096. if (listhoteldata[i].OtherRoomCount > 0)
  14097. {
  14098. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  14099. }
  14100. row["Room"] = temp;
  14101. dt.Rows.Add(row);
  14102. dayStart = dayStart.AddDays(1);
  14103. }
  14104. }
  14105. Dictionary<string, string> dic = new Dictionary<string, string>();
  14106. dic.Add("Dele", di.TeamName);
  14107. dic.Add("City", di.VisitCountry);
  14108. //模板路径
  14109. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  14110. //载入模板
  14111. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  14112. DocumentBuilder builder = new DocumentBuilder(doc);
  14113. foreach (var key in dic.Keys)
  14114. {
  14115. builder.MoveToBookmark(key);
  14116. builder.Write(dic[key]);
  14117. }
  14118. //获取word里所有表格
  14119. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14120. //获取所填表格的序数
  14121. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14122. var rowStart = tableOne.Rows[0]; //获取第1行
  14123. //循环赋值
  14124. for (int i = 0; i < dt.Rows.Count; i++)
  14125. {
  14126. builder.MoveToCell(0, i + 1, 0, 0);
  14127. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  14128. builder.MoveToCell(0, i + 1, 1, 0);
  14129. builder.Write(dt.Rows[i]["City"].ToString());
  14130. builder.MoveToCell(0, i + 1, 2, 0);
  14131. builder.Write(dt.Rows[i]["Hotel"].ToString());
  14132. builder.MoveToCell(0, i + 1, 3, 0);
  14133. builder.Write(dt.Rows[i]["Room"].ToString());
  14134. }
  14135. //删除多余行
  14136. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  14137. {
  14138. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  14139. }
  14140. string strFileName = di.TeamName + "酒店确认单.doc";
  14141. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  14142. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  14143. return Ok(JsonView(true, "成功", url));
  14144. }
  14145. catch (Exception ex)
  14146. {
  14147. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  14148. }
  14149. }
  14150. #endregion
  14151. #region 团组状态
  14152. /// <summary>
  14153. /// 团组状态列表 Page
  14154. /// </summary>
  14155. /// <param name="dto">团组列表请求dto</param>
  14156. /// <returns></returns>
  14157. [HttpPost]
  14158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14159. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  14160. {
  14161. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  14162. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  14163. {
  14164. string sqlWhere = string.Empty;
  14165. if (dto.IsSure == 0) //未完成
  14166. {
  14167. sqlWhere += string.Format(@" And IsSure = 0");
  14168. }
  14169. else if (dto.IsSure == 1) //已完成
  14170. {
  14171. sqlWhere += string.Format(@" And IsSure = 1");
  14172. }
  14173. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  14174. {
  14175. string tj = dto.SearchCriteria;
  14176. 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}%')",
  14177. tj, tj, tj, tj, tj);
  14178. }
  14179. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  14180. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  14181. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  14182. From (
  14183. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  14184. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  14185. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  14186. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  14187. From Grp_DelegationInfo gdi
  14188. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  14189. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  14190. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  14191. Where gdi.IsDel = 0 {0}
  14192. ) temp ", sqlWhere);
  14193. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  14194. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  14195. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  14196. }
  14197. else
  14198. {
  14199. return Ok(JsonView(false, "查询失败"));
  14200. }
  14201. }
  14202. /// <summary>
  14203. /// 团组状态
  14204. /// 设置操作完成
  14205. /// </summary>
  14206. /// <param name="dto">团组列表请求dto</param>
  14207. /// <returns></returns>
  14208. [HttpPost]
  14209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14210. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  14211. {
  14212. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  14213. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  14214. {
  14215. Id = dto.Id,
  14216. IsSure = 1
  14217. };
  14218. var result = await _sqlSugar.Updateable(_DelegationInfo)
  14219. .UpdateColumns(it => new { it.IsSure })
  14220. .WhereColumns(it => new { it.Id })
  14221. .ExecuteCommandAsync();
  14222. if (result > 0)
  14223. {
  14224. return Ok(JsonView(true, "操作完成!"));
  14225. }
  14226. return Ok(JsonView(false, "操作失败!"));
  14227. }
  14228. #endregion
  14229. #region 保险费用录入
  14230. /// <summary>
  14231. /// 根据团组Id查询保险费用列表
  14232. /// </summary>
  14233. /// <param name="dto"></param>
  14234. /// <returns></returns>
  14235. [HttpPost]
  14236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14237. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  14238. {
  14239. Result groupData = await _customersRep.CustomersByDiId(dto);
  14240. if (groupData.Code != 0)
  14241. {
  14242. return Ok(JsonView(false, groupData.Msg));
  14243. }
  14244. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14245. }
  14246. /// <summary>
  14247. /// 根据保险费用Id查询保险费用详细
  14248. /// </summary>
  14249. /// <param name="dto"></param>
  14250. /// <returns></returns>
  14251. [HttpPost]
  14252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14253. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  14254. {
  14255. try
  14256. {
  14257. Result groupData = await _customersRep.CustomersById(dto);
  14258. if (groupData.Code != 0)
  14259. {
  14260. return Ok(JsonView(false, groupData.Msg));
  14261. }
  14262. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14263. }
  14264. catch (Exception ex)
  14265. {
  14266. return Ok(JsonView(false, ex.Message));
  14267. }
  14268. }
  14269. /// <summary>
  14270. /// 保险费用录入页面初始化绑定
  14271. /// </summary>
  14272. /// <param name="dto"></param>
  14273. /// <returns></returns>
  14274. [HttpPost]
  14275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14276. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  14277. {
  14278. try
  14279. {
  14280. Result groupData = await _customersRep.CustomersInitialize(dto);
  14281. if (groupData.Code != 0)
  14282. {
  14283. return Ok(JsonView(false, groupData.Msg));
  14284. }
  14285. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14286. }
  14287. catch (Exception ex)
  14288. {
  14289. return Ok(JsonView(false, ex.Message));
  14290. }
  14291. }
  14292. /// <summary>
  14293. /// 保险费用操作(Status:1.新增,2.修改)
  14294. /// </summary>
  14295. /// <param name="dto"></param>
  14296. /// <returns></returns>
  14297. [HttpPost]
  14298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14299. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  14300. {
  14301. Result groupData = await _customersRep.OpCustomers(dto);
  14302. if (groupData.Code != 0)
  14303. {
  14304. return Ok(JsonView(false, groupData.Msg));
  14305. }
  14306. #region 应用推送
  14307. try
  14308. {
  14309. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14310. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14311. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  14312. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14313. //自动审核
  14314. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  14315. //2024-10-21 新增LZ UID
  14316. var userIds = new List<int>() { 21 };
  14317. string title = $"系统通知";
  14318. var diId = dto.DiId;
  14319. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14320. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14321. string content = "";
  14322. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14323. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14324. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14325. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14326. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14327. }
  14328. catch (Exception ex)
  14329. {
  14330. }
  14331. #endregion
  14332. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14333. }
  14334. /// <summary>
  14335. /// 保险文件上传
  14336. /// </summary>
  14337. /// <param name="file"></param>
  14338. /// <returns></returns>
  14339. [HttpPost]
  14340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14341. public async Task<IActionResult> UploadCus(IFormFile file)
  14342. {
  14343. try
  14344. {
  14345. if (file != null)
  14346. {
  14347. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  14348. //文件名称
  14349. string projectFileName = file.FileName;
  14350. //上传的文件的路径
  14351. string filePath = "";
  14352. if (!Directory.Exists(fileDir))
  14353. {
  14354. Directory.CreateDirectory(fileDir);
  14355. }
  14356. //上传的文件的路径
  14357. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  14358. using (FileStream fs = System.IO.File.Create(filePath))
  14359. {
  14360. file.CopyTo(fs);
  14361. fs.Flush();
  14362. }
  14363. return Ok(JsonView(true, "上传成功!", projectFileName));
  14364. }
  14365. else
  14366. {
  14367. return Ok(JsonView(false, "上传失败!"));
  14368. }
  14369. }
  14370. catch (Exception ex)
  14371. {
  14372. return Ok(JsonView(false, "程序错误!"));
  14373. throw;
  14374. }
  14375. }
  14376. /// <summary>
  14377. /// 保险删除指定文件
  14378. /// </summary>
  14379. /// <param name="dto"></param>
  14380. /// <returns></returns>
  14381. [HttpPost]
  14382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14383. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  14384. {
  14385. try
  14386. {
  14387. string filePath = "";
  14388. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  14389. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  14390. //int id = 0;
  14391. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  14392. // 删除该文件
  14393. try
  14394. {
  14395. System.IO.File.Delete(filePath);
  14396. 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()
  14397. {
  14398. Attachment = "",
  14399. }).ExecuteCommandAsync();
  14400. if (result != 0)
  14401. {
  14402. return Ok(JsonView(true, "成功!"));
  14403. }
  14404. else
  14405. {
  14406. return Ok(JsonView(false, "失败!"));
  14407. }
  14408. }
  14409. catch (Exception)
  14410. {
  14411. 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()
  14412. {
  14413. Attachment = "",
  14414. }).ExecuteCommandAsync();
  14415. if (result != 0)
  14416. {
  14417. return Ok(JsonView(true, "成功!"));
  14418. }
  14419. else
  14420. {
  14421. return Ok(JsonView(false, "失败!"));
  14422. }
  14423. }
  14424. }
  14425. catch (Exception ex)
  14426. {
  14427. return Ok(JsonView(false, "程序错误!"));
  14428. throw;
  14429. }
  14430. }
  14431. /// <summary>
  14432. /// 保险费用操作(删除)
  14433. /// </summary>
  14434. /// <param name="dto"></param>
  14435. /// <returns></returns>
  14436. [HttpPost]
  14437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14438. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  14439. {
  14440. try
  14441. {
  14442. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  14443. if (!res)
  14444. {
  14445. return Ok(JsonView(false, "删除失败"));
  14446. }
  14447. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  14448. {
  14449. IsDel = 1,
  14450. DeleteUserId = dto.DeleteUserId,
  14451. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14452. }).ExecuteCommandAsync();
  14453. return Ok(JsonView(true, "删除成功!"));
  14454. }
  14455. catch (Exception ex)
  14456. {
  14457. return Ok(JsonView(false, "程序错误!"));
  14458. throw;
  14459. }
  14460. }
  14461. #endregion
  14462. #region 接团客户名单 PageId 104
  14463. /// <summary>
  14464. /// 接团客户名单
  14465. /// 迁移数据(慎用!)
  14466. /// </summary>
  14467. /// <param name="dto"></param>
  14468. /// <returns></returns>
  14469. [HttpPost]
  14470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14471. public async Task<IActionResult> PostTourClientListChange()
  14472. {
  14473. try
  14474. {
  14475. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  14476. //var groupClinetData1
  14477. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  14478. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  14479. int updateCount = 0;
  14480. if (oldOAClientList.Count > 0)
  14481. {
  14482. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  14483. _sqlSugar.BeginTran();
  14484. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  14485. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  14486. foreach (var item in oldOAClientList)
  14487. {
  14488. int comId = 0;
  14489. string format = "yyyy-MM-dd HH:mm:ss";
  14490. string data11 = "1990-01-01 00:00";
  14491. var data1 = IsValidDate(item.OPdate, format);
  14492. if (data1) data11 = item.OPdate;
  14493. //客户公司验证
  14494. if (!string.IsNullOrEmpty(item.Company))
  14495. {
  14496. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  14497. if (clientComInfo == null) // add
  14498. {
  14499. var addInfo = new Crm_CustomerCompany()
  14500. {
  14501. CompanyAbbreviation = "",
  14502. CompanyFullName = item.Company,
  14503. Address = "",
  14504. PostCodes = "",
  14505. LastedOpUserId = item.OPer,
  14506. LastedOpDt = Convert.ToDateTime(data11),
  14507. CreateUserId = item.OPer,
  14508. CreateTime = Convert.ToDateTime(data11),
  14509. IsDel = 0
  14510. };
  14511. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  14512. if (comId1 > 0) comId = comId1;
  14513. }
  14514. else comId = clientComInfo.Id;
  14515. }
  14516. //客户人员验证
  14517. int clientId = 0;
  14518. string name = item.LastName + item.Name;
  14519. if (!string.IsNullOrEmpty(name))
  14520. {
  14521. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  14522. if (clientInfo == null)
  14523. {
  14524. DateTime? dateTime = null;
  14525. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  14526. if (isDt) dateTime = birthDayDt;
  14527. var addInfo1 = new Crm_DeleClient()
  14528. {
  14529. CrmCompanyId = comId,
  14530. DiId = -1,
  14531. LastName = item.LastName,
  14532. FirstName = item.Name,
  14533. OldName = "",
  14534. Pinyin = item.Pinyin,
  14535. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  14536. Marriage = 0,
  14537. Phone = item.Phone,
  14538. Job = item.Job,
  14539. BirthDay = dateTime
  14540. };
  14541. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  14542. if (clientId1 > 0) clientId = clientId1;
  14543. }
  14544. else clientId = clientInfo.Id;
  14545. }
  14546. if (clientId < 1)
  14547. {
  14548. continue;
  14549. }
  14550. int airType = 0;
  14551. if (item.AirType == "超经舱") airType = 459;
  14552. else if (item.AirType == "公务舱") airType = 458;
  14553. else if (item.AirType == "经济舱") airType = 460;
  14554. else if (item.AirType == "其他") airType = 565;
  14555. else if (item.AirType == "头等舱") airType = 457;
  14556. var _TourClientListEntity = new Grp_TourClientList()
  14557. {
  14558. DiId = item.Diid,
  14559. ClientId = clientId,
  14560. CreateUserId = item.OPer,
  14561. CreateTime = Convert.ToDateTime(data11),
  14562. Remark = item.Remark,
  14563. IsDel = item.Isdel,
  14564. ShippingSpaceTypeId = airType,
  14565. ShippingSpaceSpecialNeeds = item.AirRemark,
  14566. HotelSpecialNeeds = item.RoomType
  14567. };
  14568. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  14569. if (_TourClientList > 0)
  14570. {
  14571. updateCount++;
  14572. }
  14573. }
  14574. _sqlSugar.CommitTran();
  14575. }
  14576. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  14577. }
  14578. catch (Exception ex)
  14579. {
  14580. _sqlSugar.RollbackTran();
  14581. return Ok(JsonView(false, ex.Message));
  14582. }
  14583. return Ok(JsonView(true));
  14584. }
  14585. private bool IsValidDate(string dateString, string format)
  14586. {
  14587. DateTime dateValue;
  14588. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  14589. return valid;
  14590. }
  14591. /// <summary>
  14592. /// 接团客户名单
  14593. /// 根据团组Id查询List
  14594. /// </summary>
  14595. /// <param name="dto"></param>
  14596. /// <returns></returns>
  14597. [HttpPost]
  14598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14599. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  14600. {
  14601. #region 参数验证
  14602. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  14603. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  14604. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  14605. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14606. #region 页面操作权限验证
  14607. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14608. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14609. #endregion
  14610. #endregion
  14611. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  14612. if (viewData.Code != 0)
  14613. {
  14614. return Ok(JsonView(false, viewData.Msg));
  14615. }
  14616. return Ok(JsonView(viewData.Data));
  14617. }
  14618. /// <summary>
  14619. /// 接团客户名单
  14620. /// 基础数据 Init
  14621. /// </summary>
  14622. /// <param name="_dto"></param>
  14623. /// <returns></returns>
  14624. [HttpPost]
  14625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14626. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  14627. {
  14628. #region 参数验证
  14629. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14630. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14631. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14632. #region 页面操作权限验证
  14633. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14634. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14635. #endregion
  14636. #endregion
  14637. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  14638. }
  14639. /// <summary>
  14640. /// 接团客户名单
  14641. /// 根据 Id查询 Details
  14642. /// </summary>
  14643. /// <param name="_dto"></param>
  14644. /// <returns></returns>
  14645. [HttpPost]
  14646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14647. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  14648. {
  14649. #region 参数验证
  14650. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14651. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14652. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  14653. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14654. #region 页面操作权限验证
  14655. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14656. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14657. #endregion
  14658. #endregion
  14659. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  14660. if (viewData.Code != 0)
  14661. {
  14662. return Ok(JsonView(false, viewData.Msg));
  14663. }
  14664. return Ok(JsonView(viewData.Data));
  14665. }
  14666. /// <summary>
  14667. /// 接团客户名单
  14668. /// Add Or Edit
  14669. /// </summary>
  14670. /// <param name="_dto"></param>
  14671. /// <returns></returns>
  14672. [HttpPost]
  14673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14674. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  14675. {
  14676. #region 参数验证
  14677. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14678. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14679. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  14680. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14681. #region 页面操作权限验证
  14682. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14683. if (_dto.Id == 0) //添加
  14684. {
  14685. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14686. }
  14687. else if (_dto.Id >= 0) //修改
  14688. {
  14689. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14690. }
  14691. #endregion
  14692. #endregion
  14693. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  14694. if (viewData.Code != 0)
  14695. {
  14696. return Ok(JsonView(false, viewData.Msg));
  14697. }
  14698. return Ok(JsonView(true));
  14699. }
  14700. /// <summary>
  14701. /// 接团客户名单
  14702. /// AddMultiple(添加多个)
  14703. /// </summary>
  14704. /// <param name="_dto"></param>
  14705. /// <returns></returns>
  14706. [HttpPost]
  14707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14708. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  14709. {
  14710. #region 参数验证
  14711. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14712. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14713. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14714. #region 页面操作权限验证
  14715. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14716. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14717. #endregion
  14718. #endregion
  14719. var viewData = await _tourClientListRep._AddMultiple(_dto);
  14720. if (viewData.Code != 0)
  14721. {
  14722. return Ok(JsonView(false, viewData.Msg));
  14723. }
  14724. return Ok(JsonView(true));
  14725. }
  14726. /// <summary>
  14727. /// 接团客户名单
  14728. /// Del
  14729. /// </summary>
  14730. /// <param name="_dto"></param>
  14731. /// <returns></returns>
  14732. [HttpPost]
  14733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14734. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  14735. {
  14736. #region 参数验证
  14737. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14738. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14739. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14740. #region 页面操作权限验证
  14741. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14742. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14743. #endregion
  14744. #endregion
  14745. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  14746. if (viewData.Code != 0)
  14747. {
  14748. return Ok(JsonView(false, viewData.Msg));
  14749. }
  14750. return Ok(JsonView(true));
  14751. }
  14752. /// <summary>
  14753. /// 接团客户名单
  14754. /// 文件下载 客户名单
  14755. /// </summary>
  14756. /// <param name="_dto"></param>
  14757. /// <returns></returns>
  14758. [HttpPost]
  14759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14760. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  14761. {
  14762. #region 参数验证
  14763. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14764. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14765. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  14766. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14767. #region 页面操作权限验证
  14768. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14769. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14770. #endregion
  14771. #endregion
  14772. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  14773. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  14774. From Grp_TourClientList tcl
  14775. Left Join
  14776. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  14777. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  14778. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  14779. From Crm_DeleClient dc
  14780. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  14781. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  14782. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  14783. Where dc.IsDel = 0) temp
  14784. On temp.DcId =tcl.ClientId
  14785. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  14786. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  14787. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  14788. //载入模板
  14789. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  14790. if (_dto.Language == 1)
  14791. {
  14792. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  14793. }
  14794. //载入模板
  14795. var doc = new Document(tempPath);
  14796. DocumentBuilder builder = new DocumentBuilder(doc);
  14797. //获取word里所有表格
  14798. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14799. //获取所填表格的序数
  14800. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14801. var rowStart = tableOne.Rows[0]; //获取第1行
  14802. if (_dto.Language == 0)
  14803. {
  14804. //循环赋值
  14805. for (int i = 0; i < DcList.Count; i++)
  14806. {
  14807. EncryptionProcessor.DecryptProperties(DcList[i]);
  14808. builder.MoveToCell(0, i + 1, 0, 0);
  14809. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  14810. builder.MoveToCell(0, i + 1, 1, 0);
  14811. int sex = DcList[i].Sex;
  14812. string sexStr = string.Empty;
  14813. if (sex == 0) sexStr = "男";
  14814. else if (sex == 1) sexStr = "女";
  14815. else sexStr = "未设置";
  14816. builder.Write(sexStr);
  14817. builder.MoveToCell(0, i + 1, 2, 0);
  14818. string birthDay = DcList[i].BirthDay;
  14819. string birthDayStr = string.Empty;
  14820. if (!string.IsNullOrEmpty(birthDay))
  14821. {
  14822. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  14823. }
  14824. builder.Write(birthDayStr);
  14825. builder.MoveToCell(0, i + 1, 3, 0);
  14826. string company = "";
  14827. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  14828. {
  14829. company = DcList[i].CompanyFullName.ToString();
  14830. }
  14831. builder.Write(company);
  14832. builder.MoveToCell(0, i + 1, 4, 0);
  14833. builder.Write(DcList[i].Job);
  14834. }
  14835. }
  14836. else if (_dto.Language == 1)
  14837. {
  14838. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  14839. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  14840. List<string> transArrayStr = new List<string>();
  14841. string transStrRes1 = "";
  14842. for (int i = 0; i < DcList.Count; i++)
  14843. {
  14844. var dc = DcList[i];
  14845. EncryptionProcessor.DecryptProperties(dc);
  14846. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  14847. if (dc.Job.Equals("暂无")) dc.Job = "-";
  14848. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  14849. if (DcList.Count - 1 == i) transStrRes1 += str1;
  14850. else transStrRes1 += $"{str1}|";
  14851. }
  14852. //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";
  14853. string transStrRes = "";
  14854. if (transStrRes1.Length > 0)
  14855. {
  14856. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  14857. }
  14858. //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
  14859. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  14860. //List<string> transArray = new List<string> { };
  14861. List<TranslateInfo> transArray = new List<TranslateInfo>();
  14862. if (transStrRes.Contains("|"))
  14863. {
  14864. string[] transArray1 = transStrRes.Split('|');
  14865. if (transArray1.Length > 0)
  14866. {
  14867. foreach (var item in transArray1)
  14868. {
  14869. if (item.Contains("&"))
  14870. {
  14871. string[] transArray2 = item.Split('&');
  14872. int index = 0;
  14873. string companyName = "", job = "";
  14874. if (transArray2.Length > 0)
  14875. {
  14876. bool success = int.TryParse(transArray2[0].Trim(), out index);
  14877. if (1 < transArray2.Length) companyName = transArray2[1];
  14878. if (2 < transArray2.Length) job = transArray2[2];
  14879. }
  14880. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  14881. }
  14882. }
  14883. }
  14884. }
  14885. //循环赋值
  14886. for (int i = 0; i < DcList.Count; i++)
  14887. {
  14888. string PYName = "";
  14889. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  14890. {
  14891. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  14892. string PY_First = DcList[i].Pinyin.Split('/')[1];
  14893. PYName = PY_First + " " + PY_Last;
  14894. }
  14895. else
  14896. {
  14897. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  14898. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  14899. PYName = PY_First + " " + PY_Last;
  14900. }
  14901. builder.MoveToCell(0, i + 1, 0, 0);
  14902. builder.Write(PYName);
  14903. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  14904. builder.MoveToCell(0, i + 1, 1, 0);
  14905. builder.Write(sex);
  14906. DateTime birthDt;
  14907. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  14908. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  14909. builder.MoveToCell(0, i + 1, 2, 0);
  14910. builder.Write(birthday);
  14911. string company = string.Empty, job = string.Empty;
  14912. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  14913. if (dcTransInfo != null)
  14914. {
  14915. company = dcTransInfo.CompanyName;
  14916. job = dcTransInfo.Job;
  14917. }
  14918. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  14919. {
  14920. //查询对照表
  14921. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  14922. if (tempCec != null)
  14923. {
  14924. company = tempCec.enName;
  14925. }
  14926. //翻译
  14927. else
  14928. {
  14929. }
  14930. }
  14931. builder.MoveToCell(0, i + 1, 3, 0);
  14932. builder.Write(company);
  14933. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  14934. {
  14935. //查询对照表
  14936. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  14937. if (tempPec != null)
  14938. {
  14939. job = tempPec.enName;
  14940. }
  14941. //翻译
  14942. else
  14943. {
  14944. }
  14945. }
  14946. builder.MoveToCell(0, i + 1, 4, 0);
  14947. builder.Write(job);
  14948. }
  14949. }
  14950. //删除多余行
  14951. while (tableOne.Rows.Count > DcList.Count + 1)
  14952. {
  14953. tableOne.Rows.RemoveAt(DcList.Count + 1);
  14954. }
  14955. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  14956. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  14957. doc.Save(fileDir);
  14958. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  14959. return Ok(JsonView(true, "操作成功!", Url));
  14960. }
  14961. private class TranslateInfo
  14962. {
  14963. public int Index { get; set; }
  14964. public string CompanyName { get; set; }
  14965. public string Job { get; set; }
  14966. }
  14967. #endregion
  14968. #region 团组倒推表
  14969. /// <summary>
  14970. /// 倒推表基础数据
  14971. /// Init
  14972. /// </summary>
  14973. /// <param name="dto"></param>
  14974. /// <returns></returns>
  14975. [HttpPost]
  14976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14977. public async Task<IActionResult> PostInvertedListInit()
  14978. {
  14979. var viewData = await _invertedListRep._Init();
  14980. if (viewData.Code != 0)
  14981. {
  14982. return Ok(JsonView(false, viewData.Msg));
  14983. }
  14984. return Ok(JsonView(viewData.Data));
  14985. }
  14986. /// <summary>
  14987. /// 倒推表
  14988. /// Info
  14989. /// </summary>
  14990. /// <param name="dto"></param>
  14991. /// <returns></returns>
  14992. [HttpPost]
  14993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14994. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  14995. {
  14996. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  14997. if (viewData.Code != 0)
  14998. {
  14999. return Ok(JsonView(false, viewData.Msg));
  15000. }
  15001. return Ok(JsonView(viewData.Data));
  15002. }
  15003. /// <summary>
  15004. /// 倒推表
  15005. /// Create
  15006. /// </summary>
  15007. /// <param name="dto"></param>
  15008. /// <returns></returns>
  15009. [HttpPost]
  15010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15011. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  15012. {
  15013. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  15014. if (viewData.Code != 0)
  15015. {
  15016. return Ok(JsonView(false, viewData.Msg));
  15017. }
  15018. return Ok(JsonView(viewData.Data));
  15019. }
  15020. /// <summary>
  15021. /// 倒推表
  15022. /// Update
  15023. /// </summary>
  15024. /// <param name="dto"></param>
  15025. /// <returns></returns>
  15026. [HttpPost]
  15027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15028. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  15029. {
  15030. var viewData = await _invertedListRep._Update(dto);
  15031. if (viewData.Code != 0)
  15032. {
  15033. return Ok(JsonView(false, viewData.Msg));
  15034. }
  15035. return Ok(JsonView(viewData.Data));
  15036. }
  15037. /// <summary>
  15038. /// 倒推表
  15039. /// File Download
  15040. /// </summary>
  15041. /// <param name="dto"></param>
  15042. /// <returns></returns>
  15043. [HttpPost]
  15044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15045. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  15046. {
  15047. var info2 = await _invertedListRep._Info(1, dto.DiId);
  15048. if (info2.Code != 0)
  15049. {
  15050. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  15051. }
  15052. var info1 = info2.Data as InvertedListInfoView;
  15053. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  15054. string teamName = "";
  15055. if (info != null) teamName = info.TeamName;
  15056. //载入模板
  15057. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  15058. DocumentBuilder builder = new DocumentBuilder(doc);
  15059. //利用键值对存放数据
  15060. Dictionary<string, string> dic = new Dictionary<string, string>();
  15061. dic.Add("TeamName", teamName);
  15062. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  15063. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  15064. dic.Add("BPRemark", info1.ApprovalDataRemark);
  15065. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  15066. dic.Add("SQRemark", info1.ApprovalRemark);
  15067. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  15068. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  15069. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  15070. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  15071. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  15072. dic.Add("QZRemark", info1.VisaInformationRemark);
  15073. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  15074. dic.Add("SQQZRemark", info1.SendVisaRemark);
  15075. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  15076. dic.Add("CQRemark", info1.IssueVisaRemark);
  15077. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  15078. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  15079. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  15080. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  15081. #region 填充word模板书签内容
  15082. foreach (var key in dic.Keys)
  15083. {
  15084. builder.MoveToBookmark(key);
  15085. builder.Write(dic[key]);
  15086. }
  15087. #endregion
  15088. var fileDir = AppSettingsHelper.Get("WordBasePath");
  15089. string fileName = $"{teamName}团出行准备流程表.doc";
  15090. string filePath = fileDir + $@"InvertedList/{fileName}";
  15091. doc.Save(filePath);
  15092. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  15093. return Ok(JsonView(true, "操作成功!", Url));
  15094. }
  15095. #endregion
  15096. #region 三公签证费用(签证费、代办费)
  15097. /// <summary>
  15098. /// 三公签证费用(签证费、代办费)
  15099. /// List
  15100. /// </summary>
  15101. /// <returns></returns>
  15102. [HttpPost]
  15103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15104. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  15105. {
  15106. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  15107. if (_view.Code != 0)
  15108. {
  15109. return Ok(JsonView(false, _view.Msg));
  15110. }
  15111. return Ok(JsonView(true, "操作成功!", _view.Data));
  15112. }
  15113. /// <summary>
  15114. /// 三公签证费用(签证费、代办费)
  15115. /// Add Or Update
  15116. /// </summary>
  15117. /// <returns></returns>
  15118. [HttpPost]
  15119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15120. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  15121. {
  15122. var _view = await _visaFeeInfoRep._Update(_dto);
  15123. if (_view.Code != 0)
  15124. {
  15125. return Ok(JsonView(false, _view.Msg));
  15126. }
  15127. return Ok(JsonView(true, _view.Msg));
  15128. }
  15129. #endregion
  15130. #region 酒店询价
  15131. /// <summary>
  15132. /// 酒店询价
  15133. /// Init
  15134. /// </summary>
  15135. /// <param name="dto"></param>
  15136. /// <returns></returns>
  15137. [HttpPost]
  15138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15139. public async Task<IActionResult> PostHotelInquiryInit()
  15140. {
  15141. var res = await _hotelInquiryRep._Init();
  15142. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15143. return Ok(JsonView(true, res.Msg, res.Data));
  15144. }
  15145. /// <summary>
  15146. /// 酒店询价
  15147. /// page Item
  15148. /// </summary>
  15149. /// <param name="_dto"></param>
  15150. /// <returns></returns>
  15151. [HttpPost]
  15152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15153. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  15154. {
  15155. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  15156. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15157. var view = res.Data as PageDataViewBase;
  15158. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  15159. }
  15160. /// <summary>
  15161. /// 酒店询价
  15162. /// info
  15163. /// </summary>
  15164. /// <param name="_dto"></param>
  15165. /// <returns></returns>
  15166. [HttpPost]
  15167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15168. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  15169. {
  15170. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  15171. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15172. return Ok(JsonView(true, res.Msg, res.Data));
  15173. }
  15174. /// <summary>
  15175. /// 酒店询价
  15176. /// Add Or Edit
  15177. /// </summary>
  15178. /// <param name="_dto"></param>
  15179. /// <returns></returns>
  15180. [HttpPost]
  15181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15182. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  15183. {
  15184. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  15185. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15186. return Ok(JsonView(true, res.Msg, res.Data));
  15187. }
  15188. /// <summary>
  15189. /// 酒店询价
  15190. /// Del
  15191. /// </summary>
  15192. /// <param name="_dto"></param>
  15193. /// <returns></returns>
  15194. [HttpPost]
  15195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15196. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  15197. {
  15198. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  15199. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15200. return Ok(JsonView(true, res.Msg, res.Data));
  15201. }
  15202. #endregion
  15203. #region 下载匹配op行程单
  15204. /// <summary>
  15205. /// 匹配op行程单
  15206. /// Init
  15207. /// </summary>
  15208. /// <param name="dto">团组列表请求dto</param>
  15209. /// <returns></returns>
  15210. [HttpPost]
  15211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15212. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  15213. {
  15214. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  15215. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15216. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  15217. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  15218. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  15219. .Where(it => it.IsDel == 0)
  15220. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  15221. .OrderByDescending(it => it.CreateUserId)
  15222. .ToList();
  15223. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  15224. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  15225. var diids = groupInfos.Select(it => it.Id).ToList();
  15226. List<string> countrys = new List<string>();
  15227. foreach (var item in country)
  15228. {
  15229. var data = _groupRepository.FormartTeamName(item);
  15230. var dataArray = _groupRepository.GroupSplitCountry(data);
  15231. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  15232. }
  15233. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  15234. List<string> areaArray = new List<string>(); //GetGroupCityLine
  15235. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  15236. foreach (var item in areaItem)
  15237. {
  15238. string areaStr = item.Value;
  15239. if (!string.IsNullOrEmpty(areaStr))
  15240. {
  15241. string[] str1 = areaStr.Split("-");
  15242. if (str1.Length > 0)
  15243. {
  15244. areaArray.AddRange(str1);
  15245. }
  15246. }
  15247. }
  15248. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  15249. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  15250. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  15251. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  15252. .ToList();
  15253. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  15254. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  15255. .Where(it => countriesIds.Contains(it.Id))
  15256. .Select(it => new { it.Id, Name = it.Name_CN })
  15257. .ToList();
  15258. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  15259. .Select(it => it.TeamName).ToList();
  15260. stopwatch.Stop();
  15261. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  15262. }
  15263. ///// <summary>
  15264. ///// 匹配op行程单
  15265. ///// Init 查询区域数据
  15266. ///// </summary>
  15267. ///// <param name="dto">团组列表请求dto</param>
  15268. ///// <returns></returns>
  15269. //[HttpPost]
  15270. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15271. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  15272. //{
  15273. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  15274. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  15275. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  15276. // if (string.IsNullOrEmpty(countriesDataStr))
  15277. // {
  15278. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  15279. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  15280. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  15281. // }
  15282. // else
  15283. // {
  15284. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  15285. // }
  15286. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  15287. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  15288. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  15289. // List<dynamic> childList = new List<dynamic>();
  15290. // int parentId = dto.CountriesId;
  15291. // if (provinceData.Count > 1)
  15292. // {
  15293. // foreach (var item1 in provinceData)
  15294. // {
  15295. // List<dynamic> childList1 = new List<dynamic>();
  15296. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  15297. // foreach (var item2 in citiesData1)
  15298. // {
  15299. // List<dynamic> childList2 = new List<dynamic>();
  15300. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15301. // foreach (var item3 in countiesData1)
  15302. // {
  15303. // childList2.Add(new
  15304. // {
  15305. // id = item3.Id,
  15306. // parentId = item2.Id,
  15307. // level = "district",
  15308. // name = item3.Name_CN,
  15309. // });
  15310. // }
  15311. // childList1.Add(new
  15312. // {
  15313. // id = item2.Id,
  15314. // parentId = item1.Id,
  15315. // level = "city",
  15316. // name = item2.Name_CN,
  15317. // childList = childList2
  15318. // });
  15319. // }
  15320. // childList.Add(new
  15321. // {
  15322. // id = item1.Id,
  15323. // parentId = parentId,
  15324. // level = "province",
  15325. // name = item1.Name_CN,
  15326. // childList = childList1
  15327. // });
  15328. // }
  15329. // //城市
  15330. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  15331. // foreach (var item2 in citiesData2)
  15332. // {
  15333. // List<dynamic> childList22 = new List<dynamic>();
  15334. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15335. // foreach (var item3 in countiesData1)
  15336. // {
  15337. // childList22.Add(new
  15338. // {
  15339. // id = item3.Id,
  15340. // parentId = item2.Id,
  15341. // level = "district",
  15342. // name = item3.Name_CN,
  15343. // });
  15344. // }
  15345. // childList.Add(new
  15346. // {
  15347. // id = item2.Id,
  15348. // parentId = parentId,
  15349. // level = "city",
  15350. // name = item2.Name_CN,
  15351. // childList = childList22
  15352. // });
  15353. // }
  15354. // }
  15355. // else
  15356. // {
  15357. // foreach (var item2 in citiesData)
  15358. // {
  15359. // string cname = item2.Name_CN;
  15360. // List<dynamic> childList1 = new List<dynamic>();
  15361. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15362. // foreach (var item3 in countiesData1)
  15363. // {
  15364. // childList1.Add(new
  15365. // {
  15366. // Id = item3.Id,
  15367. // parentId = item2.Id,
  15368. // level = "district",
  15369. // name = item3.Name_CN
  15370. // });
  15371. // }
  15372. // childList.Add(new
  15373. // {
  15374. // id = item2.Id,
  15375. // parentId = parentId,
  15376. // level = "city",
  15377. // name = item2.Name_CN,
  15378. // childList = childList1
  15379. // });
  15380. // }
  15381. // }
  15382. // stopwatch.Stop();
  15383. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  15384. //}
  15385. /// <summary>
  15386. /// 匹配op行程单
  15387. /// 接团信息列表 Page
  15388. /// </summary>
  15389. /// <param name="dto">团组列表请求dto</param>
  15390. /// <returns></returns>
  15391. [HttpPost]
  15392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15393. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  15394. {
  15395. var swatch = new Stopwatch();
  15396. swatch.Start();
  15397. #region 参数验证
  15398. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15399. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  15400. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15401. #region 页面操作权限验证
  15402. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  15403. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  15404. #endregion
  15405. #endregion
  15406. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  15407. {
  15408. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  15409. string sqlWhere = "";
  15410. if (!string.IsNullOrEmpty(dto.Country))
  15411. {
  15412. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  15413. }
  15414. if (!string.IsNullOrEmpty(dto.Area))
  15415. {
  15416. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  15417. }
  15418. if (!string.IsNullOrEmpty(dto.TeamName))
  15419. {
  15420. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  15421. }
  15422. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  15423. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  15424. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  15425. swatch.Stop();
  15426. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  15427. }
  15428. else
  15429. {
  15430. return Ok(JsonView(false, "查询失败"));
  15431. }
  15432. }
  15433. /// <summary>
  15434. /// 匹配op行程单
  15435. /// 行程单下载
  15436. /// </summary>
  15437. /// <param name="dto">团组列表请求dto</param>
  15438. /// <returns></returns>
  15439. [HttpPost]
  15440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15441. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  15442. {
  15443. #region 参数验证
  15444. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15445. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  15446. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15447. #region 页面操作权限验证
  15448. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  15449. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  15450. #endregion
  15451. #endregion
  15452. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  15453. {
  15454. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  15455. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  15456. }
  15457. else
  15458. {
  15459. return Ok(JsonView(false, "下载失败!"));
  15460. }
  15461. }
  15462. #endregion
  15463. #region 国家信息 数据 注释
  15464. //[HttpPost]
  15465. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  15466. //{
  15467. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  15468. // foreach (var item in dto)
  15469. // {
  15470. // infos.Add(new Grp_GroupsTaskAssignment()
  15471. // {
  15472. // DIId = item,
  15473. // CTId = 82,
  15474. // UId = 248,
  15475. // IsEnable = 1,
  15476. // CreateUserId = 233,
  15477. // CreateTime = DateTime.Now,
  15478. // IsDel = 0
  15479. // });
  15480. // infos.Add(new Grp_GroupsTaskAssignment()
  15481. // {
  15482. // DIId = item,
  15483. // CTId = 82,
  15484. // UId = 286,
  15485. // IsEnable = 1,
  15486. // CreateUserId = 233,
  15487. // CreateTime = DateTime.Now,
  15488. // IsDel = 0
  15489. // });
  15490. // }
  15491. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  15492. // return Ok("操作成功");
  15493. //}
  15494. //public class paramJsonDto
  15495. //{
  15496. // public List<CountriesInfo> str { get; set; }
  15497. //}
  15498. //[HttpPost]
  15499. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  15500. //{
  15501. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  15502. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  15503. // List<Sys_Cities> cities = new List<Sys_Cities>();
  15504. // List<Sys_Cities> districts = new List<Sys_Cities>();
  15505. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  15506. // _sqlSugar.BeginTran();
  15507. // int countitiesIndex = 0;
  15508. // foreach (var item in dto.str)
  15509. // {
  15510. // dynamic data = item.c;
  15511. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  15512. // if (data != null)
  15513. // {
  15514. // countitiesIndex++;
  15515. // foreach (var item1 in data)
  15516. // {
  15517. // string cnname = item1.cn;
  15518. // string enname = item1.en;
  15519. // Sys_Cities provinceInfo = new Sys_Cities()
  15520. // {
  15521. // CountriesId = countriesId,
  15522. // Name_CN = cnname,
  15523. // Name_EN = enname,
  15524. // ParentId = 0,
  15525. // IsCapital = 1,
  15526. // CreateUserId = 208,
  15527. // CreateTime = DateTime.Now,
  15528. // IsDel = 0
  15529. // };
  15530. // if (item1.lv == "province") //省份
  15531. // {
  15532. // provinceInfo.Level = 1;
  15533. // int provinceId = 0;
  15534. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  15535. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  15536. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  15537. // var data1 = item1.c;
  15538. // foreach (var item2 in data1)
  15539. // {
  15540. // if (item2.lv == "city")
  15541. // {
  15542. // string citycnname = item2.cn;
  15543. // string cityenname = item2.en;
  15544. // Sys_Cities cityInfo = new Sys_Cities()
  15545. // {
  15546. // CountriesId = countriesId,
  15547. // ParentId = provinceId,
  15548. // Level = 2,
  15549. // Name_CN = citycnname,
  15550. // Name_EN = cityenname,
  15551. // IsCapital = 1,
  15552. // CreateUserId = 208,
  15553. // CreateTime = DateTime.Now,
  15554. // IsDel = 0
  15555. // };
  15556. // if (item2.c != null)
  15557. // {
  15558. // int cityId = 0;
  15559. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  15560. // if (citiesInfo != null) cityId = citiesInfo.Id;
  15561. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  15562. // foreach (var item3 in item2.c)
  15563. // {
  15564. // if (item3.lv == "district")
  15565. // {
  15566. // var districtInfo = new Sys_Cities()
  15567. // {
  15568. // CountriesId = countriesId,
  15569. // Name_CN = item3.cn,
  15570. // Name_EN = item3.en,
  15571. // Level = 3,
  15572. // ParentId = cityId,
  15573. // IsCapital = 1,
  15574. // CreateUserId = 208,
  15575. // CreateTime = DateTime.Now,
  15576. // IsDel = 0
  15577. // };
  15578. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  15579. // //{
  15580. // districts.Add(districtInfo);
  15581. // //}
  15582. // }
  15583. // }
  15584. // }
  15585. // else
  15586. // {
  15587. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  15588. // //{
  15589. // cities.Add(cityInfo);
  15590. // //}
  15591. // }
  15592. // }
  15593. // }
  15594. // }
  15595. // else if (item1.lv == "city")//城市
  15596. // {
  15597. // provinceInfo.Level = 2;
  15598. // if (item1.c != null)
  15599. // {
  15600. // int cityId = 0;
  15601. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  15602. // if (citiesInfo != null) cityId = citiesInfo.Id;
  15603. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  15604. // foreach (var item3 in item1.c)
  15605. // {
  15606. // if (item3.lv == "district")
  15607. // {
  15608. // var districtInfo = new Sys_Cities()
  15609. // {
  15610. // CountriesId = countriesId,
  15611. // Name_CN = item3.cn,
  15612. // Name_EN = item3.en,
  15613. // Level = 3,
  15614. // ParentId = cityId,
  15615. // IsCapital = 1,
  15616. // CreateUserId = 208,
  15617. // CreateTime = DateTime.Now,
  15618. // IsDel = 0
  15619. // };
  15620. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  15621. // //{
  15622. // districts.Add(districtInfo);
  15623. // //}
  15624. // }
  15625. // }
  15626. // }
  15627. // else
  15628. // {
  15629. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  15630. // //{
  15631. // cities.Add(provinceInfo);
  15632. // //}
  15633. // }
  15634. // }
  15635. // }
  15636. // }
  15637. // }
  15638. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  15639. // cities = cities.Distinct().ToList();
  15640. // districts = districts.Distinct().ToList();
  15641. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  15642. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  15643. // cities.AddRange(districts);
  15644. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  15645. // //_sqlSugar.RollbackTran();
  15646. // _sqlSugar.CommitTran();
  15647. // return Ok(JsonView(false, "操作成功!"));
  15648. //}
  15649. //[HttpPost]
  15650. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  15651. //{
  15652. // List<CountitiesInfo> infos = dto.MyProperty;
  15653. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  15654. // _sqlSugar.BeginTran();
  15655. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  15656. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  15657. // foreach (var item in infos)
  15658. // {
  15659. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  15660. // if (countryInfo != null)
  15661. // {
  15662. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  15663. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  15664. // if (cityInfo1 != null)
  15665. // {
  15666. // cityInfo1.IsCapital = 0;
  15667. // cityInfos.Add(cityInfo1);
  15668. // }
  15669. // }
  15670. // }
  15671. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  15672. // .UpdateColumns(it => it.IsCapital)
  15673. // .WhereColumns(it => it.Id)
  15674. // .ExecuteCommand();
  15675. // //_sqlSugar.RollbackTran();
  15676. // _sqlSugar.CommitTran();
  15677. // return Ok(JsonView(false, "操作成功!"));
  15678. //}
  15679. //public class CounrtiesDto
  15680. //{
  15681. // public List<CountitiesInfo> MyProperty { get; set; }
  15682. //}
  15683. //public class CountitiesInfo
  15684. //{
  15685. // /// <summary>
  15686. // /// 圣约翰
  15687. // /// </summary>
  15688. // public string capital_name_chinese { get; set; }
  15689. // /// <summary>
  15690. // ///
  15691. // /// </summary>
  15692. // public string capital_name { get; set; }
  15693. // /// <summary>
  15694. // ///
  15695. // /// </summary>
  15696. // public string country_type { get; set; }
  15697. // /// <summary>
  15698. // /// 安提瓜和巴布达
  15699. // /// </summary>
  15700. // public string country_name_chinese { get; set; }
  15701. // /// <summary>
  15702. // /// 安提瓜和巴布达
  15703. // /// </summary>
  15704. // public string country_name_chinese_short { get; set; }
  15705. // /// <summary>
  15706. // /// 安提瓜和巴布达
  15707. // /// </summary>
  15708. // public string country_name_chinese_UN { get; set; }
  15709. // /// <summary>
  15710. // ///
  15711. // /// </summary>
  15712. // public string country_name_english_abbreviation { get; set; }
  15713. // /// <summary>
  15714. // ///
  15715. // /// </summary>
  15716. // public string country_name_english_formal { get; set; }
  15717. // /// <summary>
  15718. // ///
  15719. // /// </summary>
  15720. // public string country_name_english_UN { get; set; }
  15721. // /// <summary>
  15722. // ///
  15723. // /// </summary>
  15724. // public string continent_name { get; set; }
  15725. // /// <summary>
  15726. // ///
  15727. // /// </summary>
  15728. // public string subregion_name { get; set; }
  15729. // /// <summary>
  15730. // ///
  15731. // /// </summary>
  15732. // public string country_code2 { get; set; }
  15733. // /// <summary>
  15734. // ///
  15735. // /// </summary>
  15736. // public string country_code3 { get; set; }
  15737. // /// <summary>
  15738. // ///
  15739. // /// </summary>
  15740. // public string phone_code { get; set; }
  15741. //}
  15742. //public class CountriesInfo : BasicInfo
  15743. //{
  15744. // public List<CitiesInfo> c { get; set; }
  15745. //}
  15746. //public class CitiesInfo : BasicInfo
  15747. //{
  15748. // public List<AreaInfo> c { get; set; }
  15749. //}
  15750. //public class AreaInfo : BasicInfo
  15751. //{
  15752. // public List<AreaInfo> c { get; set; }
  15753. //}
  15754. //public class BasicInfo
  15755. //{
  15756. // public string code { get; set; }
  15757. // public string cn { get; set; }
  15758. // public string lv { get; set; }
  15759. // public string en { get; set; }
  15760. //}
  15761. #endregion
  15762. #region 查看邀请方
  15763. /// <summary>
  15764. /// 查看邀请方
  15765. /// 邀请方信息 Init
  15766. /// </summary>
  15767. /// <param name="dto"></param>
  15768. /// <returns></returns>
  15769. [HttpPost]
  15770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15771. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  15772. {
  15773. string sqlWhere = string.Empty;
  15774. if (!string.IsNullOrEmpty(dto.Search))
  15775. {
  15776. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  15777. }
  15778. string sql = string.Format($@"Select
  15779. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  15780. Id,
  15781. UnitName
  15782. From Res_InvitationOfficialActivityData
  15783. Where IsDel = 0
  15784. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  15785. RefAsync<int> total = 0;
  15786. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15787. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  15788. }
  15789. /// <summary>
  15790. /// 查看邀请方
  15791. /// 国家信息 Init
  15792. /// </summary>
  15793. /// <param name="dto"></param>
  15794. /// <returns></returns>
  15795. [HttpPost]
  15796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15797. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  15798. {
  15799. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  15800. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  15801. var diids = groupInfos.Select(it => it.Id).ToList();
  15802. List<string> countrys = new List<string>();
  15803. foreach (var item in country)
  15804. {
  15805. var data = _groupRepository.FormartTeamName(item);
  15806. var dataArray = _groupRepository.GroupSplitCountry(data);
  15807. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  15808. }
  15809. countrys = countrys.Distinct().ToList();
  15810. for (int i = 0; i < countrys.Count; i++)
  15811. {
  15812. string item = countrys[i];
  15813. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  15814. {
  15815. countrys.Remove(item);
  15816. i--;
  15817. }
  15818. }
  15819. RefAsync<int> total = 0;
  15820. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  15821. .Where(it => countrys.Contains(it.Name_CN))
  15822. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  15823. .Select(it => new { id = it.Id, name = it.Name_CN })
  15824. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15825. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  15826. }
  15827. /// <summary>
  15828. /// 查看邀请方
  15829. /// 城市信息 Init
  15830. /// </summary>
  15831. /// <param name="dto"></param>
  15832. /// <returns></returns>
  15833. [HttpPost]
  15834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15835. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  15836. {
  15837. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  15838. RefAsync<int> total = 0;
  15839. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  15840. .Where(it => it.CountriesId == dto.CountiesId)
  15841. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  15842. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  15843. .Select(it => new { id = it.Id, name = it.Name_CN })
  15844. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15845. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  15846. }
  15847. /// <summary>
  15848. /// 查看邀请方
  15849. /// 团组名称 Init
  15850. /// </summary>
  15851. /// <param name="dto"></param>
  15852. /// <returns></returns>
  15853. [HttpPost]
  15854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15855. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  15856. {
  15857. var watch = new Stopwatch();
  15858. watch.Start();
  15859. RefAsync<int> total = 0;
  15860. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  15861. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  15862. .Where((oa, di) => oa.IsDel == 0)
  15863. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  15864. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  15865. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  15866. .Distinct()
  15867. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15868. watch.Stop();
  15869. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  15870. }
  15871. /// <summary>
  15872. /// 查看邀请方
  15873. /// 团组 & 邀请方信息
  15874. /// </summary>
  15875. /// <param name="dto"></param>
  15876. /// <returns></returns>
  15877. [HttpPost]
  15878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15879. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  15880. {
  15881. var watch = new Stopwatch();
  15882. watch.Start();
  15883. RefAsync<int> total = 0;
  15884. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  15885. .AS("Grp_DelegationInfo")
  15886. .Includes(x => x.InvitingInfos)
  15887. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  15888. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  15889. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  15890. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  15891. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  15892. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  15893. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15894. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  15895. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  15896. infos.ForEach(x =>
  15897. {
  15898. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  15899. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  15900. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  15901. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  15902. });
  15903. watch.Stop();
  15904. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  15905. }
  15906. #endregion
  15907. #region 报批行程
  15908. /// <summary>
  15909. /// 报批行程初始化
  15910. /// </summary>
  15911. /// <param name="dto"></param>
  15912. /// <returns></returns>
  15913. [HttpPost]
  15914. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  15915. {
  15916. const int chiNumber = 5;
  15917. var jw = JsonView(false);
  15918. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  15919. var group = groupList.First();
  15920. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  15921. group = groupList.First(x => x.Id == diid);
  15922. if (group == null)
  15923. {
  15924. jw.Msg = "暂无团组!";
  15925. return Ok(jw);
  15926. }
  15927. var data = new
  15928. {
  15929. groupList = groupList.Select(x => new
  15930. {
  15931. x.TeamName,
  15932. x.Id
  15933. }),
  15934. content = new ArrayList(),
  15935. groupInfo = new
  15936. {
  15937. group.VisitDays,
  15938. group.TourCode,
  15939. group.VisitPNumber,
  15940. group.TeamName,
  15941. group.Id,
  15942. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  15943. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  15944. },
  15945. };
  15946. var resultArr = new ArrayList();
  15947. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  15948. if (content.Count == 0)
  15949. {
  15950. var stay = "-";
  15951. var cityPath = "-";
  15952. //添加城市路径以及住宿地
  15953. //黑屏代码数据
  15954. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  15955. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  15956. {
  15957. jw = JsonView(true, "黑屏代码有误!", data);
  15958. return Ok(jw);
  15959. }
  15960. foreach (DataRow row in dtBlack.Rows)
  15961. {
  15962. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  15963. {
  15964. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  15965. return Ok(jw);
  15966. }
  15967. }
  15968. //黑屏代码获取时间区间
  15969. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  15970. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  15971. _sqlSugar.BeginTran();
  15972. for (int i = 0; i < timeArr.Count; i++)
  15973. {
  15974. stay = "-";
  15975. cityPath = "-";
  15976. DateTime NewData = DateTime.Parse(timeArr[i]);
  15977. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  15978. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  15979. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  15980. if (tbSelect.Length > 0)
  15981. {
  15982. List<string> threeCodeStr = new List<string>();
  15983. foreach (var item in tbSelect)
  15984. {
  15985. var threeCode = item["Three"].ToString() ?? "";
  15986. if (threeCode.Length == 6)
  15987. {
  15988. var start = threeCode.Substring(0, 3);
  15989. var end = threeCode.Substring(3, 3);
  15990. if (threeCodeStr.Count == 0)
  15991. {
  15992. threeCodeStr.Add(start);
  15993. threeCodeStr.Add(end);
  15994. }
  15995. else
  15996. {
  15997. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  15998. {
  15999. threeCodeStr.Add(end);
  16000. }
  16001. else
  16002. {
  16003. threeCodeStr.Add(start);
  16004. threeCodeStr.Add(end);
  16005. }
  16006. }
  16007. }
  16008. }
  16009. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  16010. var last = threeCodeStr.Last();
  16011. foreach (var item in threeCodeStr)
  16012. {
  16013. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  16014. if (item.Equals(last))
  16015. {
  16016. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  16017. }
  16018. }
  16019. cityPath = cityPath.Trim('-');
  16020. }
  16021. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  16022. appro.Diid = diid ?? -1;
  16023. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  16024. appro.Id = thisId;
  16025. appro.CreateUserId = dto.UserId;
  16026. appro.CreateTime = DateTime.Now;
  16027. content.Add(appro);
  16028. }
  16029. _sqlSugar.CommitTran();
  16030. }
  16031. foreach (var x in content)
  16032. {
  16033. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  16034. if (chiList.Count < chiNumber)
  16035. {
  16036. for (int i = chiList.Count; i < chiNumber; i++)
  16037. {
  16038. chiList.Add(new Grp_ApprovalTravelDetails());
  16039. }
  16040. }
  16041. resultArr.Add(new
  16042. {
  16043. x.Id,
  16044. x.Date,
  16045. x.Diid,
  16046. chiList = chiList.Select(x1 => new
  16047. {
  16048. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  16049. x1.Details,
  16050. x1.ParentId,
  16051. x1.Id
  16052. })
  16053. });
  16054. }
  16055. data = data with
  16056. {
  16057. content = resultArr,
  16058. };
  16059. jw = JsonView(true, "获取成功!", data);
  16060. return Ok(jw);
  16061. }
  16062. /// <summary>
  16063. /// 报批行程删除
  16064. /// </summary>
  16065. /// <param name="dto"></param>
  16066. /// <returns></returns>
  16067. [HttpPost]
  16068. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  16069. {
  16070. var jw = JsonView(false);
  16071. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16072. if (group == null)
  16073. {
  16074. jw.Msg = "团组参数有误!";
  16075. return Ok(jw);
  16076. }
  16077. try
  16078. {
  16079. _sqlSugar.BeginTran();
  16080. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  16081. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  16082. {
  16083. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  16084. DeleteUserId = dto.uesrId,
  16085. IsDel = 1
  16086. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  16087. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  16088. {
  16089. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  16090. DeleteUserId = dto.uesrId,
  16091. IsDel = 1
  16092. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  16093. _sqlSugar.CommitTran();
  16094. jw = JsonView(true, "删除成功");
  16095. }
  16096. catch (Exception ex)
  16097. {
  16098. jw = JsonView(false, ex.Message);
  16099. }
  16100. return Ok(jw);
  16101. }
  16102. /// <summary>
  16103. /// 报批行程保存
  16104. /// </summary>
  16105. /// <param name="dto"></param>
  16106. /// <returns></returns>
  16107. [HttpPost]
  16108. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  16109. {
  16110. var jw = JsonView(false);
  16111. var Find = dto.Arr.Find(x => x.id == 0);
  16112. if (Find != null)
  16113. {
  16114. jw.Msg = "生成的ID为0!";
  16115. return Ok(jw);
  16116. }
  16117. foreach (var item in dto.Arr)
  16118. {
  16119. foreach (var chi in item.chiList)
  16120. {
  16121. if (chi.parentId == 0)
  16122. {
  16123. chi.parentId = item.id;
  16124. }
  16125. }
  16126. }
  16127. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  16128. _sqlSugar.BeginTran();
  16129. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  16130. {
  16131. var parentIds = dto.Arr.Select(x => x.id).ToList();
  16132. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  16133. {
  16134. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  16135. DeleteUserId = dto.UserId,
  16136. IsDel = 1
  16137. }).ExecuteCommand();
  16138. }
  16139. try
  16140. {
  16141. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  16142. {
  16143. CreateTime = DateTime.Now,
  16144. CreateUserId = dto.UserId,
  16145. Details = x.details,
  16146. ParentId = x.parentId,
  16147. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  16148. Remark = "",
  16149. IsDel = 0
  16150. }).ToList()).ExecuteCommand();
  16151. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  16152. {
  16153. Id = x.id,
  16154. Details = x.details,
  16155. ParentId = x.parentId,
  16156. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  16157. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  16158. {
  16159. Details = x.Details,
  16160. ParentId = x.ParentId,
  16161. Time = x.Time
  16162. }).ExecuteCommand();
  16163. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  16164. {
  16165. Id = x.id,
  16166. Date = x.date,
  16167. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  16168. {
  16169. Date = x.Date
  16170. }).ExecuteCommand();
  16171. _sqlSugar.CommitTran();
  16172. jw = JsonView(true, "保存成功!");
  16173. }
  16174. catch (Exception ex)
  16175. {
  16176. _sqlSugar.RollbackTran();
  16177. jw = JsonView(false, "保存失败!" + ex.Message);
  16178. }
  16179. return Ok(jw);
  16180. }
  16181. /// <summary>
  16182. /// 报批行程生成
  16183. /// </summary>
  16184. /// <param name="dto"></param>
  16185. /// <returns></returns>
  16186. [HttpPost]
  16187. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  16188. {
  16189. var jw = JsonView(false);
  16190. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16191. if (group == null)
  16192. {
  16193. jw.Msg = "暂无该团组!";
  16194. return Ok(jw);
  16195. }
  16196. //黑屏代码数据
  16197. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  16198. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  16199. {
  16200. jw.Msg = "黑屏代码有误!";
  16201. return Ok(jw);
  16202. }
  16203. foreach (DataRow row in dtBlack.Rows)
  16204. {
  16205. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  16206. {
  16207. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  16208. return Ok(jw);
  16209. }
  16210. }
  16211. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  16212. var resultArr = new ArrayList();
  16213. if (officialActivitiesArr.Count == 0)
  16214. {
  16215. jw.Msg = "暂无公务出访信息!";
  16216. return Ok(jw);
  16217. }
  16218. try
  16219. {
  16220. _sqlSugar.BeginTran();
  16221. DeleteApprovalJourney(new
  16222. Domain.Dtos.Groups.DeleteApprovalJourney
  16223. {
  16224. Diid = dto.Diid,
  16225. uesrId = dto.Userid
  16226. });
  16227. var stay = "-";
  16228. var cityPath = "-";
  16229. //添加城市路径以及住宿地
  16230. //黑屏代码获取时间区间
  16231. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  16232. var empty = "【未收入该三字码!请机票同事录入】";
  16233. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  16234. for (int i = 0; i < timeArr.Count; i++)
  16235. {
  16236. stay = "-";
  16237. cityPath = "-";
  16238. var chiarr = new List<Grp_ApprovalTravelDetails>();
  16239. DateTime NewData = DateTime.Parse(timeArr[i]);
  16240. 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();
  16241. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  16242. if (tbSelect.Length > 0)
  16243. {
  16244. List<string> threeCodeStr = new List<string>();
  16245. bool isTrade = false;
  16246. string trip = string.Empty;
  16247. var rowLast = tbSelect.Last();
  16248. var rowFirst = tbSelect.First();
  16249. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  16250. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  16251. var takeOffTime = DateTime.Parse(timeArr[i]);
  16252. var fallToTime = DateTime.Parse(timeArr[i]);
  16253. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  16254. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  16255. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  16256. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  16257. foreach (var item in tbSelect)
  16258. {
  16259. var start = string.Empty;
  16260. var end = string.Empty;
  16261. var threeCode = item["Three"].ToString() ?? "";
  16262. if (threeCode.Length == 6)
  16263. {
  16264. start = threeCode.Substring(0, 3);
  16265. end = threeCode.Substring(3, 3);
  16266. if (threeCodeStr.Count == 0)
  16267. {
  16268. threeCodeStr.Add(start);
  16269. threeCodeStr.Add(end);
  16270. }
  16271. else
  16272. {
  16273. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  16274. {
  16275. threeCodeStr.Add(end);
  16276. }
  16277. else
  16278. {
  16279. threeCodeStr.Add(start);
  16280. threeCodeStr.Add(end);
  16281. }
  16282. }
  16283. }
  16284. //处理机票信息
  16285. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  16286. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  16287. if (start_Object == null)
  16288. {
  16289. start_Object = new Res_ThreeCode()
  16290. {
  16291. AirPort = empty,
  16292. AirPort_En = empty,
  16293. City = empty,
  16294. Country = empty,
  16295. Four = empty,
  16296. Three = empty,
  16297. };
  16298. }
  16299. if (end_Object == null)
  16300. {
  16301. end_Object = new Res_ThreeCode()
  16302. {
  16303. AirPort = empty,
  16304. AirPort_En = empty,
  16305. City = empty,
  16306. Country = empty,
  16307. Four = empty,
  16308. Three = empty,
  16309. };
  16310. }
  16311. //机型判断
  16312. string airModel = item["AirModel"].ToString();
  16313. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  16314. string flightTime = item["FlightTime"].ToString();
  16315. if (flightTime!.Contains(":"))
  16316. {
  16317. flightTime = flightTime.Replace(":", "小时");
  16318. flightTime += "分钟";
  16319. }
  16320. if (flightTime.Contains("H"))
  16321. {
  16322. flightTime = flightTime.Replace("H", "小时");
  16323. }
  16324. if (flightTime.Contains("M"))
  16325. {
  16326. flightTime = flightTime.Replace("M", "分钟");
  16327. }
  16328. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  16329. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  16330. {
  16331. flightTime = flightDataTime.Hour > 0
  16332. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  16333. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  16334. ? flightDataTime.Minute.ToString() + "分钟" : "";
  16335. }
  16336. //航班号
  16337. string flightcode = item["Fliagtcode"].ToString();
  16338. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  16339. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  16340. if (aircompany == null)
  16341. {
  16342. aircompany = new Res_AirCompany
  16343. {
  16344. CnName = hsEmpty,
  16345. EnName = hsEmpty,
  16346. ShortCode = hsEmpty,
  16347. };
  16348. }
  16349. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  16350. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  16351. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  16352. if (isTrade)
  16353. {
  16354. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  16355. }
  16356. else
  16357. {
  16358. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  16359. }
  16360. }
  16361. chiarr.Add(new Grp_ApprovalTravelDetails
  16362. {
  16363. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  16364. CreateTime = DateTime.Now,
  16365. CreateUserId = dto.Userid,
  16366. ParentId = 0,
  16367. Details = trip
  16368. });
  16369. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  16370. var last = threeCodeStr.Last();
  16371. foreach (var item in threeCodeStr)
  16372. {
  16373. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  16374. if (item.Equals(last))
  16375. {
  16376. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  16377. }
  16378. }
  16379. cityPath = cityPath.Trim('-');
  16380. }
  16381. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  16382. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  16383. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  16384. appro.Diid = dto.Diid;
  16385. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  16386. appro.Id = thisId;
  16387. appro.CreateUserId = dto.Userid;
  16388. appro.CreateTime = DateTime.Now;
  16389. foreach (var item in gwinfo)
  16390. {
  16391. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  16392. chi.Details = "拜访" + item.Client;
  16393. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  16394. {
  16395. chi.Details += "," + item.ReqSample;
  16396. }
  16397. chi.ParentId = thisId;
  16398. chi.Time = item.Time;
  16399. chiarr.Add(chi);
  16400. }
  16401. if (chiarr.Count < 5)
  16402. {
  16403. for (int j = chiarr.Count; j < 5; j++)
  16404. {
  16405. chiarr.Add(new
  16406. Grp_ApprovalTravelDetails());
  16407. }
  16408. }
  16409. resultArr.Add(new
  16410. {
  16411. appro.Id,
  16412. appro.Date,
  16413. appro.Diid,
  16414. chiList = chiarr.Select(x1 => new
  16415. {
  16416. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  16417. x1.Details,
  16418. x1.ParentId,
  16419. x1.Id
  16420. })
  16421. });
  16422. }
  16423. _sqlSugar.CommitTran();
  16424. jw = JsonView(true, "生成成功!", resultArr);
  16425. }
  16426. catch (Exception ex)
  16427. {
  16428. jw.Code = 400;
  16429. jw.Msg = "生成失败!" + ex.Message;
  16430. }
  16431. return Ok(jw);
  16432. }
  16433. /// <summary>
  16434. /// 报批行程word导出
  16435. /// </summary>
  16436. /// <param name="dto"></param>
  16437. /// <returns></returns>
  16438. [HttpPost]
  16439. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  16440. {
  16441. var jw = JsonView(false);
  16442. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16443. if (group == null)
  16444. {
  16445. jw.Msg = "暂无该团组!";
  16446. return Ok(jw);
  16447. }
  16448. //模板路径
  16449. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  16450. //载入模板
  16451. Document doc = new Document(tempPath);
  16452. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16453. //获取所填表格的序数
  16454. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16455. Aspose.Words.Tables.Row titleRowClone = null;
  16456. Aspose.Words.Tables.Row CenterRowClone = null;
  16457. int index = 0;
  16458. int indexChi = 0;
  16459. int SetIndex = 0;
  16460. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  16461. //获取数据,放到datatable
  16462. foreach (var item in ApprovalTravelArr)
  16463. {
  16464. if (index > 0)
  16465. {
  16466. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  16467. tableOne.AppendChild(titleRowClone);
  16468. }
  16469. var textTime = item.Date;
  16470. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  16471. SetCells(tableOne, doc, SetIndex, 0, textTime);
  16472. SetIndex++;
  16473. if (ChiRep.Count > 0)
  16474. {
  16475. foreach (var itemChi in ChiRep)
  16476. {
  16477. var txtTime = itemChi.Time;
  16478. var txtDetail = itemChi.Details;
  16479. if (indexChi > 0)
  16480. {
  16481. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  16482. tableOne.AppendChild(CenterRowClone);
  16483. }
  16484. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  16485. {
  16486. SetCells(tableOne, doc, SetIndex, 0, "");
  16487. SetCells(tableOne, doc, SetIndex, 1, "");
  16488. indexChi++;
  16489. SetIndex++;
  16490. break;
  16491. }
  16492. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  16493. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  16494. indexChi++;
  16495. SetIndex++;
  16496. }
  16497. }
  16498. else
  16499. {
  16500. if (indexChi > 0)
  16501. {
  16502. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  16503. tableOne.AppendChild(CenterRowClone);
  16504. }
  16505. SetCells(tableOne, doc, SetIndex, 0, "");
  16506. SetCells(tableOne, doc, SetIndex, 1, "");
  16507. indexChi++;
  16508. SetIndex++;
  16509. }
  16510. index++;
  16511. }
  16512. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  16513. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  16514. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  16515. jw.Code = 200;
  16516. jw.Msg = "";
  16517. return Ok(jw);
  16518. }
  16519. private string intToString(int numberVal)
  16520. {
  16521. string numberval = numberVal.ToString();
  16522. Dictionary<char, string> Number = new Dictionary<char, string>();
  16523. Number.Add('1', "一");
  16524. Number.Add('2', "二");
  16525. Number.Add('3', "三");
  16526. Number.Add('4', "四");
  16527. Number.Add('5', "五");
  16528. Number.Add('6', "六");
  16529. Number.Add('7', "七");
  16530. Number.Add('8', "八");
  16531. Number.Add('9', "九");
  16532. string stringNumberVal = string.Empty;
  16533. for (int i = 0; i < numberval.Length; i++)
  16534. {
  16535. if (i == 0)
  16536. {
  16537. stringNumberVal += Number[numberval[i]];
  16538. }
  16539. else if (i >= 1)
  16540. {
  16541. if (numberval[i] == '0')
  16542. {
  16543. stringNumberVal = "十";
  16544. }
  16545. else
  16546. {
  16547. stringNumberVal += "十" + Number[numberval[i]];
  16548. }
  16549. }
  16550. }
  16551. return stringNumberVal;
  16552. }
  16553. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  16554. {
  16555. //获取table中的某个单元格,从0开始
  16556. Cell lshCell = table.Rows[rows].Cells[cells];
  16557. //将单元格中段落移除
  16558. foreach (Node item in lshCell.Paragraphs)
  16559. {
  16560. lshCell.Paragraphs.Remove(item);
  16561. }
  16562. if (val.Contains("\r\n"))
  16563. {
  16564. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  16565. foreach (var item in spArr)
  16566. {
  16567. //新建一个段落
  16568. Paragraph p = new Paragraph(doc);
  16569. var r = new Run(doc, item);
  16570. //把设置的值赋给之前新建的段落
  16571. p.AppendChild(r);
  16572. //将此段落加到单元格内
  16573. lshCell.AppendChild(p);
  16574. }
  16575. }
  16576. else
  16577. {
  16578. //新建一个段落
  16579. Paragraph p = new Paragraph(doc);
  16580. var r = new Run(doc, val);
  16581. //把设置的值赋给之前新建的段落
  16582. p.AppendChild(r);
  16583. //将此段落加到单元格内
  16584. lshCell.AppendChild(p);
  16585. }
  16586. }
  16587. [HttpPost]
  16588. public async Task<IActionResult> ServerHttp(string paramStr)
  16589. {
  16590. paramStr = paramStr.TrimEnd('\'');
  16591. paramStr = paramStr.TrimStart('\'');
  16592. JsonView jw = JsonView(false);
  16593. JObject param = JObject.Parse(paramStr);
  16594. if (!param.ContainsKey("url"))
  16595. {
  16596. jw.Msg = "url null";
  16597. return Ok(jw);
  16598. }
  16599. string url = param["url"]!.ToString();
  16600. var methon = "get";
  16601. Dictionary<string, string> headValues = null;
  16602. string bodyStr = string.Empty;
  16603. if (param.ContainsKey("methon"))
  16604. {
  16605. methon = param["methon"]!.ToString().ToLower();
  16606. }
  16607. if (param.ContainsKey("header"))
  16608. {
  16609. var header = param["header"]!.ToString();
  16610. JObject headerJobject = JObject.Parse(header);
  16611. headValues = new Dictionary<string, string>();
  16612. foreach (JProperty item in headerJobject.Properties())
  16613. {
  16614. var value = item.Value.ToString();
  16615. var head = item.Path;
  16616. headValues.Add(head, value);
  16617. }
  16618. }
  16619. HttpClient client = new HttpClient();
  16620. string responseString = string.Empty;
  16621. StringContent content = null;
  16622. if (headValues != null)
  16623. {
  16624. foreach (var item in headValues.Keys)
  16625. {
  16626. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  16627. {
  16628. if (param.ContainsKey("body"))
  16629. {
  16630. bodyStr = param["body"]!.ToString();
  16631. }
  16632. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  16633. }
  16634. else
  16635. {
  16636. client.DefaultRequestHeaders.Add(item, headValues[item]);
  16637. }
  16638. }
  16639. }
  16640. try
  16641. {
  16642. if (methon == "get")
  16643. {
  16644. responseString = await client.GetStringAsync(url);
  16645. }
  16646. else if (methon == "post")
  16647. {
  16648. var request = new HttpRequestMessage(HttpMethod.Post, url)
  16649. {
  16650. Content = content
  16651. };
  16652. var response = await client.SendAsync(request);
  16653. try
  16654. {
  16655. Stream responseStream = await response.Content.ReadAsStreamAsync();
  16656. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  16657. {
  16658. using (StreamReader reader = new StreamReader(gzipStream))
  16659. {
  16660. responseString = await reader.ReadToEndAsync();
  16661. }
  16662. }
  16663. }
  16664. catch (Exception)
  16665. {
  16666. responseString = await response.Content.ReadAsStringAsync();
  16667. }
  16668. }
  16669. else
  16670. {
  16671. responseString = "methon error";
  16672. }
  16673. jw = JsonView(true, "success", responseString);
  16674. }
  16675. catch (Exception ex)
  16676. {
  16677. jw.Msg = "error " + ex.Message;
  16678. jw.Data = ex.StackTrace;
  16679. }
  16680. finally
  16681. {
  16682. client.Dispose();
  16683. }
  16684. return Ok(jw);
  16685. }
  16686. #endregion
  16687. #region 团组接待意见调查
  16688. /// <summary>
  16689. /// 团组接待意见调查 - 信息管理
  16690. /// 基础数据(团组)
  16691. /// </summary>
  16692. /// <param name="dto"></param>
  16693. /// <returns></returns>
  16694. [HttpGet]
  16695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16696. public async Task<IActionResult> OpinionaireInit()
  16697. {
  16698. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  16699. .Select(x => new
  16700. {
  16701. x.Id,
  16702. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  16703. })
  16704. .OrderByDescending(x => x.Id)
  16705. .ToListAsync();
  16706. return Ok(JsonView(groupData, groupData.Count));
  16707. }
  16708. /// <summary>
  16709. /// 团组接待意见调查 - 信息管理
  16710. /// 列表
  16711. /// </summary>
  16712. /// <param name="groupId"></param>
  16713. /// <returns></returns>
  16714. [HttpGet("{groupId}")]
  16715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16716. public async Task<IActionResult> OpinionaireManageList(int groupId)
  16717. {
  16718. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16719. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  16720. .Select(x => new
  16721. {
  16722. x.Id,
  16723. x.TourGuideName,
  16724. x.CityName,
  16725. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  16726. x.CreateTime
  16727. })
  16728. .OrderBy(x => x.Id)
  16729. .ToListAsync();
  16730. return Ok(JsonView(data));
  16731. }
  16732. /// <summary>
  16733. /// 团组接待意见调查 - 信息管理
  16734. /// 保存
  16735. /// </summary>
  16736. /// <param name="dto"></param>
  16737. /// <returns></returns>
  16738. [HttpPost]
  16739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16740. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  16741. {
  16742. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  16743. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  16744. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16745. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  16746. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  16747. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  16748. _opinionaireRep.BeginTran();
  16749. if (addData != null && addData.Count > 0)
  16750. {
  16751. foreach (var item in addData)
  16752. {
  16753. item.CreateUserId = currUserInfo.UserId;
  16754. item.DiId = dto.DiId;
  16755. }
  16756. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  16757. }
  16758. if (updData != null && updData.Count > 0)
  16759. {
  16760. var upd = await _opinionaireRep._sqlSugar
  16761. .Updateable(updData)
  16762. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  16763. .WhereColumns(x => new { x.Id })
  16764. .ExecuteCommandAsync();
  16765. }
  16766. _opinionaireRep.CommitTran();
  16767. return Ok(JsonView("操作成功!"));
  16768. }
  16769. /// <summary>
  16770. /// 团组接待意见调查 - 信息管理
  16771. /// 删除
  16772. /// </summary>
  16773. /// <param name="id"></param>
  16774. /// <returns></returns>
  16775. [HttpDelete("{id}")]
  16776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16777. public async Task<IActionResult> OpinionaireManageDel(int id)
  16778. {
  16779. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  16780. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  16781. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  16782. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  16783. if (!del) return Ok(JsonView("操作失败!"));
  16784. return Ok(JsonView("操作成功!"));
  16785. }
  16786. /// <summary>
  16787. /// 团组接待意见调查 - 用户
  16788. /// 列表
  16789. /// </summary>
  16790. /// <param name="id"></param>
  16791. /// <returns></returns>
  16792. [HttpGet("{diId}")]
  16793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16794. public async Task<IActionResult> OpinionaireUserList(int diId)
  16795. {
  16796. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16797. var sql = string.Format(@"
  16798. SELECT
  16799. o.Id,
  16800. o.DiId,
  16801. di.TeamName AS 'GroupName',
  16802. di.VisitPNumber AS 'PeopleNumber',
  16803. di.ClientName AS 'LeadGroup',
  16804. di.VisitCountry AS 'Travel',
  16805. di.VisitDays AS 'Days',
  16806. o.CityName,
  16807. o.TourGuideName,
  16808. o.Catering,
  16809. o.CateringReason,
  16810. o.Stay,
  16811. o.StayReason,
  16812. o.[Route],
  16813. o.RouteReason,
  16814. o.OfficialActivity,
  16815. o.OfficialActivityReason,
  16816. o.TourGuide,
  16817. o.TourGuideReason,
  16818. o.[Translate],
  16819. o.TranslateReason,
  16820. o.Trip,
  16821. o.TripReason,
  16822. o.ESFileName,
  16823. o.SignatureDate,
  16824. o.Remark
  16825. FROM
  16826. Grp_Opinionaire o
  16827. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  16828. WHERE
  16829. o.IsDel = 0
  16830. AND o.DiId = {0}
  16831. ORDER BY
  16832. o.Id ASC", diId);
  16833. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  16834. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  16835. return Ok(JsonView(data));
  16836. }
  16837. /// <summary>
  16838. /// 团组接待意见调查 - 用户
  16839. /// 保存
  16840. /// </summary>
  16841. /// <param name="id"></param>
  16842. /// <returns></returns>
  16843. [HttpPost]
  16844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16845. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  16846. {
  16847. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  16848. foreach (var item in dto)
  16849. {
  16850. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  16851. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  16852. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  16853. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  16854. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  16855. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  16856. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  16857. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  16858. }
  16859. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  16860. if (!Directory.Exists(filePathBase))
  16861. {
  16862. Directory.CreateDirectory(filePathBase);
  16863. }
  16864. #region 上传文件
  16865. var filePaths = new List<string>();
  16866. foreach (var item in dto)
  16867. {
  16868. var file = item.File;
  16869. // 将文件保存到指定位置
  16870. var filePath = Path.Combine(filePathBase, file.FileName);
  16871. using (var stream = new FileStream(filePath, FileMode.Create))
  16872. {
  16873. await file.CopyToAsync(stream);
  16874. }
  16875. //验证文件是否上传成功
  16876. if (!System.IO.File.Exists(filePath))
  16877. {
  16878. foreach (var filePathStr in filePaths)
  16879. {
  16880. System.IO.File.Delete(filePathStr);
  16881. }
  16882. return Ok(JsonView(false, "文件上传失败!"));
  16883. }
  16884. item.ESFileName = file.FileName;
  16885. }
  16886. #endregion
  16887. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  16888. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  16889. .UpdateColumns(x => new
  16890. {
  16891. x.Catering,
  16892. x.CateringReason,
  16893. x.Stay,
  16894. x.StayReason,
  16895. x.Route,
  16896. x.RouteReason,
  16897. x.OfficialActivity,
  16898. x.OfficialActivityReason,
  16899. x.TourGuide,
  16900. x.TourGuideReason,
  16901. x.Translate,
  16902. x.TranslateReason,
  16903. x.Trip,
  16904. x.TripReason,
  16905. x.ESFileName,
  16906. x.SignatureDate,
  16907. x.Remark
  16908. })
  16909. .WhereColumns(x => new { x.Id })
  16910. .ExecuteCommandAsync();
  16911. if (upd < 1)
  16912. {
  16913. foreach (var filePathStr in filePaths)
  16914. {
  16915. System.IO.File.Delete(filePathStr);
  16916. }
  16917. return Ok(JsonView(false));
  16918. }
  16919. return Ok(JsonView(true));
  16920. }
  16921. #endregion
  16922. // /// <summary>
  16923. // ///
  16924. // /// </summary>
  16925. // /// <param name="_dto"></param>
  16926. // /// <returns></returns>
  16927. // [HttpPost]
  16928. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16929. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  16930. // {
  16931. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  16932. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  16933. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  16934. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  16935. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  16936. // dic_psg.Add("客人", 974);
  16937. // dic_psg.Add("司机", 975);
  16938. // dic_psg.Add("导游", 976);
  16939. // dic_psg.Add("公司内部人员", 977);
  16940. // dic_psg.Add("司机/导游/公司内部人员", 978);
  16941. // foreach (var item in list_visa)
  16942. // {
  16943. // Grp_VisaInfo temp = new Grp_VisaInfo();
  16944. // temp.Id = item.Id;
  16945. // temp.DIId = item.DIId;
  16946. // temp.VisaClient = item.VisaClient;
  16947. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  16948. // temp.VisaCurrency = item.VisaCurrency;
  16949. // temp.IsThird = item.IsThird;
  16950. // if (dic_psg.ContainsKey(item.PassengerType))
  16951. // {
  16952. // temp.PassengerType = dic_psg[item.PassengerType];
  16953. // }
  16954. // else {
  16955. // temp.PassengerType = -1;
  16956. // }
  16957. // temp.VisaNumber = item.VisaNumber;
  16958. // temp.VisaFreeNumber = item.VisaFreeNumber;
  16959. // temp.CreateUserId = item.Operators;
  16960. // DateTime dt_ct;
  16961. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  16962. // if (b_ct)
  16963. // {
  16964. // temp.CreateTime = dt_ct;
  16965. // }
  16966. // else
  16967. // {
  16968. // temp.CreateTime = DateTime.Now;
  16969. // }
  16970. // temp.DeleteTime = "";
  16971. // temp.DeleteUserId = 0;
  16972. // temp.Remark = item.Remark;
  16973. // if (string.IsNullOrEmpty(temp.Remark)) {
  16974. // temp.Remark = "";
  16975. // }
  16976. // temp.IsDel = item.IsDel;
  16977. // temp.VisaDescription = item.VisaAttachment;
  16978. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  16979. //([Id]
  16980. // ,[DIId]
  16981. // ,[VisaClient]
  16982. // ,[VisaPrice]
  16983. // ,[VisaCurrency]
  16984. // ,[IsThird]
  16985. // ,[PassengerType]
  16986. // ,[VisaNumber]
  16987. // ,[VisaFreeNumber]
  16988. // ,[CreateUserId]
  16989. // ,[CreateTime]
  16990. // ,[DeleteTime]
  16991. // ,[DeleteUserId]
  16992. // ,[Remark]
  16993. // ,[IsDel]
  16994. // ,[visaDescription])
  16995. // VALUES
  16996. // ({0},{1},'{2}',{3},{4}
  16997. //,{5},{6},{7},{8},{9}
  16998. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  16999. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  17000. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  17001. //);
  17002. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  17003. // }
  17004. // return Ok(JsonView(true, "操作成功!"));
  17005. // }
  17006. /// <summary>
  17007. /// 123132123
  17008. /// </summary>
  17009. /// <param name="_dto"></param>
  17010. /// <returns></returns>
  17011. [HttpPost]
  17012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17013. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  17014. {
  17015. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  17016. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  17017. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  17018. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  17019. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  17020. dicDetail.Add(789, 1034);
  17021. dicDetail.Add(790, 1035);
  17022. dicDetail.Add(791, 1036);
  17023. dicDetail.Add(792, 1037);
  17024. dicDetail.Add(793, 1038);
  17025. dicDetail.Add(794, 1039);
  17026. dicDetail.Add(795, 1040);
  17027. dicDetail.Add(796, 1041);
  17028. dicDetail.Add(797, 1042);
  17029. dicDetail.Add(798, 1043);
  17030. dicDetail.Add(801, 1044);
  17031. dicDetail.Add(802, 1045);
  17032. dicDetail.Add(803, 1046);
  17033. Dictionary<int, int> dic = new Dictionary<int, int>();
  17034. dic.Add(806, 1027);
  17035. dic.Add(807, 1028);
  17036. dic.Add(808, 1029);
  17037. dic.Add(809, 1030);
  17038. dic.Add(810, 1031);
  17039. dic.Add(811, 1032);
  17040. dic.Add(812, 1033);
  17041. foreach (var item in list_visa)
  17042. {
  17043. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  17044. temp.Coefficient = item.coefficient;
  17045. DateTime dtCrt;
  17046. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  17047. if (b1)
  17048. {
  17049. temp.CreateTime = dtCrt;
  17050. }
  17051. else
  17052. {
  17053. temp.CreateTime = DateTime.Now;
  17054. }
  17055. temp.CreateUserId = item.Operators;
  17056. temp.DeleteTime = "";
  17057. temp.DeleteUserId = 0;
  17058. temp.DiId = int.Parse(item.DIID);
  17059. temp.FilePath = item.FilePath;
  17060. temp.IsDel = item.IsDel;
  17061. temp.Price = item.Price;
  17062. temp.PriceCount = 1;
  17063. temp.PriceCurrency = item.Currency;
  17064. int detailId = 0;
  17065. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  17066. {
  17067. detailId = dicDetail[item.PriceTypeDetail];
  17068. }
  17069. temp.PriceDetailType = detailId;
  17070. temp.PriceDt = DateTime.Now;
  17071. temp.PriceName = item.PriceName;
  17072. temp.PriceSum = item.Price;
  17073. int tid = 0;
  17074. if (dic.ContainsKey(item.PriceType))
  17075. {
  17076. tid = dic[item.PriceType];
  17077. }
  17078. temp.PriceType = tid;
  17079. temp.Remark = item.Remark;
  17080. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  17081. }
  17082. return Ok(JsonView(true, "操作成功!"));
  17083. }
  17084. [HttpPost]
  17085. public IActionResult TimeTest()
  17086. {
  17087. var jw = JsonView(false, "error");
  17088. _sqlSugar.BeginTran();
  17089. try
  17090. {
  17091. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  17092. .Select(x => new Crm_NewClientData
  17093. {
  17094. Id = x.Id,
  17095. Client = x.Client,
  17096. Contact = x.Contact,
  17097. Location = x.Location,
  17098. })
  17099. .ToList();
  17100. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  17101. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  17102. Stopwatch stopwatch = new Stopwatch();
  17103. // 开始计时
  17104. stopwatch.Start();
  17105. foreach (var item in clientList)
  17106. {
  17107. EncryptionProcessor.DecryptProperties(item);
  17108. }
  17109. stopwatch.Stop();
  17110. jw.Code = 200;
  17111. jw.Data = stopwatch.ElapsedMilliseconds;
  17112. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  17113. }
  17114. catch (Exception ex)
  17115. {
  17116. jw.Code = 400;
  17117. jw.Msg = ex.Message;
  17118. }
  17119. return Ok(jw);
  17120. }
  17121. }
  17122. }