GroupsController.cs 1.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547
  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 Microsoft.VisualBasic;
  8. using MySqlX.XDevAPI.Relational;
  9. using NPOI.HSSF.UserModel;
  10. using NPOI.SS.Formula.Functions;
  11. using NPOI.SS.UserModel;
  12. using NPOI.SS.Util;
  13. using NPOI.XSSF.UserModel;
  14. using OASystem.API.Middlewares;
  15. using OASystem.API.OAMethodLib;
  16. using OASystem.API.OAMethodLib.APNs;
  17. using OASystem.API.OAMethodLib.File;
  18. using OASystem.API.OAMethodLib.Hub.HubClients;
  19. using OASystem.API.OAMethodLib.Hub.Hubs;
  20. using OASystem.API.OAMethodLib.JuHeAPI;
  21. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  22. using OASystem.Domain.AesEncryption;
  23. using OASystem.Domain.Attributes;
  24. using OASystem.Domain.Dtos.CRM;
  25. using OASystem.Domain.Dtos.FileDto;
  26. using OASystem.Domain.Dtos.Financial;
  27. using OASystem.Domain.Dtos.Groups;
  28. using OASystem.Domain.Entities.Customer;
  29. using OASystem.Domain.Entities.Financial;
  30. using OASystem.Domain.Entities.Groups;
  31. using OASystem.Domain.ViewModels.Financial;
  32. using OASystem.Domain.ViewModels.Groups;
  33. using OASystem.Domain.ViewModels.QiYeWeChat;
  34. using OASystem.Infrastructure.Repositories.CRM;
  35. using OASystem.Infrastructure.Repositories.Financial;
  36. using OASystem.Infrastructure.Repositories.Groups;
  37. using OASystem.Infrastructure.Tools;
  38. using Quartz.Util;
  39. using SqlSugar.Extensions;
  40. using System.Collections;
  41. using System.Data;
  42. using System.Diagnostics;
  43. using System.Globalization;
  44. using System.IO.Compression;
  45. using System.Text.Json;
  46. using TencentCloud.Ocr.V20181119.Models;
  47. using static OASystem.API.OAMethodLib.JWTHelper;
  48. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  49. using Bookmark = Aspose.Words.Bookmark;
  50. using Cell = Aspose.Words.Tables.Cell;
  51. using Table = Aspose.Words.Tables.Table;
  52. namespace OASystem.API.Controllers
  53. {
  54. /// <summary>
  55. /// 团组相关
  56. /// </summary>
  57. //[Authorize]
  58. [Route("api/[controller]/[action]")]
  59. public class GroupsController : ControllerBase
  60. {
  61. private readonly ILogger<GroupsController> _logger;
  62. private readonly GrpScheduleRepository _grpScheduleRep;
  63. private readonly IMapper _mapper;
  64. private readonly DelegationInfoRepository _groupRepository;
  65. private readonly TaskAssignmentRepository _taskAssignmentRep;
  66. private readonly AirTicketResRepository _airTicketResRep;
  67. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  68. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  69. private readonly DelegationEnDataRepository _delegationEnDataRep;
  70. private readonly DelegationVisaRepository _delegationVisaRep;
  71. private readonly VisaPriceRepository _visaPriceRep;
  72. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  73. private readonly HotelPriceRepository _hotelPriceRep;
  74. private readonly CustomersRepository _customersRep;
  75. private readonly MessageRepository _message;
  76. private readonly SqlSugarClient _sqlSugar;
  77. private readonly TourClientListRepository _tourClientListRep;
  78. private readonly TeamRateRepository _teamRateRep;
  79. #region 成本相关
  80. private readonly CheckBoxsRepository _checkBoxs;
  81. private readonly GroupCostRepository _GroupCostRepository;
  82. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  83. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  84. #endregion
  85. private readonly SetDataRepository _setDataRep;
  86. private string url;
  87. private string path;
  88. private readonly EnterExitCostRepository _enterExitCostRep;
  89. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  90. private readonly UsersRepository _usersRep;
  91. private readonly IJuHeApiService _juHeApi;
  92. private readonly InvertedListRepository _invertedListRep;
  93. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  94. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  95. private readonly ThreeCodeRepository _threeCodeRepository;
  96. private readonly HotelInquiryRepository _hotelInquiryRep;
  97. private readonly FeeAuditRepository _feeAuditRep;
  98. private readonly VisaCommissionRepository _visaCommissionRep;
  99. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  100. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  101. private readonly List<CurrencyInfo> _currencyInit;
  102. private readonly List<int> _portTypeData;
  103. private readonly TableOperationRecordRepository _tableorRep;
  104. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  105. private readonly RestaurantRepository _restaurantRep;
  106. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  107. /// <summary>
  108. /// 构造函数
  109. /// </summary>
  110. /// <param name="logger"></param>
  111. /// <param name="mapper"></param>
  112. /// <param name="hubContext"></param>
  113. /// <param name="sqlSugar"></param>
  114. /// <param name="grpScheduleRep"></param>
  115. /// <param name="groupRepository"></param>
  116. /// <param name="taskAssignmentRep"></param>
  117. /// <param name="airTicketResRep"></param>
  118. /// <param name="decreasePaymentsRep"></param>
  119. /// <param name="InvitationOfficialActivitiesRep"></param>
  120. /// <param name="delegationEnDataRep"></param>
  121. /// <param name="enterExitCostRep"></param>
  122. /// <param name="delegationVisaRep"></param>
  123. /// <param name="message"></param>
  124. /// <param name="visaPriceRep"></param>
  125. /// <param name="carTouristGuideGroundRep"></param>
  126. /// <param name="checkBoxs"></param>
  127. /// <param name="GroupCostRepository"></param>
  128. /// <param name="CostTypeHotelNumberRepository"></param>
  129. /// <param name="GroupCostParameterRepository"></param>
  130. /// <param name="hotelPriceRep"></param>
  131. /// <param name="customersRep"></param>
  132. /// <param name="setDataRep"></param>
  133. /// <param name="tourClientListRep"></param>
  134. /// <param name="teamRateRep"></param>
  135. /// <param name="usersRep"></param>
  136. /// <param name="juHeApi"></param>
  137. /// <param name="invertedListRep"></param>
  138. /// <param name="visaFeeInfoRep"></param>
  139. /// <param name="ticketBlackCodeRep"></param>
  140. /// <param name="hotelInquiryRep"></param>
  141. /// <param name="threeCodeRepository"></param>
  142. /// <param name="feeAuditRep"></param>
  143. /// <param name="visaCommissionRep"></param>
  144. /// <param name="ffrRep"></param>
  145. /// <param name="opinionaireRep"></param>
  146. /// <param name="tableorRep"></param>
  147. /// <param name="enterExitCostDraftRep"></param>
  148. /// <param name="restaurantRep"></param>
  149. /// <param name="enterExitCostQuoteRep"></param>
  150. public GroupsController(
  151. ILogger<GroupsController> logger,
  152. IMapper mapper,
  153. IHubContext<ChatHub, IChatClient> hubContext,
  154. SqlSugarClient sqlSugar,
  155. GrpScheduleRepository grpScheduleRep,
  156. DelegationInfoRepository groupRepository,
  157. TaskAssignmentRepository taskAssignmentRep,
  158. AirTicketResRepository airTicketResRep,
  159. DecreasePaymentsRepository decreasePaymentsRep,
  160. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  161. DelegationEnDataRepository delegationEnDataRep,
  162. EnterExitCostRepository enterExitCostRep,
  163. DelegationVisaRepository delegationVisaRep,
  164. MessageRepository message,
  165. VisaPriceRepository visaPriceRep,
  166. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  167. CheckBoxsRepository checkBoxs,
  168. GroupCostRepository GroupCostRepository,
  169. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  170. GroupCostParameterRepository GroupCostParameterRepository,
  171. HotelPriceRepository hotelPriceRep,
  172. CustomersRepository customersRep,
  173. SetDataRepository setDataRep,
  174. TourClientListRepository tourClientListRep,
  175. TeamRateRepository teamRateRep,
  176. UsersRepository usersRep, IJuHeApiService juHeApi,
  177. InvertedListRepository invertedListRep,
  178. VisaFeeInfoRepository visaFeeInfoRep,
  179. TicketBlackCodeRepository ticketBlackCodeRep,
  180. HotelInquiryRepository hotelInquiryRep,
  181. ThreeCodeRepository threeCodeRepository,
  182. FeeAuditRepository feeAuditRep,
  183. VisaCommissionRepository visaCommissionRep,
  184. ForeignReceivablesRepository ffrRep,
  185. OpinionaireRepository opinionaireRep,
  186. TableOperationRecordRepository tableorRep,
  187. EnterExitCostDraftRepository enterExitCostDraftRep,
  188. RestaurantRepository restaurantRep,
  189. EnterExitCostQuoteRepository enterExitCostQuoteRep
  190. )
  191. {
  192. _logger = logger;
  193. _mapper = mapper;
  194. _grpScheduleRep = grpScheduleRep;
  195. _groupRepository = groupRepository;
  196. _taskAssignmentRep = taskAssignmentRep;
  197. _airTicketResRep = airTicketResRep;
  198. _sqlSugar = sqlSugar;
  199. url = AppSettingsHelper.Get("ExcelBaseUrl");
  200. path = AppSettingsHelper.Get("ExcelBasePath");
  201. if (!System.IO.Directory.Exists(path))
  202. {
  203. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  204. }
  205. _decreasePaymentsRep = decreasePaymentsRep;
  206. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  207. _delegationEnDataRep = delegationEnDataRep;
  208. _enterExitCostRep = enterExitCostRep;
  209. _delegationVisaRep = delegationVisaRep;
  210. _message = message;
  211. _visaPriceRep = visaPriceRep;
  212. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  213. _checkBoxs = checkBoxs;
  214. _GroupCostRepository = GroupCostRepository;
  215. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  216. _GroupCostParameterRepository = GroupCostParameterRepository;
  217. _hotelPriceRep = hotelPriceRep;
  218. _customersRep = customersRep;
  219. _setDataRep = setDataRep;
  220. _tourClientListRep = tourClientListRep;
  221. _teamRateRep = teamRateRep;
  222. _hubContext = hubContext;
  223. _usersRep = usersRep;
  224. _juHeApi = juHeApi;
  225. _invertedListRep = invertedListRep;
  226. _visaFeeInfoRep = visaFeeInfoRep;
  227. _ticketBlackCodeRep = ticketBlackCodeRep;
  228. _hotelInquiryRep = hotelInquiryRep;
  229. _threeCodeRepository = threeCodeRepository;
  230. _feeAuditRep = feeAuditRep;
  231. _visaCommissionRep = visaCommissionRep;
  232. _ffrRep = ffrRep;
  233. _opinionaireRep = opinionaireRep;
  234. _currencyInit = new List<CurrencyInfo>()
  235. {
  236. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  237. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  238. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  239. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  240. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  241. };
  242. _portTypeData = new List<int>() { 2, 3 };
  243. _tableorRep = tableorRep;
  244. _enterExitCostDraftRep = enterExitCostDraftRep;
  245. _restaurantRep = restaurantRep;
  246. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  247. }
  248. #region 流程管控
  249. /// <summary>
  250. /// 获取团组流程管控信息
  251. /// </summary>
  252. /// <param name="_jsonDto"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  257. {
  258. if (string.IsNullOrEmpty(_jsonDto.Paras))
  259. {
  260. return Ok(JsonView(false, "参数为空"));
  261. }
  262. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  263. if (_ScheduleDto != null)
  264. {
  265. if (_ScheduleDto.SearchType == 2)//获取列表
  266. {
  267. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  268. return Ok(JsonView(_grpScheduleViewList));
  269. }
  270. else//获取对象
  271. {
  272. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  273. if (_grpScheduleView != null)
  274. {
  275. return Ok(JsonView(_grpScheduleView));
  276. }
  277. }
  278. }
  279. else
  280. {
  281. return Ok(JsonView(false, "参数反序列化失败"));
  282. }
  283. return Ok(JsonView(false, "暂无数据!"));
  284. }
  285. /// <summary>
  286. /// 修改团组流程管控详细表数据
  287. /// </summary>
  288. /// <param name="dto"></param>
  289. /// <returns></returns>
  290. [HttpPost]
  291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  292. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  293. {
  294. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  295. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  296. .SetColumns(it => it.Duty == _detail.Duty)
  297. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  298. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  299. .SetColumns(it => it.JobContent == _detail.JobContent)
  300. .SetColumns(it => it.Remark == _detail.Remark)
  301. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  302. .Where(s => s.Id == dto.Id)
  303. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  304. .ExecuteCommandAsync();
  305. if (result > 0)
  306. {
  307. return Ok(JsonView(true, "保存成功!"));
  308. }
  309. return Ok(JsonView(false, "保存失败!"));
  310. }
  311. /// <summary>
  312. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  313. /// </summary>
  314. /// <param name="dto"></param>
  315. /// <returns></returns>
  316. [HttpPost]
  317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  318. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  319. {
  320. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  321. _detail.IsDel = 1;
  322. _detail.DeleteUserId = dto.Duty;
  323. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  324. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  325. .SetColumns(it => it.IsDel == _detail.IsDel)
  326. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  327. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  328. .Where(it => it.Id == dto.Id)
  329. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  330. //.WhereColumns(s => s.Id == dto.Id)
  331. .ExecuteCommandAsync();
  332. if (result > 0)
  333. {
  334. return Ok(JsonView(true, "删除成功!"));
  335. }
  336. return Ok(JsonView(false, "删除失败!"));
  337. }
  338. /// <summary>
  339. /// 增加团组流程管控详细表数据
  340. /// </summary>
  341. /// <param name="dto"></param>
  342. /// <returns></returns>
  343. [HttpPost]
  344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  345. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  346. {
  347. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  348. if (DateTime.Now < _detail.ExpectBeginDt)
  349. {
  350. _detail.StepStatus = 0;
  351. }
  352. else
  353. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  354. _detail.StepStatus = 1;
  355. }
  356. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  357. if (result > 0)
  358. {
  359. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  360. return Ok(JsonView(true, "添加成功!", _result));
  361. }
  362. return Ok(JsonView(false, "添加失败!"));
  363. }
  364. #endregion
  365. #region 团组基本信息
  366. /// <summary>
  367. /// 接团信息列表
  368. /// </summary>
  369. /// <param name="dto">团组列表请求dto</param>
  370. /// <returns></returns>
  371. [HttpPost]
  372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  373. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  374. {
  375. var groupData = await _groupRepository.GetGroupList(dto);
  376. if (groupData.Code != 0)
  377. {
  378. return Ok(JsonView(false, groupData.Msg));
  379. }
  380. return Ok(JsonView(groupData.Data));
  381. }
  382. /// <summary>
  383. /// 分页查询团组列表
  384. /// </summary>
  385. /// <param name="dto"></param>
  386. /// <returns></returns>
  387. [HttpPost]
  388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  389. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  390. {
  391. var watch = new Stopwatch();
  392. watch.Start();
  393. RefAsync<int> total = 0;
  394. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  395. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  396. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  397. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  398. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  399. .Distinct()
  400. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  401. watch.Stop();
  402. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  403. }
  404. /// <summary>
  405. /// 接团信息列表 Page Init
  406. /// </summary>
  407. /// <returns></returns>
  408. [HttpPost]
  409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  410. public async Task<IActionResult> PostGroupPageListInit()
  411. {
  412. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  413. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  414. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  415. var _view = new
  416. {
  417. depData = depDatas,
  418. rankData = rankDatas
  419. };
  420. return Ok(JsonView(true, "查询成功!", _view));
  421. }
  422. /// <summary>
  423. /// 接团信息列表 Page
  424. /// </summary>
  425. /// <param name="dto">团组列表请求dto</param>
  426. /// <returns></returns>
  427. [HttpPost]
  428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  429. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  430. {
  431. #region 参数验证
  432. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  433. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  434. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  435. #region 页面操作权限验证
  436. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  437. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  438. #endregion
  439. #endregion
  440. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  441. {
  442. string sqlWhere = string.Empty;
  443. if (dto.IsSure == 0) //未完成
  444. {
  445. sqlWhere += string.Format(@" And IsSure = 0");
  446. }
  447. else if (dto.IsSure == 1) //已完成
  448. {
  449. sqlWhere += string.Format(@" And IsSure = 1");
  450. }
  451. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  452. {
  453. string tj = dto.SearchCriteria;
  454. 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}%')",
  455. tj, tj, tj, tj, tj);
  456. }
  457. if (int.TryParse(dto.Rank, out int rankId))
  458. {
  459. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  460. }
  461. string sqlWhere1 = string.Empty;
  462. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  463. {
  464. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  465. }
  466. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  467. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  468. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  469. JietuanOperator,IsSure,CreateTime,IsBid
  470. From (
  471. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  472. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  473. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  474. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  475. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  476. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  477. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  478. From Grp_DelegationInfo gdi
  479. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  480. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  481. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  482. Where gdi.IsDel = 0 {0}
  483. ) temp {1}", sqlWhere, sqlWhere1);
  484. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  485. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  486. var _view = new
  487. {
  488. PageFuncAuth = pageFunAuthView,
  489. Data = _DelegationList
  490. };
  491. return Ok(JsonView(true, "查询成功!", _view, total));
  492. }
  493. else
  494. {
  495. return Ok(JsonView(false, "查询失败"));
  496. }
  497. }
  498. /// <summary>
  499. /// 团组列表
  500. /// </summary>
  501. /// <returns></returns>
  502. [HttpPost]
  503. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  504. {
  505. #region 参数验证
  506. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  507. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  508. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  509. #region 页面操作权限验证
  510. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  511. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  512. #endregion
  513. #endregion
  514. if (dto.PortType != 1 && dto.PortType != 2)
  515. {
  516. return Ok(JsonView(false, "查询失败!"));
  517. }
  518. string orderbyStr = "order by gdi.CreateTime Desc";
  519. string sqlWhere = string.Empty;
  520. if (dto.IsSure == 0) //未完成
  521. {
  522. sqlWhere += string.Format(@" And IsSure = 0");
  523. }
  524. else if (dto.IsSure == 1) //已完成
  525. {
  526. sqlWhere += string.Format(@" And IsSure = 1");
  527. }
  528. //团组类型
  529. if (dto.TeamDid > 0)
  530. {
  531. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  532. }
  533. //团组名称
  534. if (!string.IsNullOrEmpty(dto.TeamName))
  535. {
  536. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  537. }
  538. //客户名称
  539. if (!string.IsNullOrEmpty(dto.ClientName))
  540. {
  541. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  542. }
  543. //客户单位
  544. if (!string.IsNullOrEmpty(dto.ClientUnit))
  545. {
  546. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  547. }
  548. //出访时间
  549. if (!string.IsNullOrEmpty(dto.visitDataTime))
  550. {
  551. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  552. orderbyStr = "order by gdi.VisitDate";
  553. }
  554. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  555. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  556. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  557. JietuanOperator,IsSure,CreateTime
  558. From (
  559. Select row_number() over({0}) as Row_Number,
  560. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  561. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  562. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  563. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  564. From Grp_DelegationInfo gdi
  565. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  566. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  567. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  568. Where gdi.IsDel = 0 {1}
  569. ) temp ", orderbyStr, sqlWhere);
  570. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  571. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  572. #region 处理所属部门
  573. /*
  574. * 1.sq 和 gyy 等显示 市场部
  575. * 2.王鸽和主管及张总还有管理员号统一国交部
  576. * 2-1. 4 管理员 ,21 张海麟
  577. */
  578. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  579. List<int> userIds1 = new List<int>() { 4, 21 };
  580. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  581. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  582. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  583. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  584. .ToList();
  585. foreach (var item in _DelegationList)
  586. {
  587. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  588. }
  589. #endregion
  590. var _view = new
  591. {
  592. PageFuncAuth = pageFunAuthView,
  593. Data = _DelegationList
  594. };
  595. return Ok(JsonView(true, "查询成功!", _view, total));
  596. }
  597. /// <summary>
  598. /// 接团信息详情
  599. /// </summary>
  600. /// <param name="dto">团组info请求dto</param>
  601. /// <returns></returns>
  602. [HttpPost]
  603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  604. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  605. {
  606. var groupData = await _groupRepository.GetGroupInfo(dto);
  607. if (groupData.Code != 0)
  608. {
  609. return Ok(JsonView(false, groupData.Msg));
  610. }
  611. return Ok(JsonView(groupData.Data));
  612. }
  613. /// <summary>
  614. /// 接团信息 编辑添加
  615. /// 基础信息数据源
  616. /// </summary>
  617. /// <param name="dto"></param>
  618. /// <returns></returns>
  619. [HttpPost]
  620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  621. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  622. {
  623. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  624. if (groupData.Code != 0)
  625. {
  626. return Ok(JsonView(false, groupData.Msg));
  627. }
  628. return Ok(JsonView(groupData.Data));
  629. }
  630. /// <summary>
  631. /// 接团信息 操作(增改)
  632. /// </summary>
  633. /// <param name="dto"></param>
  634. /// <returns></returns>
  635. [HttpPost]
  636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  637. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  638. {
  639. // 创建 Stopwatch 实例
  640. Stopwatch stopwatch = Stopwatch.StartNew();
  641. decimal ffrPrice = 0.00M;
  642. DateTime? visitDt = null;
  643. if (dto.Status == 2)
  644. {
  645. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  646. if (groupInfo != null)
  647. {
  648. ffrPrice = groupInfo.PaymentMoney;
  649. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  650. }
  651. }
  652. var groupData = await _groupRepository.GroupOperation(dto);
  653. if (groupData.Code != 0)
  654. {
  655. return Ok(JsonView(false, groupData.Msg));
  656. }
  657. int diId = 0;
  658. try
  659. {
  660. //添加时 默认加入团组汇率
  661. if (dto.Status == 1) //添加
  662. {
  663. diId = groupData.Data;
  664. //添加默认币种
  665. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  666. //默认分配权限
  667. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  668. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  669. var _managerIds = new List<int>() { 22, 32, 21 };
  670. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  671. if (userIds.Count > 0)
  672. {
  673. userIds.Add(208);
  674. //创建团组管控
  675. GroupStepForDelegation.CreateWorkStep(diId);
  676. //发送消息
  677. string groupName = dto.TeamName;
  678. string createGroupUser = string.Empty;
  679. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  680. if (userInfo != null) createGroupUser = userInfo.CnName;
  681. string title = $"系统通知";
  682. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  683. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  684. }
  685. //默认创建倒推表
  686. await _invertedListRep._Create(dto.UserId, diId);
  687. }
  688. else if (dto.Status == 2)
  689. {
  690. diId = dto.Id;
  691. }
  692. #region 签证人员团组时间通知
  693. #region 计算出访起止时间
  694. var startTime = new DateTime();
  695. var endTime = new DateTime();
  696. if (DateTime.TryParse(dto.VisitDate, out startTime))
  697. {
  698. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  699. }
  700. #endregion
  701. #endregion
  702. #region 团组操作默认添加/修改收款账单
  703. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  704. {
  705. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  706. .Where(x => x.IsDel == 0 &&
  707. x.Diid == diId &&
  708. x.Remark.Equals("预付款")
  709. )
  710. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  711. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  712. .FirstAsync();
  713. ffrInfo = new Fin_ForeignReceivables()
  714. {
  715. Diid = diId,
  716. PriceName = dto.ClientUnit,
  717. Price = dto.PaymentMoney,
  718. Count = 1,
  719. Unit = $"元",
  720. ItemSumPrice = dto.PaymentMoney,
  721. Rate = 1.0000M,
  722. Currency = 836,
  723. AddingWay = 0,
  724. CreateUserId = dto.UserId,
  725. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  726. Remark = $"预付款"
  727. };
  728. if (ffrInfo == null) //Add
  729. {
  730. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  731. }
  732. else //修改
  733. {
  734. await _sqlSugar.Updateable(ffrInfo)
  735. .UpdateColumns(x => new
  736. {
  737. x.PriceName,
  738. x.Price,
  739. x.ItemSumPrice,
  740. x.CreateTime,
  741. x.CreateUserId
  742. })
  743. .WhereColumns(x => x.Id)
  744. .ExecuteCommandAsync();
  745. }
  746. }
  747. #endregion
  748. if (diId > 0)
  749. {
  750. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  751. }
  752. // 停止计时
  753. stopwatch.Stop();
  754. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  755. }
  756. catch (Exception ex)
  757. {
  758. // 停止计时
  759. stopwatch.Stop();
  760. Logs("[response]" + JsonConvert.SerializeObject(dto));
  761. Logs(ex.Message);
  762. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  763. }
  764. // 停止计时
  765. stopwatch.Stop();
  766. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  767. }
  768. /// <summary>
  769. /// 接团流程操作(增改)
  770. /// 安卓端使用 建团时添加客户名单
  771. /// </summary>
  772. /// <param name="dto"></param>
  773. /// <returns></returns>
  774. [HttpPost]
  775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  776. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  777. {
  778. #region 参数验证
  779. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  780. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  781. #region 页面操作权限验证
  782. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  783. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  784. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  785. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  786. #endregion
  787. #endregion
  788. try
  789. {
  790. //_sqlSugar.BeginTran();
  791. decimal ffrPrice = 0.00M;
  792. DateTime? visitDt = null;
  793. if (dto.Status == 2)
  794. {
  795. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  796. if (groupInfo != null)
  797. {
  798. ffrPrice = groupInfo.PaymentMoney;
  799. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  800. }
  801. }
  802. var _dto = new GroupOperationDto();
  803. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  804. var groupData = await _groupRepository.GroupOperation(_dto);
  805. if (groupData.Code != 0)
  806. {
  807. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  808. }
  809. int diId = 0;
  810. //添加时 默认加入团组汇率
  811. if (dto.Status == 1) //添加
  812. {
  813. diId = groupData.Data;
  814. //添加默认币种
  815. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  816. //默认分配权限
  817. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  818. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  819. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  820. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  821. if (userIds.Count > 0)
  822. {
  823. userIds.Add(208);
  824. //创建团组管控
  825. GroupStepForDelegation.CreateWorkStep(diId);
  826. //发送消息
  827. string groupName = dto.TeamName;
  828. string createGroupUser = string.Empty;
  829. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  830. if (userInfo != null) createGroupUser = userInfo.CnName;
  831. string title = $"系统通知";
  832. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  833. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  834. }
  835. #region 应用推送
  836. try
  837. {
  838. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  839. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  840. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  841. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  842. {
  843. List<string> userList = new List<string>() { users.QiyeChatUserId };
  844. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  845. }
  846. }
  847. catch (Exception ex)
  848. {
  849. }
  850. #endregion
  851. //默认创建倒推表
  852. await _invertedListRep._Create(dto.UserId, diId);
  853. }
  854. if (dto.Status == 2)
  855. {
  856. diId = dto.Id;
  857. if (diId == 0)
  858. {
  859. //_sqlSugar.RollbackTran();
  860. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  861. }
  862. }
  863. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  864. if (viewData.Code != 0)
  865. {
  866. //_sqlSugar.RollbackTran();
  867. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  868. }
  869. #region 团组操作默认添加/修改收款账单
  870. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  871. {
  872. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  873. .Where(x => x.IsDel == 0 &&
  874. x.Diid == diId &&
  875. x.Remark.Equals("预付款")
  876. )
  877. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  878. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  879. .FirstAsync();
  880. ffrInfo = new Fin_ForeignReceivables()
  881. {
  882. Diid = diId,
  883. PriceName = dto.ClientUnit,
  884. Price = dto.PaymentMoney,
  885. Count = 1,
  886. Unit = $"元",
  887. ItemSumPrice = dto.PaymentMoney,
  888. Rate = 1.0000M,
  889. Currency = 836,
  890. AddingWay = 0,
  891. CreateUserId = dto.UserId,
  892. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  893. Remark = $"预付款"
  894. };
  895. if (ffrInfo == null) //Add
  896. {
  897. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  898. }
  899. else //修改
  900. {
  901. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  902. .UpdateColumns(x => new
  903. {
  904. x.PriceName,
  905. x.Price,
  906. x.ItemSumPrice,
  907. x.CreateTime,
  908. x.CreateUserId
  909. })
  910. .WhereColumns(x => x.Id)
  911. .ExecuteCommandAsync();
  912. }
  913. }
  914. #endregion
  915. #region 签证人员团组时间通知
  916. #region 计算出访起止时间
  917. var startTime = new DateTime();
  918. var endTime = new DateTime();
  919. if (DateTime.TryParse(dto.VisitDate, out startTime))
  920. {
  921. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  922. }
  923. #endregion
  924. if (diId > 0)
  925. {
  926. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  927. }
  928. #endregion
  929. //_sqlSugar.CommitTran();
  930. return Ok(JsonView(true, "添加成功"));
  931. }
  932. catch (Exception ex)
  933. {
  934. _sqlSugar.RollbackTran();
  935. return Ok(JsonView(false, ex.Message));
  936. }
  937. }
  938. /// <summary>
  939. /// 接团流程操作(增改)
  940. /// 安卓端使用 建团时添加客户名单
  941. /// </summary>
  942. /// <param name="dto"></param>
  943. /// <returns></returns>
  944. [HttpPost]
  945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  946. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  947. {
  948. #region 参数验证
  949. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  950. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  951. #region 页面操作权限验证
  952. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  953. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  954. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  955. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  956. #endregion
  957. #endregion
  958. _sqlSugar.BeginTran();
  959. decimal ffrPrice = 0.00M;
  960. DateTime? visitDt = null;
  961. if (dto.Status == 2)
  962. {
  963. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  964. if (groupInfo != null)
  965. {
  966. ffrPrice = groupInfo.PaymentMoney;
  967. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  968. }
  969. }
  970. var _dto = new GroupOperationDto();
  971. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  972. var groupData = await _groupRepository.GroupOperation(_dto);
  973. if (groupData.Code != 0)
  974. {
  975. _sqlSugar.RollbackTran();
  976. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  977. }
  978. try
  979. {
  980. int diId = 0;
  981. //添加时 默认加入团组汇率
  982. if (dto.Status == 1) //添加
  983. {
  984. diId = groupData.Data;
  985. //添加默认币种
  986. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  987. //默认分配权限
  988. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  989. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  990. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  991. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  992. if (userIds.Count > 0)
  993. {
  994. userIds.Add(208);
  995. //创建团组管控
  996. GroupStepForDelegation.CreateWorkStep(diId);
  997. //发送消息
  998. string groupName = dto.TeamName;
  999. string createGroupUser = string.Empty;
  1000. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1001. if (userInfo != null) createGroupUser = userInfo.CnName;
  1002. string title = $"系统通知";
  1003. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1004. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1005. }
  1006. #region 应用推送
  1007. try
  1008. {
  1009. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1010. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1011. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1012. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1013. {
  1014. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1015. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1016. }
  1017. }
  1018. catch (Exception ex)
  1019. {
  1020. _sqlSugar.CommitTran();
  1021. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1022. }
  1023. #endregion
  1024. //默认创建倒推表
  1025. await _invertedListRep._Create(dto.UserId, diId);
  1026. }
  1027. else if (dto.Status == 2)
  1028. {
  1029. diId = dto.Id;
  1030. if (diId == 0)
  1031. {
  1032. _sqlSugar.RollbackTran();
  1033. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1034. }
  1035. }
  1036. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1037. if (viewData.Code != 0)
  1038. {
  1039. _sqlSugar.RollbackTran();
  1040. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1041. }
  1042. #region 团组操作默认添加/修改收款账单
  1043. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1044. {
  1045. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1046. .Where(x => x.IsDel == 0 &&
  1047. x.Diid == diId &&
  1048. x.Remark.Equals("预付款")
  1049. )
  1050. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1051. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1052. .FirstAsync();
  1053. ffrInfo = new Fin_ForeignReceivables()
  1054. {
  1055. Diid = diId,
  1056. PriceName = dto.ClientUnit,
  1057. Price = dto.PaymentMoney,
  1058. Count = 1,
  1059. Unit = $"元",
  1060. ItemSumPrice = dto.PaymentMoney,
  1061. Rate = 1.0000M,
  1062. Currency = 836,
  1063. AddingWay = 0,
  1064. CreateUserId = dto.UserId,
  1065. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1066. Remark = $"预付款"
  1067. };
  1068. if (ffrInfo == null) //Add
  1069. {
  1070. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1071. }
  1072. else //修改
  1073. {
  1074. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1075. .UpdateColumns(x => new
  1076. {
  1077. x.PriceName,
  1078. x.Price,
  1079. x.ItemSumPrice,
  1080. x.CreateTime,
  1081. x.CreateUserId
  1082. })
  1083. .WhereColumns(x => x.Id)
  1084. .ExecuteCommandAsync();
  1085. }
  1086. }
  1087. #endregion
  1088. #region 签证人员团组时间通知
  1089. #region 计算出访起止时间
  1090. var startTime = new DateTime();
  1091. var endTime = new DateTime();
  1092. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1093. {
  1094. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1095. }
  1096. #endregion
  1097. if (diId > 0)
  1098. {
  1099. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1100. }
  1101. #endregion
  1102. _sqlSugar.CommitTran();
  1103. return Ok(JsonView(true));
  1104. }
  1105. catch (Exception ex)
  1106. {
  1107. _sqlSugar.RollbackTran();
  1108. return Ok(JsonView(false, ex.Message));
  1109. }
  1110. }
  1111. /// <summary>
  1112. /// 接团信息 操作(删除)
  1113. /// </summary>
  1114. /// <param name="dto"></param>
  1115. /// <returns></returns>
  1116. [HttpPost]
  1117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1118. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1119. {
  1120. var diId = dto.Id;
  1121. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1122. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1123. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1124. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1125. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1126. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1127. #endregion
  1128. var groupData = await _groupRepository.GroupDel(dto);
  1129. if (groupData.Code != 0)
  1130. {
  1131. return Ok(JsonView(false, groupData.Msg));
  1132. }
  1133. return Ok(JsonView(true));
  1134. }
  1135. /// <summary>
  1136. /// 获取团组销售报价号
  1137. /// 团组添加时 使用
  1138. /// </summary>
  1139. /// <returns></returns>
  1140. [HttpPost]
  1141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1142. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1143. {
  1144. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1145. if (groupData.Code != 0)
  1146. {
  1147. return Ok(JsonView(false, groupData.Msg));
  1148. }
  1149. object salesQuoteNo = new
  1150. {
  1151. SalesQuoteNo = groupData.Data
  1152. };
  1153. return Ok(JsonView(salesQuoteNo));
  1154. }
  1155. /// <summary>
  1156. /// 设置确认出团
  1157. /// </summary>
  1158. /// <param name="dto"></param>
  1159. /// <returns></returns>
  1160. [HttpPost]
  1161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1162. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1163. {
  1164. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1165. if (groupData.Code != 0)
  1166. {
  1167. return Ok(JsonView(false, groupData.Msg));
  1168. }
  1169. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1170. #region OA消息推送
  1171. try
  1172. {
  1173. string groupName = groupInfo.TeamName;
  1174. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1175. string title = $"系统通知";
  1176. string content = $"团组[{groupName}]已确认出团!";
  1177. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1178. }
  1179. catch (Exception ex)
  1180. {
  1181. }
  1182. #endregion
  1183. #region 应用推送
  1184. try
  1185. {
  1186. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1187. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1188. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1189. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1190. {
  1191. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1192. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1193. }
  1194. }
  1195. catch (Exception ex)
  1196. {
  1197. }
  1198. #endregion
  1199. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1200. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1201. }
  1202. /// <summary>
  1203. /// 获取团组名称data And 签证国别Data
  1204. /// </summary>
  1205. /// <param name="dto"></param>
  1206. /// <returns></returns>
  1207. [HttpPost]
  1208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1209. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1210. {
  1211. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1212. if (groupData.Code != 0)
  1213. {
  1214. return Ok(JsonView(false, groupData.Msg));
  1215. }
  1216. return Ok(JsonView(groupData.Data));
  1217. }
  1218. /// <summary>
  1219. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1220. /// </summary>
  1221. /// <returns></returns>
  1222. [HttpPost]
  1223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1224. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1225. {
  1226. try
  1227. {
  1228. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1229. if (groupData.Code != 0)
  1230. {
  1231. return Ok(JsonView(false, groupData.Msg));
  1232. }
  1233. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1234. }
  1235. catch (Exception ex)
  1236. {
  1237. return Ok(JsonView(false, "程序错误!"));
  1238. throw;
  1239. }
  1240. }
  1241. /// <summary>
  1242. /// 团组清单 Excel
  1243. /// </summary>
  1244. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1245. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1246. /// <returns></returns>
  1247. [HttpGet]
  1248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1249. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1250. {
  1251. DateTime _beginDt, _endDt;
  1252. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1253. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1254. if (!beginBool && !endBool)
  1255. {
  1256. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1257. }
  1258. string sql = string.Format(@"
  1259. SELECT
  1260. ROW_NUMBER,
  1261. Id,
  1262. SalesQuoteNo,
  1263. TourCode,
  1264. TeamTypeId,
  1265. TeamType,
  1266. TeamLevId,
  1267. TeamLev,
  1268. TeamName,
  1269. ClientName,
  1270. ClientUnit,
  1271. VisitDate,
  1272. VisitDays,
  1273. VisitPNumber,
  1274. JietuanOperatorId,
  1275. JietuanOperator,
  1276. IsSure,
  1277. CreateUserName,
  1278. IsBid
  1279. FROM
  1280. (
  1281. SELECT
  1282. ROW_NUMBER() OVER(
  1283. ORDER BY
  1284. gdi.CreateTime Desc
  1285. ) AS ROW_NUMBER,
  1286. gdi.Id,
  1287. SalesQuoteNo,
  1288. TourCode,
  1289. ssd.Id TeamTypeId,
  1290. ssd.Name TeamType,
  1291. ssd1.Id TeamLevId,
  1292. ssd1.Name TeamLev,
  1293. TeamName,
  1294. ClientName,
  1295. ClientUnit,
  1296. VisitDate,
  1297. VisitDays,
  1298. VisitPNumber,
  1299. JietuanOperator JietuanOperatorId,
  1300. su.CnName JietuanOperator,
  1301. IsSure,
  1302. gdi.CreateTime,
  1303. su1.CnName As CreateUserName,
  1304. gdi.IsBid
  1305. FROM
  1306. Grp_DelegationInfo gdi
  1307. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1308. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1309. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1310. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1311. WHERE
  1312. gdi.IsDel = 0
  1313. AND gdi.IsBid = 0
  1314. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1315. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1316. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1317. #region 处理所属部门
  1318. /*
  1319. * 1.sq 和 gyy 等显示 市场部
  1320. * 2.王鸽和主管及张总还有管理员号统一国交部
  1321. * 2-1. 4 管理员 ,21 张海麟
  1322. */
  1323. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1324. List<int> userIds1 = new List<int>() { 4, 21 };
  1325. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1326. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1327. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1328. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1329. .ToListAsync();
  1330. var droupIds = groupList.Select(it => it.Id).ToList();
  1331. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1332. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1333. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1334. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1335. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1336. {
  1337. DiId = tcl.DiId,
  1338. LastName = dc.LastName,
  1339. FirstName = dc.FirstName,
  1340. Sex = dc.Sex,
  1341. Birthday = dc.BirthDay,
  1342. Company = cc.CompanyFullName,
  1343. Job = dc.Job,
  1344. CreateTime = tcl.CreateTime,
  1345. })
  1346. .ToList();
  1347. foreach (var item in groupList)
  1348. {
  1349. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1350. string groupFirstName = "";
  1351. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1352. if (currDatas.Any())
  1353. {
  1354. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1355. }
  1356. item.GroupFirst = groupFirstName;
  1357. }
  1358. #endregion
  1359. #region Excel
  1360. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1361. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1362. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1363. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1364. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1365. //载入模板
  1366. WorkbookDesigner designer = new WorkbookDesigner();
  1367. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1368. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1369. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1370. dt.TableName = "GroupList";
  1371. designer.SetDataSource(dt);
  1372. designer.Process();
  1373. if (!Directory.Exists(savePath))
  1374. {
  1375. Directory.CreateDirectory(savePath);
  1376. }
  1377. string serverPath = $"{savePath}{fileName}";
  1378. designer.Workbook.Save(serverPath);
  1379. string rst = $"{servicePath}{ftpPath}{fileName}";
  1380. #endregion
  1381. return Ok(JsonView(true, "操作成功!", rst));
  1382. }
  1383. #endregion
  1384. #region 团组&签证
  1385. /// <summary>
  1386. /// 根据团组Id获取签证客户信息List
  1387. /// </summary>
  1388. /// <param name="dto">请求dto</param>
  1389. /// <returns></returns>
  1390. [HttpPost]
  1391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1392. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1393. {
  1394. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1395. if (groupData.Code != 0)
  1396. {
  1397. return Ok(JsonView(false, groupData.Msg));
  1398. }
  1399. return Ok(JsonView(groupData.Data));
  1400. }
  1401. /// <summary>
  1402. /// IOS获取团组签证拍照上传进度01(团组列表)
  1403. /// </summary>
  1404. /// <param name="dto">请求dto</param>
  1405. /// <returns></returns>
  1406. [HttpPost]
  1407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1408. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1409. {
  1410. if (dto == null)
  1411. {
  1412. return Ok(JsonView(false, "参数为空"));
  1413. }
  1414. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1415. return Ok(JsonView(visaList));
  1416. }
  1417. /// <summary>
  1418. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1419. /// </summary>
  1420. /// <returns></returns>
  1421. [HttpPost]
  1422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1423. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1424. {
  1425. if (dto == null)
  1426. {
  1427. return Ok(JsonView(false, "请求错误:"));
  1428. }
  1429. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1430. return Ok(JsonView(list));
  1431. }
  1432. /// <summary>
  1433. /// IOS获取团组签证拍照上传进度03(相册)
  1434. /// </summary>
  1435. /// <returns></returns>
  1436. [HttpPost]
  1437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1438. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1439. {
  1440. if (dto == null)
  1441. {
  1442. return Ok(JsonView(false, "请求错误:"));
  1443. }
  1444. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1445. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1446. list.ForEach(s => s.url = url);
  1447. return Ok(JsonView(list));
  1448. }
  1449. /// <summary>
  1450. /// IOS获取团组签证拍照上传进度04(图片上传)
  1451. /// </summary>
  1452. /// <param name="dto"></param>
  1453. /// <returns></returns>
  1454. [HttpPost]
  1455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1456. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1457. {
  1458. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1459. //if (!string.IsNullOrEmpty(result))
  1460. //{
  1461. //}
  1462. //else {
  1463. // return Ok(JsonView(false, "上传失败"));
  1464. //}
  1465. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1466. int sucNum = 0;
  1467. try
  1468. {
  1469. foreach (var item in dto.base64DataList)
  1470. {
  1471. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1472. string result = DecodeBase64ToImage(item, imageName);
  1473. if (!string.IsNullOrEmpty(result))
  1474. {
  1475. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1476. pic.CreateUserId = dto.CreateUserId;
  1477. pic.PicName = imageName;
  1478. pic.PicPath = result;
  1479. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1480. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1481. if (insertResult > 0)
  1482. {
  1483. sucNum++;
  1484. }
  1485. }
  1486. }
  1487. }
  1488. catch (Exception ex)
  1489. {
  1490. return Ok(JsonView(false, ex.Message));
  1491. }
  1492. string msg = string.Format(@"成功上传{0}张", sucNum);
  1493. return Ok(JsonView(true, msg));
  1494. }
  1495. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1496. {
  1497. string filename = "";//声明一个string类型的相对路径
  1498. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1499. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1500. try//会有异常抛出,try,catch一下
  1501. {
  1502. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1503. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1504. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1505. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1506. //文件名称
  1507. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1508. //上传的文件的路径
  1509. string filePath = "";
  1510. if (!Directory.Exists(fileDir))
  1511. {
  1512. Directory.CreateDirectory(fileDir);
  1513. }
  1514. //上传的文件的路径
  1515. filePath = fileDir + filename;
  1516. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1517. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1518. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1519. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1520. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1521. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1522. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1523. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1524. bitmap.Dispose();
  1525. }
  1526. catch (Exception e)
  1527. {
  1528. string massage = e.Message;
  1529. Logs("IOS图片上传Error:" + massage);
  1530. //filename = e.Message;
  1531. }
  1532. return filename;//返回相对路径
  1533. }
  1534. /// <summary>
  1535. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1536. /// </summary>
  1537. /// <param name="dto"></param>
  1538. /// <returns></returns>
  1539. [HttpPost]
  1540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1541. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1542. {
  1543. if (dto == null)
  1544. {
  1545. return Ok(JsonView(false, "请求错误:"));
  1546. }
  1547. string msg = "参数错误";
  1548. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1549. {
  1550. try
  1551. {
  1552. //_delegationVisaRep.BeginTran();
  1553. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1554. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1555. .Where(s => s.Id == dto.visaProgressCustomerId)
  1556. .ExecuteCommandAsync();
  1557. if (updCount > 0 && dto.publishCode == 1)
  1558. {
  1559. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1560. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1561. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1562. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1563. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1564. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1565. if (groupData == null)
  1566. {
  1567. _delegationVisaRep.RollbackTran();
  1568. }
  1569. string title = string.Format(@"[签证进度更新]");
  1570. string content = string.Format(@"测试文本");
  1571. bool rst = await _message.AddMsg(new MessageDto()
  1572. {
  1573. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1574. IssuerId = dto.publisher,
  1575. Title = title,
  1576. Content = content,
  1577. ReleaseTime = DateTime.Now,
  1578. UIdList = new List<int> {
  1579. 234
  1580. }
  1581. });
  1582. if (rst)
  1583. {
  1584. return Ok(JsonView(true, "发送通知成功"));
  1585. }
  1586. }
  1587. //_delegationVisaRep.CommitTran();
  1588. }
  1589. catch (Exception)
  1590. {
  1591. //_delegationVisaRep.RollbackTran();
  1592. }
  1593. }
  1594. return Ok(JsonView(true, msg));
  1595. }
  1596. #endregion
  1597. #region 团组任务分配
  1598. /// <summary>
  1599. /// 团组任务分配初始化
  1600. /// </summary>
  1601. /// <returns></returns>
  1602. [HttpPost]
  1603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1604. public async Task<IActionResult> GetTaskAssignmen()
  1605. {
  1606. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1607. if (groupData.Code != 0)
  1608. {
  1609. return Ok(JsonView(false, groupData.Msg));
  1610. }
  1611. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1612. }
  1613. /// <summary>
  1614. /// 团组任务分配查询
  1615. /// </summary>
  1616. /// <param name="dto"></param>
  1617. /// <returns></returns>
  1618. [HttpPost]
  1619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1620. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1621. {
  1622. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1623. if (groupData.Code != 0)
  1624. {
  1625. return Ok(JsonView(false, groupData.Msg));
  1626. }
  1627. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1628. }
  1629. /// <summary>
  1630. /// 团组任务分配操作
  1631. /// </summary>
  1632. /// <param name="dto"></param>
  1633. /// <returns></returns>
  1634. [HttpPost]
  1635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1636. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1637. {
  1638. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1639. if (groupData.Code != 0)
  1640. {
  1641. return Ok(JsonView(false, groupData.Msg));
  1642. }
  1643. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1644. }
  1645. /// <summary>
  1646. /// 团组任务分配
  1647. /// 批量分配
  1648. /// 查询团组
  1649. /// </summary>
  1650. /// <param name="dto"></param>
  1651. /// <returns></returns>
  1652. [HttpPost]
  1653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1654. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1655. {
  1656. //参数验证
  1657. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1658. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1659. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1660. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1661. }
  1662. /// <summary>
  1663. /// 团组任务分配
  1664. /// 批量分配
  1665. /// </summary>
  1666. /// <param name="dto"></param>
  1667. /// <returns></returns>
  1668. [HttpPost]
  1669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1670. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1671. {
  1672. //参数验证
  1673. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1674. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1675. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1676. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1677. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1678. }
  1679. #endregion
  1680. #region 团组费用审核
  1681. /// <summary>
  1682. /// 费用审核
  1683. /// 团组列表 Page
  1684. /// </summary>
  1685. /// <param name="_dto">团组列表请求dto</param>
  1686. /// <returns></returns>
  1687. [HttpPost]
  1688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1689. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1690. {
  1691. #region 参数验证
  1692. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1693. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1694. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1695. #region 页面操作权限验证
  1696. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1697. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1698. #endregion
  1699. #endregion
  1700. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1701. {
  1702. string sqlWhere = string.Empty;
  1703. if (_dto.IsSure == 0) //未完成
  1704. {
  1705. sqlWhere += string.Format(@" And IsSure = 0");
  1706. }
  1707. else if (_dto.IsSure == 1) //已完成
  1708. {
  1709. sqlWhere += string.Format(@" And IsSure = 1");
  1710. }
  1711. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1712. {
  1713. string tj = _dto.SearchCriteria;
  1714. 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}%')",
  1715. tj, tj, tj, tj, tj);
  1716. }
  1717. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1718. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1719. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1720. From (
  1721. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1722. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1723. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1724. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1725. From Grp_DelegationInfo gdi
  1726. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1727. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1728. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1729. Where gdi.IsDel = 0 {0}
  1730. ) temp ", sqlWhere);
  1731. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1732. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1733. var _view = new
  1734. {
  1735. PageFuncAuth = pageFunAuthView,
  1736. Data = _DelegationList
  1737. };
  1738. return Ok(JsonView(true, "查询成功!", _view, total));
  1739. }
  1740. else
  1741. {
  1742. return Ok(JsonView(false, "查询失败"));
  1743. }
  1744. }
  1745. /// <summary>
  1746. /// 获取团组费用审核
  1747. /// </summary>
  1748. /// <param name="_dto"></param>
  1749. /// <returns></returns>
  1750. [HttpPost]
  1751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1752. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1753. {
  1754. try
  1755. {
  1756. #region 参数验证
  1757. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1758. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1759. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1760. #region 页面操作权限验证
  1761. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1762. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1763. #endregion
  1764. #endregion
  1765. var _view = new Grp_CreditCardPaymentView();
  1766. var clientNameList = getSimplClientList(_dto.DiId);
  1767. #region 费用清单
  1768. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1769. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1770. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1771. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1772. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1773. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1774. /*
  1775. * 76://酒店预订
  1776. */
  1777. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1778. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1779. /*
  1780. * 79://车/导游地接
  1781. */
  1782. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1783. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1784. /*
  1785. * 80: //签证
  1786. */
  1787. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1788. /*
  1789. *81: //邀请/公务活动
  1790. */
  1791. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1792. /*
  1793. * 82: //团组客户保险
  1794. */
  1795. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1796. /*
  1797. * Lable = 85 机票预订
  1798. */
  1799. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1800. /*
  1801. * 85 机票预定
  1802. */
  1803. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1804. /*
  1805. * 98 其他款项
  1806. */
  1807. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1808. /*
  1809. * 285:收款退还
  1810. */
  1811. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1812. /*
  1813. * 1015: //超支费用
  1814. */
  1815. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1816. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1817. /*
  1818. * 币种信息
  1819. */
  1820. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1821. /*
  1822. * 车/导游地接 费用类型
  1823. */
  1824. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1825. /*
  1826. * 车/导游地接 费用类型
  1827. */
  1828. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1829. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1830. /*
  1831. * 用户信息
  1832. */
  1833. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1834. /*
  1835. * 费用模块
  1836. */
  1837. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1838. string priceModule = string.Empty;
  1839. if (sdPriceName != null)
  1840. {
  1841. priceModule = sdPriceName.Name;
  1842. }
  1843. /*
  1844. * 成本信息
  1845. */
  1846. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1847. decimal _groupRate = 0.0000M;
  1848. string _groupCurrencyCode = "-";
  1849. if (groupCost != null)
  1850. {
  1851. _groupRate = groupCost.Rate;
  1852. if (int.TryParse(groupCost.Currency, out int _currency))
  1853. {
  1854. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1855. }
  1856. else _groupCurrencyCode = groupCost.Currency;
  1857. }
  1858. string costContentSql = $"Select * From Grp_GroupCost";
  1859. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1860. //处理日期为空的天数
  1861. for (int i = 0; i < groupCostDetails.Count; i++)
  1862. if (i != 0)
  1863. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1864. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1865. /*
  1866. * 处理详情数据
  1867. */
  1868. foreach (var entity in entityList)
  1869. {
  1870. var _detail = new Grp_CreditCardPaymentDetailView();
  1871. _detail.Id = entity.Id;
  1872. _detail.PriceName = priceModule;
  1873. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1874. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1875. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1876. //处理金额
  1877. if (entity.CTable == 1015)
  1878. {
  1879. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1880. if (czInfo != null)
  1881. {
  1882. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1883. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1884. }
  1885. }
  1886. /*
  1887. * 应付款金额
  1888. */
  1889. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1890. string PaymentCurrency_WaitPay = "Unknown";
  1891. string hotelCurrncyCode = "Unknown";
  1892. string hotelCurrncyName = "Unknown";
  1893. if (sdPaymentCurrency_WaitPay != null)
  1894. {
  1895. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1896. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1897. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1898. if (hotelCurrncyCode.Equals("CNY"))
  1899. {
  1900. entity.DayRate = 1.0000M;
  1901. }
  1902. }
  1903. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1904. /*
  1905. * 此次付款金额
  1906. */
  1907. decimal CurrPayStr = 0.00M,
  1908. OriginalCurrPay = 0.00M;
  1909. if (entity.PayPercentage == 0)
  1910. {
  1911. if (entity.PayThenMoney != 0)
  1912. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1913. }
  1914. else
  1915. {
  1916. if (entity.PayMoney != 0)
  1917. {
  1918. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1919. }
  1920. }
  1921. //if (_dto.Label == 79)
  1922. //{
  1923. // string original = string.Empty;
  1924. // if (hotelCurrncyCode.Equals("CNY"))
  1925. // {
  1926. // OriginalCurrPay = CurrPayStr;
  1927. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1928. // }
  1929. // else
  1930. // {
  1931. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1932. // //760 EUR(7600.00 CNY)
  1933. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1934. // }
  1935. //}
  1936. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1937. string original = string.Empty;
  1938. if (hotelCurrncyCode.Equals("CNY"))
  1939. {
  1940. OriginalCurrPay = CurrPayStr;
  1941. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1942. }
  1943. else
  1944. {
  1945. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1946. //760 EUR(7600.00 CNY)
  1947. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1948. }
  1949. /*
  1950. * 剩余尾款
  1951. */
  1952. decimal BalanceStr = 0;
  1953. if (CurrPayStr != 0)
  1954. {
  1955. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1956. BalanceStr = 0;
  1957. else
  1958. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1959. }
  1960. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1961. /*
  1962. * Bus名称
  1963. */
  1964. _detail.BusName = "待增加";
  1965. /*
  1966. *费用所属
  1967. */
  1968. switch (entity.CTable)
  1969. {
  1970. case 76://酒店预订
  1971. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1972. if (hotelReservations != null)
  1973. {
  1974. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1975. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1976. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1977. string roomFeeStr = "", roomFeestr1 = "";
  1978. //是否比较房型价格
  1979. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1980. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1981. roomFeeStr += $"<br/>";
  1982. var roomTotal = 0.00M;
  1983. if (hotelReservations.SingleRoomPrice > 0)
  1984. {
  1985. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1986. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1987. //__isSingle = true;
  1988. roomTotal += fee;
  1989. }
  1990. if (hotelReservations.DoubleRoomPrice > 0)
  1991. {
  1992. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1993. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1994. // __isDouble = true;
  1995. roomTotal += fee;
  1996. }
  1997. if (hotelReservations.SuiteRoomPrice > 0)
  1998. {
  1999. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2000. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2001. //__isSuite = true;
  2002. roomTotal += fee;
  2003. }
  2004. if (hotelReservations.OtherRoomPrice > 0)
  2005. {
  2006. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2007. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2008. //__isOther = true;
  2009. roomTotal += fee;
  2010. }
  2011. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2012. else roomFeeStr += " 0.00 * 0";
  2013. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2014. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2015. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2016. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2017. /*
  2018. * 费用类型
  2019. * 1:房费
  2020. * 2:早餐
  2021. * 3:地税
  2022. * 4:城市税
  2023. * </summary>
  2024. */
  2025. //地税
  2026. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2027. if (governmentRentData != null)
  2028. {
  2029. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2030. governmentRentFee = governmentRentData.Price;
  2031. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2032. if (governmentRentCurrData != null)
  2033. {
  2034. governmentRentCode = governmentRentCurrData.Name;
  2035. governmentRentName = $"({governmentRentCurrData.Remark})";
  2036. }
  2037. }
  2038. //城市税
  2039. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2040. if (cityTaxData != null)
  2041. {
  2042. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2043. cityTaxFee = cityTaxData.Price;
  2044. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2045. if (cityTaxCurrData != null)
  2046. {
  2047. cityTaxCode = cityTaxCurrData.Name;
  2048. cityTaxName = $"({cityTaxCurrData.Remark})";
  2049. }
  2050. }
  2051. //酒店早餐
  2052. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2053. if (breakfastData != null)
  2054. {
  2055. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2056. breakfastFee = breakfastData.Price;
  2057. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2058. if (breakfastCurrData != null)
  2059. {
  2060. breakfastCode = breakfastCurrData.Name;
  2061. breakfastName = $"({breakfastCurrData.Remark})";
  2062. }
  2063. }
  2064. //房间费用
  2065. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2066. if (roomData != null)
  2067. {
  2068. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2069. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2070. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2071. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2072. roomFee = roomData.Price;
  2073. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2074. if (roomCurrData != null)
  2075. {
  2076. roomCode = roomCurrData.Name;
  2077. roomName = $"({roomCurrData.Remark})";
  2078. }
  2079. }
  2080. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2081. string hotelCostStr = "";
  2082. decimal hotelCsotTotal = 0.00M;
  2083. if (groupCost != null)
  2084. {
  2085. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2086. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2087. }
  2088. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2089. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2090. string hotelCost_day = "";
  2091. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2092. foreach (var item in hotelCostDetails1)
  2093. {
  2094. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2095. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2096. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2097. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2098. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2099. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2100. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2101. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2102. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2103. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2104. hotelCost_day += @$"<br/>";
  2105. }
  2106. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2107. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2108. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2109. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2110. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2111. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2112. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2113. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2114. $"房间说明: {hotelReservations.Remark} <br/>" +
  2115. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2116. $"{hotelBreakfastStr}" +
  2117. $"{hotelGovernmentRentStr}" +
  2118. $"{hotelCityTaxStr}";
  2119. _detail.PriceNameContent = hotelReservations.HotelName;
  2120. }
  2121. break;
  2122. case 79://车/导游地接
  2123. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2124. if (touristGuideGroundReservations != null)
  2125. {
  2126. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2127. {
  2128. _detail.BusName = touristGuideGroundReservations.BusName;
  2129. }
  2130. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2131. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2132. //if (isInt)
  2133. //{
  2134. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2135. // if (cityInfo != null)
  2136. // {
  2137. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2138. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2139. // if (carFeeItem != null)
  2140. // {
  2141. // nameContent += $@"({carFeeItem.Name})";
  2142. // }
  2143. // _detail.PriceNameContent = nameContent;
  2144. // }
  2145. //}
  2146. //else
  2147. //{
  2148. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2149. //}
  2150. var touristGuideGroundReservationsContents =
  2151. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2152. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2153. foreach (var item in touristGuideGroundReservationsContents)
  2154. {
  2155. string typeName = "Unknown";
  2156. string carCurrencyCode = "Unknown";
  2157. string carCurrencyName = "Unknown";
  2158. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2159. if (carTypeData != null) typeName = carTypeData.Name;
  2160. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2161. if (currencyData != null)
  2162. {
  2163. carCurrencyCode = currencyData.Name;
  2164. carCurrencyName = currencyData.Remark;
  2165. }
  2166. //op、成本 币种是否一致
  2167. bool IsCurrencyAgreement = false;
  2168. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2169. string opCostStr = string.Empty;
  2170. decimal opCostTypePrice = 0.00M;
  2171. #region 处理成本各项费用
  2172. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2173. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2174. if (opCost.Count > 0)
  2175. {
  2176. switch (item.SId)
  2177. {
  2178. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2179. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2180. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2181. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2182. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2183. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2184. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2185. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2186. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2187. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2188. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2189. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2190. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2191. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2192. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2193. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2194. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2195. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2196. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2197. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2198. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2199. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2200. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2201. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2202. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2203. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2204. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2205. }
  2206. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2207. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2208. }
  2209. #endregion
  2210. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2211. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2212. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2213. $"{opTypeStr} {opCostStr}<br/>" +
  2214. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2215. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2216. }
  2217. _detail.PriceMsgContent = priceMsg;
  2218. }
  2219. break;
  2220. case 80: //签证
  2221. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2222. if (visaInfo != null)
  2223. {
  2224. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2225. _detail.PriceNameContent = visaInfo.VisaDescription;
  2226. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2227. }
  2228. break;
  2229. case 81: //邀请/公务活动
  2230. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2231. if (_ioa != null)
  2232. {
  2233. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2234. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2235. sendCurrName = "Unknown", //快递费用币种 Name
  2236. sendCurrCode = "Unknown", //快递费用币种 Code
  2237. eventsCurrName = "Unknown", //公务活动费币种 Name
  2238. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2239. translateCurrName = "Unknown", //公务翻译费 Name
  2240. translateCurrCode = "Unknown"; //公务翻译费 Code
  2241. #region 处理费用币种
  2242. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2243. if (inviteCurrData != null)
  2244. {
  2245. inviteCurrName = inviteCurrData.Remark;
  2246. inviteCurrCode = inviteCurrData.Name;
  2247. }
  2248. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2249. if (sendCurrData != null)
  2250. {
  2251. sendCurrName = sendCurrData.Remark;
  2252. sendCurrCode = sendCurrData.Name;
  2253. }
  2254. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2255. if (eventsCurrData != null)
  2256. {
  2257. eventsCurrName = eventsCurrData.Remark;
  2258. eventsCurrCode = eventsCurrData.Name;
  2259. }
  2260. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2261. if (translateCurrData != null)
  2262. {
  2263. translateCurrName = translateCurrData.Remark;
  2264. translateCurrCode = translateCurrData.Name;
  2265. }
  2266. #endregion
  2267. _detail.PriceNameContent = _ioa.InviterArea;
  2268. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2269. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2270. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2271. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2272. $@"备注:" + _ioa.Remark + "<br/>";
  2273. }
  2274. break;
  2275. case 82: //团组客户保险
  2276. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2277. if (customers != null)
  2278. {
  2279. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2280. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2281. }
  2282. break;
  2283. case 85: //机票预订
  2284. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2285. if (jpRes != null)
  2286. {
  2287. string FlightsDescription = jpRes.FlightsDescription;
  2288. string PriceDescription = jpRes.PriceDescription;
  2289. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2290. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2291. }
  2292. break;
  2293. case 98://其他款项
  2294. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2295. if (gdpRes != null)
  2296. {
  2297. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2298. _detail.PriceNameContent = gdpRes.PriceName;
  2299. }
  2300. break;
  2301. case 285://收款退还
  2302. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2303. if (refundAndOtherMoney != null)
  2304. {
  2305. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2306. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2307. }
  2308. break;
  2309. case 751://酒店早餐
  2310. break;
  2311. case 1015://超支费用
  2312. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2313. if (groupExtraCost != null)
  2314. {
  2315. _detail.PriceNameContent = groupExtraCost.PriceName;
  2316. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2317. }
  2318. break;
  2319. default:
  2320. break;
  2321. }
  2322. /*
  2323. * 申请人
  2324. */
  2325. string operatorName = " - ";
  2326. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2327. if (_opUser != null)
  2328. {
  2329. operatorName = _opUser.CnName;
  2330. }
  2331. _detail.OperatorName = operatorName;
  2332. /*
  2333. * 审核人
  2334. */
  2335. string auditOperatorName = "Unknown";
  2336. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2337. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2338. else
  2339. {
  2340. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2341. if (_adUser != null)
  2342. {
  2343. auditOperatorName = _adUser.CnName;
  2344. }
  2345. }
  2346. _detail.AuditOperatorName = auditOperatorName;
  2347. /*
  2348. * 超预算比例
  2349. */
  2350. string overBudgetStr = "";
  2351. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2352. else if (entity.ExceedBudget == 0)
  2353. {
  2354. if (entity.CTable == 76 || entity.CTable == 79)
  2355. {
  2356. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2357. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2358. }
  2359. else
  2360. {
  2361. overBudgetStr = "未超预算";
  2362. }
  2363. }
  2364. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2365. _detail.OverBudget = overBudgetStr;
  2366. decimal auditFee = 0.00M; //已审核金额 人名币
  2367. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2368. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2369. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2370. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2371. {
  2372. auditedFeeOriginal = entity.PayMoney;
  2373. auditFee = CurrPayStr;
  2374. }
  2375. else if (entity.IsAuditGM == 0)
  2376. {
  2377. unAuditFeeCNY = CurrPayStr;
  2378. unAuditFeeOriginal = OriginalCurrPay;
  2379. OriginalCurrPay = 0.00M;
  2380. }
  2381. /*
  2382. * 费用总计
  2383. */
  2384. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2385. {
  2386. CurrencyId = entity.PaymentCurrency,
  2387. CurrencyName = PaymentCurrency_WaitPay,
  2388. AmountPayable = entity.PayMoney,
  2389. ThisPayment = OriginalCurrPay,
  2390. BalancePayment = BalanceStr,
  2391. AuditedFunds = auditFee,
  2392. AuditedFundsOriginal = auditedFeeOriginal,
  2393. UnAuditFundsCNY = unAuditFeeCNY,
  2394. UnAuditFundsOriginal = unAuditFeeOriginal
  2395. });
  2396. _detail.IsAuditGM = entity.IsAuditGM;
  2397. detailList.Add(_detail);
  2398. }
  2399. #endregion
  2400. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2401. /*
  2402. * 下方描述处理
  2403. */
  2404. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2405. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2406. if (ccpCurrencyPrice != null)
  2407. {
  2408. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2409. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2410. }
  2411. else
  2412. {
  2413. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2414. }
  2415. string amountPayableStr = string.Format(@"应付款总金额: ");
  2416. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2417. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2418. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2419. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2420. foreach (var item in nonDuplicat)
  2421. {
  2422. var currencyName = item.CurrencyName;
  2423. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2424. if (strs.Count > 0)
  2425. {
  2426. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2427. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2428. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2429. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2430. //单独处理此次付款金额
  2431. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2432. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2433. //单独处理已审核费用
  2434. //if (item.CurrencyId == 836) //人民币
  2435. //{
  2436. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2437. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2438. //}
  2439. //else
  2440. //{
  2441. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2442. //}
  2443. if (currencyName.Equals("CNY"))
  2444. {
  2445. //已审核费用
  2446. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2447. //未审核费用
  2448. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2449. }
  2450. else
  2451. {
  2452. //已审核费用
  2453. 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"));
  2454. //未审核费用
  2455. 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"));
  2456. }
  2457. }
  2458. }
  2459. _view.TotalStr1 = amountPayableStr[..^1];
  2460. _view.TotalStr2 = thisPaymentStr[..^1];
  2461. _view.TotalStr3 = balancePaymentStr[..^1];
  2462. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2463. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2464. var _view1 = new
  2465. {
  2466. PageFuncAuth = pageFunAuthView,
  2467. Data = _view
  2468. };
  2469. return Ok(JsonView(_view1));
  2470. }
  2471. catch (Exception ex)
  2472. {
  2473. return Ok(JsonView(false, ex.Message));
  2474. }
  2475. }
  2476. /// <summary>
  2477. /// 费用审核
  2478. /// 修改团组费用审核状态
  2479. /// </summary>
  2480. /// <param name="_dto">参数Json字符串</param>
  2481. /// <returns></returns>
  2482. [HttpPost]
  2483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2484. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2485. {
  2486. #region 参数验证
  2487. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2488. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2489. #endregion
  2490. #region 页面操作权限验证
  2491. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2492. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2493. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2494. #endregion
  2495. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2496. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2497. DateTime dtNow = DateTime.Now;
  2498. _groupRepository.BeginTran();
  2499. int rst = 0;
  2500. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2501. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2502. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2503. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2504. List<dynamic> msgDatas = new List<dynamic>();
  2505. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2506. foreach (var item in idList)
  2507. {
  2508. int CreditId = int.Parse(item);
  2509. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2510. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2511. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2512. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2513. .Where(s => s.Id == CreditId)
  2514. .ExecuteCommandAsync();
  2515. if (result < 1)
  2516. {
  2517. rst = -1;
  2518. _groupRepository.RollbackTran();
  2519. return Ok(JsonView(false, "操作失败并回滚!"));
  2520. }
  2521. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2522. if (creditData != null)
  2523. {
  2524. #region 应用通知配置
  2525. try
  2526. {
  2527. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2528. }
  2529. catch (Exception ex)
  2530. {
  2531. }
  2532. #endregion
  2533. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2534. string groupNameStr = string.Empty;
  2535. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2536. if (groupData != null) groupNameStr = groupData.TeamName;
  2537. string creditTypeStr = string.Empty;
  2538. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2539. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2540. string creditCurrency = string.Empty;
  2541. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2542. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2543. if (creditCurrency.Equals("CNY"))
  2544. {
  2545. creditData.DayRate = 1.0000M;
  2546. }
  2547. if (creditData.PayPercentage == 0.00M)
  2548. {
  2549. creditData.PayPercentage = 100M;
  2550. }
  2551. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2552. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2553. string msgContent = "";
  2554. if (creditCurrency.Equals("CNY"))
  2555. {
  2556. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2557. }
  2558. else
  2559. {
  2560. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2561. }
  2562. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2563. }
  2564. }
  2565. if (rst == 0)
  2566. {
  2567. _groupRepository.CommitTran();
  2568. foreach (var item in msgDatas)
  2569. {
  2570. //发送消息
  2571. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2572. }
  2573. #region 应用推送
  2574. try
  2575. {
  2576. foreach (var ccpId in dic_ccp_user.Keys)
  2577. {
  2578. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2579. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2580. }
  2581. }
  2582. catch (Exception)
  2583. {
  2584. }
  2585. #endregion
  2586. return Ok(JsonView(true, "操作成功!"));
  2587. }
  2588. return Ok(JsonView(false, "操作失败!"));
  2589. }
  2590. #endregion
  2591. #region 机票费用录入
  2592. /// <summary>
  2593. /// 机票录入当前登录人可操作团组
  2594. /// </summary>
  2595. /// <param name="dto"></param>
  2596. /// <returns></returns>
  2597. [HttpPost]
  2598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2599. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2600. {
  2601. try
  2602. {
  2603. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2604. if (groupData.Code != 0)
  2605. {
  2606. return Ok(JsonView(false, groupData.Msg));
  2607. }
  2608. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2609. }
  2610. catch (Exception ex)
  2611. {
  2612. return Ok(JsonView(false, "程序错误!"));
  2613. throw;
  2614. }
  2615. }
  2616. /// <summary>
  2617. /// 机票费用录入列表
  2618. /// </summary>
  2619. /// <param name="dto"></param>
  2620. /// <returns></returns>
  2621. [HttpPost]
  2622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2623. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2624. {
  2625. try
  2626. {
  2627. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2628. if (groupData.Code != 0)
  2629. {
  2630. return Ok(JsonView(false, groupData.Msg));
  2631. }
  2632. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2633. }
  2634. catch (Exception ex)
  2635. {
  2636. return Ok(JsonView(false, ex.Message));
  2637. throw;
  2638. }
  2639. }
  2640. /// <summary>
  2641. /// 根据id查询费用录入信息
  2642. /// </summary>
  2643. /// <param name="dto"></param>
  2644. /// <returns></returns>
  2645. [HttpPost]
  2646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2647. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2648. {
  2649. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2650. if (groupData.Code != 0)
  2651. {
  2652. return Ok(JsonView(false, groupData.Msg));
  2653. }
  2654. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2655. }
  2656. /// <summary>
  2657. /// 机票费用录入操作(Status:1.新增,2.修改)
  2658. /// </summary>
  2659. /// <param name="dto"></param>
  2660. /// <returns></returns>
  2661. [HttpPost]
  2662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2663. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2664. {
  2665. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2666. if (groupData.Code != 0)
  2667. {
  2668. return Ok(JsonView(false, groupData.Msg));
  2669. }
  2670. #region 应用推送
  2671. try
  2672. {
  2673. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2674. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2675. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2676. //2024-10-21 新增LZ UID
  2677. var userIds = new List<int>() { 21 };
  2678. string title = $"系统通知";
  2679. string content = "";
  2680. var diId = dto.AirTicketResOpData.DiId;
  2681. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2682. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2683. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2684. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2685. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2686. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2687. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2688. }
  2689. catch (Exception ex)
  2690. {
  2691. }
  2692. #endregion
  2693. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2694. }
  2695. /// <summary>
  2696. /// 根据舱位类型查询接团客户名单信息
  2697. /// </summary>
  2698. /// <param name="dto"></param>
  2699. /// <returns></returns>
  2700. [HttpPost]
  2701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2702. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2703. {
  2704. try
  2705. {
  2706. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2707. if (crm_Groups.Count != 0)
  2708. {
  2709. List<dynamic> Customer = new List<dynamic>();
  2710. foreach (var item in crm_Groups)
  2711. {
  2712. var data = new
  2713. {
  2714. Id = item.Id,
  2715. Pinyin = item.Pinyin,
  2716. Name = item.LastName + item.FirstName
  2717. };
  2718. Customer.Add(data);
  2719. }
  2720. return Ok(JsonView(true, "查询成功!", Customer));
  2721. }
  2722. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2723. }
  2724. catch (Exception ex)
  2725. {
  2726. return Ok(JsonView(false, "程序错误!"));
  2727. throw;
  2728. }
  2729. }
  2730. /// <summary>
  2731. /// 根据团号获取客户信息
  2732. /// </summary>
  2733. /// <param name="dto"></param>
  2734. /// <returns></returns>
  2735. [HttpPost]
  2736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2737. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2738. {
  2739. var jw = JsonView(false);
  2740. if (dto.DIID < 1)
  2741. {
  2742. jw.Msg += "请输入正确的diid";
  2743. return Ok(jw);
  2744. }
  2745. var arr = getSimplClientList(dto.DIID);
  2746. jw = JsonView(true, "获取成功!", arr);
  2747. return Ok(jw);
  2748. }
  2749. private List<SimplClientInfo> getSimplClientList(int diId)
  2750. {
  2751. 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);
  2752. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2753. foreach (var item in arr)
  2754. {
  2755. EncryptionProcessor.DecryptProperties(item);
  2756. }
  2757. return arr;
  2758. }
  2759. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2760. {
  2761. string result = origin;
  2762. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2763. {
  2764. string[] temparr = origin.Split(',');
  2765. string fistrStr = temparr[0];
  2766. int count = temparr.Count();
  2767. int tempId;
  2768. bool success = int.TryParse(fistrStr, out tempId);
  2769. if (success)
  2770. {
  2771. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2772. if (tempInfo != null)
  2773. {
  2774. if (count > 1)
  2775. {
  2776. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2777. }
  2778. else
  2779. {
  2780. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2781. }
  2782. }
  2783. }
  2784. }
  2785. return result;
  2786. }
  2787. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2788. {
  2789. string result = origin;
  2790. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2791. {
  2792. string[] temparr = origin.Split(',');
  2793. result = "";
  2794. foreach (var item in temparr)
  2795. {
  2796. int tempId;
  2797. bool success = int.TryParse(item, out tempId);
  2798. if (success)
  2799. {
  2800. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2801. if (tempInfo != null)
  2802. {
  2803. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2804. }
  2805. }
  2806. }
  2807. }
  2808. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2809. return result;
  2810. }
  2811. /// <summary>
  2812. /// 机票费用录入,删除
  2813. /// </summary>
  2814. /// <param name="dto"></param>
  2815. /// <returns></returns>
  2816. [HttpPost]
  2817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2818. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2819. {
  2820. try
  2821. {
  2822. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2823. if (res)
  2824. {
  2825. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2826. {
  2827. IsDel = 1,
  2828. DeleteUserId = dto.DeleteUserId,
  2829. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2830. }).ExecuteCommandAsync();
  2831. return Ok(JsonView(true, "删除成功!"));
  2832. }
  2833. return Ok(JsonView(false, "删除失败!"));
  2834. }
  2835. catch (Exception ex)
  2836. {
  2837. return Ok(JsonView(false, "程序错误!"));
  2838. throw;
  2839. }
  2840. }
  2841. /// <summary>
  2842. /// 导出机票录入报表
  2843. /// </summary>
  2844. /// <param name="dto"></param>
  2845. /// <returns></returns>
  2846. [HttpPost]
  2847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2848. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2849. {
  2850. try
  2851. {
  2852. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2853. if (groupData.Code != 0)
  2854. {
  2855. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2856. }
  2857. else
  2858. {
  2859. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2860. if (AirTicketReservations.Count != 0)
  2861. {
  2862. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2863. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2864. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2865. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2866. WorkbookDesigner designer = new WorkbookDesigner();
  2867. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2868. decimal countCost = 0;
  2869. foreach (var item in AirTicketReservations)
  2870. {
  2871. #region 处理客人姓名
  2872. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2873. item.ClientName = clientNames;
  2874. #endregion
  2875. if (item.BankType == "其他")
  2876. {
  2877. item.BankNo = "--";
  2878. }
  2879. else
  2880. {
  2881. if (!string.IsNullOrEmpty(item.BankType))
  2882. {
  2883. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2884. }
  2885. }
  2886. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2887. item.Price = System.Decimal.Round(item.Price, 2);
  2888. countCost += Convert.ToDecimal(item.Price);
  2889. }
  2890. designer.SetDataSource("Export", AirTicketReservations);
  2891. designer.SetDataSource("ExportDiCode", diCode);
  2892. designer.SetDataSource("ExportDiName", diName);
  2893. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2894. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2895. designer.Process();
  2896. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2897. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2898. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2899. return Ok(JsonView(true, "成功", url = rst));
  2900. }
  2901. else
  2902. {
  2903. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2904. }
  2905. }
  2906. }
  2907. catch (Exception ex)
  2908. {
  2909. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2910. throw;
  2911. }
  2912. }
  2913. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2914. /// <summary>
  2915. /// 行程单导出
  2916. /// </summary>
  2917. /// <param name="dto"></param>
  2918. /// <returns></returns>
  2919. [HttpPost]
  2920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2921. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2922. {
  2923. try
  2924. {
  2925. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2926. if (groupData.Code != 0)
  2927. {
  2928. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2929. }
  2930. else
  2931. {
  2932. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2933. if (dto.Language == "CN")
  2934. {
  2935. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2936. DocumentBuilder builder = new DocumentBuilder(doc);
  2937. int tableIndex = 0;//表格索引
  2938. //得到文档中的第一个表格
  2939. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2940. foreach (var item in _AirTicketReservations)
  2941. {
  2942. #region 处理固定数据
  2943. string[] FlightsCode = item.FlightsCode.Split('/');
  2944. if (FlightsCode.Length != 0)
  2945. {
  2946. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2947. if (_AirCompany != null)
  2948. {
  2949. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2950. }
  2951. else
  2952. {
  2953. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2954. }
  2955. }
  2956. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2957. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2958. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2959. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2960. string name = "";
  2961. foreach (string clientName in nameArray)
  2962. {
  2963. if (!name.Contains(clientName))
  2964. {
  2965. name += clientName + ",";
  2966. }
  2967. }
  2968. if (!string.IsNullOrWhiteSpace(name))
  2969. {
  2970. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2971. }
  2972. else
  2973. {
  2974. table.Range.Bookmarks["ClientName"].Text = "--";
  2975. }
  2976. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2977. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2978. table.Range.Bookmarks["JointTicket"].Text = "--";
  2979. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2980. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2981. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2982. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2983. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2984. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2985. #endregion
  2986. #region 循环数据处理
  2987. List<AirInfo> airs = new List<AirInfo>();
  2988. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2989. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2990. for (int i = 0; i < FlightsCode.Length; i++)
  2991. {
  2992. AirInfo air = new AirInfo();
  2993. string[] tempstr = DayArray[i]
  2994. .Replace("\r\n", string.Empty)
  2995. .Replace("\\r\\n", string.Empty)
  2996. .TrimStart().TrimEnd()
  2997. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2998. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2999. string starCity = "";
  3000. if (star_Three != null)
  3001. {
  3002. starCity = star_Three.AirPort;
  3003. }
  3004. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3005. string EndCity = "";
  3006. if (End_Three != null)
  3007. {
  3008. EndCity = End_Three.AirPort;
  3009. }
  3010. air.Destination = starCity + "/" + EndCity;
  3011. air.Flight = FlightsCode[i];
  3012. air.SeatingClass = item.CTypeName;
  3013. string dateTime = tempstr[2];
  3014. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3015. air.FlightDate = DateTemp;
  3016. air.DepartureTime = tempstr[5];
  3017. air.LandingTime = tempstr[6];
  3018. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3019. air.TicketStatus = "--";
  3020. air.Luggage = "--";
  3021. air.DepartureTerminal = "--";
  3022. air.LandingTerminal = "--";
  3023. airs.Add(air);
  3024. }
  3025. int row = 13;
  3026. for (int i = 0; i < airs.Count; i++)
  3027. {
  3028. if (airs.Count > 2)
  3029. {
  3030. for (int j = 0; j < airs.Count - 2; j++)
  3031. {
  3032. var CopyRow = table.Rows[12].Clone(true);
  3033. table.Rows.Add(CopyRow);
  3034. }
  3035. }
  3036. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3037. int index = 0;
  3038. foreach (PropertyInfo property in properties)
  3039. {
  3040. string value = property.GetValue(airs[i]).ToString();
  3041. Cell ishcel0 = table.Rows[row].Cells[index];
  3042. Paragraph p = new Paragraph(doc);
  3043. string s = value;
  3044. p.AppendChild(new Run(doc, s));
  3045. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3046. ishcel0.AppendChild(p);
  3047. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3048. index++;
  3049. }
  3050. row++;
  3051. }
  3052. #endregion
  3053. Paragraph lastParagraph = new Paragraph(doc);
  3054. //第一个表格末尾加段落
  3055. table.ParentNode.InsertAfter(lastParagraph, table);
  3056. //复制第一个表格
  3057. Table cloneTable = (Table)table.Clone(true);
  3058. //在文档末尾段落后面加入复制的表格
  3059. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3060. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3061. {
  3062. int rownewsIndex = 13;
  3063. for (int i = 0; i < 2; i++)
  3064. {
  3065. var CopyRow = table.Rows[12].Clone(true);
  3066. table.Rows.RemoveAt(13);
  3067. table.Rows.Add(CopyRow);
  3068. rownewsIndex++;
  3069. }
  3070. }
  3071. else
  3072. {
  3073. table.Rows.RemoveAt(12);
  3074. }
  3075. cloneTable.Rows.RemoveAt(12);
  3076. }
  3077. if (_AirTicketReservations.Count != 0)
  3078. {
  3079. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3080. if (FlightsCode.Length != 0)
  3081. {
  3082. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3083. if (_AirCompany != null)
  3084. {
  3085. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3086. }
  3087. else
  3088. {
  3089. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3090. }
  3091. }
  3092. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3093. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3094. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3095. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3096. string name = "";
  3097. foreach (string clientName in nameArray)
  3098. {
  3099. if (!name.Contains(clientName))
  3100. {
  3101. name += clientName + ",";
  3102. }
  3103. }
  3104. if (!string.IsNullOrWhiteSpace(name))
  3105. {
  3106. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3107. }
  3108. else
  3109. {
  3110. table.Range.Bookmarks["ClientName"].Text = "--";
  3111. }
  3112. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3113. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3114. table.Range.Bookmarks["JointTicket"].Text = "--";
  3115. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3116. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3117. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3118. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3119. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3120. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3121. }
  3122. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3123. //保存合并后的文档
  3124. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3125. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3126. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3127. return Ok(JsonView(true, "成功!", rst));
  3128. }
  3129. else
  3130. {
  3131. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3132. DocumentBuilder builder = new DocumentBuilder(doc);
  3133. int tableIndex = 0;//表格索引
  3134. //得到文档中的第一个表格
  3135. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3136. List<string> texts = new List<string>();
  3137. foreach (var item in _AirTicketReservations)
  3138. {
  3139. string[] FlightsCode = item.FlightsCode.Split('/');
  3140. if (FlightsCode.Length != 0)
  3141. {
  3142. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3143. if (_AirCompany != null)
  3144. {
  3145. if (!transDic.ContainsKey(_AirCompany.CnName))
  3146. {
  3147. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3148. }
  3149. }
  3150. else
  3151. {
  3152. if (!transDic.ContainsKey("--"))
  3153. {
  3154. transDic.Add("--", "--");
  3155. }
  3156. }
  3157. }
  3158. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3159. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3160. string name = "";
  3161. foreach (string clientName in nameArray)
  3162. {
  3163. name += clientName + ",";
  3164. }
  3165. if (!texts.Contains(name))
  3166. {
  3167. texts.Add(name);
  3168. }
  3169. List<AirInfo> airs = new List<AirInfo>();
  3170. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3171. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3172. for (int i = 0; i < FlightsCode.Length; i++)
  3173. {
  3174. AirInfo air = new AirInfo();
  3175. string[] tempstr = DayArray[i]
  3176. .Replace("\r\n", string.Empty)
  3177. .Replace("\\r\\n", string.Empty)
  3178. .TrimStart().TrimEnd()
  3179. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3180. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3181. if (star_Three != null)
  3182. {
  3183. if (!transDic.ContainsKey(star_Three.AirPort))
  3184. {
  3185. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3186. }
  3187. }
  3188. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3189. if (End_Three != null)
  3190. {
  3191. if (!transDic.ContainsKey(End_Three.AirPort))
  3192. {
  3193. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3194. }
  3195. }
  3196. if (!texts.Contains(item.CTypeName))
  3197. {
  3198. texts.Add(item.CTypeName);
  3199. }
  3200. }
  3201. }
  3202. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3203. if (transData.Count > 0)
  3204. {
  3205. foreach (TranslateResult item in transData)
  3206. {
  3207. if (!transDic.ContainsKey(item.Query))
  3208. {
  3209. transDic.Add(item.Query, item.Translation);
  3210. }
  3211. }
  3212. }
  3213. foreach (var item in _AirTicketReservations)
  3214. {
  3215. #region 处理固定数据
  3216. string[] FlightsCode = item.FlightsCode.Split('/');
  3217. if (FlightsCode.Length != 0)
  3218. {
  3219. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3220. if (_AirCompany != null)
  3221. {
  3222. string str = "--";
  3223. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3224. if (!string.IsNullOrEmpty(translateResult))
  3225. {
  3226. str = translateResult;
  3227. str = _airTicketResRep.Processing(str);
  3228. }
  3229. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3230. }
  3231. else
  3232. {
  3233. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3234. }
  3235. }
  3236. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3237. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3238. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3239. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3240. string names = "";
  3241. foreach (string clientName in nameArray)
  3242. {
  3243. names += clientName + ",";
  3244. }
  3245. if (!string.IsNullOrWhiteSpace(names))
  3246. {
  3247. string str = "--";
  3248. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3249. if (!string.IsNullOrEmpty(translateResult))
  3250. {
  3251. str = translateResult;
  3252. str = _airTicketResRep.Processing(str);
  3253. }
  3254. table.Range.Bookmarks["ClientName"].Text = str;
  3255. }
  3256. else
  3257. {
  3258. table.Range.Bookmarks["ClientName"].Text = "--";
  3259. }
  3260. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3261. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3262. table.Range.Bookmarks["JointTicket"].Text = "--";
  3263. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3264. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3265. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3266. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3267. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3268. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3269. #endregion
  3270. #region 循环数据处理
  3271. List<AirInfo> airs = new List<AirInfo>();
  3272. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3273. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3274. for (int i = 0; i < FlightsCode.Length; i++)
  3275. {
  3276. AirInfo air = new AirInfo();
  3277. string[] tempstr = DayArray[i]
  3278. .Replace("\r\n", string.Empty)
  3279. .Replace("\\r\\n", string.Empty)
  3280. .TrimStart().TrimEnd()
  3281. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3282. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3283. string starCity = "";
  3284. if (star_Three != null)
  3285. {
  3286. string str2 = "--";
  3287. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3288. if (!string.IsNullOrEmpty(translateResult2))
  3289. {
  3290. str2 = translateResult2;
  3291. str2 = _airTicketResRep.Processing(str2);
  3292. }
  3293. starCity = str2;
  3294. }
  3295. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3296. string EndCity = "";
  3297. if (End_Three != null)
  3298. {
  3299. string str1 = "--";
  3300. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3301. if (!string.IsNullOrEmpty(translateResult1))
  3302. {
  3303. str1 = translateResult1;
  3304. str1 = _airTicketResRep.Processing(str1);
  3305. }
  3306. EndCity = str1;
  3307. }
  3308. air.Destination = starCity + "/" + EndCity;
  3309. air.Flight = FlightsCode[i];
  3310. string str = "--";
  3311. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3312. if (!string.IsNullOrEmpty(translateResult))
  3313. {
  3314. str = translateResult;
  3315. str = _airTicketResRep.Processing(str);
  3316. }
  3317. air.SeatingClass = str;
  3318. string dateTime = tempstr[2];
  3319. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3320. air.FlightDate = DateTemp;
  3321. air.DepartureTime = tempstr[5];
  3322. air.LandingTime = tempstr[6];
  3323. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3324. air.TicketStatus = "--";
  3325. air.Luggage = "--";
  3326. air.DepartureTerminal = "--";
  3327. air.LandingTerminal = "--";
  3328. airs.Add(air);
  3329. }
  3330. int row = 13;
  3331. for (int i = 0; i < airs.Count; i++)
  3332. {
  3333. if (airs.Count > 2)
  3334. {
  3335. for (int j = 0; j < airs.Count - 2; j++)
  3336. {
  3337. var CopyRow = table.Rows[12].Clone(true);
  3338. table.Rows.Add(CopyRow);
  3339. }
  3340. }
  3341. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3342. int index = 0;
  3343. foreach (PropertyInfo property in properties)
  3344. {
  3345. string value = property.GetValue(airs[i]).ToString();
  3346. Cell ishcel0 = table.Rows[row].Cells[index];
  3347. Paragraph p = new Paragraph(doc);
  3348. string s = value;
  3349. p.AppendChild(new Run(doc, s));
  3350. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3351. ishcel0.AppendChild(p);
  3352. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3353. //ishcel0.CellFormat.VerticalAlignment=
  3354. index++;
  3355. }
  3356. row++;
  3357. }
  3358. #endregion
  3359. Paragraph lastParagraph = new Paragraph(doc);
  3360. //第一个表格末尾加段落
  3361. table.ParentNode.InsertAfter(lastParagraph, table);
  3362. //复制第一个表格
  3363. Table cloneTable = (Table)table.Clone(true);
  3364. //在文档末尾段落后面加入复制的表格
  3365. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3366. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3367. {
  3368. int rownewsIndex = 13;
  3369. for (int i = 0; i < 2; i++)
  3370. {
  3371. var CopyRow = table.Rows[12].Clone(true);
  3372. table.Rows.RemoveAt(13);
  3373. table.Rows.Add(CopyRow);
  3374. rownewsIndex++;
  3375. }
  3376. }
  3377. else
  3378. {
  3379. table.Rows.RemoveAt(12);
  3380. }
  3381. cloneTable.Rows.RemoveAt(12);
  3382. }
  3383. if (_AirTicketReservations.Count != 0)
  3384. {
  3385. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3386. if (FlightsCode.Length != 0)
  3387. {
  3388. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3389. if (_AirCompany != null)
  3390. {
  3391. string str = "--";
  3392. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3393. if (!string.IsNullOrEmpty(translateResult))
  3394. {
  3395. str = translateResult;
  3396. str = _airTicketResRep.Processing(str);
  3397. }
  3398. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3399. }
  3400. else
  3401. {
  3402. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3403. }
  3404. }
  3405. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3406. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3407. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3408. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3409. string names = "";
  3410. foreach (string clientName in nameArray)
  3411. {
  3412. names += clientName + ",";
  3413. }
  3414. if (!string.IsNullOrWhiteSpace(names))
  3415. {
  3416. string str = "--";
  3417. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3418. if (!string.IsNullOrEmpty(translateResult))
  3419. {
  3420. str = translateResult;
  3421. str = _airTicketResRep.Processing(str);
  3422. }
  3423. table.Range.Bookmarks["ClientName"].Text = str;
  3424. }
  3425. else
  3426. {
  3427. table.Range.Bookmarks["ClientName"].Text = "--";
  3428. }
  3429. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3430. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3431. table.Range.Bookmarks["JointTicket"].Text = "--";
  3432. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3433. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3434. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3435. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3436. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3437. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3438. }
  3439. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3440. //保存合并后的文档
  3441. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3442. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3443. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3444. return Ok(JsonView(true, "成功!", rst));
  3445. }
  3446. }
  3447. }
  3448. catch (Exception ex)
  3449. {
  3450. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3451. throw;
  3452. }
  3453. }
  3454. #endregion
  3455. #region 团组增减款项 --> 其他款项
  3456. /// <summary>
  3457. /// 团组增减款项下拉框绑定
  3458. /// </summary>
  3459. /// <param name="dto"></param>
  3460. /// <returns></returns>
  3461. [HttpPost]
  3462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3463. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3464. {
  3465. #region 参数验证
  3466. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3467. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3468. #endregion
  3469. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3470. }
  3471. /// <summary>
  3472. /// 根据团组Id查询团组增减款项
  3473. /// </summary>
  3474. /// <param name="dto"></param>
  3475. /// <returns></returns>
  3476. [HttpPost]
  3477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3478. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3479. {
  3480. #region 参数验证
  3481. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3482. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3483. #endregion
  3484. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3485. }
  3486. /// <summary>
  3487. /// 团组增减款项操作(Status:1.新增,2.修改)
  3488. /// </summary>
  3489. /// <param name="dto"></param>
  3490. /// <returns></returns>
  3491. [HttpPost]
  3492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3493. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3494. {
  3495. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3496. if (groupData.Code != 200)
  3497. {
  3498. return Ok(JsonView(false, groupData.Msg));
  3499. }
  3500. #region 应用推送
  3501. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3502. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3503. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3504. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3505. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3506. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3507. //自动审核
  3508. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3509. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3510. //2024-10-21 新增LZ UID
  3511. var userIds = new List<int>() { 21 };
  3512. string title = $"系统通知";
  3513. string content = "";
  3514. var diId = dto.DiId;
  3515. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3516. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3517. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3518. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3519. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3520. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3521. #endregion
  3522. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3523. }
  3524. /// <summary>
  3525. /// 团组增减款项操作 删除
  3526. /// </summary>
  3527. /// <param name="dto"></param>
  3528. /// <returns></returns>
  3529. [HttpPost]
  3530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3531. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3532. {
  3533. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3534. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3535. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3536. if (res.Code == 0)
  3537. {
  3538. return Ok(JsonView(true, "删除成功!"));
  3539. }
  3540. return Ok(JsonView(false, "删除失败!"));
  3541. }
  3542. /// <summary>
  3543. /// 根据团组增减款项Id查询
  3544. /// </summary>
  3545. /// <param name="dto"></param>
  3546. /// <returns></returns>
  3547. [HttpPost]
  3548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3549. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3550. {
  3551. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3552. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3553. }
  3554. /// <summary>
  3555. /// 查询供应商名称
  3556. /// </summary>
  3557. /// <param name="dto"></param>
  3558. /// <returns></returns>
  3559. [HttpPost]
  3560. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3561. {
  3562. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3563. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3564. ?? new List<Grp_DecreasePayments>();
  3565. dbResult = dbResult.Distinct(new
  3566. ProductComparer()).ToList();
  3567. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3568. {
  3569. x.Id,
  3570. x.SupplierAddress,
  3571. x.SupplierArea,
  3572. x.SupplierContact,
  3573. x.SupplierContactNumber,
  3574. x.SupplierEmail,
  3575. x.SupplierName,
  3576. x.SupplierSocialAccount,
  3577. x.SupplierTypeId,
  3578. }).ToList());
  3579. return Ok(jw);
  3580. }
  3581. /// <summary>
  3582. /// 团组增减款项 OTA匹配
  3583. /// </summary>
  3584. /// <param name="file"></param>
  3585. /// <returns></returns>
  3586. [HttpPost]
  3587. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3588. {
  3589. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3590. string fileName = file.FileName;
  3591. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3592. {
  3593. return Ok(JsonView(false, "请上传Excel文件!"));
  3594. }
  3595. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3596. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3597. if (!Directory.Exists(path))
  3598. {
  3599. Directory.CreateDirectory(path);
  3600. }
  3601. var filePath = @$"{path}/{fileName}";
  3602. //保存文件
  3603. using (FileStream fs = System.IO.File.Create(filePath))
  3604. {
  3605. file.CopyTo(fs);
  3606. fs.Flush();
  3607. }
  3608. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3609. //读取ExcelFile
  3610. DataTable dt = ConvertExcelToDataTable(filePath);
  3611. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3612. dt.TableName = "TB";
  3613. //修改table列名
  3614. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3615. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3616. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3617. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3618. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3619. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3620. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3621. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3622. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3623. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3624. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3625. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3626. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3627. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3628. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3629. var otaOrderNos = new List<string>();
  3630. foreach (DataRow item in dt.Rows)
  3631. {
  3632. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3633. }
  3634. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3635. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3636. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3637. .Select((dp, di) => new
  3638. {
  3639. dp.PriceName,
  3640. dp.OTAOrderNo,
  3641. dp.FeeTotal,
  3642. di.TeamName,
  3643. })
  3644. .ToListAsync();
  3645. foreach (DataRow item in dt.Rows)
  3646. {
  3647. var otaOrderNo = item["OTAOrderNo"].ToString();
  3648. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3649. if (oaData == null) continue;
  3650. item["GroupName"] = oaData.TeamName;
  3651. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3652. }
  3653. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3654. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3655. List<DataTable> datas = new List<DataTable>();
  3656. datas.Add(dt);
  3657. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3658. return Ok(JsonView(true, "操作成功", new { url = url }));
  3659. }
  3660. #region
  3661. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3662. {
  3663. // 创建Workbook对象
  3664. Workbook workbook = new Workbook(excelFilePath);
  3665. // 获取第一个工作表
  3666. Worksheet worksheet = workbook.Worksheets[0];
  3667. // 将工作表转换为DataTable
  3668. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3669. return dataTable;
  3670. }
  3671. #endregion
  3672. #endregion
  3673. #region 文件上传、删除
  3674. /// <summary>
  3675. /// region 文件上传 可以带参数
  3676. /// </summary>
  3677. /// <param name="file"></param>
  3678. /// <returns></returns>
  3679. [HttpPost]
  3680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3681. public async Task<IActionResult> UploadProject(IFormFile file)
  3682. {
  3683. //var TypeName = Request.Headers["TypeName"].ToString();
  3684. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3685. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3686. ////文件名称
  3687. //string projectFileName = file.FileName;
  3688. ////上传的文件的路径
  3689. //string filePath = $"{fileDir}/{projectFileName}";
  3690. //if (TypeName == "A")//A代表团组增减款项
  3691. //{
  3692. // filePath = fileDir + $@"\团组增减款项相关文件";
  3693. // if (!Directory.Exists(filePath))
  3694. // {
  3695. // Directory.CreateDirectory(filePath);
  3696. // }
  3697. // //上传的文件的路径
  3698. // filePath += $@"\{projectFileName}";
  3699. //}
  3700. //else if (TypeName == "B")//B代表商邀相关文件
  3701. //{
  3702. // //上传的文件的路径
  3703. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3704. // if (!Directory.Exists(filePath))
  3705. // {
  3706. // Directory.CreateDirectory(filePath);
  3707. // }
  3708. // //上传的文件的路径
  3709. // filePath = $@"\{projectFileName}";
  3710. //}
  3711. //try
  3712. //{
  3713. // using (FileStream fs = System.IO.File.Create(filePath))
  3714. // {
  3715. // file.CopyTo(fs);
  3716. // fs.Flush();
  3717. // }
  3718. //}
  3719. //catch (Exception ex)
  3720. //{
  3721. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3722. //}
  3723. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3724. try
  3725. {
  3726. var TypeName = Request.Headers["TypeName"].ToString();
  3727. if (file != null)
  3728. {
  3729. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3730. //文件名称
  3731. string projectFileName = file.FileName;
  3732. //上传的文件的路径
  3733. string filePath = $"{fileDir}/{projectFileName}";
  3734. if (TypeName == "A")//A代表团组增减款项
  3735. {
  3736. if (!Directory.Exists(fileDir))
  3737. {
  3738. Directory.CreateDirectory(fileDir);
  3739. }
  3740. //上传的文件的路径
  3741. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3742. }
  3743. else if (TypeName == "B")//B代表商邀相关文件
  3744. {
  3745. if (!Directory.Exists(fileDir))
  3746. {
  3747. Directory.CreateDirectory(fileDir);
  3748. }
  3749. //上传的文件的路径
  3750. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3751. }
  3752. using (FileStream fs = System.IO.File.Create(filePath))
  3753. {
  3754. file.CopyTo(fs);
  3755. fs.Flush();
  3756. }
  3757. return Ok(JsonView(true, "上传成功!", projectFileName));
  3758. }
  3759. else
  3760. {
  3761. return Ok(JsonView(false, "上传失败!"));
  3762. }
  3763. }
  3764. catch (Exception ex)
  3765. {
  3766. return Ok(JsonView(false, "程序错误!"));
  3767. }
  3768. }
  3769. /// <summary>
  3770. /// 删除指定文件
  3771. /// </summary>
  3772. /// <param name="dto"></param>
  3773. /// <returns></returns>
  3774. [HttpPost]
  3775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3776. public async Task<IActionResult> DelFile(DelFileDto dto)
  3777. {
  3778. try
  3779. {
  3780. var TypeName = Request.Headers["TypeName"].ToString();
  3781. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3782. string filePath = "";
  3783. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3784. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3785. int id = 0;
  3786. if (TypeName == "A")
  3787. {
  3788. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3789. // 删除该文件
  3790. System.IO.File.Delete(filePath);
  3791. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3792. .Where(a => a.Id == dto.Id)
  3793. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3794. .ExecuteCommandAsync();
  3795. }
  3796. else if (TypeName == "B")
  3797. {
  3798. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3799. // 删除该文件
  3800. System.IO.File.Delete(filePath);
  3801. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3802. if (info != null)
  3803. {
  3804. string[] files = new string[] { };
  3805. if (!string.IsNullOrEmpty(info.Attachment))
  3806. {
  3807. try
  3808. {
  3809. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3810. }
  3811. catch (Exception)
  3812. {
  3813. files = new List<string>() { info.Attachment }.ToArray();
  3814. }
  3815. }
  3816. if (files.Length > 0)
  3817. {
  3818. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3819. string filePath2 = string.Empty;
  3820. if (files1.Length > 0)
  3821. {
  3822. filePath2 = JsonConvert.SerializeObject(files1);
  3823. }
  3824. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3825. .Where(a => a.Id == dto.Id)
  3826. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3827. .ExecuteCommandAsync();
  3828. }
  3829. }
  3830. }
  3831. if (id != 0)
  3832. {
  3833. return Ok(JsonView(true, "成功!"));
  3834. }
  3835. else
  3836. {
  3837. return Ok(JsonView(false, "失败!"));
  3838. }
  3839. }
  3840. catch (Exception ex)
  3841. {
  3842. return Ok(JsonView(false, "程序错误!"));
  3843. throw;
  3844. }
  3845. }
  3846. /// <summary>
  3847. /// 文件上传多个文件 可以带参数
  3848. /// </summary>
  3849. /// <param name="files"></param>
  3850. /// <returns></returns>
  3851. [HttpPost]
  3852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3853. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3854. {
  3855. try
  3856. {
  3857. var TypeName = Request.Headers["TypeName"].ToString();
  3858. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3859. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3860. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3861. var filePahts = new List<string>();
  3862. foreach (var file in files)
  3863. {
  3864. //文件名称
  3865. string projectFileName = file.FileName;
  3866. //上传的文件的路径
  3867. string filePath = $"{fileDir}/{projectFileName}";
  3868. if (TypeName == "A")//A代表团组增减款项
  3869. {
  3870. if (!Directory.Exists(fileDir))
  3871. {
  3872. Directory.CreateDirectory(fileDir);
  3873. }
  3874. //上传的文件的路径
  3875. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3876. }
  3877. else if (TypeName == "B")//B代表商邀相关文件
  3878. {
  3879. if (!Directory.Exists(fileDir))
  3880. {
  3881. Directory.CreateDirectory(fileDir);
  3882. }
  3883. //上传的文件的路径
  3884. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3885. }
  3886. using (FileStream fs = System.IO.File.Create(filePath))
  3887. {
  3888. file.CopyTo(fs);
  3889. fs.Flush();
  3890. }
  3891. filePahts.Add(projectFileName);
  3892. }
  3893. return Ok(JsonView(true, "上传成功!", filePahts));
  3894. }
  3895. catch (Exception ex)
  3896. {
  3897. return Ok(JsonView(false, "程序错误!"));
  3898. }
  3899. }
  3900. #endregion
  3901. #region 商邀费用录入
  3902. /// <summary>
  3903. /// 根据团组Id查询商邀费用列表
  3904. /// </summary>
  3905. /// <param name="dto"></param>
  3906. /// <returns></returns>
  3907. [HttpPost]
  3908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3909. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3910. {
  3911. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3912. if (groupData.Code != 0)
  3913. {
  3914. return Ok(JsonView(false, groupData.Msg));
  3915. }
  3916. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3917. }
  3918. /// <summary>
  3919. /// 商邀费用列表
  3920. /// 下载文件
  3921. /// </summary>
  3922. /// <param name="id"></param>
  3923. /// <returns></returns>
  3924. [HttpGet("{id}")]
  3925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3926. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3927. {
  3928. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3929. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3930. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3931. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3932. var filePaths = new List<string>();
  3933. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3934. try
  3935. {
  3936. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3937. }
  3938. catch (Exception ex)
  3939. {
  3940. filePaths.Add(info.Attachment);
  3941. }
  3942. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3943. for (int i = 0; i < filePaths.Count; i++)
  3944. {
  3945. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3946. }
  3947. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3948. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3949. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3950. {
  3951. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3952. {
  3953. foreach (string filePath in filePaths)
  3954. {
  3955. if (System.IO.File.Exists(filePath))
  3956. {
  3957. // 获取文件名
  3958. string fileName = Path.GetFileName(filePath);
  3959. // 将文件添加到ZIP归档中
  3960. zipArchive.CreateEntryFromFile(filePath, fileName);
  3961. }
  3962. }
  3963. }
  3964. }
  3965. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3966. }
  3967. /// <summary>
  3968. /// 商邀费用 Info Page 基础数据源
  3969. /// </summary>
  3970. /// <returns></returns>
  3971. [HttpPost]
  3972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3973. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3974. {
  3975. try
  3976. {
  3977. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3978. if (groupData.Code != 0)
  3979. {
  3980. return Ok(JsonView(false, groupData.Msg));
  3981. }
  3982. return Ok(JsonView(true, "操作成功", groupData.Data));
  3983. }
  3984. catch (Exception ex)
  3985. {
  3986. return Ok(JsonView(false, ex.Message));
  3987. throw;
  3988. }
  3989. }
  3990. /// <summary>
  3991. /// 根据商邀费用ID查询C表和商邀费用数据
  3992. /// </summary>
  3993. /// <param name="dto"></param>
  3994. /// <returns></returns>
  3995. [HttpPost]
  3996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3997. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3998. {
  3999. try
  4000. {
  4001. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4002. if (groupData.Code != 0)
  4003. {
  4004. return Ok(JsonView(false, groupData.Msg));
  4005. }
  4006. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4007. }
  4008. catch (Exception ex)
  4009. {
  4010. return Ok(JsonView(false, ex.Message));
  4011. throw;
  4012. }
  4013. }
  4014. /// <summary>
  4015. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4016. /// </summary>
  4017. /// <param name="dto"></param>
  4018. /// <returns></returns>
  4019. [HttpPost]
  4020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4021. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4022. {
  4023. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4024. if (groupData.Code != 0)
  4025. {
  4026. return Ok(JsonView(false, groupData.Msg));
  4027. }
  4028. #region 应用推送
  4029. try
  4030. {
  4031. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4032. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4033. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4034. //2024-10-21 新增LZ UID
  4035. var userIds = new List<int>() { 21 };
  4036. string title = $"系统通知";
  4037. string content = "";
  4038. var diId = dto.DiId;
  4039. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4040. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4041. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4042. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4043. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4044. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4045. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4046. }
  4047. catch (Exception ex)
  4048. {
  4049. }
  4050. #endregion
  4051. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4052. }
  4053. /// <summary>
  4054. /// 商邀删除
  4055. /// </summary>
  4056. /// <param name="dto"></param>
  4057. /// <returns></returns>
  4058. [HttpPost]
  4059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4060. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4061. {
  4062. try
  4063. {
  4064. _sqlSugar.BeginTran();
  4065. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4066. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4067. {
  4068. IsDel = 1,
  4069. DeleteUserId = dto.DeleteUserId,
  4070. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4071. })
  4072. .Where(it => it.Id == dto.Id)
  4073. .ExecuteCommand();
  4074. if (res1 > 0)
  4075. {
  4076. int _diId = 0;
  4077. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4078. if (_ioaInfo != null)
  4079. {
  4080. _diId = _ioaInfo.DiId;
  4081. }
  4082. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4083. .SetColumns(a => new Grp_CreditCardPayment()
  4084. {
  4085. IsDel = 1,
  4086. DeleteUserId = dto.DeleteUserId,
  4087. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4088. })
  4089. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4090. .ExecuteCommand();
  4091. if (res2 > 0)
  4092. {
  4093. _sqlSugar.CommitTran();
  4094. return Ok(JsonView(true, "删除成功!"));
  4095. }
  4096. }
  4097. _sqlSugar.RollbackTran();
  4098. return Ok(JsonView(false, "删除失败"));
  4099. }
  4100. catch (Exception ex)
  4101. {
  4102. _sqlSugar.RollbackTran();
  4103. return Ok(JsonView(false, ex.Message));
  4104. }
  4105. }
  4106. /// <summary>
  4107. /// 团组模块文件上传
  4108. /// </summary>
  4109. /// <param name="dto"></param>
  4110. /// <returns></returns>
  4111. [HttpPost]
  4112. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4113. {
  4114. var jw = JsonView(false);
  4115. long M = 1024 * 1024;
  4116. if (dto.Files == null || dto.Files.Count == 0)
  4117. {
  4118. jw.Msg = "无文件信息!";
  4119. return Ok(jw);
  4120. }
  4121. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4122. {
  4123. jw.Msg = "文件大小超过20M!";
  4124. return Ok(jw);
  4125. }
  4126. //var nameSp = dto.File.FileName.Split(".");
  4127. //if (nameSp.Length < 2)
  4128. //{
  4129. // jw.Msg = "拓展名称有误!";
  4130. // return Ok(jw);
  4131. //}
  4132. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4133. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4134. //{
  4135. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4136. // return Ok(jw);
  4137. //}
  4138. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4139. if (Ctable == null)
  4140. {
  4141. jw.Msg = "Ctable指向有误!";
  4142. return Ok(jw);
  4143. }
  4144. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4145. if (groupInfo == null)
  4146. {
  4147. jw.Msg = "团组信息不存在!";
  4148. return Ok(jw);
  4149. }
  4150. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4151. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4152. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4153. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4154. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4155. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4156. try
  4157. {
  4158. if (!Directory.Exists(fileBase))
  4159. {
  4160. Directory.CreateDirectory(fileBase);
  4161. }
  4162. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4163. foreach (var fileStream in dto.Files)
  4164. {
  4165. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4166. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4167. {
  4168. Cid = dto.Cid,
  4169. CreateTime = DateTime.Now,
  4170. CreateUserId = dto.Userid,
  4171. Ctable = dto.Ctable,
  4172. Diid = dto.Diid,
  4173. IsDel = 0,
  4174. FilePath = saveFilePath,
  4175. FileName = fileStream.FileName
  4176. };
  4177. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4178. {
  4179. fileStream.CopyTo(fs);
  4180. fs.Flush();
  4181. }
  4182. saveArr.Add(file);
  4183. }
  4184. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4185. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4186. jw = JsonView(true, "保存成功!", new
  4187. {
  4188. count = addResult,
  4189. filesName = saveArr.Select(x => x.FileName)
  4190. });
  4191. }
  4192. catch (Exception ex)
  4193. {
  4194. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4195. {
  4196. count = 0,
  4197. filesName = new string[0],
  4198. });
  4199. }
  4200. return Ok(jw);
  4201. }
  4202. /// <summary>
  4203. /// 查询各模块已保存文件
  4204. /// </summary>
  4205. /// <param name="dto"></param>
  4206. /// <returns></returns>
  4207. [HttpPost]
  4208. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4209. {
  4210. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4211. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4212. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4213. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4214. {
  4215. expression = Expressionable.Create<Grp_GroupModelFile>()
  4216. .And(x => visaIds.Contains(x.CreateUserId));
  4217. }
  4218. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4219. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4220. .Where(expression.ToExpression())
  4221. .ToList();
  4222. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4223. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4224. {
  4225. x.FileName,
  4226. x.Id,
  4227. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4228. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4229. })));
  4230. }
  4231. /// <summary>
  4232. /// 下载该团组下的所有文件
  4233. /// </summary>
  4234. /// <param name="dto"></param>
  4235. /// <returns></returns>
  4236. [HttpPost]
  4237. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4238. {
  4239. var jw = JsonView(false);
  4240. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4241. if (groupInfo == null)
  4242. {
  4243. jw.Msg = "团组信息不存在!";
  4244. return Ok(jw);
  4245. }
  4246. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4247. var isModule = Convert.ToBoolean(dto.isModule);
  4248. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4249. IOOperatorHelper io = new IOOperatorHelper();
  4250. if (isModule)
  4251. {
  4252. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4253. foreach (var moduleArr in moduleGroup)
  4254. {
  4255. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4256. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4257. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4258. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4259. foreach (var item in moduleArr)
  4260. {
  4261. if (System.IO.File.Exists(item.FilePath))
  4262. {
  4263. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4264. {
  4265. byte[] bytes = new byte[fileStream.Length];
  4266. fileStream.Read(bytes, 0, bytes.Length);
  4267. fileStream.Close();
  4268. Stream stream = new MemoryStream(bytes);
  4269. chiZips.Add(item.FileName, stream);
  4270. }
  4271. }
  4272. }
  4273. if (chiZips.Count > 0)
  4274. {
  4275. var byts = io.ConvertZipStream(chiZips);
  4276. Stream stream = new MemoryStream(byts);
  4277. Zips.Add(key.Name + "_.zip", stream);
  4278. }
  4279. }
  4280. }
  4281. else
  4282. {
  4283. foreach (var item in dbQuery)
  4284. {
  4285. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4286. {
  4287. byte[] bytes = new byte[fileStream.Length];
  4288. fileStream.Read(bytes, 0, bytes.Length);
  4289. fileStream.Close();
  4290. Stream stream = new MemoryStream(bytes);
  4291. while (Zips.Keys.Contains(item.FileName))
  4292. {
  4293. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4294. }
  4295. Zips.Add(item.FileName, stream);
  4296. }
  4297. }
  4298. }
  4299. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4300. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4301. if (Zips.Count > 0)
  4302. {
  4303. var byts = io.ConvertZipStream(Zips);
  4304. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4305. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4306. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4307. }
  4308. else
  4309. {
  4310. jw.Msg = "暂无生成文件!";
  4311. }
  4312. return Ok(jw);
  4313. }
  4314. /// <summary>
  4315. /// 下载该团组下此模块的所有文件
  4316. /// </summary>
  4317. /// <param name="dto"></param>
  4318. /// <returns></returns>
  4319. [HttpPost]
  4320. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4321. {
  4322. var jw = JsonView(false);
  4323. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4324. if (groupInfo == null)
  4325. {
  4326. jw.Msg = "团组信息不存在!";
  4327. return Ok(jw);
  4328. }
  4329. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4330. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4331. && x.IsDel == 0);
  4332. if (key == null)
  4333. {
  4334. jw.Msg = "Ctable指向错误!";
  4335. return Ok(jw);
  4336. }
  4337. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4338. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4339. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4340. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4341. IOOperatorHelper io = new IOOperatorHelper();
  4342. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4343. foreach (var item in dbQuery)
  4344. {
  4345. if (System.IO.File.Exists(item.FilePath))
  4346. {
  4347. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4348. {
  4349. byte[] bytes = new byte[fileStream.Length];
  4350. fileStream.Read(bytes, 0, bytes.Length);
  4351. fileStream.Close();
  4352. Stream stream = new MemoryStream(bytes);
  4353. while (Zips.Keys.Contains(item.FileName))
  4354. {
  4355. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4356. }
  4357. Zips.Add(item.FileName, stream);
  4358. }
  4359. }
  4360. }
  4361. if (Zips.Count > 0)
  4362. {
  4363. var byts = io.ConvertZipStream(Zips);
  4364. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4365. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4366. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4367. }
  4368. else
  4369. {
  4370. jw.Msg = "暂无生成文件!";
  4371. }
  4372. return Ok(jw);
  4373. }
  4374. /// <summary>
  4375. /// 删除该团组下的指定文件
  4376. /// </summary>
  4377. /// <param name="dto"></param>
  4378. /// <returns></returns>
  4379. [HttpPost]
  4380. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4381. {
  4382. var jw = JsonView(false);
  4383. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4384. if (sing == null)
  4385. {
  4386. jw.Msg = "暂无";
  4387. return Ok(jw);
  4388. }
  4389. if (System.IO.File.Exists(sing.FilePath))
  4390. {
  4391. try
  4392. {
  4393. System.IO.File.Delete(sing.FilePath);
  4394. }
  4395. catch (Exception ex)
  4396. {
  4397. jw.Msg = "删除失败!" + ex.Message;
  4398. return Ok(jw);
  4399. }
  4400. }
  4401. sing.IsDel = 1;
  4402. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4403. sing.DeleteUserId = dto.UserId;
  4404. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4405. jw = JsonView(true, "删除成功!");
  4406. return Ok(jw);
  4407. }
  4408. #endregion
  4409. #region 团组英文资料
  4410. /// <summary>
  4411. /// 查询团组英文所有资料
  4412. /// </summary>
  4413. /// <param name="dto"></param>
  4414. /// <returns></returns>
  4415. [HttpPost]
  4416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4417. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4418. {
  4419. try
  4420. {
  4421. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4422. if (groupData.Code != 0)
  4423. {
  4424. return Ok(JsonView(false, groupData.Msg));
  4425. }
  4426. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4427. }
  4428. catch (Exception ex)
  4429. {
  4430. return Ok(JsonView(false, "程序错误!"));
  4431. throw;
  4432. }
  4433. }
  4434. /// <summary>
  4435. /// 团组英文资料操作(Status:1.新增,2.修改)
  4436. /// </summary>
  4437. /// <param name="dto"></param>
  4438. /// <returns></returns>
  4439. [HttpPost]
  4440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4441. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4442. {
  4443. try
  4444. {
  4445. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4446. if (groupData.Code != 0)
  4447. {
  4448. return Ok(JsonView(false, groupData.Msg));
  4449. }
  4450. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4451. }
  4452. catch (Exception ex)
  4453. {
  4454. return Ok(JsonView(false, "程序错误!"));
  4455. throw;
  4456. }
  4457. }
  4458. /// <summary>
  4459. /// 团组英文资料Id查询数据
  4460. /// </summary>
  4461. /// <param name="dto"></param>
  4462. /// <returns></returns>
  4463. [HttpPost]
  4464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4465. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4466. {
  4467. try
  4468. {
  4469. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4470. if (_DelegationEnData != null)
  4471. {
  4472. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4473. }
  4474. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4475. }
  4476. catch (Exception ex)
  4477. {
  4478. return Ok(JsonView(false, "程序错误!"));
  4479. throw;
  4480. }
  4481. }
  4482. /// <summary>
  4483. /// 团组英文资料删除
  4484. /// </summary>
  4485. /// <param name="dto"></param>
  4486. /// <returns></returns>
  4487. [HttpPost]
  4488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4489. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4490. {
  4491. try
  4492. {
  4493. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4494. if (!res)
  4495. {
  4496. return Ok(JsonView(false, "删除失败"));
  4497. }
  4498. return Ok(JsonView(true, "删除成功!"));
  4499. }
  4500. catch (Exception ex)
  4501. {
  4502. return Ok(JsonView(false, "程序错误!"));
  4503. throw;
  4504. }
  4505. }
  4506. #endregion
  4507. #region 导出邀请函
  4508. /// <summary>
  4509. /// 导出邀请函页面初始化
  4510. /// </summary>
  4511. /// <param name="dto"></param>
  4512. /// <returns></returns>
  4513. [HttpPost]
  4514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4515. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4516. {
  4517. try
  4518. {
  4519. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  4520. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4521. if (dto.DiId == 0)
  4522. {
  4523. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4524. }
  4525. else
  4526. {
  4527. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4528. }
  4529. return Ok(JsonView(true, "查询成功!", new
  4530. {
  4531. deleClient = crm_Deles,
  4532. delegations = grp_Delegations
  4533. }));
  4534. }
  4535. catch (Exception ex)
  4536. {
  4537. return Ok(JsonView(false, "程序错误!"));
  4538. throw;
  4539. }
  4540. }
  4541. /// <summary>
  4542. /// 导出邀请函
  4543. /// </summary>
  4544. /// <param name="dto"></param>
  4545. /// <returns></returns>
  4546. [HttpPost]
  4547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4548. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4549. {
  4550. #region 参数验证
  4551. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4552. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4553. #endregion
  4554. try
  4555. {
  4556. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4557. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4558. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4559. From Grp_TourClientList tcl
  4560. Left Join
  4561. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4562. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4563. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4564. From Crm_DeleClient dc
  4565. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4566. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4567. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4568. Where dc.IsDel = 0) temp
  4569. On temp.DcId =tcl.ClientId
  4570. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4571. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4572. List<string> texts = new List<string>();
  4573. if (datas.Count != 0)
  4574. {
  4575. foreach (TourClientListDetailsView item in datas)
  4576. {
  4577. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4578. {
  4579. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4580. }
  4581. else
  4582. {
  4583. string name = item.LastName + item.FirstName;
  4584. texts.Add(name);
  4585. }
  4586. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4587. {
  4588. if (!transDic.ContainsKey(item.Job))
  4589. {
  4590. texts.Add(item.Job);
  4591. }
  4592. }
  4593. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4594. {
  4595. texts.Add(item.CompanyFullName);
  4596. }
  4597. }
  4598. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4599. if (transData.Count > 0)
  4600. {
  4601. foreach (TranslateResult item in transData)
  4602. {
  4603. if (!transDic.ContainsKey(item.Query))
  4604. {
  4605. transDic.Add(item.Query, item.Translation);
  4606. }
  4607. }
  4608. }
  4609. List<GuestList> list = new List<GuestList>();
  4610. foreach (TourClientListDetailsView dele in datas)
  4611. {
  4612. GuestList guestList = new GuestList();
  4613. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4614. {
  4615. guestList.Name = dele.Pinyin;
  4616. }
  4617. else
  4618. {
  4619. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4620. guestList.Name = Name;
  4621. }
  4622. if (dele.Sex == 0)
  4623. {
  4624. guestList.Sex = "Male";
  4625. }
  4626. else if (dele.Sex == 1)
  4627. {
  4628. guestList.Sex = "Female";
  4629. }
  4630. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4631. if (!string.IsNullOrEmpty(dele.Job))
  4632. {
  4633. guestList.Job = dele.Job;
  4634. }
  4635. list.Add(guestList);
  4636. }
  4637. //载入模板
  4638. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4639. DocumentBuilder builder = new DocumentBuilder(doc);
  4640. //获取word里所有表格
  4641. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4642. //获取所填表格的序数
  4643. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4644. var rowStart = tableOne.Rows[0]; //获取第1行
  4645. //循环赋值
  4646. for (int i = 0; i < list.Count; i++)
  4647. {
  4648. builder.MoveToCell(0, i + 1, 0, 0);
  4649. builder.Write(list[i].Name.ToString());
  4650. builder.MoveToCell(0, i + 1, 1, 0);
  4651. builder.Write(list[i].Sex.ToString());
  4652. builder.MoveToCell(0, i + 1, 2, 0);
  4653. builder.Write(list[i].DOB.ToString());
  4654. builder.MoveToCell(0, i + 1, 3, 0);
  4655. builder.Write(list[i].Job.ToString());
  4656. }
  4657. //删除多余行
  4658. while (tableOne.Rows.Count > list.Count + 1)
  4659. {
  4660. tableOne.Rows.RemoveAt(list.Count + 1);
  4661. }
  4662. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4663. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4664. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4665. doc.Save(filePath);
  4666. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4667. return Ok(JsonView(true, "操作成功!", Url));
  4668. }
  4669. else
  4670. {
  4671. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4672. }
  4673. }
  4674. catch (Exception ex)
  4675. {
  4676. return Ok(JsonView(false, ex.Message));
  4677. throw;
  4678. }
  4679. }
  4680. #endregion
  4681. #region 团组经理模块 出入境费用
  4682. /// <summary>
  4683. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4684. /// </summary>
  4685. /// <returns></returns>
  4686. [HttpPost]
  4687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4688. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4689. {
  4690. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4691. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4692. //SetDataInfoView
  4693. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4694. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4695. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4696. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4697. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4698. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4699. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4700. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4701. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4702. return Ok(JsonView(true, "查询成功!", new
  4703. {
  4704. GroupNameData = groupNameData.Data,
  4705. CurrencyData = _CurrencyData,
  4706. WordTypeData = _WordTypeData,
  4707. ExcelTypeData = _ExcelTypeData,
  4708. CurrencyInit = _currencyInfos,
  4709. ViewPermissionData = viewPermissionData
  4710. }));
  4711. }
  4712. /// <summary>
  4713. /// 团组模块 - 出入境费用
  4714. /// 实时汇率 tips
  4715. /// 签证费用 tips
  4716. /// 机票费用 tips
  4717. /// </summary>
  4718. /// <returns></returns>
  4719. [HttpPost]
  4720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4721. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4722. {
  4723. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4724. //默认币种显示
  4725. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4726. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  4727. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4728. return Ok(JsonView(true, "查询成功!", new
  4729. {
  4730. //GroupNameData = groupNameData.Data,
  4731. visaData = visaData.Data,
  4732. airData = airData.Data,
  4733. reteInfos = reteInfos
  4734. }));
  4735. }
  4736. /// <summary>
  4737. /// 团组模块 - 出入境费用 - Info
  4738. /// </summary>
  4739. /// <returns></returns>
  4740. [HttpPost]
  4741. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4743. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4744. {
  4745. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4746. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4747. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4748. }
  4749. /// <summary>
  4750. /// 团组模块 - 出入境费用 - 设置view权限
  4751. /// </summary>
  4752. /// <returns></returns>
  4753. [HttpPost]
  4754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4755. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4756. {
  4757. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4758. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4759. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4760. var permissions = new List<Grp_EnterExitCostPermission>();
  4761. foreach (var userId in dto.UserIds)
  4762. {
  4763. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4764. }
  4765. if (permissions.Any())
  4766. {
  4767. _sqlSugar.BeginTran();
  4768. try
  4769. {
  4770. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4771. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4772. if (result < 1)
  4773. {
  4774. _sqlSugar.RollbackTran();
  4775. return Ok(JsonView(false));
  4776. }
  4777. }
  4778. catch (Exception ex)
  4779. {
  4780. _sqlSugar.RollbackTran();
  4781. return Ok(JsonView(false, ex.Message));
  4782. }
  4783. _sqlSugar.CommitTran();
  4784. return Ok(JsonView(true));
  4785. }
  4786. return Ok(JsonView(false));
  4787. }
  4788. /// <summary>
  4789. /// 团组模块 - 出入境费用 - Add And Update
  4790. /// </summary>
  4791. /// <returns></returns>
  4792. [HttpPost]
  4793. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  4794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4795. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4796. {
  4797. try
  4798. {
  4799. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4800. if (dto.DayOtherPriceData.Any())
  4801. {
  4802. var inserList = dto.DayOtherPriceData
  4803. .Where(x => x.Id == 0)
  4804. .Select(x => new Grp_DayOtherPrice
  4805. {
  4806. Cost = x.Cost,
  4807. Id = x.Id,
  4808. CreateTime = DateTime.Now,
  4809. CreateUserId = dto.UserId,
  4810. Currency = x.Currency,
  4811. Diid = x.DiId,
  4812. Index = x.Index,
  4813. IsDel = 0,
  4814. SetDataId = x.SetDataId,
  4815. SubTotal = x.SubTotal,
  4816. Remark = x.Remark
  4817. })
  4818. .ToList();
  4819. var updateList = dto.DayOtherPriceData
  4820. .Where(x => x.Id != 0)
  4821. .Select(x => new Grp_DayOtherPrice
  4822. {
  4823. Cost = x.Cost,
  4824. Id = x.Id,
  4825. CreateTime = DateTime.Now,
  4826. CreateUserId = dto.UserId,
  4827. Currency = x.Currency,
  4828. Diid = x.DiId,
  4829. Index = x.Index,
  4830. IsDel = 0,
  4831. SetDataId = x.SetDataId,
  4832. SubTotal = x.SubTotal,
  4833. Remark = x.Remark
  4834. })
  4835. .ToList();
  4836. //添加
  4837. _sqlSugar.BeginTran();
  4838. if (inserList.Any())
  4839. {
  4840. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4841. }
  4842. if (updateList.Any())
  4843. {
  4844. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4845. }
  4846. _sqlSugar.CommitTran();
  4847. }
  4848. if (data.Code != 0)
  4849. {
  4850. return Ok(JsonView(false, data.Msg));
  4851. }
  4852. //生成默认文件pdf并且通知人员
  4853. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4854. {
  4855. DiId = dto.DiId,
  4856. ExportType = 1,
  4857. SubTypeId = 1005
  4858. }, "pdf");
  4859. //发送通知
  4860. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4861. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4862. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4863. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4864. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4865. //汇率信息记录
  4866. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4867. return Ok(JsonView(true, data.Msg, data.Data));
  4868. }
  4869. catch (Exception ex)
  4870. {
  4871. return Ok(JsonView(false, ex.Message));
  4872. }
  4873. }
  4874. /// <summary>
  4875. /// 团组模块 - 出入境费用 - Confirm 费用
  4876. /// </summary>
  4877. /// <returns></returns>
  4878. [HttpPost]
  4879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4880. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4881. {
  4882. //TODO:测试完毕需把对应的用户ID更改
  4883. //1、数据表添加字段
  4884. //2、更改字段接口()
  4885. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4886. //3、确认成功 给财务发送消息
  4887. if (_view.Code == 200)
  4888. {
  4889. if (dto.Type == 1)
  4890. {
  4891. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4892. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4893. }
  4894. }
  4895. return Ok(_view);
  4896. }
  4897. /// <summary>
  4898. /// 团组模块 - 出入境费用 - File download
  4899. /// </summary>
  4900. /// <param name="dto"></param>
  4901. /// <returns></returns>
  4902. [HttpPost]
  4903. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  4904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4905. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4906. {
  4907. try
  4908. {
  4909. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4910. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4911. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4912. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4913. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4914. 3 团组成员名单 1 团组成员名单", ""));
  4915. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4916. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4917. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4918. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  4919. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  4920. //数据源
  4921. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4922. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4923. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4924. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4925. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4926. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4927. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4928. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4929. .Select((x, a, b) => new
  4930. {
  4931. x.Index,
  4932. itemName = a.Name,
  4933. CurrencyStr = b.Name,
  4934. x.Cost,
  4935. x.SubTotal,
  4936. x.Remark
  4937. })
  4938. .OrderBy((x) => x.Index)
  4939. .ToList(); //其他款项费用
  4940. var peiceItemCurrencys = new List<string>();
  4941. if (_DayAndCosts.Any())
  4942. {
  4943. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  4944. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  4945. }
  4946. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  4947. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  4948. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  4949. {
  4950. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  4951. }
  4952. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4953. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4954. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4955. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4956. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4957. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4958. .Select((tcl, dc, cc) => new ClientInfo
  4959. {
  4960. LastName = dc.LastName,
  4961. FirstName = dc.FirstName,
  4962. Sex = dc.Sex,
  4963. Birthday = dc.BirthDay,
  4964. Company = cc.CompanyFullName,
  4965. Job = dc.Job
  4966. })
  4967. .ToList();
  4968. foreach (var item in DeleClientList)
  4969. {
  4970. EncryptionProcessor.DecryptProperties(item);
  4971. }
  4972. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4973. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4974. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4975. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4976. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4977. if (dto.ExportType == 1) //明细表
  4978. {
  4979. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4980. {
  4981. //获取模板
  4982. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4983. //载入模板
  4984. Document doc = new Document(tempPath);
  4985. DocumentBuilder builder = new DocumentBuilder(doc);
  4986. //利用键值对存放数据
  4987. Dictionary<string, string> dic = new Dictionary<string, string>();
  4988. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  4989. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  4990. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  4991. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  4992. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  4993. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  4994. //境内费用(其他费用)
  4995. if (_EnterExitCosts.ChoiceOne == 1)
  4996. {
  4997. string row1_1 = "";
  4998. if (_EnterExitCosts.Visa > 0)
  4999. {
  5000. //insidePayTotal += _EnterExitCosts.Visa;
  5001. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5002. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5003. {
  5004. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5005. }
  5006. }
  5007. string row1_2 = "";
  5008. if (_EnterExitCosts.YiMiao > 0)
  5009. {
  5010. //insidePayTotal += _EnterExitCosts.YiMiao;
  5011. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5012. }
  5013. if (_EnterExitCosts.HeSuan > 0)
  5014. {
  5015. //insidePayTotal += _EnterExitCosts.HeSuan;
  5016. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5017. }
  5018. if (_EnterExitCosts.Service > 0)
  5019. {
  5020. //insidePayTotal += _EnterExitCosts.Service;
  5021. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5022. }
  5023. string row1_3 = "";
  5024. if (_EnterExitCosts.Safe > 0)
  5025. {
  5026. //insidePayTotal += _EnterExitCosts.Safe;
  5027. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5028. }
  5029. if (_EnterExitCosts.Ticket > 0)
  5030. {
  5031. //insidePayTotal += _EnterExitCosts.Ticket;
  5032. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5033. }
  5034. string row1 = "";
  5035. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5036. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5037. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5038. row1 += $"备注:{_EnterExitCosts.Remark}";
  5039. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5040. dic.Add("Row1Str", row1);
  5041. }
  5042. string airTotalStr = string.Empty,
  5043. airPriceStr = string.Empty;
  5044. //经济舱
  5045. if (_EnterExitCosts.SumJJC == 1)
  5046. {
  5047. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5048. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5049. }
  5050. //公务舱
  5051. if (_EnterExitCosts.SumGWC == 1)
  5052. {
  5053. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5054. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5055. }
  5056. //头等舱
  5057. if (_EnterExitCosts.SumTDC == 1)
  5058. {
  5059. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5060. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5061. }
  5062. //汇率描述
  5063. string rateStr = "";
  5064. if (peiceItemCurrencyInfos.Any())
  5065. {
  5066. rateStr = "\r\n汇率描述:";
  5067. foreach (var item in peiceItemCurrencyInfos)
  5068. {
  5069. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5070. }
  5071. }
  5072. string twoItemRemark = "备注:";
  5073. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5074. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5075. dic.Add("AirTotalStr", airTotalStr);
  5076. dic.Add("AirPriceStr", airPriceStr);
  5077. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5078. dic.Add("TwoItemRemark", twoItemRemark);
  5079. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5080. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5081. int table1Row = 0,
  5082. table2Row = 0,
  5083. table3Row = 0,
  5084. table4Row = 0,
  5085. table5Row = 0;
  5086. //住宿费
  5087. if (_EnterExitCosts.ChoiceThree == 1)
  5088. {
  5089. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5090. table1Row = dac1.Count;
  5091. #region 填充word表格内容
  5092. for (int i = 0; i < dac1.Count; i++)
  5093. {
  5094. Grp_DayAndCost dac = dac1[i];
  5095. if (dac == null) continue;
  5096. builder.MoveToCell(0, i, 0, 0);
  5097. builder.Write("第" + dac.Days.ToString() + "晚:");
  5098. builder.MoveToCell(0, i, 1, 0);
  5099. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5100. //builder.Write(dac.Place == null ? "" : dac.Place);
  5101. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5102. builder.MoveToCell(0, i, 2, 0);
  5103. builder.Write("费用标准:");
  5104. string curr = "";
  5105. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5106. if (currData != null)
  5107. {
  5108. curr = currData.Name;
  5109. }
  5110. builder.MoveToCell(0, i, 3, 0);
  5111. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5112. builder.MoveToCell(0, i, 4, 0);
  5113. builder.Write("费用小计:");
  5114. builder.MoveToCell(0, i, 5, 0);
  5115. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5116. }
  5117. #endregion
  5118. }
  5119. else dic.Add("SubZS", "0.00");
  5120. //删除多余行
  5121. while (table1.Rows.Count > table1Row)
  5122. {
  5123. table1.Rows.RemoveAt(table1Row);
  5124. }
  5125. //伙食费
  5126. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5127. if (_EnterExitCosts.ChoiceFour == 1)
  5128. {
  5129. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5130. table2Row = dac2.Count;
  5131. #region 填充word表格内容
  5132. for (int i = 0; i < dac2.Count; i++)
  5133. {
  5134. Grp_DayAndCost dac = dac2[i];
  5135. if (dac == null) continue;
  5136. builder.MoveToCell(1, i, 0, 0);
  5137. builder.Write("第" + dac.Days.ToString() + "天:");
  5138. builder.MoveToCell(1, i, 1, 0);
  5139. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5140. builder.MoveToCell(1, i, 2, 0);
  5141. builder.Write("费用标准:");
  5142. string curr = "";
  5143. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5144. if (currData != null)
  5145. {
  5146. curr = currData.Name;
  5147. }
  5148. builder.MoveToCell(1, i, 3, 0);
  5149. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5150. builder.MoveToCell(1, i, 4, 0);
  5151. builder.Write("费用小计:");
  5152. builder.MoveToCell(1, i, 5, 0);
  5153. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5154. }
  5155. #endregion
  5156. }
  5157. else dic.Add("SubHS", "0.00");
  5158. //删除多余行
  5159. while (table2.Rows.Count > table2Row)
  5160. {
  5161. table2.Rows.RemoveAt(table2Row);
  5162. }
  5163. //公杂费
  5164. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5165. if (_EnterExitCosts.ChoiceFive == 1)
  5166. {
  5167. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5168. table3Row = dac3.Count;
  5169. #region 填充word表格内容
  5170. for (int i = 0; i < dac3.Count; i++)
  5171. {
  5172. Grp_DayAndCost dac = dac3[i];
  5173. if (dac == null) continue;
  5174. builder.MoveToCell(2, i, 0, 0);
  5175. builder.Write("第" + dac.Days.ToString() + "天:");
  5176. builder.MoveToCell(2, i, 1, 0);
  5177. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5178. builder.MoveToCell(2, i, 2, 0);
  5179. builder.Write("费用标准:");
  5180. string curr = "";
  5181. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5182. if (currData != null)
  5183. {
  5184. curr = currData.Name;
  5185. }
  5186. builder.MoveToCell(2, i, 3, 0);
  5187. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5188. builder.MoveToCell(2, i, 4, 0);
  5189. builder.Write("费用小计:");
  5190. builder.MoveToCell(2, i, 5, 0);
  5191. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5192. }
  5193. //删除多余行
  5194. while (table3.Rows.Count > table3Row)
  5195. {
  5196. table3.Rows.RemoveAt(table3Row);
  5197. }
  5198. #endregion
  5199. }
  5200. else dic.Add("SubGZF", "0.00");
  5201. //删除多余行
  5202. while (table3.Rows.Count > table3Row)
  5203. {
  5204. table3.Rows.RemoveAt(table3Row);
  5205. }
  5206. //培训费
  5207. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5208. if (_EnterExitCosts.ChoiceSix == 1)
  5209. {
  5210. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5211. dic.Add("SubPX", pxStr);
  5212. table4Row = dac4.Count;
  5213. #region 填充word表格内容
  5214. for (int i = 0; i < dac4.Count; i++)
  5215. {
  5216. Grp_DayAndCost dac = dac4[i];
  5217. if (dac == null) continue;
  5218. builder.MoveToCell(3, i, 0, 0);
  5219. builder.Write("第" + dac.Days.ToString() + "天:");
  5220. builder.MoveToCell(3, i, 1, 0);
  5221. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5222. builder.MoveToCell(3, i, 2, 0);
  5223. builder.Write("费用标准:");
  5224. string curr = "";
  5225. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5226. if (currData != null)
  5227. {
  5228. curr = currData.Name;
  5229. }
  5230. builder.MoveToCell(3, i, 3, 0);
  5231. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5232. builder.MoveToCell(3, i, 4, 0);
  5233. builder.Write("费用小计:");
  5234. builder.MoveToCell(3, i, 5, 0);
  5235. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5236. }
  5237. #endregion
  5238. }
  5239. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5240. //删除多余行
  5241. while (table4.Rows.Count > table4Row)
  5242. {
  5243. table4.Rows.RemoveAt(table4Row);
  5244. }
  5245. //其他费用
  5246. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5247. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5248. {
  5249. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5250. dic.Add("titleQi", qtStr);
  5251. table5Row = dac5.Count;
  5252. #region 填充word表格内容
  5253. for (int i = 0; i < dac5.Count; i++)
  5254. {
  5255. var dac = dac5[i];
  5256. if (dac == null) continue;
  5257. builder.MoveToCell(4, i, 0, 0);
  5258. builder.Write("第" + dac.Index.ToString() + "项:");
  5259. builder.MoveToCell(4, i, 1, 0);
  5260. builder.Write(dac.itemName);
  5261. builder.MoveToCell(4, i, 2, 0);
  5262. builder.Write("费用标准:");
  5263. builder.MoveToCell(4, i, 3, 0);
  5264. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5265. builder.MoveToCell(4, i, 4, 0);
  5266. builder.Write("费用小计:");
  5267. builder.MoveToCell(4, i, 5, 0);
  5268. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5269. builder.MoveToCell(4, i, 6, 0);
  5270. builder.Write("备注:");
  5271. builder.MoveToCell(4, i, 7, 0);
  5272. builder.Write(dac.Remark);
  5273. }
  5274. #endregion
  5275. }
  5276. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5277. //删除多余行
  5278. while (table5.Rows.Count > table5Row)
  5279. {
  5280. table5.Rows.RemoveAt(table5Row);
  5281. }
  5282. //加上其他费用
  5283. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5284. decimal subJJC = 0.00M,
  5285. subGWC = 0.00M,
  5286. subTDC = 0.00M;
  5287. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5288. string totalLabel = string.Format("全部费用总计:");
  5289. //经济舱
  5290. if (_EnterExitCosts.SumJJC == 1)
  5291. {
  5292. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5293. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5294. }
  5295. //公务舱
  5296. if (_EnterExitCosts.SumGWC == 1) {
  5297. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5298. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5299. }
  5300. //头等舱
  5301. if (_EnterExitCosts.SumTDC == 1)
  5302. {
  5303. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5304. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5305. }
  5306. //TotalLabel
  5307. dic.Add("TotalLabel", totalLabel);
  5308. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5309. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5310. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5311. #region 填充word模板书签内容
  5312. foreach (var key in dic.Keys)
  5313. {
  5314. Bookmark bookmark = doc.Range.Bookmarks[key];
  5315. if (bookmark != null)
  5316. {
  5317. builder.MoveToBookmark(key);
  5318. builder.Write(dic[key]);
  5319. }
  5320. }
  5321. #endregion
  5322. #region 设置页眉
  5323. string userLabel = string.Empty;
  5324. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5325. if (currUserInfo != null)
  5326. {
  5327. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5328. if (userInfo != null)
  5329. {
  5330. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5331. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5332. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5333. }
  5334. }
  5335. //设置页脚
  5336. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5337. #endregion
  5338. //文件名
  5339. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5340. AsposeHelper.removewatermark_v2180();
  5341. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5342. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5343. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5344. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5345. }
  5346. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5347. {
  5348. //获取模板
  5349. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5350. //载入模板
  5351. Document doc = new Document(tempPath);
  5352. DocumentBuilder builder = new DocumentBuilder(doc);
  5353. Dictionary<string, string> dic = new Dictionary<string, string>();
  5354. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5355. {
  5356. List<string> list = new List<string>();
  5357. try
  5358. {
  5359. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5360. foreach (var item in spilitArr)
  5361. {
  5362. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5363. var depCode = spDotandEmpty[2].Substring(0, 3);
  5364. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5365. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5366. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5367. list.Add(depName);
  5368. list.Add(arrName);
  5369. }
  5370. list = list.Distinct().ToList();
  5371. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5372. }
  5373. catch (Exception)
  5374. {
  5375. dic.Add("ReturnCode", "行程录入不正确!");
  5376. }
  5377. }
  5378. else
  5379. {
  5380. dic.Add("ReturnCode", "未录入行程!");
  5381. }
  5382. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5383. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5384. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5385. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5386. {
  5387. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5388. dic.Add("Day", sp.Days.ToString());
  5389. }
  5390. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5391. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5392. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5393. //dic.Add("Names", Names);
  5394. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5395. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5396. decimal dac1totalPrice = 0.00M;
  5397. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5398. foreach (var dac in dac1)
  5399. {
  5400. if (dac.SubTotal == 0.00M)
  5401. {
  5402. continue;
  5403. }
  5404. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5405. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5406. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5407. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5408. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5409. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5410. builder.Write(currency);//币种
  5411. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5412. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5413. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5414. builder.Write("");//人数
  5415. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5416. builder.Write("");//天数
  5417. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5418. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5419. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5420. decimal rate = 0.00M;
  5421. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5422. builder.Write(rate.ToString("#0.0000"));//汇率
  5423. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5424. decimal rbmPrice = dac.SubTotal;
  5425. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5426. accommodationStartIndex++;
  5427. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5428. }
  5429. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5430. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5431. {
  5432. table1.Rows.RemoveAt(i - 1);
  5433. foodandotherStartIndex--;
  5434. }
  5435. if (dac2.Count == dac3.Count)//国家 币种 金额
  5436. {
  5437. for (int i = 0; i < dac2.Count; i++)
  5438. {
  5439. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5440. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5441. }
  5442. }
  5443. decimal dac2totalPrice = 0.00M;
  5444. foreach (var dac in dac2)
  5445. {
  5446. if (dac.SubTotal == 0)
  5447. {
  5448. continue;
  5449. }
  5450. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5451. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5452. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5453. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5454. builder.Write(currency);//币种
  5455. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5456. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5457. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5458. builder.Write("");//人数
  5459. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5460. builder.Write("");//天数
  5461. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5462. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5463. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5464. decimal rate = 0.00M;
  5465. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5466. builder.Write(rate.ToString("#0.0000"));//汇率
  5467. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5468. decimal rbmPrice = dac.SubTotal;
  5469. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5470. foodandotherStartIndex++;
  5471. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5472. }
  5473. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5474. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5475. {
  5476. table1.Rows.RemoveAt(i - 1);
  5477. }
  5478. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5479. string otherFeeStr = "";
  5480. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5481. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5482. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5483. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5484. foreach (var otherInfo in dac5)
  5485. {
  5486. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5487. }
  5488. #endregion
  5489. if (otherFeeStr.Length > 0)
  5490. {
  5491. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5492. otherFeeStr = $"({otherFeeStr})";
  5493. dic.Add("OtherFeeStr", otherFeeStr);
  5494. }
  5495. //总计
  5496. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5497. //国际旅费
  5498. string outsideAir = string.Empty;
  5499. string allPriceAir = string.Empty;
  5500. if (_EnterExitCosts.SumJJC == 1)
  5501. {
  5502. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5503. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5504. }
  5505. if (_EnterExitCosts.SumGWC == 1)
  5506. {
  5507. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5508. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5509. }
  5510. if (_EnterExitCosts.SumTDC == 1)
  5511. {
  5512. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5513. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5514. }
  5515. dic.Add("InTravelPrice", $"({outsideAir})");
  5516. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5517. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5518. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5519. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5520. foreach (var key in dic.Keys)
  5521. {
  5522. builder.MoveToBookmark(key);
  5523. builder.Write(dic[key]);
  5524. }
  5525. //模板文件名
  5526. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5527. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5528. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5529. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5530. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5531. }
  5532. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5533. {
  5534. //获取模板
  5535. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5536. //载入模板
  5537. WorkbookDesigner designer = new WorkbookDesigner();
  5538. designer.Workbook = new Workbook(tempPath);
  5539. Dictionary<string, string> dic = new Dictionary<string, string>();
  5540. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5541. {
  5542. List<string> list = new List<string>();
  5543. try
  5544. {
  5545. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5546. foreach (var item in spilitArr)
  5547. {
  5548. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5549. var depCode = spDotandEmpty[2].Substring(0, 3);
  5550. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5551. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5552. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5553. list.Add(depName);
  5554. list.Add(arrName);
  5555. }
  5556. list = list.Distinct().ToList();
  5557. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5558. }
  5559. catch (Exception)
  5560. {
  5561. dic.Add("ReturnCode", "行程录入不正确!");
  5562. }
  5563. }
  5564. else
  5565. {
  5566. dic.Add("ReturnCode", "未录入行程!");
  5567. }
  5568. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5569. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5570. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5571. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5572. {
  5573. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5574. dic.Add("Day", sp.Days.ToString());
  5575. }
  5576. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5577. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5578. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5579. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5580. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5581. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5582. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5583. designer.SetDataSource("Name", Names);
  5584. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5585. designer.SetDataSource("Day", dic["Day"] + "天");
  5586. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5587. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5588. int startIndex = 10;
  5589. const int startIndexcopy = 10;
  5590. if (dac2.Count == dac3.Count)//国家 币种 金额
  5591. {
  5592. for (int i = 0; i < dac2.Count; i++)
  5593. {
  5594. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5595. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5596. }
  5597. }
  5598. DataTable dtdac1 = new DataTable();
  5599. List<string> place = new List<string>();
  5600. dtdac1.Columns.AddRange(new DataColumn[] {
  5601. new DataColumn(){ ColumnName = "city"},
  5602. new DataColumn(){ ColumnName = "curr"},
  5603. new DataColumn(){ ColumnName = "criterion"},
  5604. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5605. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5606. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5607. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5608. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5609. });
  5610. DataTable dtdac2 = new DataTable();
  5611. dtdac2.Columns.AddRange(new DataColumn[] {
  5612. new DataColumn(){ ColumnName = "city"},
  5613. new DataColumn(){ ColumnName = "curr"},
  5614. new DataColumn(){ ColumnName = "criterion"},
  5615. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5616. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5617. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5618. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5619. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5620. });
  5621. dtdac1.TableName = "tb1";
  5622. dtdac2.TableName = "tb2";
  5623. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5624. foreach (var item in dac1)
  5625. {
  5626. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5627. if (place.Contains(item.Place))
  5628. {
  5629. continue;
  5630. }
  5631. DataRow row = dtdac1.NewRow();
  5632. row["city"] = item.Place;
  5633. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5634. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5635. row["curr"] = currency;
  5636. row["rate"] = rate.ToString("#0.0000");
  5637. row["criterion"] = item.Cost.ToString("#0.00");
  5638. row["number"] = 1;
  5639. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5640. //row["costRMB"] = rbmPrice;
  5641. dtdac1.Rows.Add(row);
  5642. place.Add(item.Place);
  5643. }
  5644. place = new List<string>();
  5645. foreach (var item in dac2)
  5646. {
  5647. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5648. if (place.Contains(item.Place))
  5649. {
  5650. continue;
  5651. }
  5652. DataRow row = dtdac2.NewRow();
  5653. row["city"] = item.Place;
  5654. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5655. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5656. row["curr"] = currency;
  5657. row["rate"] = rate.ToString("#0.0000");
  5658. row["criterion"] = item.Cost.ToString("#0.00");
  5659. row["number"] = 1;
  5660. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5661. //row["cost"] = item.SubTotal;
  5662. //row["costRMB"] = rbmPrice;
  5663. dtdac2.Rows.Add(row);
  5664. place.Add(item.Place);
  5665. //dac2totalPrice += rbmPrice;
  5666. }
  5667. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5668. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5669. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5670. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5671. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5672. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5673. string cell4Str1 = string.Empty;
  5674. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5675. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5676. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5677. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5678. string cellStr = $" 5.其他费用(";
  5679. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5680. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5681. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5682. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5683. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5684. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5685. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5686. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5687. foreach (var otherInfo in dac5)
  5688. {
  5689. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5690. }
  5691. #endregion
  5692. if (cellStr.Length > 8)
  5693. {
  5694. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5695. }
  5696. cellStr += ")";
  5697. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5698. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5699. decimal pxFee = dac4.Sum(it => it.Cost);
  5700. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5701. string celllastStr1 = "";
  5702. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5703. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5704. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5705. celllastStr1 += $",国际旅费 元";
  5706. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5707. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5708. designer.SetDataSource("cell4Str", cell4Str);
  5709. designer.SetDataSource("cellStr", cellStr);
  5710. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5711. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5712. designer.SetDataSource("celllastStr", celllastStr);
  5713. Workbook wb = designer.Workbook;
  5714. var sheet = wb.Worksheets[0];
  5715. //绑定datatable数据集
  5716. designer.SetDataSource(dtdac1);
  5717. designer.SetDataSource(dtdac2);
  5718. designer.Process();
  5719. var rowStart = dtdac1.Rows.Count;
  5720. while (rowStart > 0)
  5721. {
  5722. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5723. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5724. startIndex++;
  5725. rowStart--;
  5726. }
  5727. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5728. startIndex += 1; //总计行
  5729. rowStart = dtdac2.Rows.Count;
  5730. while (rowStart > 0)
  5731. {
  5732. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5733. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5734. startIndex++;
  5735. rowStart--;
  5736. }
  5737. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5738. wb.CalculateFormula(true);
  5739. //模板文件名
  5740. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5741. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5742. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5743. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5744. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5745. }
  5746. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5747. {
  5748. //获取模板
  5749. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5750. //载入模板
  5751. Document doc = new Document(tempPath);
  5752. DocumentBuilder builder = new DocumentBuilder(doc);
  5753. Dictionary<string, string> dic = new Dictionary<string, string>();
  5754. dic.Add("GroupName", _DelegationInfo.TeamName);
  5755. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5756. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5757. string missionLeaderJob = "";//负责人job
  5758. //int groupNumber = 0; //团人数
  5759. if (DeleClientList.Count > 0)
  5760. {
  5761. missionLeader = DeleClientList[0]?.Name ?? "";
  5762. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5763. }
  5764. dic.Add("MissionLeader", missionLeader); //团负责人
  5765. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5766. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5767. #region MyRegion
  5768. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5769. //{
  5770. // List<string> list = new List<string>();
  5771. // try
  5772. // {
  5773. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5774. // foreach (var item in spilitArr)
  5775. // {
  5776. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5777. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5778. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5779. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5780. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5781. // list.Add(depName);
  5782. // list.Add(arrName);
  5783. // }
  5784. // list = list.Distinct().ToList();
  5785. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5786. // }
  5787. // catch (Exception)
  5788. // {
  5789. // dic.Add("ReturnCode", "行程录入不正确!");
  5790. // }
  5791. //}
  5792. //else
  5793. //{
  5794. // dic.Add("ReturnCode", "未录入行程!");
  5795. //}
  5796. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5797. dic.Add("ReturnCode", string.Join("、", countrys));
  5798. #endregion
  5799. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5800. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5801. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5802. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5803. //{
  5804. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5805. // dic.Add("Day", sp.Days.ToString());
  5806. //}
  5807. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5808. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5809. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5810. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5811. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5812. //培训人员名单
  5813. int cultivateRowIndex = 7;
  5814. foreach (var item in DeleClientList)
  5815. {
  5816. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5817. builder.Write(item.Name);
  5818. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5819. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5820. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5821. string birthDay = "";
  5822. if (item.Birthday != null)
  5823. {
  5824. DateTime dt = Convert.ToDateTime(item.Birthday);
  5825. birthDay = $"{dt.Year}.{dt.Month}";
  5826. }
  5827. builder.Write(birthDay);
  5828. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5829. builder.Write(item.Company);
  5830. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5831. builder.Write(item.Job);
  5832. cultivateRowIndex++;
  5833. }
  5834. //删除多余行
  5835. //cultivateRowIndex -= 2;
  5836. int delRows = 10 + 7 - cultivateRowIndex;
  5837. if (delRows > 0)
  5838. {
  5839. for (int i = 0; i < delRows; i++)
  5840. {
  5841. table1.Rows.RemoveAt(cultivateRowIndex);
  5842. //cultivateRowIndex++;
  5843. }
  5844. }
  5845. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5846. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5847. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5848. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5849. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5850. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5851. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5852. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5853. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5854. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5855. //其他费用
  5856. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5857. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5858. //其他费用合计
  5859. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5860. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5861. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5862. //公务舱合计
  5863. //国际旅费
  5864. //string outsideJJ = "";
  5865. //string allPriceJJ = "";
  5866. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5867. {
  5868. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5869. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5870. }
  5871. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5872. {
  5873. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5874. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5875. }
  5876. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5877. {
  5878. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5879. dic.Add("AirFeeTotal", airFeeTotalStr);
  5880. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5881. dic.Add("FeeTotal", feeTotalStr);
  5882. }
  5883. foreach (var key in dic.Keys)
  5884. {
  5885. builder.MoveToBookmark(key);
  5886. builder.Write(dic[key]);
  5887. }
  5888. //模板文件名
  5889. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5890. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5891. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5892. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5893. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5894. }
  5895. }
  5896. else if (dto.ExportType == 2) //表格
  5897. {
  5898. //利用键值对存放数据
  5899. Dictionary<string, string> dic = new Dictionary<string, string>();
  5900. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5901. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5902. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5903. dic.Add("Day", sp.Days.ToString());
  5904. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5905. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5906. {
  5907. //获取模板
  5908. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5909. //载入模板
  5910. Document doc = new Document(tempPath);
  5911. DocumentBuilder builder = new DocumentBuilder(doc);
  5912. dic.Add("TeamName", _DelegationInfo.TeamName);
  5913. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5914. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5915. string missionLeaderName = "",
  5916. missionLeaderJob = "";
  5917. if (DeleClientList.Count > 0)
  5918. {
  5919. missionLeaderName = DeleClientList[0].Name;
  5920. missionLeaderJob = DeleClientList[0].Job;
  5921. }
  5922. dic.Add("MissionLeaderName", missionLeaderName);
  5923. dic.Add("MissionLeaderJob", missionLeaderJob);
  5924. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5925. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5926. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5927. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5928. int rowCount = 10;//总人数行
  5929. int startRowIndex = 7; //起始行
  5930. for (int i = 0; i < DeleClientList.Count; i++)
  5931. {
  5932. builder.MoveToCell(0, startRowIndex, 0, 0);
  5933. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5934. builder.MoveToCell(0, startRowIndex, 1, 0);
  5935. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5936. builder.Write(sex);//性别
  5937. builder.MoveToCell(0, startRowIndex, 2, 0);
  5938. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5939. builder.MoveToCell(0, startRowIndex, 3, 0);
  5940. builder.Write(DeleClientList[i].Company);//工作单位
  5941. builder.MoveToCell(0, startRowIndex, 4, 0);
  5942. builder.Write(DeleClientList[i].Job);//职务及级别
  5943. builder.MoveToCell(0, startRowIndex, 5, 0);
  5944. builder.Write("");//人员属性
  5945. builder.MoveToCell(0, startRowIndex, 6, 0);
  5946. builder.Write("");//上次出国时间
  5947. startRowIndex++;
  5948. }
  5949. int nullRow = rowCount - DeleClientList.Count;//空行
  5950. for (int i = 0; i < nullRow; i++)
  5951. {
  5952. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5953. }
  5954. foreach (var key in dic.Keys)
  5955. {
  5956. builder.MoveToBookmark(key);
  5957. builder.Write(dic[key]);
  5958. }
  5959. //模板文件名
  5960. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5961. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5962. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5963. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5964. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5965. }
  5966. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5967. {
  5968. //获取模板
  5969. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5970. //载入模板
  5971. Document doc = new Document(tempPath);
  5972. DocumentBuilder builder = new DocumentBuilder(doc);
  5973. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5974. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5975. dic.Add("Names", Names);
  5976. int accommodationRows = 12;
  5977. //int foodandotherRows = 12;
  5978. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5979. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5980. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5981. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5982. int accommodationStartIndex = 6;
  5983. decimal dac1totalPrice = 0.00M;
  5984. foreach (var dac in dac1)
  5985. {
  5986. if (dac.SubTotal == 0)
  5987. {
  5988. continue;
  5989. }
  5990. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5991. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5992. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5993. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5994. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5995. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5996. builder.Write(currency);//币种
  5997. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5998. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5999. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6000. builder.Write("");//人数
  6001. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6002. builder.Write("");//天数
  6003. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6004. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6005. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6006. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6007. builder.Write(rate.ToString("#0.0000"));//汇率
  6008. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6009. decimal rbmPrice = rate * dac.SubTotal;
  6010. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6011. accommodationStartIndex++;
  6012. dac1totalPrice += rbmPrice;
  6013. }
  6014. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6015. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6016. builder.Write("小计");
  6017. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6018. builder.Write(dac1totalPrice.ToString("#0.00"));
  6019. accommodationStartIndex++;
  6020. int nullRow = accommodationRows - dac1.Count;
  6021. //删除空行
  6022. //if (nullRow > 0)
  6023. //{
  6024. // int rowIndex = accommodationStartIndex;
  6025. // for (int i = 0; i < nullRow; i++)
  6026. // {
  6027. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6028. // row.Remove();
  6029. // rowIndex++;
  6030. // }
  6031. //}
  6032. if (dac2.Count == dac3.Count)//国家 币种 金额
  6033. {
  6034. for (int i = 0; i < dac2.Count; i++)
  6035. {
  6036. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6037. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6038. }
  6039. }
  6040. int foodandotherStartIndex = 19;//
  6041. decimal dac2totalPrice = 0.00M;
  6042. foreach (var dac in dac2)
  6043. {
  6044. if (dac.SubTotal == 0)
  6045. {
  6046. continue;
  6047. }
  6048. //foodandotherStartIndex = 12;
  6049. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6050. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6051. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6052. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6053. builder.Write(currency);//币种
  6054. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6055. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6056. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6057. builder.Write("");//人数
  6058. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6059. builder.Write("");//天数
  6060. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6061. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6062. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6063. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6064. builder.Write(rate.ToString("#0.0000"));//汇率
  6065. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6066. decimal rbmPrice = rate * dac.SubTotal;
  6067. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6068. foodandotherStartIndex++;
  6069. dac2totalPrice += rbmPrice;
  6070. }
  6071. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6072. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6073. //删除空行
  6074. //if (dac2.Count < foodandotherRows)
  6075. //{
  6076. // while (table2.Rows.Count > dac2.Count)
  6077. // {
  6078. // table2.Rows.RemoveAt(dac2.Count);
  6079. // }
  6080. //}
  6081. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6082. string otherFeeStr = "";
  6083. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6084. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6085. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6086. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6087. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6088. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6089. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6090. foreach (var otherInfo in dac5)
  6091. {
  6092. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6093. }
  6094. #endregion
  6095. if (otherFeeStr.Length > 0)
  6096. {
  6097. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6098. otherFeeStr = $"({otherFeeStr})";
  6099. dic.Add("OtherFeeStr", otherFeeStr);
  6100. }
  6101. foreach (var key in dic.Keys)
  6102. {
  6103. builder.MoveToBookmark(key);
  6104. builder.Write(dic[key]);
  6105. }
  6106. //模板文件名
  6107. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6108. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6109. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6110. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6111. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6112. }
  6113. }
  6114. else if (dto.ExportType == 3)
  6115. {
  6116. if (dto.SubTypeId == 1) //团组成员名单
  6117. {
  6118. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6119. //获取模板
  6120. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6121. //载入模板
  6122. Document doc = new Document(tempPath);
  6123. DocumentBuilder builder = new DocumentBuilder(doc);
  6124. //获取word里所有表格
  6125. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6126. //获取所填表格的序数
  6127. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6128. var rowStart = tableOne.Rows[0]; //获取第1行
  6129. //循环赋值
  6130. for (int i = 0; i < DeleClientList.Count; i++)
  6131. {
  6132. builder.MoveToCell(0, i + 1, 0, 0);
  6133. builder.Write(DeleClientList[i].Name);
  6134. builder.MoveToCell(0, i + 1, 1, 0);
  6135. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6136. builder.Write(sex);
  6137. builder.MoveToCell(0, i + 1, 2, 0);
  6138. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6139. builder.MoveToCell(0, i + 1, 3, 0);
  6140. builder.Write(DeleClientList[i].Company);
  6141. builder.MoveToCell(0, i + 1, 4, 0);
  6142. builder.Write(DeleClientList[i].Job);
  6143. }
  6144. //删除多余行
  6145. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6146. {
  6147. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6148. }
  6149. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6150. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6151. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6152. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6153. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6154. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6155. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6156. }
  6157. }
  6158. return Ok(JsonView(400, "操作失败!", ""));
  6159. }
  6160. catch (Exception ex)
  6161. {
  6162. return Ok(JsonView(400, ex.Message, ""));
  6163. }
  6164. }
  6165. /// <summary>
  6166. /// 获取三公费用标准city
  6167. /// </summary>
  6168. /// <param name="placeData"></param>
  6169. /// <param name="nationalTravelFeeId"></param>
  6170. /// <returns></returns>
  6171. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6172. {
  6173. string _city = string.Empty;
  6174. if (placeData.Count < 1) return _city;
  6175. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6176. if (data == null) return _city;
  6177. string country = data.Country;
  6178. string city = data.City;
  6179. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6180. else _city = city;
  6181. return _city;
  6182. }
  6183. /// <summary>
  6184. /// 团组模块 - 出入境费用 - 明细表导出
  6185. /// </summary>
  6186. /// <returns></returns>
  6187. [HttpPost]
  6188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6189. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6190. {
  6191. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6192. if (data.Code != 0)
  6193. {
  6194. return Ok(JsonView(false, data.Msg));
  6195. }
  6196. return Ok(JsonView(true, data.Msg, data.Data));
  6197. }
  6198. /// <summary>
  6199. /// 团组模块 - 出入境费用 - 一键清空
  6200. /// </summary>
  6201. /// <returns></returns>
  6202. [HttpPost]
  6203. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6205. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6206. {
  6207. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6208. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6209. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6210. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6211. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6212. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6213. .SetColumns(x => new Grp_DayOtherPrice
  6214. {
  6215. IsDel = 1,
  6216. DeleteUserId = dto.UserId,
  6217. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6218. })
  6219. .ExecuteCommandAsync();
  6220. if (_view.Code == 0)
  6221. {
  6222. return Ok(JsonView(true, "操作成功"));
  6223. }
  6224. return Ok(JsonView(false, "操作失败"));
  6225. }
  6226. /// <summary>
  6227. /// 团组模块 - 出入境费用 - 子项删除
  6228. /// </summary>
  6229. /// <returns></returns>
  6230. [HttpPost]
  6231. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6233. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6234. {
  6235. try
  6236. {
  6237. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6238. if (data.Code != 0)
  6239. {
  6240. return Ok(JsonView(false, data.Msg));
  6241. }
  6242. return Ok(JsonView(true, "操作成功!", data.Data));
  6243. }
  6244. catch (Exception ex)
  6245. {
  6246. return Ok(JsonView(false, ex.Message));
  6247. }
  6248. }
  6249. /// <summary>
  6250. /// 删除三公其他费用
  6251. /// </summary>
  6252. /// <param name="dto"></param>
  6253. /// <returns></returns>
  6254. [HttpPost]
  6255. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6256. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6257. {
  6258. var jw = JsonView(false, "删除失败!");
  6259. var data = new Grp_DayOtherPrice()
  6260. {
  6261. Id = dto.Id,
  6262. IsDel = 1,
  6263. DeleteUserId = dto.DeleteUserId,
  6264. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6265. };
  6266. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6267. if (del > 0)
  6268. {
  6269. jw.Code = 200;
  6270. jw.Msg = "删除成功!";
  6271. }
  6272. return Ok(jw);
  6273. }
  6274. /// <summary>
  6275. /// 团组模块 - 出入境国家费用标准 List
  6276. /// </summary>
  6277. /// <returns></returns>
  6278. [HttpPost]
  6279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6280. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6281. {
  6282. try
  6283. {
  6284. Stopwatch sw = new Stopwatch();
  6285. sw.Start();
  6286. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6287. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6288. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6289. Where gntf.Isdel = 0");
  6290. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6291. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6292. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6293. //foreach (var item in nationalTravel)
  6294. //{
  6295. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6296. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6297. // if (otherData != null)
  6298. // {
  6299. // cityData.Remove(otherData);
  6300. // cityData.Add(otherData);
  6301. // }
  6302. // nationalTravelFeeData1.Add(new
  6303. // {
  6304. // Country = item.Country,
  6305. // CityData = cityData
  6306. // });
  6307. //}
  6308. sw.Stop();
  6309. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6310. }
  6311. catch (Exception ex)
  6312. {
  6313. return Ok(JsonView(false, ex.Message));
  6314. throw;
  6315. }
  6316. }
  6317. /// <summary>
  6318. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6319. /// </summary>
  6320. /// <returns></returns>
  6321. [HttpPost]
  6322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6323. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6324. {
  6325. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6326. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6327. List<string> countryData = new List<string>();
  6328. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6329. countryData = countryData.Distinct().ToList();
  6330. List<dynamic> dataSource = new List<dynamic>();
  6331. foreach (var item in countryData)
  6332. {
  6333. var cityData1 = new List<string>();
  6334. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6335. var countryData2 = new
  6336. {
  6337. CountryName = item,
  6338. CityData = cityData1
  6339. };
  6340. dataSource.Add(countryData2);
  6341. }
  6342. return Ok(JsonView(true, "查询成功!", dataSource));
  6343. }
  6344. /// <summary>
  6345. /// 团组模块 - 出入境国家费用标准 Page List
  6346. /// </summary>
  6347. /// <returns></returns>
  6348. [HttpPost]
  6349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6350. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6351. {
  6352. int portId = dto.PortType;
  6353. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6354. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6355. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6356. string whereSql = string.Empty;
  6357. if (!string.IsNullOrEmpty(dto.Country))
  6358. {
  6359. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6360. }
  6361. if (!string.IsNullOrEmpty(dto.City))
  6362. {
  6363. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6364. }
  6365. string pageSql = string.Format(@"Select * From (
  6366. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6367. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6368. From Grp_NationalTravelFee gntf
  6369. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6370. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6371. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6372. RefAsync<int> total = 0;
  6373. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6374. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6375. }
  6376. /// <summary>
  6377. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6378. /// </summary>
  6379. /// <returns></returns>
  6380. [HttpPost]
  6381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6382. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6383. {
  6384. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6385. int portId = dto.PortType;
  6386. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6387. string whereSql = string.Empty;
  6388. if (!string.IsNullOrEmpty(dto.Country))
  6389. {
  6390. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6391. }
  6392. if (!string.IsNullOrEmpty(dto.City))
  6393. {
  6394. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6395. }
  6396. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6397. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6398. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6399. From Grp_NationalTravelFee gntf
  6400. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6401. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6402. Where gntf.Isdel = 0 {0} ", whereSql);
  6403. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6404. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6405. }
  6406. /// <summary>
  6407. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6408. /// </summary>
  6409. /// <returns></returns>
  6410. [HttpPost]
  6411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6412. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6413. {
  6414. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6415. if (data.Code != 0)
  6416. {
  6417. return Ok(JsonView(false, data.Msg));
  6418. }
  6419. return Ok(JsonView(true, "操作成功!", data.Data));
  6420. }
  6421. /// <summary>
  6422. /// 团组模块 - 出入境国家费用标准 - Del
  6423. /// </summary>
  6424. /// <returns></returns>
  6425. [HttpPost]
  6426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6427. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6428. {
  6429. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6430. {
  6431. Id = dto.Id,
  6432. DeleteUserId = dto.DeleteUserId,
  6433. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6434. IsDel = 1
  6435. };
  6436. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6437. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6438. .WhereColumns(it => new { it.Id })
  6439. .ExecuteCommandAsync();
  6440. if (delStatus <= 0)
  6441. {
  6442. return Ok(JsonView(false, "删除失败!"));
  6443. }
  6444. return Ok(JsonView(true, "操作成功!"));
  6445. }
  6446. /// <summary>
  6447. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6448. /// 注:Get 请求Headers 加 Token
  6449. /// </summary>
  6450. /// <param name="groupId"></param>
  6451. /// <returns></returns>
  6452. [HttpGet("{groupId}")]
  6453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6454. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6455. {
  6456. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6457. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6458. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6459. data.ForEach(x =>
  6460. {
  6461. x.CreateUserId = _currUserInfo.UserId;
  6462. });
  6463. if (data.Any())
  6464. {
  6465. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6466. if (add > 0)
  6467. {
  6468. return Ok(JsonView(true, "操作成功!"));
  6469. }
  6470. }
  6471. return Ok(JsonView(false, "未操作!"));
  6472. }
  6473. #endregion
  6474. #region 团组经理模块 出入境费用-草稿
  6475. /// <summary>
  6476. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6477. /// </summary>
  6478. /// <returns></returns>
  6479. [HttpPost]
  6480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6481. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6482. {
  6483. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6484. .Where(x => x.IsDel == 0)
  6485. .OrderByDescending(x => x.CreateTime)
  6486. .Select(x => new { x.Id, x.DraftName })
  6487. .ToListAsync();
  6488. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6489. //SetDataInfoView
  6490. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6491. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6492. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6493. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6494. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6495. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6496. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6497. //默认币种显示
  6498. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6499. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6500. return Ok(JsonView(true, "查询成功!", new
  6501. {
  6502. DraftNameDatas = draftNameDatas,
  6503. CurrencyData = _CurrencyData,
  6504. WordTypeData = _WordTypeData,
  6505. ExcelTypeData = _ExcelTypeData,
  6506. CurrencyInit = _currencyInfos,
  6507. ViewPermissionData = viewPermissionData
  6508. }));
  6509. }
  6510. /// <summary>
  6511. /// 团组模块 - 出入境费用-草稿
  6512. /// 实时汇率 tips
  6513. /// 机票费用 tips
  6514. /// </summary>
  6515. /// <returns></returns>
  6516. [HttpPost]
  6517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6518. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6519. {
  6520. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6521. return Ok(JsonView(true, "查询成功!", new
  6522. {
  6523. //GroupNameData = groupNameData.Data,
  6524. //visaData = visaData.Data,
  6525. //airData = airData.Data,
  6526. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6527. }));
  6528. }
  6529. /// <summary>
  6530. /// 团组模块 - 出入境费用-草稿
  6531. /// 签证费用 tips
  6532. /// </summary>
  6533. /// <returns></returns>
  6534. [HttpPost]
  6535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6536. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6537. {
  6538. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6539. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6540. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6541. .Select(x => x.NationalTravelFeeId)
  6542. .Distinct()
  6543. .ToListAsync();
  6544. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6545. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6546. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6547. .Select(x => x.Country)
  6548. .Distinct()
  6549. .ToArrayAsync();
  6550. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6551. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6552. return Ok(JsonView(true, "查询成功!", new
  6553. {
  6554. totalAmt = totalAmt,
  6555. remark = remark
  6556. }));
  6557. }
  6558. /// <summary>
  6559. /// 团组模块 - 出入境费用-草稿 - Info
  6560. /// </summary>
  6561. /// <returns></returns>
  6562. [HttpPost]
  6563. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6565. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6566. {
  6567. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6568. }
  6569. /// <summary>
  6570. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6571. /// </summary>
  6572. /// <returns></returns>
  6573. [HttpPost]
  6574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6575. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6576. {
  6577. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6578. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6579. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6580. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6581. foreach (var userId in dto.UserIds)
  6582. {
  6583. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6584. }
  6585. if (permissions.Any())
  6586. {
  6587. _sqlSugar.BeginTran();
  6588. try
  6589. {
  6590. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6591. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6592. if (result < 1)
  6593. {
  6594. _sqlSugar.RollbackTran();
  6595. return Ok(JsonView(false));
  6596. }
  6597. }
  6598. catch (Exception ex)
  6599. {
  6600. _sqlSugar.RollbackTran();
  6601. return Ok(JsonView(false, ex.Message));
  6602. }
  6603. _sqlSugar.CommitTran();
  6604. return Ok(JsonView(true));
  6605. }
  6606. return Ok(JsonView(false));
  6607. }
  6608. /// <summary>
  6609. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6610. /// </summary>
  6611. /// <returns></returns>
  6612. [HttpPost]
  6613. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6615. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6616. {
  6617. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6618. if (data.Code != 0)
  6619. {
  6620. return Ok(JsonView(false, data.Msg));
  6621. }
  6622. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6623. //汇率信息记录
  6624. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6625. return Ok(JsonView(true, data.Msg, data.Data));
  6626. }
  6627. /// <summary>
  6628. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6629. /// </summary>
  6630. /// <param name="dto"></param>
  6631. /// <returns></returns>
  6632. [HttpPost]
  6633. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6635. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6636. {
  6637. try
  6638. {
  6639. var id = dto.Id;
  6640. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6641. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6642. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6643. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6644. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6645. 3 团组成员名单 1 团组成员名单", ""));
  6646. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6647. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6648. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6649. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6650. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6651. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6652. //数据源
  6653. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6654. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6655. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6656. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6657. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6658. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6659. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6660. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6661. .Select((x, a, b) => new
  6662. {
  6663. x.Index,
  6664. itemName = a.Name,
  6665. CurrencyStr = b.Name,
  6666. x.Cost,
  6667. x.SubTotal,
  6668. x.Remark
  6669. })
  6670. .OrderBy((x) => x.Index)
  6671. .ToList(); //其他款项费用
  6672. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6673. var peiceItemCurrencys = new List<string>();
  6674. if (_DayAndCosts.Any())
  6675. {
  6676. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6677. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6678. }
  6679. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6680. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6681. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6682. {
  6683. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6684. }
  6685. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6686. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6687. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6688. if (dto.ExportType == 1) //明细表
  6689. {
  6690. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6691. {
  6692. //获取模板
  6693. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6694. //载入模板
  6695. Document doc = new Document(tempPath);
  6696. DocumentBuilder builder = new DocumentBuilder(doc);
  6697. //利用键值对存放数据
  6698. Dictionary<string, string> dic = new Dictionary<string, string>();
  6699. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6700. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6701. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6702. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6703. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6704. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6705. //境内费用(其他费用)
  6706. if (_EnterExitCosts.ChoiceOne == 1)
  6707. {
  6708. string row1_1 = "";
  6709. if (_EnterExitCosts.Visa > 0)
  6710. {
  6711. //insidePayTotal += _EnterExitCosts.Visa;
  6712. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6713. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6714. {
  6715. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6716. }
  6717. }
  6718. string row1_2 = "";
  6719. if (_EnterExitCosts.YiMiao > 0)
  6720. {
  6721. //insidePayTotal += _EnterExitCosts.YiMiao;
  6722. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6723. }
  6724. if (_EnterExitCosts.HeSuan > 0)
  6725. {
  6726. //insidePayTotal += _EnterExitCosts.HeSuan;
  6727. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6728. }
  6729. if (_EnterExitCosts.Service > 0)
  6730. {
  6731. //insidePayTotal += _EnterExitCosts.Service;
  6732. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6733. }
  6734. string row1_3 = "";
  6735. if (_EnterExitCosts.Safe > 0)
  6736. {
  6737. //insidePayTotal += _EnterExitCosts.Safe;
  6738. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6739. }
  6740. if (_EnterExitCosts.Ticket > 0)
  6741. {
  6742. //insidePayTotal += _EnterExitCosts.Ticket;
  6743. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6744. }
  6745. string row1 = "";
  6746. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6747. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6748. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6749. row1 += $"备注:{_EnterExitCosts.Remark}";
  6750. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6751. dic.Add("Row1Str", row1);
  6752. }
  6753. string airTotalStr = string.Empty,
  6754. airPriceStr = string.Empty;
  6755. //经济舱
  6756. if (_EnterExitCosts.SumJJC == 1)
  6757. {
  6758. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6759. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6760. }
  6761. //公务舱
  6762. if (_EnterExitCosts.SumGWC == 1)
  6763. {
  6764. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6765. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6766. }
  6767. //头等舱
  6768. if (_EnterExitCosts.SumTDC == 1)
  6769. {
  6770. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6771. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6772. }
  6773. //汇率描述
  6774. string rateStr = "";
  6775. if (peiceItemCurrencyInfos.Any())
  6776. {
  6777. rateStr = "\r\n汇率描述:";
  6778. foreach (var item in peiceItemCurrencyInfos)
  6779. {
  6780. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6781. }
  6782. }
  6783. string twoItemRemark = "备注:";
  6784. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6785. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6786. dic.Add("AirTotalStr", airTotalStr);
  6787. dic.Add("AirPriceStr", airPriceStr);
  6788. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6789. dic.Add("TwoItemRemark", twoItemRemark);
  6790. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6791. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6792. int table1Row = 0,
  6793. table2Row = 0,
  6794. table3Row = 0,
  6795. table4Row = 0,
  6796. table5Row = 0;
  6797. //住宿费
  6798. if (_EnterExitCosts.ChoiceThree == 1)
  6799. {
  6800. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6801. table1Row = dac1.Count;
  6802. #region 填充word表格内容
  6803. for (int i = 0; i < dac1.Count; i++)
  6804. {
  6805. var dac = dac1[i];
  6806. if (dac == null) continue;
  6807. builder.MoveToCell(0, i, 0, 0);
  6808. builder.Write("第" + dac.Days.ToString() + "晚:");
  6809. builder.MoveToCell(0, i, 1, 0);
  6810. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6811. //builder.Write(dac.Place == null ? "" : dac.Place);
  6812. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6813. builder.MoveToCell(0, i, 2, 0);
  6814. builder.Write("费用标准:");
  6815. string curr = "";
  6816. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6817. if (currData != null)
  6818. {
  6819. curr = currData.Name;
  6820. }
  6821. builder.MoveToCell(0, i, 3, 0);
  6822. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6823. builder.MoveToCell(0, i, 4, 0);
  6824. builder.Write("费用小计:");
  6825. builder.MoveToCell(0, i, 5, 0);
  6826. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6827. }
  6828. #endregion
  6829. }
  6830. else dic.Add("SubZS", "0.00");
  6831. //删除多余行
  6832. while (table1.Rows.Count > table1Row)
  6833. {
  6834. table1.Rows.RemoveAt(table1Row);
  6835. }
  6836. //伙食费
  6837. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6838. if (_EnterExitCosts.ChoiceFour == 1)
  6839. {
  6840. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6841. table2Row = dac2.Count;
  6842. #region 填充word表格内容
  6843. for (int i = 0; i < dac2.Count; i++)
  6844. {
  6845. var dac = dac2[i];
  6846. if (dac == null) continue;
  6847. builder.MoveToCell(1, i, 0, 0);
  6848. builder.Write("第" + dac.Days.ToString() + "天:");
  6849. builder.MoveToCell(1, i, 1, 0);
  6850. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6851. builder.MoveToCell(1, i, 2, 0);
  6852. builder.Write("费用标准:");
  6853. string curr = "";
  6854. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6855. if (currData != null)
  6856. {
  6857. curr = currData.Name;
  6858. }
  6859. builder.MoveToCell(1, i, 3, 0);
  6860. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6861. builder.MoveToCell(1, i, 4, 0);
  6862. builder.Write("费用小计:");
  6863. builder.MoveToCell(1, i, 5, 0);
  6864. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6865. }
  6866. #endregion
  6867. }
  6868. else dic.Add("SubHS", "0.00");
  6869. //删除多余行
  6870. while (table2.Rows.Count > table2Row)
  6871. {
  6872. table2.Rows.RemoveAt(table2Row);
  6873. }
  6874. //公杂费
  6875. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6876. if (_EnterExitCosts.ChoiceFive == 1)
  6877. {
  6878. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6879. table3Row = dac3.Count;
  6880. #region 填充word表格内容
  6881. for (int i = 0; i < dac3.Count; i++)
  6882. {
  6883. var dac = dac3[i];
  6884. if (dac == null) continue;
  6885. builder.MoveToCell(2, i, 0, 0);
  6886. builder.Write("第" + dac.Days.ToString() + "天:");
  6887. builder.MoveToCell(2, i, 1, 0);
  6888. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6889. builder.MoveToCell(2, i, 2, 0);
  6890. builder.Write("费用标准:");
  6891. string curr = "";
  6892. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6893. if (currData != null)
  6894. {
  6895. curr = currData.Name;
  6896. }
  6897. builder.MoveToCell(2, i, 3, 0);
  6898. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6899. builder.MoveToCell(2, i, 4, 0);
  6900. builder.Write("费用小计:");
  6901. builder.MoveToCell(2, i, 5, 0);
  6902. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6903. }
  6904. //删除多余行
  6905. while (table3.Rows.Count > table3Row)
  6906. {
  6907. table3.Rows.RemoveAt(table3Row);
  6908. }
  6909. #endregion
  6910. }
  6911. else dic.Add("SubGZF", "0.00");
  6912. //删除多余行
  6913. while (table3.Rows.Count > table3Row)
  6914. {
  6915. table3.Rows.RemoveAt(table3Row);
  6916. }
  6917. //培训费
  6918. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6919. if (_EnterExitCosts.ChoiceSix == 1)
  6920. {
  6921. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6922. dic.Add("SubPX", pxStr);
  6923. table4Row = dac4.Count;
  6924. #region 填充word表格内容
  6925. for (int i = 0; i < dac4.Count; i++)
  6926. {
  6927. var dac = dac4[i];
  6928. if (dac == null) continue;
  6929. builder.MoveToCell(3, i, 0, 0);
  6930. builder.Write("第" + dac.Days.ToString() + "天:");
  6931. builder.MoveToCell(3, i, 1, 0);
  6932. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6933. builder.MoveToCell(3, i, 2, 0);
  6934. builder.Write("费用标准:");
  6935. string curr = "";
  6936. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6937. if (currData != null)
  6938. {
  6939. curr = currData.Name;
  6940. }
  6941. builder.MoveToCell(3, i, 3, 0);
  6942. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6943. builder.MoveToCell(3, i, 4, 0);
  6944. builder.Write("费用小计:");
  6945. builder.MoveToCell(3, i, 5, 0);
  6946. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6947. }
  6948. #endregion
  6949. }
  6950. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6951. //删除多余行
  6952. while (table4.Rows.Count > table4Row)
  6953. {
  6954. table4.Rows.RemoveAt(table4Row);
  6955. }
  6956. //其他费用
  6957. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6958. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6959. {
  6960. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6961. dic.Add("titleQi", qtStr);
  6962. table5Row = dac5.Count;
  6963. #region 填充word表格内容
  6964. for (int i = 0; i < dac5.Count; i++)
  6965. {
  6966. var dac = dac5[i];
  6967. if (dac == null) continue;
  6968. builder.MoveToCell(4, i, 0, 0);
  6969. builder.Write("第" + dac.Index.ToString() + "项:");
  6970. builder.MoveToCell(4, i, 1, 0);
  6971. builder.Write(dac.itemName);
  6972. builder.MoveToCell(4, i, 2, 0);
  6973. builder.Write("费用标准:");
  6974. builder.MoveToCell(4, i, 3, 0);
  6975. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6976. builder.MoveToCell(4, i, 4, 0);
  6977. builder.Write("费用小计:");
  6978. builder.MoveToCell(4, i, 5, 0);
  6979. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6980. builder.MoveToCell(4, i, 6, 0);
  6981. builder.Write("备注:");
  6982. builder.MoveToCell(4, i, 7, 0);
  6983. builder.Write(dac.Remark);
  6984. }
  6985. #endregion
  6986. }
  6987. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6988. //删除多余行
  6989. while (table5.Rows.Count > table5Row)
  6990. {
  6991. table5.Rows.RemoveAt(table5Row);
  6992. }
  6993. //加上其他费用
  6994. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6995. decimal subJJC = 0.00M,
  6996. subGWC = 0.00M,
  6997. subTDC = 0.00M;
  6998. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6999. string totalLabel = string.Format("全部费用总计:");
  7000. //经济舱
  7001. if (_EnterExitCosts.SumJJC == 1)
  7002. {
  7003. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7004. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7005. }
  7006. //公务舱
  7007. if (_EnterExitCosts.SumGWC == 1)
  7008. {
  7009. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7010. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7011. }
  7012. //头等舱
  7013. if (_EnterExitCosts.SumTDC == 1)
  7014. {
  7015. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7016. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7017. }
  7018. //TotalLabel
  7019. dic.Add("TotalLabel", totalLabel);
  7020. #region 填充word模板书签内容
  7021. foreach (var key in dic.Keys)
  7022. {
  7023. Bookmark bookmark = doc.Range.Bookmarks[key];
  7024. if (bookmark != null)
  7025. {
  7026. builder.MoveToBookmark(key);
  7027. builder.Write(dic[key]);
  7028. }
  7029. }
  7030. #endregion
  7031. //文件名
  7032. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7033. strFileName = CommonFun.ValidFileName(strFileName);
  7034. AsposeHelper.removewatermark_v2180();
  7035. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7036. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7037. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7038. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7039. }
  7040. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7041. {
  7042. //获取模板
  7043. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7044. //载入模板
  7045. Document doc = new Document(tempPath);
  7046. DocumentBuilder builder = new DocumentBuilder(doc);
  7047. Dictionary<string, string> dic = new Dictionary<string, string>();
  7048. string returnCodeLabel = string.Empty;
  7049. if (nationalTravelFeeData.Any())
  7050. {
  7051. List<string> list = new List<string>();
  7052. foreach (var item in nationalTravelFeeData)
  7053. {
  7054. list.Add($"{item.Country}({item.City})");
  7055. }
  7056. list = list.Distinct().ToList();
  7057. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7058. }
  7059. var countryLabel = string.Empty;
  7060. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7061. if (countryData.Any())
  7062. {
  7063. countryLabel = string.Join("、", countryData);
  7064. }
  7065. dic.Add("ReturnCodeAir", returnCodeLabel);
  7066. dic.Add("VisitStartDate", "-");
  7067. dic.Add("VisitEndDate", "-");
  7068. dic.Add("Day", "-");
  7069. dic.Add("VisitCountry", countryLabel);
  7070. dic.Add("ClientUnit", "-");
  7071. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7072. //dic.Add("Names", Names);
  7073. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7074. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7075. decimal dac1totalPrice = 0.00M;
  7076. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7077. foreach (var dac in dac1)
  7078. {
  7079. if (dac.SubTotal == 0.00M)
  7080. {
  7081. continue;
  7082. }
  7083. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7084. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7085. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7086. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7087. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7088. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7089. builder.Write(currency);//币种
  7090. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7091. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7092. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7093. builder.Write("");//人数
  7094. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7095. builder.Write("");//天数
  7096. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7097. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7098. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7099. decimal rate = 0.00M;
  7100. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7101. builder.Write(rate.ToString("#0.0000"));//汇率
  7102. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7103. decimal rbmPrice = dac.SubTotal;
  7104. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7105. accommodationStartIndex++;
  7106. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7107. }
  7108. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7109. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7110. {
  7111. table1.Rows.RemoveAt(i - 1);
  7112. foodandotherStartIndex--;
  7113. }
  7114. if (dac2.Count == dac3.Count)//国家 币种 金额
  7115. {
  7116. for (int i = 0; i < dac2.Count; i++)
  7117. {
  7118. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7119. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7120. }
  7121. }
  7122. decimal dac2totalPrice = 0.00M;
  7123. foreach (var dac in dac2)
  7124. {
  7125. if (dac.SubTotal == 0)
  7126. {
  7127. continue;
  7128. }
  7129. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7130. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7131. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7132. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7133. builder.Write(currency);//币种
  7134. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7135. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7136. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7137. builder.Write("");//人数
  7138. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7139. builder.Write("");//天数
  7140. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7141. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7142. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7143. decimal rate = 0.00M;
  7144. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7145. builder.Write(rate.ToString("#0.0000"));//汇率
  7146. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7147. decimal rbmPrice = dac.SubTotal;
  7148. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7149. foodandotherStartIndex++;
  7150. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7151. }
  7152. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7153. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7154. {
  7155. table1.Rows.RemoveAt(i - 1);
  7156. }
  7157. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7158. string otherFeeStr = "";
  7159. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7160. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7161. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7162. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7163. foreach (var otherInfo in dac5)
  7164. {
  7165. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7166. }
  7167. #endregion
  7168. if (otherFeeStr.Length > 0)
  7169. {
  7170. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7171. otherFeeStr = $"({otherFeeStr})";
  7172. dic.Add("OtherFeeStr", otherFeeStr);
  7173. }
  7174. //总计
  7175. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7176. //国际旅费
  7177. string outsideAir = string.Empty;
  7178. string allPriceAir = string.Empty;
  7179. if (_EnterExitCosts.SumJJC == 1)
  7180. {
  7181. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7182. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7183. }
  7184. if (_EnterExitCosts.SumGWC == 1)
  7185. {
  7186. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7187. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7188. }
  7189. if (_EnterExitCosts.SumTDC == 1)
  7190. {
  7191. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7192. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7193. }
  7194. dic.Add("InTravelPrice", $"({outsideAir})");
  7195. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7196. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7197. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7198. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7199. foreach (var key in dic.Keys)
  7200. {
  7201. builder.MoveToBookmark(key);
  7202. builder.Write(dic[key]);
  7203. }
  7204. //模板文件名
  7205. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7206. strFileName = CommonFun.ValidFileName(strFileName);
  7207. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7208. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7209. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7210. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7211. }
  7212. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7213. {
  7214. //获取模板
  7215. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7216. //载入模板
  7217. WorkbookDesigner designer = new WorkbookDesigner();
  7218. designer.Workbook = new Workbook(tempPath);
  7219. Dictionary<string, string> dic = new Dictionary<string, string>();
  7220. string returnCodeLabel = string.Empty;
  7221. if (nationalTravelFeeData.Any())
  7222. {
  7223. List<string> list = new List<string>();
  7224. foreach (var item in nationalTravelFeeData)
  7225. {
  7226. list.Add($"{item.Country}({item.City})");
  7227. }
  7228. list = list.Distinct().ToList();
  7229. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7230. }
  7231. var countryLabel = string.Empty;
  7232. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7233. if (countryData.Any())
  7234. {
  7235. countryLabel = string.Join("、", countryData);
  7236. }
  7237. dic.Add("ReturnCodeAir", returnCodeLabel);
  7238. dic.Add("VisitStartDate", "-");
  7239. dic.Add("VisitEndDate", "-");
  7240. dic.Add("Day", "0");
  7241. dic.Add("VisitCountry", countryLabel);
  7242. dic.Add("ClientUnit", "-");
  7243. designer.SetDataSource("ClientUnit", "-");
  7244. designer.SetDataSource("VisitCountry", countryLabel);
  7245. designer.SetDataSource("Group", "-");
  7246. designer.SetDataSource("ClientUnitTitle", "-");
  7247. designer.SetDataSource("Name", "-");
  7248. designer.SetDataSource("VisitStartDate", "-");
  7249. designer.SetDataSource("Day", "0");
  7250. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7251. designer.SetDataSource("ReturnCodeAir", "-");
  7252. int startIndex = 10;
  7253. const int startIndexcopy = 10;
  7254. if (dac2.Count == dac3.Count)//国家 币种 金额
  7255. {
  7256. for (int i = 0; i < dac2.Count; i++)
  7257. {
  7258. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7259. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7260. }
  7261. }
  7262. DataTable dtdac1 = new DataTable();
  7263. List<string> place = new List<string>();
  7264. dtdac1.Columns.AddRange(new DataColumn[] {
  7265. new DataColumn(){ ColumnName = "city"},
  7266. new DataColumn(){ ColumnName = "curr"},
  7267. new DataColumn(){ ColumnName = "criterion"},
  7268. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7269. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7270. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7271. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7272. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7273. });
  7274. DataTable dtdac2 = new DataTable();
  7275. dtdac2.Columns.AddRange(new DataColumn[] {
  7276. new DataColumn(){ ColumnName = "city"},
  7277. new DataColumn(){ ColumnName = "curr"},
  7278. new DataColumn(){ ColumnName = "criterion"},
  7279. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7280. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7281. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7282. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7283. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7284. });
  7285. dtdac1.TableName = "tb1";
  7286. dtdac2.TableName = "tb2";
  7287. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7288. foreach (var item in dac1)
  7289. {
  7290. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7291. if (place.Contains(item.Place))
  7292. {
  7293. continue;
  7294. }
  7295. DataRow row = dtdac1.NewRow();
  7296. row["city"] = item.Place;
  7297. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7298. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7299. row["curr"] = currency;
  7300. row["rate"] = rate.ToString("#0.0000");
  7301. row["criterion"] = item.Cost.ToString("#0.00");
  7302. row["number"] = 1;
  7303. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7304. //row["costRMB"] = rbmPrice;
  7305. dtdac1.Rows.Add(row);
  7306. place.Add(item.Place);
  7307. }
  7308. place = new List<string>();
  7309. foreach (var item in dac2)
  7310. {
  7311. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7312. if (place.Contains(item.Place))
  7313. {
  7314. continue;
  7315. }
  7316. DataRow row = dtdac2.NewRow();
  7317. row["city"] = item.Place;
  7318. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7319. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7320. row["curr"] = currency;
  7321. row["rate"] = rate.ToString("#0.0000");
  7322. row["criterion"] = item.Cost.ToString("#0.00");
  7323. row["number"] = 1;
  7324. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7325. //row["cost"] = item.SubTotal;
  7326. //row["costRMB"] = rbmPrice;
  7327. dtdac2.Rows.Add(row);
  7328. place.Add(item.Place);
  7329. //dac2totalPrice += rbmPrice;
  7330. }
  7331. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7332. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7333. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7334. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7335. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7336. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7337. string cell4Str1 = string.Empty;
  7338. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7339. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7340. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7341. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7342. string cellStr = $" 5.其他费用(";
  7343. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7344. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7345. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7346. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7347. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7348. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7349. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7350. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7351. foreach (var otherInfo in dac5)
  7352. {
  7353. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7354. }
  7355. #endregion
  7356. if (cellStr.Length > 8)
  7357. {
  7358. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7359. }
  7360. cellStr += ")";
  7361. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7362. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7363. decimal pxFee = dac4.Sum(it => it.Cost);
  7364. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7365. string celllastStr1 = "";
  7366. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7367. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7368. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7369. celllastStr1 += $",国际旅费 元";
  7370. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7371. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7372. designer.SetDataSource("cell4Str", cell4Str);
  7373. designer.SetDataSource("cellStr", cellStr);
  7374. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7375. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7376. designer.SetDataSource("celllastStr", celllastStr);
  7377. Workbook wb = designer.Workbook;
  7378. var sheet = wb.Worksheets[0];
  7379. //绑定datatable数据集
  7380. designer.SetDataSource(dtdac1);
  7381. designer.SetDataSource(dtdac2);
  7382. designer.Process();
  7383. var rowStart = dtdac1.Rows.Count;
  7384. while (rowStart > 0)
  7385. {
  7386. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7387. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7388. startIndex++;
  7389. rowStart--;
  7390. }
  7391. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7392. startIndex += 1; //总计行
  7393. rowStart = dtdac2.Rows.Count;
  7394. while (rowStart > 0)
  7395. {
  7396. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7397. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7398. startIndex++;
  7399. rowStart--;
  7400. }
  7401. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7402. wb.CalculateFormula(true);
  7403. //模板文件名
  7404. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7405. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7406. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7407. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7408. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7409. }
  7410. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7411. {
  7412. //获取模板
  7413. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7414. //载入模板
  7415. Document doc = new Document(tempPath);
  7416. DocumentBuilder builder = new DocumentBuilder(doc);
  7417. Dictionary<string, string> dic = new Dictionary<string, string>();
  7418. dic.Add("GroupName", "-");
  7419. dic.Add("ClientUnit", "-");
  7420. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7421. //string missionLeaderJob = "";//负责人job
  7422. //int groupNumber = 0; //团人数
  7423. dic.Add("MissionLeader", "-"); //团负责人
  7424. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7425. dic.Add("GroupNumber", "0"); //团人数
  7426. dic.Add("Day", "0");
  7427. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7428. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7429. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7430. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7431. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7432. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7433. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7434. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7435. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7436. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7437. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7438. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7439. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7440. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7441. //其他费用
  7442. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7443. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7444. //其他费用合计
  7445. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7446. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7447. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7448. //公务舱合计
  7449. //国际旅费
  7450. //string outsideJJ = "";
  7451. //string allPriceJJ = "";
  7452. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7453. {
  7454. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7455. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7456. }
  7457. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7458. {
  7459. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7460. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7461. }
  7462. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7463. {
  7464. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7465. dic.Add("AirFeeTotal", airFeeTotalStr);
  7466. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7467. dic.Add("FeeTotal", feeTotalStr);
  7468. }
  7469. foreach (var key in dic.Keys)
  7470. {
  7471. builder.MoveToBookmark(key);
  7472. builder.Write(dic[key]);
  7473. }
  7474. //模板文件名
  7475. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7476. strFileName = CommonFun.ValidFileName(strFileName);
  7477. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7478. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7479. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7480. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7481. }
  7482. }
  7483. else if (dto.ExportType == 2) //表格
  7484. {
  7485. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7486. }
  7487. else if (dto.ExportType == 3)
  7488. {
  7489. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7490. }
  7491. return Ok(JsonView(400, "只可导出明细表!", ""));
  7492. }
  7493. catch (Exception ex)
  7494. {
  7495. return Ok(JsonView(400, ex.Message, ""));
  7496. }
  7497. }
  7498. /// <summary>
  7499. /// 获取三公费用标准city
  7500. /// </summary>
  7501. /// <param name="placeData"></param>
  7502. /// <param name="nationalTravelFeeId"></param>
  7503. /// <returns></returns>
  7504. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7505. {
  7506. string _city = string.Empty;
  7507. if (!placeData.Any()) return _city;
  7508. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7509. if (data == null) return _city;
  7510. string country = data.Country;
  7511. string city = data.City;
  7512. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7513. else _city = city;
  7514. return _city;
  7515. }
  7516. /// <summary>
  7517. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7518. /// </summary>
  7519. /// <returns></returns>
  7520. [HttpPost]
  7521. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7523. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7524. {
  7525. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7526. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7527. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7528. if (_view.Code == 0)
  7529. {
  7530. return Ok(JsonView(true, "操作成功"));
  7531. }
  7532. return Ok(JsonView(false, "操作失败"));
  7533. }
  7534. /// <summary>
  7535. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7536. /// </summary>
  7537. /// <returns></returns>
  7538. [HttpPost]
  7539. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7541. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7542. {
  7543. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7544. if (data.Code != 0)
  7545. {
  7546. return Ok(JsonView(false, data.Msg));
  7547. }
  7548. return Ok(JsonView(true, "操作成功!", data.Data));
  7549. }
  7550. /// <summary>
  7551. /// 三公其他费用草稿 删除
  7552. /// </summary>
  7553. /// <param name="dto"></param>
  7554. /// <returns></returns>
  7555. [HttpPost]
  7556. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7557. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7558. {
  7559. var jw = JsonView(false, "删除失败!");
  7560. var data = new Grp_DayOtherPriceDraft()
  7561. {
  7562. Id = dto.Id,
  7563. IsDel = 1,
  7564. DeleteUserId = dto.DeleteUserId,
  7565. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7566. };
  7567. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7568. if (del > 0)
  7569. {
  7570. jw.Code = 200;
  7571. jw.Msg = "删除成功!";
  7572. }
  7573. return Ok(jw);
  7574. }
  7575. /// <summary>
  7576. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7577. /// </summary>
  7578. /// <returns></returns>
  7579. [HttpPost]
  7580. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7581. {
  7582. var jw = JsonView(false);
  7583. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7584. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7585. jw.Code = StatusCodes.Status200OK;
  7586. jw.Msg = "操作成功!";
  7587. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7588. return Ok(jw);
  7589. }
  7590. /// <summary>
  7591. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7592. /// </summary>
  7593. /// <param name="dto"></param>
  7594. /// <returns></returns>
  7595. [HttpPost]
  7596. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7597. {
  7598. int userId = dto.UserId,
  7599. portId = dto.PortType,
  7600. groupId = dto.GroupId,
  7601. draftId = dto.DraftId;
  7602. _portTypeData.Add(1);
  7603. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7604. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7605. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7606. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7607. _sqlSugar.BeginTran();
  7608. try
  7609. {
  7610. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7611. if (draftDatas == null)
  7612. {
  7613. _sqlSugar.RollbackTran();
  7614. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7615. }
  7616. //验证可覆盖已有数据 两边创建人需为同一人;
  7617. int draftCreateUserId = draftDatas.CreateUserId,
  7618. formalCreateUserId = 0;
  7619. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7620. if (formalData != null)
  7621. {
  7622. formalCreateUserId = formalData.CreateUserId;
  7623. if (draftCreateUserId != formalCreateUserId)
  7624. {
  7625. _sqlSugar.RollbackTran();
  7626. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7627. }
  7628. }
  7629. //默认添加查看、编辑权限(创建人、自己)
  7630. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7631. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7632. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7633. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7634. newExterData.DiId = groupId;
  7635. newExterData.CreateUserId = userId;
  7636. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7637. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7638. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7639. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7640. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7641. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7642. //数据如果存在执行删除
  7643. if (enterExitCostInfo != null)
  7644. {
  7645. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7646. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7647. .Where(x => x.Id == enterExitCostInfo.Id)
  7648. .ExecuteCommand();
  7649. _sqlSugar.Updateable<Grp_DayAndCost>()
  7650. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7651. .Where(x => x.DiId == groupId)
  7652. .ExecuteCommand();
  7653. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7654. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7655. .Where(x => x.Diid == groupId)
  7656. .ExecuteCommand();
  7657. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7658. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7659. .Where(x => x.GroupId == groupId)
  7660. .ExecuteCommand();
  7661. }
  7662. //执行insert
  7663. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7664. if (insertId < 1)
  7665. {
  7666. _sqlSugar.RollbackTran();
  7667. return Ok(JsonView(false, "草稿数据导入失败!"));
  7668. }
  7669. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7670. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7671. #region 默认添加权限
  7672. #endregion
  7673. _sqlSugar.CommitTran();
  7674. //执行操作之后
  7675. //生成默认文件pdf并且通知人员
  7676. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7677. {
  7678. DiId = groupId,
  7679. ExportType = 1,
  7680. SubTypeId = 1005
  7681. }, "pdf");
  7682. //发送通知
  7683. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7684. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7685. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7686. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7687. //汇率信息记录
  7688. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7689. return Ok(JsonView(true));
  7690. }
  7691. catch (Exception ex)
  7692. {
  7693. _sqlSugar.RollbackTran();
  7694. return Ok(JsonView(false, ex.Message));
  7695. }
  7696. }
  7697. #endregion
  7698. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7699. /// <summary>
  7700. /// 获取币种基础数据(含逻辑处理)
  7701. /// </summary>
  7702. /// <returns></returns>
  7703. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7704. {
  7705. return await GeneralMethod.EnterExitCostInitRate();
  7706. }
  7707. /// <summary>
  7708. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7709. /// </summary>
  7710. /// <returns></returns>
  7711. [HttpPost]
  7712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7713. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7714. {
  7715. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7716. //SetDataInfoView
  7717. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7718. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7719. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7720. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7721. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7722. //默认币种显示
  7723. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7724. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7725. return Ok(JsonView(true, "查询成功!", new
  7726. {
  7727. WordTypeData = _WordTypeData,
  7728. ExcelTypeData = _ExcelTypeData,
  7729. CurrencyInit = _currencyInfos,
  7730. viewPermissionData = viewPermissionData
  7731. }));
  7732. }
  7733. /// <summary>
  7734. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7735. /// </summary>
  7736. /// <returns></returns>
  7737. [HttpPost]
  7738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7739. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7740. {
  7741. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7742. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7743. RefAsync<int> total = 0;
  7744. int diId = 0;
  7745. var status = int.TryParse(dto.GroupName, out diId);
  7746. string sql = string.Format(@"SELECT
  7747. Id,
  7748. TeamName GroupName,
  7749. CASE WHEN EXISTS (
  7750. SELECT
  7751. 1
  7752. FROM
  7753. Grp_EnterExitCost
  7754. WHERE
  7755. IsDel = 0
  7756. AND DiId = di.Id
  7757. ) THEN 1 ELSE 0 END AS [IsNull],
  7758. CASE WHEN EXISTS(
  7759. SELECT
  7760. TOP 1 *
  7761. FROM
  7762. Grp_EnterExitCost
  7763. WHERE
  7764. IsDel = 0
  7765. AND DiId = di.Id
  7766. AND CreateUserId = {0}
  7767. ORDER BY
  7768. CreateTime DESC
  7769. ) THEN 1 ELSE 0 END AS [IsEdit],
  7770. CASE WHEN EXISTS(
  7771. SELECT
  7772. TOP 1 *
  7773. FROM
  7774. Grp_EnterExitCost
  7775. WHERE
  7776. IsDel = 0
  7777. AND DiId = di.Id
  7778. AND CreateUserId = {0}
  7779. ORDER BY
  7780. CreateTime DESC
  7781. ) THEN 1 WHEN EXISTS(
  7782. SELECT
  7783. TOP 1 *
  7784. FROM
  7785. Grp_EnterExitCostPermission
  7786. WHERE
  7787. IsDel = 0
  7788. AND GroupId = di.Id
  7789. AND Permission = 1
  7790. AND UserId = {0}
  7791. ORDER BY
  7792. CreateTime DESC
  7793. ) THEN 1 ELSE 0 END AS [IsView]
  7794. FROM
  7795. Grp_DelegationInfo di
  7796. WHERE
  7797. di.Isdel = 0 ", dto.CurrUserId);
  7798. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7799. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7800. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7801. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7802. .OrderByDescending(x => x.Id)
  7803. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7804. return Ok(JsonView(true, "查询成功!", data, total));
  7805. }
  7806. /// <summary>
  7807. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7808. /// </summary>
  7809. /// <returns></returns>
  7810. [HttpPost]
  7811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7812. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7813. {
  7814. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7815. RefAsync<int> total = 0;
  7816. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7817. .Where(x => x.IsDel == 0 && x.STid == 66)
  7818. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7819. .Select(x => new
  7820. {
  7821. id = x.Id,
  7822. name = x.Name,
  7823. remark = x.Remark,
  7824. })
  7825. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7826. return Ok(JsonView(true, "查询成功!", data, total));
  7827. }
  7828. /// <summary>
  7829. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7830. /// </summary>
  7831. /// <returns></returns>
  7832. [HttpPost]
  7833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7834. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7835. {
  7836. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7837. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7838. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7839. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7840. var groupOtherRateData = groupRateData.TeamRates;
  7841. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7842. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7843. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7844. groupOtherRateData = groupOtherRateData
  7845. .Select(x => new TeamRateDescAddCurrencyIdView
  7846. {
  7847. CurrencyId = x.CurrencyId,
  7848. CurrencyName = x.CurrencyName,
  7849. CurrencyCode = x.CurrencyCode,
  7850. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7851. }).ToList();
  7852. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7853. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7854. }
  7855. /// <summary>
  7856. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7857. /// </summary>
  7858. /// <returns></returns>
  7859. [HttpPost]
  7860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7861. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7862. {
  7863. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7864. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7865. var tipsData = new List<int>() { 1, 2, 3 };
  7866. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7867. if (dto.TipsType == 1)
  7868. {
  7869. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  7870. }
  7871. else if (dto.TipsType == 2)
  7872. {
  7873. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  7874. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7875. }
  7876. else if (dto.TipsType == 3)
  7877. {
  7878. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7879. return Ok(JsonView(true, "查询成功!", airData.Data));
  7880. }
  7881. return Ok(JsonView(false));
  7882. }
  7883. /// <summary>
  7884. /// 团组模块 - 出入境国家费用标准-移动端 List
  7885. /// </summary>
  7886. /// <returns></returns>
  7887. [HttpPost]
  7888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7889. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7890. {
  7891. Stopwatch sw = new Stopwatch();
  7892. sw.Start();
  7893. RefAsync<int> total = 0;
  7894. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7895. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7896. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7897. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7898. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7899. .Select((ntf, sd, u) => new
  7900. {
  7901. Id = ntf.Id,
  7902. Area = $"{ntf.Country}-{ntf.City}",
  7903. Currency = ntf.Currency,
  7904. CurrencyCode = sd.Name,
  7905. CurrencyName = sd.Remark,
  7906. RoomCost = ntf.RoomCost,
  7907. FoodCost = ntf.FoodCost,
  7908. PublicCost = ntf.PublicCost,
  7909. LastUpdateUserId = ntf.LastUpdateUserId,
  7910. LastUpdateUserName = u.CnName,
  7911. LastUpdateTime = ntf.LastUpdateTime,
  7912. })
  7913. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7914. sw.Stop();
  7915. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  7916. }
  7917. /// <summary>
  7918. /// 团组模块 - 出入境费用-移动端 - Info
  7919. /// </summary>
  7920. /// <returns></returns>
  7921. [HttpPost]
  7922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7923. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7924. {
  7925. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7926. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7927. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7928. return Ok(data);
  7929. }
  7930. /// <summary>
  7931. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7932. /// </summary>
  7933. /// <returns></returns>
  7934. [HttpPost]
  7935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7936. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  7937. {
  7938. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7939. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7940. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7941. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7942. var mobileInfo = new EnterExitCostMobileParentInfoView();
  7943. mobileInfo.DiId = dto.DiId;
  7944. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  7945. if (eecInfo == null) return Ok(mobileInfo);
  7946. //验证查看权限
  7947. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  7948. //if (!isView) return Ok(JsonView(false, msg));
  7949. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  7950. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  7951. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7952. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7953. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  7954. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7955. {
  7956. SubId = dac.Id,
  7957. DiId = dac.DiId,
  7958. Type = dac.Type,
  7959. Days = dac.Days,
  7960. NationalTravelFeeId = dac.NationalTravelFeeId,
  7961. Arae = $"{ntf.Country}-{ntf.City}",
  7962. Cost = dac.Cost,
  7963. Currency = dac.Currency,
  7964. CurrencyName = sd.Name,
  7965. SubTotal = dac.SubTotal,
  7966. })
  7967. .ToList();
  7968. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  7969. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  7970. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  7971. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  7972. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  7973. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  7974. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  7975. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  7976. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  7977. //其他款项
  7978. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7979. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  7980. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  7981. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  7982. .OrderBy((dop, sd1, sd2) => dop.Index)
  7983. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  7984. {
  7985. SubId = dop.Id,
  7986. DiId = dop.Diid,
  7987. Index = dop.Index,
  7988. SetDataId = dop.SetDataId,
  7989. SetDataName = sd1.Name,
  7990. Cost = dop.Cost,
  7991. Currency = dop.Currency,
  7992. CurrencyName = sd2.Remark,
  7993. SubTotal = dop.SubTotal,
  7994. Remark = dop.Remark,
  7995. })
  7996. .ToArray();
  7997. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  7998. return Ok(mobileInfo);
  7999. }
  8000. /// <summary>
  8001. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8002. /// </summary>
  8003. /// <returns></returns>
  8004. [HttpPost]
  8005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8006. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8007. {
  8008. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8009. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8010. //验证查看权限
  8011. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8012. if (!isView) return Ok(JsonView(false, msg));
  8013. var userIds = Array.Empty<int>();
  8014. userIds = await _sqlSugar
  8015. .Queryable<Grp_EnterExitCostPermission>()
  8016. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8017. .Select(x => x.UserId)
  8018. .ToArrayAsync();
  8019. return Ok(userIds);
  8020. }
  8021. /// <summary>
  8022. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8023. /// </summary>
  8024. /// <returns></returns>
  8025. [HttpPost]
  8026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8027. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8028. {
  8029. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8030. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8031. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8032. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8033. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8034. //验证查看权限
  8035. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8036. //if (!isView) return Ok(JsonView(false, msg));
  8037. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8038. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8039. var subType = dto.SubType;
  8040. if (subType == 1) //1:境内费用
  8041. {
  8042. var oneData = new ChoiceOneMobileSubInfoView()
  8043. {
  8044. Id = eecInfo.Id,
  8045. ChoiceOne = eecInfo.ChoiceOne,
  8046. ChoiceOneTotalCost = eecInfo.InsidePay,
  8047. Visa = eecInfo.Visa,
  8048. VisaRemark = eecInfo.VisaRemark,
  8049. YiMiao = eecInfo.YiMiao,
  8050. HeSuan = eecInfo.HeSuan,
  8051. Service = eecInfo.Service,
  8052. Ticket = eecInfo.Ticket,
  8053. Safe = eecInfo.Safe,
  8054. FirstItemRemark = eecInfo.FirstItemRemark
  8055. };
  8056. return Ok(JsonView(oneData));
  8057. }
  8058. else if (subType == 2) //2:国际旅费
  8059. {
  8060. var twoData = new ChoiceTwoMobileSubInfoView()
  8061. {
  8062. Id = eecInfo.Id,
  8063. ChoiceTwoJJ = eecInfo.SumJJC,
  8064. OutsideJJPay = eecInfo.OutsideJJPay,
  8065. ChoiceTwoGW = eecInfo.SumGWC,
  8066. OutsideGWPay = eecInfo.OutsideGWPay,
  8067. ChoiceTwoTD = eecInfo.SumTDC,
  8068. OutsideTDPay = eecInfo.OutsideTDPay,
  8069. AirJJ = eecInfo.AirJJ,
  8070. AirGW = eecInfo.AirGW,
  8071. AirTD = eecInfo.AirTD,
  8072. CityTranffic = eecInfo.CityTranffic,
  8073. TwoItemRemark = eecInfo.TwoItemRemark
  8074. };
  8075. return Ok(JsonView(twoData));
  8076. }
  8077. else if (subType == 3) //3:住宿费
  8078. {
  8079. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8080. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8081. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8082. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8083. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8084. {
  8085. SubId = dac.Id,
  8086. DiId = dac.DiId,
  8087. Type = dac.Type,
  8088. Days = dac.Days,
  8089. NationalTravelFeeId = dac.NationalTravelFeeId,
  8090. Arae = $"{ntf.Country}-{ntf.City}",
  8091. Cost = dac.Cost,
  8092. Currency = dac.Currency,
  8093. CurrencyName = sd.Name,
  8094. SubTotal = dac.SubTotal,
  8095. })
  8096. .ToArray();
  8097. var data = new ChoiceMobileSubInfo3To6View()
  8098. {
  8099. ParentId = eecInfo.Id,
  8100. Choice = eecInfo.ChoiceThree,
  8101. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8102. Details = dayAndCostDatas
  8103. };
  8104. return Ok(JsonView(data));
  8105. }
  8106. else if (subType == 4) //4:伙食费
  8107. {
  8108. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8109. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8110. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8111. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8112. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8113. {
  8114. SubId = dac.Id,
  8115. DiId = dac.DiId,
  8116. Type = dac.Type,
  8117. Days = dac.Days,
  8118. NationalTravelFeeId = dac.NationalTravelFeeId,
  8119. Arae = $"{ntf.Country}-{ntf.City}",
  8120. Cost = dac.Cost,
  8121. Currency = dac.Currency,
  8122. CurrencyName = sd.Name,
  8123. SubTotal = dac.SubTotal,
  8124. })
  8125. .ToArray();
  8126. var data = new ChoiceMobileSubInfo3To6View()
  8127. {
  8128. ParentId = eecInfo.Id,
  8129. Choice = eecInfo.ChoiceFour,
  8130. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8131. Details = dayAndCostDatas
  8132. };
  8133. return Ok(JsonView(data));
  8134. }
  8135. else if (subType == 5) //5:公杂费
  8136. {
  8137. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8138. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8139. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8140. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8141. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8142. {
  8143. SubId = dac.Id,
  8144. DiId = dac.DiId,
  8145. Type = dac.Type,
  8146. Days = dac.Days,
  8147. NationalTravelFeeId = dac.NationalTravelFeeId,
  8148. Arae = $"{ntf.Country}-{ntf.City}",
  8149. Cost = dac.Cost,
  8150. Currency = dac.Currency,
  8151. CurrencyName = sd.Name,
  8152. SubTotal = dac.SubTotal,
  8153. })
  8154. .ToArray();
  8155. var data = new ChoiceMobileSubInfo3To6View()
  8156. {
  8157. ParentId = eecInfo.Id,
  8158. Choice = eecInfo.ChoiceFive,
  8159. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8160. Details = dayAndCostDatas
  8161. };
  8162. return Ok(JsonView(data));
  8163. }
  8164. else if (subType == 6) //6:培训费
  8165. {
  8166. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8167. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8168. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8169. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8170. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8171. {
  8172. SubId = dac.Id,
  8173. DiId = dac.DiId,
  8174. Type = dac.Type,
  8175. Days = dac.Days,
  8176. NationalTravelFeeId = dac.NationalTravelFeeId,
  8177. Arae = $"{ntf.Country}-{ntf.City}",
  8178. Cost = dac.Cost,
  8179. Currency = dac.Currency,
  8180. CurrencyName = sd.Name,
  8181. SubTotal = dac.SubTotal,
  8182. })
  8183. .ToArray();
  8184. var data = new ChoiceMobileSubInfo3To6View()
  8185. {
  8186. ParentId = eecInfo.Id,
  8187. Choice = eecInfo.ChoiceSix,
  8188. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8189. Details = dayAndCostDatas
  8190. };
  8191. return Ok(JsonView(data));
  8192. }
  8193. else if (subType == 7) //7:其他
  8194. {
  8195. //其他款项
  8196. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8197. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8198. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8199. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8200. .OrderBy((dop, sd1, sd2) => dop.Index)
  8201. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8202. {
  8203. SubId = dop.Id,
  8204. DiId = dop.Diid,
  8205. Index = dop.Index,
  8206. SetDataId = dop.SetDataId,
  8207. SetDataName = sd1.Name,
  8208. Cost = dop.Cost,
  8209. Currency = dop.Currency,
  8210. CurrencyName = sd2.Name,
  8211. SubTotal = dop.SubTotal,
  8212. Remark = dop.Remark,
  8213. })
  8214. .ToArray();
  8215. var data = new ChoiceSevenMobileSubInfoView()
  8216. {
  8217. ParentId = eecInfo.Id,
  8218. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8219. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8220. Details = otherData
  8221. };
  8222. return Ok(JsonView(data));
  8223. }
  8224. return Ok(JsonView(false));
  8225. }
  8226. #region op
  8227. /// <summary>
  8228. /// 移动端更新费用消息通知
  8229. /// </summary>
  8230. /// <param name="diid"></param>
  8231. /// <param name="id"></param>
  8232. /// <param name="currUserId"></param>
  8233. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8234. {
  8235. try
  8236. {
  8237. ////生成默认文件pdf并且通知人员
  8238. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8239. //{
  8240. // DiId = diid,
  8241. // ExportType = 1,
  8242. // SubTypeId = 1005
  8243. //}, "pdf");
  8244. ////发送通知
  8245. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8246. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8247. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8248. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8249. ////汇率信息记录
  8250. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8251. }
  8252. catch (Exception ex)
  8253. {
  8254. //记录日志
  8255. throw;
  8256. }
  8257. }
  8258. /// <summary>
  8259. /// 验证出入境费用数据是否存在
  8260. /// 不存在添加
  8261. /// </summary>
  8262. /// <param name="diId"></param>
  8263. /// <param name="currUserId"></param>
  8264. /// <returns></returns>
  8265. /// <exception cref="CustomException"></exception>
  8266. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8267. {
  8268. var parentId = 0;
  8269. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8270. if (info != null)
  8271. {
  8272. parentId = info.Id;
  8273. }
  8274. else
  8275. {
  8276. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8277. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8278. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8279. parentId = addId;
  8280. }
  8281. return parentId;
  8282. }
  8283. /// <summary>
  8284. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8285. /// </summary>
  8286. /// <returns></returns>
  8287. [HttpPost]
  8288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8289. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8290. {
  8291. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8292. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8293. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8294. //验证编辑权限
  8295. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8296. //if (!isEdit) return Ok(JsonView(false, msg));
  8297. var permissions = new List<Grp_EnterExitCostPermission>();
  8298. foreach (var userId in dto.UserIds)
  8299. {
  8300. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8301. }
  8302. if (permissions.Any())
  8303. {
  8304. _sqlSugar.BeginTran();
  8305. try
  8306. {
  8307. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8308. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8309. if (result < 1)
  8310. {
  8311. _sqlSugar.RollbackTran();
  8312. return Ok(JsonView(false));
  8313. }
  8314. }
  8315. catch (Exception ex)
  8316. {
  8317. _sqlSugar.RollbackTran();
  8318. return Ok(JsonView(false, ex.Message));
  8319. }
  8320. _sqlSugar.CommitTran();
  8321. return Ok(JsonView(true));
  8322. }
  8323. return Ok(JsonView(false));
  8324. }
  8325. /// <summary>
  8326. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8327. /// </summary>
  8328. /// <returns></returns>
  8329. [HttpPost]
  8330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8331. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8332. {
  8333. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8334. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8335. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8336. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8337. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8338. int id = dto.Id;
  8339. if (id <= 0) //add
  8340. {
  8341. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8342. if (add < 1) return Ok(JsonView(false));
  8343. id = add;
  8344. }
  8345. else //update
  8346. {
  8347. ////验证编辑权限
  8348. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8349. //if (!isEdit) return Ok(JsonView(false, msg));
  8350. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8351. if (upd < 1) return Ok(JsonView(false));
  8352. }
  8353. #region 汇率变更时更改币种相关费用
  8354. var opDayCosts = new List<Grp_DayAndCost>();
  8355. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8356. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8357. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8358. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8359. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8360. .Select((dac, sd) => new
  8361. {
  8362. dac.Id,
  8363. dac.DiId,
  8364. CurrencyCode = sd.Name,
  8365. dac.Cost
  8366. })
  8367. .ToList();
  8368. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8369. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8370. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8371. .Select((dop, sd) => new
  8372. {
  8373. dop.Id,
  8374. dop.Diid,
  8375. CurrencyCode = sd.Name,
  8376. dop.Cost
  8377. })
  8378. .ToList();
  8379. if (dayCosts.Count > 0)
  8380. {
  8381. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8382. foreach (var dc in new_dayCosts)
  8383. {
  8384. var thisCurrency = dc.Key.ToUpper();
  8385. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8386. if (thisRate == 0.00M) continue;
  8387. foreach (var dcSub in dc)
  8388. {
  8389. opDayCosts.Add(new Grp_DayAndCost()
  8390. {
  8391. Id = dcSub.Id,
  8392. DiId = dcSub.DiId,
  8393. Cost = dcSub.Cost,
  8394. SubTotal = dcSub.Cost * thisRate,
  8395. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8396. });
  8397. }
  8398. }
  8399. if (opDayCosts.Count > 0)
  8400. {
  8401. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8402. }
  8403. }
  8404. if (dayOtherCosts.Count > 0)
  8405. {
  8406. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8407. foreach (var dc in new_dayOtherCosts)
  8408. {
  8409. var thisCurrency = dc.Key.ToUpper();
  8410. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8411. if (thisRate == 0.00M) continue;
  8412. foreach (var dcSub in dc)
  8413. {
  8414. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8415. {
  8416. Id = dcSub.Id,
  8417. Diid = dcSub.Diid,
  8418. Cost = dcSub.Cost,
  8419. SubTotal = dcSub.Cost * thisRate,
  8420. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8421. });
  8422. }
  8423. }
  8424. if (opDayOtherCosts.Count > 0)
  8425. {
  8426. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8427. }
  8428. }
  8429. #endregion
  8430. //消息通知
  8431. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8432. //汇率信息记录
  8433. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8434. return Ok(JsonView(new { parentId = id }));
  8435. }
  8436. /// <summary>
  8437. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8438. /// </summary>
  8439. /// <returns></returns>
  8440. [HttpPost]
  8441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8442. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8443. {
  8444. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8445. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8446. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8447. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8448. int id = dto.Id;
  8449. if (id <= 0) //add
  8450. {
  8451. checkboxInfo.CreateUserId = dto.CurrUserId;
  8452. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8453. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8454. if (add < 1) return Ok(JsonView(false));
  8455. }
  8456. else //update
  8457. {
  8458. ////验证编辑权限
  8459. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8460. //if (!isEdit) return Ok(JsonView(false, msg));
  8461. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8462. .UpdateColumns(x => new
  8463. {
  8464. x.ChoiceOne,
  8465. x.ChoiceTwo,
  8466. x.SumJJC,
  8467. x.SumGWC,
  8468. x.SumTDC,
  8469. x.ChoiceThree,
  8470. x.ChoiceFour,
  8471. x.ChoiceFive,
  8472. x.ChoiceSix,
  8473. x.OtherExpenses_Checked
  8474. })
  8475. .Where(x => x.Id == id)
  8476. .ExecuteCommandAsync();
  8477. if (upd < 1) return Ok(JsonView(false));
  8478. }
  8479. return Ok(JsonView(new { parentId = id }));
  8480. }
  8481. /// <summary>
  8482. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8483. /// </summary>
  8484. /// <returns></returns>
  8485. [HttpPost]
  8486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8487. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8488. {
  8489. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8490. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8491. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8492. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8493. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8494. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8495. var checkboxInfo = new Grp_EnterExitCost()
  8496. {
  8497. Id = id,
  8498. DiId = diId,
  8499. CreateUserId = currUserId
  8500. };
  8501. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8502. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8503. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8504. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8505. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8506. if (id <= 0) //add
  8507. {
  8508. checkboxInfo.CreateUserId = dto.CurrUserId;
  8509. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8510. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8511. if (add < 1) return Ok(JsonView(false));
  8512. }
  8513. else //update
  8514. {
  8515. ////验证编辑权限
  8516. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8517. //if (!isEdit) return Ok(JsonView(false, msg));
  8518. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8519. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8520. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8521. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8522. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8523. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8524. .Where(x => x.Id == id)
  8525. .ExecuteCommandAsync();
  8526. if (upd < 1) return Ok(JsonView(false));
  8527. }
  8528. return Ok(JsonView(new { parentId = id }));
  8529. }
  8530. /// <summary>
  8531. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8532. /// </summary>
  8533. /// <returns></returns>
  8534. [HttpPost]
  8535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8536. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8537. {
  8538. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8539. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8540. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8541. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8542. info.FirstItemRemark = dto.FirstItemRemark;
  8543. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8544. int id = dto.Id;
  8545. if (id <= 0) //add
  8546. {
  8547. info.CreateUserId = dto.CurrUserId;
  8548. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8549. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8550. if (add < 1) return Ok(JsonView(false));
  8551. id = add;
  8552. }
  8553. else //update
  8554. {
  8555. ////验证编辑权限
  8556. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8557. //if (!isEdit) return Ok(JsonView(false, msg));
  8558. var upd = await _sqlSugar.Updateable(info)
  8559. .UpdateColumns(x => new
  8560. {
  8561. x.ChoiceOne,
  8562. x.InsidePay,
  8563. x.VisaRemark,
  8564. x.Visa,
  8565. x.Service,
  8566. x.Safe,
  8567. x.Ticket,
  8568. x.HeSuan,
  8569. x.YiMiao,
  8570. x.FirstItemRemark
  8571. })
  8572. .Where(x => x.Id == id)
  8573. .ExecuteCommandAsync();
  8574. if (upd < 1) return Ok(JsonView(false));
  8575. }
  8576. //消息通知
  8577. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8578. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8579. }
  8580. /// <summary>
  8581. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8582. /// </summary>
  8583. /// <returns></returns>
  8584. [HttpPost]
  8585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8586. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8587. {
  8588. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8589. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8590. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8591. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8592. info.OutsideJJPay = dto.OutsideJJPay;
  8593. info.OutsideGWPay = dto.OutsideGWPay;
  8594. info.OutsideTDPay = dto.OutsideTDPay;
  8595. info.AirJJ = dto.AirJJ;
  8596. info.AirGW = dto.AirGW;
  8597. info.AirTD = dto.AirTD;
  8598. info.CityTranffic = dto.CityTranffic;
  8599. info.TwoItemRemark = dto.TwoItemRemark;
  8600. info.SumJJC = dto.ChoiceTwoJJ;
  8601. info.SumGWC = dto.ChoiceTwoGW;
  8602. info.SumTDC = dto.ChoiceTwoTD;
  8603. int id = dto.Id;
  8604. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8605. if (id <= 0) //add
  8606. {
  8607. info.CreateUserId = dto.CurrUserId;
  8608. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8609. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8610. if (addId <= 0) return Ok(JsonView(false));
  8611. id = addId;
  8612. }
  8613. else //update
  8614. {
  8615. ////验证编辑权限
  8616. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8617. //if (!isEdit) return Ok(JsonView(false, msg));
  8618. var upd = await _sqlSugar.Updateable(info)
  8619. .UpdateColumns(x => new
  8620. {
  8621. x.SumJJC,
  8622. x.OutsideJJPay,
  8623. x.SumGWC,
  8624. x.OutsideGWPay,
  8625. x.SumTDC,
  8626. x.OutsideTDPay,
  8627. x.AirJJ,
  8628. x.AirGW,
  8629. x.AirTD,
  8630. x.CityTranffic,
  8631. x.TwoItemRemark
  8632. })
  8633. .Where(x => x.Id == id)
  8634. .ExecuteCommandAsync();
  8635. if (upd < 1) return Ok(JsonView(false));
  8636. }
  8637. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8638. gwcItemTotal = info.AirGW + info.CityTranffic;
  8639. tdcItemTotal = info.AirTD + info.CityTranffic;
  8640. //消息通知
  8641. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8642. return Ok(JsonView(new
  8643. {
  8644. parentId = id,
  8645. choiceTwoJJ = dto.ChoiceTwoJJ,
  8646. jjcItemTotal = jjcItemTotal,
  8647. choiceTwoGW = dto.ChoiceTwoGW,
  8648. gwcItemTotal = gwcItemTotal,
  8649. choiceTwoTD = dto.ChoiceTwoTD,
  8650. tdcItemTotal = tdcItemTotal
  8651. }));
  8652. }
  8653. /// <summary>
  8654. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8655. /// </summary>
  8656. /// <returns></returns>
  8657. [HttpPost]
  8658. [ApiExplorerSettings(IgnoreApi = true)]
  8659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8660. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8661. {
  8662. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8663. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8664. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8665. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8666. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8667. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8668. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8669. var infos = infos1.Select(x => new Grp_DayAndCost
  8670. {
  8671. Id = x.Id,
  8672. DiId = dto.DiId,
  8673. Type = dto.FeeType,
  8674. Days = x.Days,
  8675. NationalTravelFeeId = x.NationalTravelFeeId,
  8676. Cost = x.Cost,
  8677. Currency = x.Currency,
  8678. SubTotal = x.SubTotal,
  8679. CreateUserId = dto.CurrUserId
  8680. })
  8681. .ToList();
  8682. var adds = infos.Where(x => x.Id <= 0).ToList();
  8683. var upds = infos.Where(x => x.Id > 0).ToList();
  8684. if (adds.Count > 0)
  8685. {
  8686. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8687. if (add < 1) return Ok(JsonView(false));
  8688. }
  8689. if (upds.Count > 0)
  8690. {
  8691. var upd = await _sqlSugar.Updateable(adds)
  8692. .UpdateColumns(x => new
  8693. {
  8694. x.Days,
  8695. x.NationalTravelFeeId,
  8696. x.Cost,
  8697. x.Currency,
  8698. x.SubTotal
  8699. })
  8700. .WhereColumns(x => new { x.Id })
  8701. .ExecuteCommandAsync();
  8702. if (upd < 1) return Ok(JsonView(false));
  8703. }
  8704. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8705. //消息通知
  8706. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8707. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8708. return Ok(JsonView(new { itemTotal = itemTotal }));
  8709. }
  8710. /// <summary>
  8711. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8712. /// </summary>
  8713. /// <returns></returns>
  8714. [HttpPost]
  8715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8716. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8717. {
  8718. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8719. int subId = dto.SubId, feeType = dto.FeeType;
  8720. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8721. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8722. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8723. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8724. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8725. subInfo.Id = subId;
  8726. subInfo.DiId = dto.DiId;
  8727. if (feeType == 3) subInfo.Type = 1;
  8728. else if (feeType == 4) subInfo.Type = 2;
  8729. else if (feeType == 5) subInfo.Type = 3;
  8730. else if (feeType == 6) subInfo.Type = 4;
  8731. subInfo.CreateUserId = dto.CurrUserId;
  8732. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8733. if (parentId < 1) return Ok(JsonView(false));
  8734. //子表op
  8735. if (subId < 1)
  8736. {
  8737. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8738. if (subAdd < 1) return Ok(JsonView(false));
  8739. }
  8740. else
  8741. {
  8742. ////验证编辑权限
  8743. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8744. //if (!isEdit) return Ok(JsonView(false, msg));
  8745. var subUpd = await _sqlSugar.Updateable(subInfo)
  8746. .UpdateColumns(x => new
  8747. {
  8748. x.Days,
  8749. x.NationalTravelFeeId,
  8750. x.Cost,
  8751. x.Currency,
  8752. x.SubTotal
  8753. })
  8754. .WhereColumns(x => new { x.Id })
  8755. .ExecuteCommandAsync();
  8756. if (subUpd < 1) return Ok(JsonView(false));
  8757. }
  8758. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8759. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8760. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8761. }
  8762. /// <summary>
  8763. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8764. /// </summary>
  8765. /// <returns></returns>
  8766. [HttpPost]
  8767. [ApiExplorerSettings(IgnoreApi = true)]
  8768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8769. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8770. {
  8771. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8772. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8773. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8774. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8775. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8776. {
  8777. Id = x.Id,
  8778. Diid = dto.DiId,
  8779. SetDataId = x.SetDataId,
  8780. Index = x.Index,
  8781. Cost = x.Cost,
  8782. Currency = x.Currency,
  8783. SubTotal = x.SubTotal,
  8784. CreateUserId = dto.CurrUserId,
  8785. Remark = x.Remark
  8786. }).ToList();
  8787. var adds = infos.Where(x => x.Id <= 0).ToList();
  8788. var upds = infos.Where(x => x.Id > 0).ToList();
  8789. if (adds.Count > 0)
  8790. {
  8791. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8792. if (add < 1) return Ok(JsonView(false));
  8793. }
  8794. if (upds.Count > 0)
  8795. {
  8796. var upd = await _sqlSugar.Updateable(adds)
  8797. .UpdateColumns(x => new
  8798. {
  8799. x.Index,
  8800. x.SetDataId,
  8801. x.Cost,
  8802. x.Currency,
  8803. x.SubTotal,
  8804. x.Remark
  8805. })
  8806. .WhereColumns(x => new { x.Id })
  8807. .ExecuteCommandAsync();
  8808. if (upd < 1) return Ok(JsonView(false));
  8809. }
  8810. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8811. //消息通知
  8812. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8813. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8814. return Ok(JsonView(new { itemTotal = itemTotal }));
  8815. }
  8816. /// <summary>
  8817. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8818. /// </summary>
  8819. /// <returns></returns>
  8820. [HttpPost]
  8821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8822. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8823. {
  8824. int subId = dto.SubId;
  8825. int diId = dto.Diid;
  8826. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8827. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8828. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8829. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8830. subInfo.Id = subId;
  8831. subInfo.Diid = dto.Diid;
  8832. subInfo.CreateUserId = dto.CurrUserId;
  8833. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8834. if (parentId < 1) return Ok(JsonView(false));
  8835. #region 子表op
  8836. if (subId < 1)//add
  8837. {
  8838. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8839. if (subAdd < 1) return Ok(JsonView(false));
  8840. }
  8841. else //upd
  8842. {
  8843. ////验证编辑权限
  8844. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8845. //if (!isEdit) return Ok(JsonView(false, msg));
  8846. var subUpd = await _sqlSugar.Updateable(subInfo)
  8847. .UpdateColumns(x => new
  8848. {
  8849. x.Index,
  8850. x.SetDataId,
  8851. x.Cost,
  8852. x.Currency,
  8853. x.SubTotal,
  8854. x.Remark
  8855. })
  8856. .WhereColumns(x => new { x.Id })
  8857. .ExecuteCommandAsync();
  8858. if (subUpd < 1) return Ok(JsonView(false));
  8859. }
  8860. #endregion
  8861. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8862. //消息通知
  8863. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8864. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8865. }
  8866. /// <summary>
  8867. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8868. /// </summary>
  8869. /// <returns></returns>
  8870. [HttpPost]
  8871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8872. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8873. {
  8874. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8875. if (data.Code != 0)
  8876. {
  8877. return Ok(JsonView(false, data.Msg));
  8878. }
  8879. return Ok(JsonView(true, "操作成功!", data.Data));
  8880. }
  8881. /// <summary>
  8882. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8883. /// </summary>
  8884. /// <param name="dto"></param>
  8885. /// <returns></returns>
  8886. [HttpPost]
  8887. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8888. {
  8889. var data = new Grp_DayOtherPrice()
  8890. {
  8891. Id = dto.Id,
  8892. IsDel = 1,
  8893. DeleteUserId = dto.DeleteUserId,
  8894. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8895. };
  8896. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8897. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  8898. return Ok(JsonView(false, "删除失败!"));
  8899. }
  8900. #endregion
  8901. #endregion
  8902. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  8903. /// <summary>
  8904. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  8905. /// </summary>
  8906. /// <returns></returns>
  8907. [HttpPost]
  8908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8909. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  8910. {
  8911. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8912. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8913. RefAsync<int> total = 0;
  8914. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8915. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  8916. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  8917. .Select(x => new
  8918. {
  8919. Id = x.Id,
  8920. DraftName = x.DraftName,
  8921. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  8922. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  8923. .Any()
  8924. })
  8925. .OrderByDescending(x => x.Id)
  8926. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8927. return Ok(JsonView(true, "查询成功!", data, total));
  8928. }
  8929. /// <summary>
  8930. /// 出入境费用-草稿 移动端
  8931. /// 获取币种基础数据(含逻辑处理)
  8932. /// </summary>
  8933. /// <returns></returns>
  8934. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  8935. {
  8936. return await GeneralMethod.EnterExitCostInitRate();
  8937. }
  8938. /// <summary>
  8939. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8940. /// </summary>
  8941. /// <returns></returns>
  8942. [HttpPost]
  8943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8944. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  8945. {
  8946. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8947. //SetDataInfoView
  8948. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  8949. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  8950. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  8951. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  8952. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  8953. //默认币种显示
  8954. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8955. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8956. return Ok(JsonView(true, "查询成功!", new
  8957. {
  8958. WordTypeData = _WordTypeData,
  8959. ExcelTypeData = _ExcelTypeData,
  8960. CurrencyInit = _currencyInfos,
  8961. viewPermissionData = viewPermissionData
  8962. }));
  8963. }
  8964. /// <summary>
  8965. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  8966. /// </summary>
  8967. /// <returns></returns>
  8968. [HttpPost]
  8969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8970. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  8971. {
  8972. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8973. RefAsync<int> total = 0;
  8974. int diId = 0;
  8975. var status = int.TryParse(dto.GroupName, out diId);
  8976. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  8977. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  8978. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  8979. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  8980. .Select(x => new
  8981. {
  8982. Id = x.Id,
  8983. GroupName = x.TeamName
  8984. })
  8985. .OrderByDescending(x => x.Id)
  8986. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8987. return Ok(JsonView(true, "查询成功!", data, total));
  8988. }
  8989. /// <summary>
  8990. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  8991. /// </summary>
  8992. /// <returns></returns>
  8993. [HttpPost]
  8994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8995. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  8996. {
  8997. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8998. RefAsync<int> total = 0;
  8999. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9000. .Where(x => x.IsDel == 0 && x.STid == 66)
  9001. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9002. .Select(x => new
  9003. {
  9004. id = x.Id,
  9005. name = x.Name,
  9006. remark = x.Remark,
  9007. })
  9008. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9009. return Ok(JsonView(true, "查询成功!", data, total));
  9010. }
  9011. /// <summary>
  9012. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9013. /// </summary>
  9014. /// <returns></returns>
  9015. [HttpPost]
  9016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9017. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9018. {
  9019. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9020. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9021. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9022. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9023. var groupOtherRateData = groupRateData.TeamRates;
  9024. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9025. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9026. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9027. groupOtherRateData = groupOtherRateData
  9028. .Select(x => new TeamRateDescAddCurrencyIdView
  9029. {
  9030. CurrencyId = x.CurrencyId,
  9031. CurrencyName = x.CurrencyName,
  9032. CurrencyCode = x.CurrencyCode,
  9033. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9034. }).ToList();
  9035. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9036. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9037. }
  9038. /// <summary>
  9039. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9040. /// </summary>
  9041. /// <returns></returns>
  9042. [HttpPost]
  9043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9044. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9045. {
  9046. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9047. var tipsData = new List<int>() { 1, 2, 3 };
  9048. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9049. if (dto.TipsType == 1)
  9050. {
  9051. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9052. }
  9053. else if (dto.TipsType == 2)
  9054. {
  9055. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9056. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9057. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9058. .Select(x => x.NationalTravelFeeId)
  9059. .Distinct()
  9060. .ToListAsync();
  9061. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9062. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9063. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9064. .Select(x => x.Country)
  9065. .Distinct()
  9066. .ToArrayAsync();
  9067. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9068. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9069. return Ok(JsonView(true, "查询成功!", new
  9070. {
  9071. totalAmt = totalAmt,
  9072. remark = remark
  9073. }));
  9074. }
  9075. else if (dto.TipsType == 3)
  9076. {
  9077. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9078. }
  9079. return Ok(JsonView(false));
  9080. }
  9081. /// <summary>
  9082. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9083. /// </summary>
  9084. /// <returns></returns>
  9085. [HttpPost]
  9086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9087. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9088. {
  9089. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9090. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9091. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9092. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9093. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9094. var info = new Grp_EnterExitCostDraft() {
  9095. DraftName = dto.DraftName,
  9096. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9097. CreateUserId = dto.CurrUserId
  9098. };
  9099. _sqlSugar.BeginTran();
  9100. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9101. if (draftId < 1) {
  9102. _sqlSugar.RollbackTran();
  9103. return Ok(JsonView(false, "草稿创建失败!"));
  9104. }
  9105. //添加默认权限
  9106. await _enterExitCostDraftRep.InitPerm(draftId,dto.CurrUserId);
  9107. _sqlSugar.CommitTran();
  9108. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9109. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9110. mobileInfo.Id = draftId;
  9111. mobileInfo.DraftName = dto.DraftName;
  9112. mobileInfo.Currencys = rateInfos;
  9113. mobileInfo.IsAssignPerm = assignPerm;
  9114. return Ok(JsonView(mobileInfo));
  9115. }
  9116. /// <summary>
  9117. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9118. /// </summary>
  9119. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9120. /// <summary>
  9121. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9122. /// </summary>
  9123. /// <returns></returns>
  9124. [HttpPost]
  9125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9126. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9127. {
  9128. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9129. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9130. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9131. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9132. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9133. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9134. //验证查看编辑权限
  9135. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9136. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9137. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9138. mobileInfo.IsAssignPerm = assignPerm;
  9139. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9140. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9141. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9142. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9143. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9144. {
  9145. ParentId = dac.ParentId,
  9146. SubId = dac.Id,
  9147. Type = dac.Type,
  9148. Days = dac.Days,
  9149. NationalTravelFeeId = dac.NationalTravelFeeId,
  9150. Arae = $"{ntf.Country}-{ntf.City}",
  9151. Cost = dac.Cost,
  9152. Currency = dac.Currency,
  9153. CurrencyName = sd.Name,
  9154. SubTotal = dac.SubTotal,
  9155. })
  9156. .ToList();
  9157. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9158. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9159. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9160. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9161. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9162. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9163. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9164. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9165. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9166. //其他款项
  9167. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9168. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9169. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9170. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9171. .OrderBy((dop, sd1, sd2) => dop.Index)
  9172. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9173. {
  9174. ParentId = dop.ParentId,
  9175. SubId = dop.Id,
  9176. Index = dop.Index,
  9177. SetDataId = dop.SetDataId,
  9178. SetDataName = sd1.Name,
  9179. Cost = dop.Cost,
  9180. Currency = dop.Currency,
  9181. CurrencyName = sd2.Remark,
  9182. SubTotal = dop.SubTotal,
  9183. Remark = dop.Remark,
  9184. })
  9185. .ToArray();
  9186. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9187. return Ok(mobileInfo);
  9188. }
  9189. /// <summary>
  9190. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9191. /// </summary>
  9192. /// <returns></returns>
  9193. [HttpPost]
  9194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9195. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9196. {
  9197. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9198. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9199. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9200. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9201. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9202. //验证查看编辑权限
  9203. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9204. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9205. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9206. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9207. var subType = dto.SubType;
  9208. if (subType == 1) //1:境内费用
  9209. {
  9210. var oneData = new ChoiceOneMobileSubInfoView()
  9211. {
  9212. Id = eecInfo.Id,
  9213. ChoiceOne = eecInfo.ChoiceOne,
  9214. ChoiceOneTotalCost = eecInfo.InsidePay,
  9215. Visa = eecInfo.Visa,
  9216. VisaRemark = eecInfo.VisaRemark,
  9217. YiMiao = eecInfo.YiMiao,
  9218. HeSuan = eecInfo.HeSuan,
  9219. Service = eecInfo.Service,
  9220. Ticket = eecInfo.Ticket,
  9221. Safe = eecInfo.Safe,
  9222. FirstItemRemark = eecInfo.FirstItemRemark
  9223. };
  9224. return Ok(JsonView(oneData));
  9225. }
  9226. else if (subType == 2) //2:国际旅费
  9227. {
  9228. var twoData = new ChoiceTwoMobileSubInfoView()
  9229. {
  9230. Id = eecInfo.Id,
  9231. ChoiceTwoJJ = eecInfo.SumJJC,
  9232. OutsideJJPay = eecInfo.OutsideJJPay,
  9233. ChoiceTwoGW = eecInfo.SumGWC,
  9234. OutsideGWPay = eecInfo.OutsideGWPay,
  9235. ChoiceTwoTD = eecInfo.SumTDC,
  9236. OutsideTDPay = eecInfo.OutsideTDPay,
  9237. AirJJ = eecInfo.AirJJ,
  9238. AirGW = eecInfo.AirGW,
  9239. AirTD = eecInfo.AirTD,
  9240. CityTranffic = eecInfo.CityTranffic,
  9241. TwoItemRemark = eecInfo.TwoItemRemark
  9242. };
  9243. return Ok(JsonView(twoData));
  9244. }
  9245. else if (subType == 3) //3:住宿费
  9246. {
  9247. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9248. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9249. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9250. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9251. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9252. {
  9253. ParentId = dac.ParentId,
  9254. SubId = dac.Id,
  9255. Type = dac.Type,
  9256. Days = dac.Days,
  9257. NationalTravelFeeId = dac.NationalTravelFeeId,
  9258. Arae = $"{ntf.Country}-{ntf.City}",
  9259. Cost = dac.Cost,
  9260. Currency = dac.Currency,
  9261. CurrencyName = sd.Name,
  9262. SubTotal = dac.SubTotal,
  9263. })
  9264. .ToArray();
  9265. var data = new ChoiceDraftMobileSubInfo3To6View()
  9266. {
  9267. ParentId = eecInfo.Id,
  9268. Choice = eecInfo.ChoiceThree,
  9269. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9270. Details = dayAndCostDatas
  9271. };
  9272. return Ok(JsonView(data));
  9273. }
  9274. else if (subType == 4) //4:伙食费
  9275. {
  9276. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9277. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9278. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9279. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9280. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9281. {
  9282. ParentId = dac.ParentId,
  9283. SubId = dac.Id,
  9284. Type = dac.Type,
  9285. Days = dac.Days,
  9286. NationalTravelFeeId = dac.NationalTravelFeeId,
  9287. Arae = $"{ntf.Country}-{ntf.City}",
  9288. Cost = dac.Cost,
  9289. Currency = dac.Currency,
  9290. CurrencyName = sd.Name,
  9291. SubTotal = dac.SubTotal,
  9292. })
  9293. .ToArray();
  9294. var data = new ChoiceDraftMobileSubInfo3To6View()
  9295. {
  9296. ParentId = eecInfo.Id,
  9297. Choice = eecInfo.ChoiceFour,
  9298. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9299. Details = dayAndCostDatas
  9300. };
  9301. return Ok(JsonView(data));
  9302. }
  9303. else if (subType == 5) //5:公杂费
  9304. {
  9305. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9306. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9307. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9308. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9309. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9310. {
  9311. ParentId = dac.ParentId,
  9312. SubId = dac.Id,
  9313. Type = dac.Type,
  9314. Days = dac.Days,
  9315. NationalTravelFeeId = dac.NationalTravelFeeId,
  9316. Arae = $"{ntf.Country}-{ntf.City}",
  9317. Cost = dac.Cost,
  9318. Currency = dac.Currency,
  9319. CurrencyName = sd.Name,
  9320. SubTotal = dac.SubTotal,
  9321. })
  9322. .ToArray();
  9323. var data = new ChoiceDraftMobileSubInfo3To6View()
  9324. {
  9325. ParentId = eecInfo.Id,
  9326. Choice = eecInfo.ChoiceFive,
  9327. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9328. Details = dayAndCostDatas
  9329. };
  9330. return Ok(JsonView(data));
  9331. }
  9332. else if (subType == 6) //6:培训费
  9333. {
  9334. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9335. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9336. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9337. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9338. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9339. {
  9340. ParentId = dac.ParentId,
  9341. SubId = dac.Id,
  9342. Type = dac.Type,
  9343. Days = dac.Days,
  9344. NationalTravelFeeId = dac.NationalTravelFeeId,
  9345. Arae = $"{ntf.Country}-{ntf.City}",
  9346. Cost = dac.Cost,
  9347. Currency = dac.Currency,
  9348. CurrencyName = sd.Name,
  9349. SubTotal = dac.SubTotal,
  9350. })
  9351. .ToArray();
  9352. var data = new ChoiceDraftMobileSubInfo3To6View()
  9353. {
  9354. ParentId = eecInfo.Id,
  9355. Choice = eecInfo.ChoiceSix,
  9356. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9357. Details = dayAndCostDatas
  9358. };
  9359. return Ok(JsonView(data));
  9360. }
  9361. else if (subType == 7) //7:其他
  9362. {
  9363. //其他款项
  9364. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9365. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9366. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9367. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9368. .OrderBy((dop, sd1, sd2) => dop.Index)
  9369. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9370. {
  9371. ParentId = dop.ParentId,
  9372. SubId = dop.Id,
  9373. Index = dop.Index,
  9374. SetDataId = dop.SetDataId,
  9375. SetDataName = sd1.Name,
  9376. Cost = dop.Cost,
  9377. Currency = dop.Currency,
  9378. CurrencyName = sd2.Name,
  9379. SubTotal = dop.SubTotal,
  9380. Remark = dop.Remark,
  9381. })
  9382. .ToArray();
  9383. var data = new ChoiceSevenDraftMobileSubInfoView()
  9384. {
  9385. ParentId = eecInfo.Id,
  9386. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9387. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9388. Details = otherData
  9389. };
  9390. return Ok(JsonView(data));
  9391. }
  9392. return Ok(JsonView(false));
  9393. }
  9394. #region op
  9395. /// <summary>
  9396. /// 移动端更新费用消息通知
  9397. /// </summary>
  9398. /// <param name="draftId"></param>
  9399. /// <param name="id"></param>
  9400. /// <param name="currUserId"></param>
  9401. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9402. {
  9403. try
  9404. {
  9405. ////生成默认文件pdf并且通知人员
  9406. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9407. //{
  9408. // DiId = draftId,
  9409. // ExportType = 1,
  9410. // SubTypeId = 1005
  9411. //}, "pdf");
  9412. ////发送通知
  9413. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9414. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9415. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9416. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9417. ////汇率信息记录
  9418. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9419. }
  9420. catch (Exception ex)
  9421. {
  9422. //记录日志
  9423. throw;
  9424. }
  9425. }
  9426. /// <summary>
  9427. /// 验证出入境费用数据是否存在
  9428. /// 不存在添加
  9429. /// </summary>
  9430. /// <param name="draftId"></param>
  9431. /// <param name="currUserId"></param>
  9432. /// <returns></returns>
  9433. /// <exception cref="CustomException"></exception>
  9434. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9435. {
  9436. var parentId = 0;
  9437. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9438. if (info != null) parentId = info.Id;
  9439. else
  9440. {
  9441. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9442. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9443. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9444. parentId = addId;
  9445. }
  9446. return parentId;
  9447. }
  9448. /// <summary>
  9449. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9450. /// </summary>
  9451. /// <returns></returns>
  9452. [HttpPost]
  9453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9454. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9455. {
  9456. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9457. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9458. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9459. //验证查看编辑权限
  9460. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9461. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9462. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9463. foreach (var userId in dto.UserIds)
  9464. {
  9465. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9466. }
  9467. if (permissions.Any())
  9468. {
  9469. _sqlSugar.BeginTran();
  9470. try
  9471. {
  9472. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9473. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9474. if (result < 1)
  9475. {
  9476. _sqlSugar.RollbackTran();
  9477. return Ok(JsonView(false));
  9478. }
  9479. }
  9480. catch (Exception ex)
  9481. {
  9482. _sqlSugar.RollbackTran();
  9483. return Ok(JsonView(false, ex.Message));
  9484. }
  9485. _sqlSugar.CommitTran();
  9486. return Ok(JsonView(true));
  9487. }
  9488. return Ok(JsonView(false));
  9489. }
  9490. /// <summary>
  9491. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9492. /// </summary>
  9493. /// <returns></returns>
  9494. [HttpPost]
  9495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9496. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9497. {
  9498. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9499. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9500. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9501. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9502. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9503. int id = dto.DraftId;
  9504. if (id <= 0) //add
  9505. {
  9506. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9507. if (add < 1) return Ok(JsonView(false));
  9508. id = add;
  9509. }
  9510. else //update
  9511. {
  9512. //验证查看编辑权限
  9513. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9514. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9515. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9516. if (upd < 1) return Ok(JsonView(false));
  9517. }
  9518. #region 汇率变更时更改币种相关费用
  9519. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9520. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9521. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9522. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9523. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9524. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9525. .Select((dac, sd) => new
  9526. {
  9527. dac.Id,
  9528. dac.ParentId,
  9529. CurrencyCode = sd.Name,
  9530. dac.Cost
  9531. })
  9532. .ToList();
  9533. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9534. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9535. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9536. .Select((dop, sd) => new
  9537. {
  9538. dop.Id,
  9539. dop.ParentId,
  9540. CurrencyCode = sd.Name,
  9541. dop.Cost
  9542. })
  9543. .ToList();
  9544. if (dayCosts.Count > 0)
  9545. {
  9546. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9547. foreach (var dc in new_dayCosts)
  9548. {
  9549. var thisCurrency = dc.Key.ToUpper();
  9550. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9551. if (thisRate == 0.00M) continue;
  9552. foreach (var dcSub in dc)
  9553. {
  9554. opDayCosts.Add(new Grp_DayAndCostDraft()
  9555. {
  9556. Id = dcSub.Id,
  9557. ParentId = dcSub.ParentId,
  9558. Cost = dcSub.Cost,
  9559. SubTotal = dcSub.Cost * thisRate,
  9560. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9561. });
  9562. }
  9563. }
  9564. if (opDayCosts.Count > 0)
  9565. {
  9566. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9567. }
  9568. }
  9569. if (dayOtherCosts.Count > 0)
  9570. {
  9571. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9572. foreach (var dc in new_dayOtherCosts)
  9573. {
  9574. var thisCurrency = dc.Key.ToUpper();
  9575. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9576. if (thisRate == 0.00M) continue;
  9577. foreach (var dcSub in dc)
  9578. {
  9579. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9580. {
  9581. Id = dcSub.Id,
  9582. ParentId = dcSub.ParentId,
  9583. Cost = dcSub.Cost,
  9584. SubTotal = dcSub.Cost * thisRate,
  9585. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9586. });
  9587. }
  9588. }
  9589. if (opDayOtherCosts.Count > 0)
  9590. {
  9591. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9592. }
  9593. }
  9594. #endregion
  9595. ////消息通知
  9596. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9597. ////汇率信息记录
  9598. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9599. return Ok(JsonView(new { parentId = id }));
  9600. }
  9601. /// <summary>
  9602. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9603. /// </summary>
  9604. /// <returns></returns>
  9605. [HttpPost]
  9606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9607. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9608. {
  9609. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9610. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9611. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9612. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9613. int id = dto.DraftId;
  9614. if (id <= 0) //add
  9615. {
  9616. checkboxInfo.CreateUserId = dto.CurrUserId;
  9617. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9618. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9619. if (add < 1) return Ok(JsonView(false));
  9620. }
  9621. else //update
  9622. {
  9623. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9624. .UpdateColumns(x => new
  9625. {
  9626. x.ChoiceOne,
  9627. x.ChoiceTwo,
  9628. x.SumJJC,
  9629. x.SumGWC,
  9630. x.SumTDC,
  9631. x.ChoiceThree,
  9632. x.ChoiceFour,
  9633. x.ChoiceFive,
  9634. x.ChoiceSix,
  9635. x.OtherExpenses_Checked
  9636. })
  9637. .Where(x => x.Id == id)
  9638. .ExecuteCommandAsync();
  9639. if (upd < 1) return Ok(JsonView(false));
  9640. }
  9641. return Ok(JsonView(new { parentId = id }));
  9642. }
  9643. /// <summary>
  9644. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9645. /// </summary>
  9646. /// <returns></returns>
  9647. [HttpPost]
  9648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9649. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9650. {
  9651. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9652. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9653. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9654. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9655. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9656. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9657. var checkboxInfo = new Grp_EnterExitCostDraft()
  9658. {
  9659. Id = draftId,
  9660. CreateUserId = currUserId
  9661. };
  9662. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9663. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9664. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9665. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9666. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9667. if (draftId <= 0) //add
  9668. {
  9669. checkboxInfo.CreateUserId = dto.CurrUserId;
  9670. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9671. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9672. if (add < 1) return Ok(JsonView(false));
  9673. }
  9674. else //update
  9675. {
  9676. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9677. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9678. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9679. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9680. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9681. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9682. .Where(x => x.Id == draftId)
  9683. .ExecuteCommandAsync();
  9684. if (upd < 1) return Ok(JsonView(false));
  9685. }
  9686. return Ok(JsonView(new { parentId = draftId }));
  9687. }
  9688. /// <summary>
  9689. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9690. /// </summary>
  9691. /// <returns></returns>
  9692. [HttpPost]
  9693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9694. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9695. {
  9696. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9697. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9698. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9699. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9700. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9701. info.FirstItemRemark = dto.FirstItemRemark;
  9702. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9703. if (id <= 0) //add
  9704. {
  9705. info.CreateUserId = dto.CurrUserId;
  9706. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9707. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9708. if (add < 1) return Ok(JsonView(false));
  9709. id = add;
  9710. }
  9711. else //update
  9712. {
  9713. var upd = await _sqlSugar.Updateable(info)
  9714. .UpdateColumns(x => new
  9715. {
  9716. x.ChoiceOne,
  9717. x.InsidePay,
  9718. x.VisaRemark,
  9719. x.Visa,
  9720. x.Service,
  9721. x.Safe,
  9722. x.Ticket,
  9723. x.HeSuan,
  9724. x.YiMiao,
  9725. x.FirstItemRemark
  9726. })
  9727. .Where(x => x.Id == id)
  9728. .ExecuteCommandAsync();
  9729. if (upd < 1) return Ok(JsonView(false));
  9730. }
  9731. ////消息通知
  9732. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9733. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9734. }
  9735. /// <summary>
  9736. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9737. /// </summary>
  9738. /// <returns></returns>
  9739. [HttpPost]
  9740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9741. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9742. {
  9743. int id = dto.DraftId;
  9744. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9745. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9746. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9747. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9748. info.OutsideJJPay = dto.OutsideJJPay;
  9749. info.OutsideGWPay = dto.OutsideGWPay;
  9750. info.OutsideTDPay = dto.OutsideTDPay;
  9751. info.AirJJ = dto.AirJJ;
  9752. info.AirGW = dto.AirGW;
  9753. info.AirTD = dto.AirTD;
  9754. info.CityTranffic = dto.CityTranffic;
  9755. info.TwoItemRemark = dto.TwoItemRemark;
  9756. info.SumJJC = dto.ChoiceTwoJJ;
  9757. info.SumGWC = dto.ChoiceTwoGW;
  9758. info.SumTDC = dto.ChoiceTwoTD;
  9759. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9760. if (id <= 0) //add
  9761. {
  9762. info.CreateUserId = dto.CurrUserId;
  9763. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9764. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9765. if (addId <= 0) return Ok(JsonView(false));
  9766. id = addId;
  9767. }
  9768. else //update
  9769. {
  9770. var upd = await _sqlSugar.Updateable(info)
  9771. .UpdateColumns(x => new
  9772. {
  9773. x.SumJJC,
  9774. x.OutsideJJPay,
  9775. x.SumGWC,
  9776. x.OutsideGWPay,
  9777. x.SumTDC,
  9778. x.OutsideTDPay,
  9779. x.AirJJ,
  9780. x.AirGW,
  9781. x.AirTD,
  9782. x.CityTranffic,
  9783. x.TwoItemRemark
  9784. })
  9785. .Where(x => x.Id == id)
  9786. .ExecuteCommandAsync();
  9787. if (upd < 1) return Ok(JsonView(false));
  9788. }
  9789. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9790. gwcItemTotal = info.AirGW + info.CityTranffic;
  9791. tdcItemTotal = info.AirTD + info.CityTranffic;
  9792. ////消息通知
  9793. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9794. return Ok(JsonView(new
  9795. {
  9796. parentId = id,
  9797. choiceTwoJJ = dto.ChoiceTwoJJ,
  9798. jjcItemTotal = jjcItemTotal,
  9799. choiceTwoGW = dto.ChoiceTwoGW,
  9800. gwcItemTotal = gwcItemTotal,
  9801. choiceTwoTD = dto.ChoiceTwoTD,
  9802. tdcItemTotal = tdcItemTotal
  9803. }));
  9804. }
  9805. /// <summary>
  9806. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9807. /// </summary>
  9808. /// <returns></returns>
  9809. [HttpPost]
  9810. [ApiExplorerSettings(IgnoreApi = true)]
  9811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9812. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9813. {
  9814. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9815. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9816. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9817. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9818. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9819. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9820. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9821. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9822. {
  9823. Id = x.Id,
  9824. ParentId = dto.DraftId,
  9825. Type = dto.FeeType,
  9826. Days = x.Days,
  9827. NationalTravelFeeId = x.NationalTravelFeeId,
  9828. Cost = x.Cost,
  9829. Currency = x.Currency,
  9830. SubTotal = x.SubTotal,
  9831. CreateUserId = dto.CurrUserId
  9832. })
  9833. .ToList();
  9834. var adds = infos.Where(x => x.Id <= 0).ToList();
  9835. var upds = infos.Where(x => x.Id > 0).ToList();
  9836. if (adds.Count > 0)
  9837. {
  9838. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9839. if (add < 1) return Ok(JsonView(false));
  9840. }
  9841. if (upds.Count > 0)
  9842. {
  9843. var upd = await _sqlSugar.Updateable(adds)
  9844. .UpdateColumns(x => new
  9845. {
  9846. x.Days,
  9847. x.NationalTravelFeeId,
  9848. x.Cost,
  9849. x.Currency,
  9850. x.SubTotal
  9851. })
  9852. .WhereColumns(x => new { x.Id })
  9853. .ExecuteCommandAsync();
  9854. if (upd < 1) return Ok(JsonView(false));
  9855. }
  9856. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9857. ////消息通知
  9858. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9859. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9860. return Ok(JsonView(new { itemTotal = itemTotal }));
  9861. }
  9862. /// <summary>
  9863. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9864. /// </summary>
  9865. /// <returns></returns>
  9866. [HttpPost]
  9867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9868. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9869. {
  9870. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9871. int subId = dto.SubId, feeType = dto.FeeType;
  9872. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9873. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9874. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9875. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9876. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9877. subInfo.Id = subId;
  9878. subInfo.ParentId = dto.DraftId;
  9879. if (feeType == 3) subInfo.Type = 1;
  9880. else if (feeType == 4) subInfo.Type = 2;
  9881. else if (feeType == 5) subInfo.Type = 3;
  9882. else if (feeType == 6) subInfo.Type = 4;
  9883. subInfo.CreateUserId = dto.CurrUserId;
  9884. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9885. if (parentId < 1) return Ok(JsonView(false));
  9886. //子表op
  9887. if (subId < 1)
  9888. {
  9889. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9890. if (subAdd < 1) return Ok(JsonView(false));
  9891. }
  9892. else
  9893. {
  9894. var subUpd = await _sqlSugar.Updateable(subInfo)
  9895. .UpdateColumns(x => new
  9896. {
  9897. x.Days,
  9898. x.NationalTravelFeeId,
  9899. x.Cost,
  9900. x.Currency,
  9901. x.SubTotal
  9902. })
  9903. .WhereColumns(x => new { x.Id })
  9904. .ExecuteCommandAsync();
  9905. if (subUpd < 1) return Ok(JsonView(false));
  9906. }
  9907. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  9908. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9909. }
  9910. /// <summary>
  9911. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  9912. /// </summary>
  9913. /// <returns></returns>
  9914. [HttpPost]
  9915. [ApiExplorerSettings(IgnoreApi = true)]
  9916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9917. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  9918. {
  9919. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9920. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9921. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9922. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  9923. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  9924. {
  9925. Id = x.Id,
  9926. ParentId = dto.DraftId,
  9927. SetDataId = x.SetDataId,
  9928. Index = x.Index,
  9929. Cost = x.Cost,
  9930. Currency = x.Currency,
  9931. SubTotal = x.SubTotal,
  9932. CreateUserId = dto.CurrUserId,
  9933. Remark = x.Remark
  9934. }).ToList();
  9935. var adds = infos.Where(x => x.Id <= 0).ToList();
  9936. var upds = infos.Where(x => x.Id > 0).ToList();
  9937. if (adds.Count > 0)
  9938. {
  9939. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9940. if (add < 1) return Ok(JsonView(false));
  9941. }
  9942. if (upds.Count > 0)
  9943. {
  9944. var upd = await _sqlSugar.Updateable(adds)
  9945. .UpdateColumns(x => new
  9946. {
  9947. x.Index,
  9948. x.SetDataId,
  9949. x.Cost,
  9950. x.Currency,
  9951. x.SubTotal,
  9952. x.Remark
  9953. })
  9954. .WhereColumns(x => new { x.Id })
  9955. .ExecuteCommandAsync();
  9956. if (upd < 1) return Ok(JsonView(false));
  9957. }
  9958. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  9959. //消息通知
  9960. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  9961. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9962. return Ok(JsonView(new { itemTotal = itemTotal }));
  9963. }
  9964. /// <summary>
  9965. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  9966. /// </summary>
  9967. /// <returns></returns>
  9968. [HttpPost]
  9969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9970. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  9971. {
  9972. int subId = dto.SubId, id = dto.DarftId;
  9973. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9974. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  9975. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9976. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  9977. subInfo.Id = subId;
  9978. subInfo.ParentId = dto.DarftId;
  9979. subInfo.CreateUserId = dto.CurrUserId;
  9980. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  9981. if (parentId < 1) return Ok(JsonView(false));
  9982. #region 子表op
  9983. if (subId < 1)//add
  9984. {
  9985. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9986. if (subAdd < 1) return Ok(JsonView(false));
  9987. }
  9988. else //upd
  9989. {
  9990. var subUpd = await _sqlSugar.Updateable(subInfo)
  9991. .UpdateColumns(x => new
  9992. {
  9993. x.Index,
  9994. x.SetDataId,
  9995. x.Cost,
  9996. x.Currency,
  9997. x.SubTotal,
  9998. x.Remark
  9999. })
  10000. .WhereColumns(x => new { x.Id })
  10001. .ExecuteCommandAsync();
  10002. if (subUpd < 1) return Ok(JsonView(false));
  10003. }
  10004. #endregion
  10005. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10006. ////消息通知
  10007. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10008. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10009. }
  10010. /// <summary>
  10011. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10012. /// </summary>
  10013. /// <returns></returns>
  10014. [HttpPost]
  10015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10016. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10017. {
  10018. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10019. if (data.Code != 0)
  10020. {
  10021. return Ok(JsonView(false, data.Msg));
  10022. }
  10023. return Ok(JsonView(true, "操作成功!", data.Data));
  10024. }
  10025. /// <summary>
  10026. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10027. /// </summary>
  10028. /// <param name="dto"></param>
  10029. /// <returns></returns>
  10030. [HttpPost]
  10031. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10032. {
  10033. var data = new Grp_DayOtherPriceDraft()
  10034. {
  10035. Id = dto.Id,
  10036. IsDel = 1,
  10037. DeleteUserId = dto.DeleteUserId,
  10038. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10039. };
  10040. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10041. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10042. return Ok(JsonView(false, "删除失败!"));
  10043. }
  10044. #endregion
  10045. #endregion
  10046. #region 团组经理模块 出入境费用报价表
  10047. /// <summary>
  10048. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10049. /// </summary>
  10050. /// <returns></returns>
  10051. [HttpPost]
  10052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10053. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10054. {
  10055. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10056. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10057. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10058. initRates.Insert(0, cnyInfo);
  10059. liveRates.Insert(0, cnyInfo);
  10060. return Ok(JsonView(true, "查询成功!", new
  10061. {
  10062. InitRates = initRates,
  10063. LiveRates = liveRates
  10064. }));
  10065. }
  10066. /// <summary>
  10067. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10068. /// </summary>
  10069. /// <returns></returns>
  10070. [HttpPost]
  10071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10072. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10073. {
  10074. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10075. }
  10076. /// <summary>
  10077. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10078. /// </summary>
  10079. /// <returns></returns>
  10080. [HttpPost]
  10081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10082. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10083. {
  10084. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10085. }
  10086. /// <summary>
  10087. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10088. /// </summary>
  10089. /// <returns></returns>
  10090. [HttpPost]
  10091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10092. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10093. {
  10094. int groupId = dto.DiId,
  10095. currUserId = dto.CurrUserId;
  10096. if (groupId < 1) return Ok(JsonView(false,"请传入有效的GroupId;"));
  10097. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10098. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10099. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10100. var infoView = info.Data as EnterExitCostInfoView;
  10101. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10102. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10103. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10104. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10105. var eecRates = infoView.Currencys;
  10106. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10107. int pplNum = 1;
  10108. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10109. var views = new List<QuoteSubItemInfo>();
  10110. #region 数据填充
  10111. var intTravelCosts = new List<QuoteSubItemInfo>();
  10112. #region 机票费用 1354
  10113. int intTravelIndex = 1;
  10114. if (infoView.SumJJC == 1)
  10115. {
  10116. intTravelCosts.Add(new QuoteSubItemInfo
  10117. {
  10118. ItemId = 1354,
  10119. Index = intTravelIndex,
  10120. FeeName = "经济舱",
  10121. UnitPrice = infoView.AirJJ,
  10122. Currency = "CNY",
  10123. Quantity = 1,
  10124. PplNum = 1,
  10125. TotalAmt = infoView.AirJJ,
  10126. Remark = "",
  10127. });
  10128. intTravelIndex++;
  10129. }
  10130. if (infoView.SumGWC == 1)
  10131. {
  10132. intTravelCosts.Add(new QuoteSubItemInfo
  10133. {
  10134. ItemId = 1354,
  10135. Index = intTravelIndex,
  10136. FeeName = "公务舱",
  10137. UnitPrice = infoView.AirGW,
  10138. Currency = "CNY",
  10139. Quantity = 1,
  10140. PplNum = 1,
  10141. TotalAmt = infoView.AirGW,
  10142. Remark = "",
  10143. });
  10144. intTravelIndex++;
  10145. }
  10146. if (infoView.SumTDC == 1)
  10147. {
  10148. intTravelCosts.Add(new QuoteSubItemInfo
  10149. {
  10150. ItemId = 1354,
  10151. Index = intTravelIndex,
  10152. FeeName = "头等舱",
  10153. UnitPrice = infoView.AirTD,
  10154. Currency = "CNY",
  10155. Quantity = 1,
  10156. PplNum = 1,
  10157. TotalAmt = infoView.AirTD,
  10158. Remark = "",
  10159. });
  10160. intTravelIndex++;
  10161. }
  10162. intTravelCosts.Add(new QuoteSubItemInfo
  10163. {
  10164. ItemId = 1354,
  10165. Index = intTravelIndex,
  10166. FeeName = "城市间交通费用",
  10167. UnitPrice = infoView.CityTranffic,
  10168. Currency = "CNY",
  10169. Quantity = 1,
  10170. PplNum = pplNum,
  10171. TotalAmt = infoView.CityTranffic * pplNum,
  10172. Remark = "",
  10173. });
  10174. views.AddRange(intTravelCosts);
  10175. #endregion
  10176. var accomCosts = new List<QuoteSubItemInfo>();
  10177. #region 住宿费 1355
  10178. if (infoView.QuarterageData.Any())
  10179. {
  10180. int accomIndex = 1;
  10181. int accomItemTypeId = 1355;
  10182. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10183. foreach (var item in groupData)
  10184. {
  10185. string feeName = string.Empty;
  10186. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10187. if (countryInfo != null)
  10188. {
  10189. feeName = countryInfo.Country;
  10190. var city = countryInfo.City;
  10191. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10192. {
  10193. feeName += $"-{city}";
  10194. }
  10195. }
  10196. var hotelInfo = item.FirstOrDefault();
  10197. if (hotelInfo == null) continue;
  10198. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10199. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10200. int quantity = item.ToList().Count;
  10201. accomCosts.Add(new QuoteSubItemInfo
  10202. {
  10203. ItemId = accomItemTypeId,
  10204. Index = accomIndex,
  10205. FeeName = feeName,
  10206. UnitPrice = hotelInfo.Cost,
  10207. Currency = thisCurrency,
  10208. Quantity = quantity,
  10209. PplNum = pplNum,
  10210. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10211. Remark = "",
  10212. });
  10213. accomIndex++;
  10214. }
  10215. views.AddRange(accomCosts);
  10216. }
  10217. #endregion
  10218. var mealCosts = new List<QuoteSubItemInfo>();
  10219. #region 餐饮费 1356
  10220. if (infoView.BoardWagesData.Any())
  10221. {
  10222. var mealIndex = 1;
  10223. int mealItemTypeId = 1356;
  10224. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10225. foreach (var item in groupData)
  10226. {
  10227. string feeName = string.Empty;
  10228. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10229. if (countryInfo != null)
  10230. {
  10231. feeName = countryInfo.Country;
  10232. var city = countryInfo.City;
  10233. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10234. {
  10235. feeName += $"-{city}";
  10236. }
  10237. }
  10238. var mealInfo = item.FirstOrDefault();
  10239. if (mealInfo == null) continue;
  10240. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10241. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10242. int quantity = item.ToList().Count;
  10243. mealCosts.Add(new QuoteSubItemInfo
  10244. {
  10245. ItemId = mealItemTypeId,
  10246. Index = mealIndex,
  10247. FeeName = feeName,
  10248. UnitPrice = mealInfo.Cost,
  10249. Currency = thisCurrency,
  10250. Quantity = quantity,
  10251. PplNum = pplNum,
  10252. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10253. Remark = "",
  10254. });
  10255. mealIndex++;
  10256. }
  10257. views.AddRange(mealCosts);
  10258. }
  10259. #endregion
  10260. var miscCosts = new List<QuoteSubItemInfo>();
  10261. #region 公杂费 1364
  10262. if (infoView.MiscellaneousFeeData.Any())
  10263. {
  10264. var miscIndex = 1;
  10265. int miscItemTypeId = 1364;
  10266. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10267. foreach (var item in groupData)
  10268. {
  10269. string feeName = string.Empty;
  10270. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10271. if (countryInfo != null)
  10272. {
  10273. feeName = countryInfo.Country;
  10274. var city = countryInfo.City;
  10275. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10276. {
  10277. feeName += $"-{city}";
  10278. }
  10279. }
  10280. var miscInfo = item.FirstOrDefault();
  10281. if (miscInfo == null) continue;
  10282. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10283. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10284. int quantity = item.ToList().Count;
  10285. mealCosts.Add(new QuoteSubItemInfo
  10286. {
  10287. ItemId = miscItemTypeId,
  10288. Index = miscIndex,
  10289. FeeName = feeName,
  10290. UnitPrice = miscInfo.Cost,
  10291. Currency = thisCurrency,
  10292. Quantity = quantity,
  10293. PplNum = pplNum,
  10294. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10295. Remark = "",
  10296. });
  10297. miscIndex++;
  10298. }
  10299. views.AddRange(mealCosts);
  10300. }
  10301. #endregion
  10302. #region 签证+保险 1362
  10303. int visaInsIndex = 1;
  10304. int visaInsItemTypeId = 1362;
  10305. if (infoView.Visa > 0)
  10306. {
  10307. views.Add(new QuoteSubItemInfo() {
  10308. ItemId = visaInsItemTypeId,
  10309. Index = visaInsIndex,
  10310. FeeName = $"签证",
  10311. UnitPrice = infoView.Visa,
  10312. Currency = $"CNY",
  10313. Quantity = 1,
  10314. PplNum = pplNum,
  10315. TotalAmt = infoView.Visa * pplNum,
  10316. Remark = "",
  10317. });
  10318. visaInsIndex++;
  10319. }
  10320. if (infoView.Safe > 0)
  10321. {
  10322. views.Add(new QuoteSubItemInfo()
  10323. {
  10324. ItemId = visaInsItemTypeId,
  10325. Index = visaInsIndex,
  10326. FeeName = $"保险",
  10327. UnitPrice = infoView.Safe,
  10328. Currency = $"CNY",
  10329. Quantity = 1,
  10330. PplNum = pplNum,
  10331. TotalAmt = infoView.Safe * pplNum,
  10332. Remark = "",
  10333. });
  10334. }
  10335. #endregion
  10336. #region 服务费 1363
  10337. int serviceFeeIndex = 1;
  10338. int serviceFeeItemTypeId = 1363;
  10339. if (infoView.Service > 0)
  10340. {
  10341. views.Add(new QuoteSubItemInfo()
  10342. {
  10343. ItemId = serviceFeeItemTypeId,
  10344. Index = serviceFeeIndex,
  10345. FeeName = $"服务费",
  10346. UnitPrice = infoView.Service,
  10347. Currency = $"CNY",
  10348. Quantity = 1,
  10349. PplNum = pplNum,
  10350. TotalAmt = infoView.Service * pplNum,
  10351. Remark = "",
  10352. });
  10353. }
  10354. #endregion
  10355. #endregion
  10356. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10357. result.Rates = eecRates.ToArray();
  10358. if (result.FeeItems.Any())
  10359. {
  10360. result.FeeItems.Select(x =>
  10361. {
  10362. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10363. if (feeInfos.Any()) x.Infos = feeInfos;
  10364. return x;
  10365. }
  10366. )
  10367. .OrderBy(x => x.Index)
  10368. .ToList();
  10369. }
  10370. return Ok(JsonView(result));
  10371. }
  10372. /// <summary>
  10373. /// 团组模块 - 出入境费用报价表 - Info
  10374. /// </summary>
  10375. /// <returns></returns>
  10376. [HttpPost]
  10377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10378. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10379. {
  10380. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10381. if (!info.Rates.Any())
  10382. {
  10383. var rates = await GeneralMethod.EnterExitCostInitRate();
  10384. info.Rates = rates.ToArray();
  10385. }
  10386. return Ok(JsonView(info));
  10387. }
  10388. /// <summary>
  10389. /// 团组模块 - 出入境费用报价表 - OP
  10390. /// </summary>
  10391. /// <returns></returns>
  10392. [HttpPost]
  10393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10394. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10395. {
  10396. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10397. }
  10398. /// <summary>
  10399. /// 团组模块 - 出入境费用报价表 - 删除 项
  10400. /// </summary>
  10401. /// <returns></returns>
  10402. [HttpPost]
  10403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10404. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10405. {
  10406. if (dto.Id < 1) return Ok(JsonView(false,MsgTips.Id));
  10407. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10408. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10409. }
  10410. /// <summary>
  10411. /// 团组模块 - 出入境费用报价表 - 导出
  10412. /// </summary>
  10413. /// <returns></returns>
  10414. [HttpPost]
  10415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10416. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10417. {
  10418. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10419. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10420. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id= dto.Id });
  10421. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10422. var rates = info.Rates;
  10423. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10424. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10425. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10426. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10427. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10428. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10429. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10430. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10431. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10432. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10433. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10434. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10435. //获取模板
  10436. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx");
  10437. var designer = new WorkbookDesigner();
  10438. designer.Workbook = new Workbook(tempPath);
  10439. designer.SetDataSource("QuoteName", info.Name);
  10440. designer.SetDataSource("CompanyTitle", "公司名称");
  10441. designer.SetDataSource("CompanyLabel", "");
  10442. #region 国际旅费
  10443. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10444. if (intTravelCosts.Infos.Any())
  10445. {
  10446. var cabClassFilter = new string[] {"经济舱","公务舱","头等舱" };
  10447. string label = string.Empty;
  10448. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10449. if (infos.Any())
  10450. {
  10451. label = $"{infos.Sum(x => x.PplNum)}人全程机票:{infos.Sum(x => x.TotalAmt).TruncDecimals(2)}元\r\n";
  10452. }
  10453. foreach (var item in intTravelCosts.Infos)
  10454. {
  10455. label += $"{item.FeeName}:{item.UnitPrice.TruncDecimals(2)}元/人*{item.PplNum}人\r\n";
  10456. }
  10457. label += $"\r\n以上小计:{intTravelCosts.TotalAmt.TruncDecimals(2)}元";
  10458. designer.SetDataSource("IntTravelLabel", label);
  10459. }
  10460. #endregion
  10461. #region 住宿费
  10462. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10463. if (accomCosts.Infos.Any())
  10464. {
  10465. string currencyName = string.Empty;
  10466. decimal rate = 1.0000M;
  10467. string label = "全程五星酒店,每人1间房\r\n";
  10468. foreach (var item in accomCosts.Infos)
  10469. {
  10470. string hotelName = string.Empty;
  10471. if (item.FeeName.Contains("-"))
  10472. {
  10473. var feeName = item.FeeName.Split('-');
  10474. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10475. }
  10476. else hotelName = $"\r\n{item.FeeName}:";
  10477. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10478. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10479. rate = rateInfo?.Rate ?? 1.0000M;
  10480. label += $"{hotelName}{item.UnitPrice.TruncDecimals(2)}{currencyName}/间/晚*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10481. }
  10482. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元({currencyName}汇率:{rate.TruncDecimals(4)})";
  10483. designer.SetDataSource("AccomLabel", label);
  10484. }
  10485. #endregion
  10486. designer.Process();
  10487. //文件名
  10488. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10489. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  10490. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  10491. return Ok(JsonView(true, "成功", url));
  10492. }
  10493. #endregion
  10494. #region 签证费用录入
  10495. /// <summary>
  10496. /// 根据diid查询签证费用列表
  10497. /// </summary>
  10498. /// <param name="dto"></param>
  10499. /// <returns></returns>
  10500. [HttpPost]
  10501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10502. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10503. {
  10504. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10505. if (groupData.Code != 0)
  10506. {
  10507. return Ok(JsonView(false, groupData.Msg));
  10508. }
  10509. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10510. }
  10511. /// <summary>
  10512. /// 根据签证费用Id查询单条数据及c表数据
  10513. /// </summary>
  10514. /// <param name="dto"></param>
  10515. /// <returns></returns>
  10516. [HttpPost]
  10517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10518. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10519. {
  10520. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10521. if (groupData.Code != 0)
  10522. {
  10523. return Ok(JsonView(false, groupData.Msg));
  10524. }
  10525. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10526. }
  10527. /// <summary>
  10528. /// 签证费用删除
  10529. /// </summary>
  10530. /// <param name="dto"></param>
  10531. /// <returns></returns>
  10532. [HttpPost]
  10533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10534. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10535. {
  10536. _sqlSugar.BeginTran();
  10537. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10538. if (!res)
  10539. {
  10540. _sqlSugar.RollbackTran();
  10541. return Ok(JsonView(false, "删除失败"));
  10542. }
  10543. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10544. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10545. .SetColumns(a => new Grp_CreditCardPayment()
  10546. {
  10547. IsDel = 1,
  10548. DeleteUserId = dto.DeleteUserId,
  10549. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10550. })
  10551. .ExecuteCommand();
  10552. if (resSub < 1)
  10553. {
  10554. _sqlSugar.RollbackTran();
  10555. return Ok(JsonView(false, "删除失败"));
  10556. }
  10557. _sqlSugar.CommitTran();
  10558. return Ok(JsonView(true, "删除成功!"));
  10559. }
  10560. /// <summary>
  10561. /// 签证费用录入下拉框初始化
  10562. /// </summary>
  10563. /// <returns></returns>
  10564. [HttpPost]
  10565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10566. public async Task<IActionResult> VisaPriceAddSelect()
  10567. {
  10568. //支付方式
  10569. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10570. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10571. //币种
  10572. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10573. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10574. //乘客类型
  10575. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10576. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10577. //卡类型
  10578. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10579. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10580. //代办费类型
  10581. var agencyFeeTypeData = new List<dynamic>() {
  10582. new { id = 0 , Text = "未选择" },
  10583. new { id = 1 , Text = "小公务" },
  10584. new { id = 2 , Text = "大公务" },
  10585. };
  10586. //签证费用标准国家Data
  10587. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10588. var data = new
  10589. {
  10590. Payment = _Payment,
  10591. CurrencyList = _CurrencyList,
  10592. PassengerType = _PassengerType,
  10593. BankCard = _BankCard,
  10594. AgencyFeeType = agencyFeeTypeData,
  10595. CountryFeeData = visaCountryFeeData
  10596. };
  10597. return Ok(JsonView(true, "查询成功!", data));
  10598. }
  10599. /// <summary>
  10600. /// 签证费用录入操作(Status:1.新增,2.修改)
  10601. /// </summary>
  10602. /// <param name="dto"></param>
  10603. /// <returns></returns>
  10604. [HttpPost]
  10605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10606. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10607. {
  10608. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10609. if (groupData.Code != 0)
  10610. {
  10611. return Ok(JsonView(false, groupData.Msg));
  10612. }
  10613. #region 应用推送
  10614. try
  10615. {
  10616. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10617. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10618. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10619. //2024-10-21 新增LZ UID
  10620. var userIds = new List<int>() { 21 };
  10621. string title = $"系统通知";
  10622. string content = "";
  10623. var diId = dto.DiId;
  10624. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10625. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10626. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10627. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10628. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10629. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10630. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10631. }
  10632. catch (Exception ex)
  10633. {
  10634. }
  10635. #endregion
  10636. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10637. }
  10638. #endregion
  10639. #region 签证提成录入
  10640. /// <summary>
  10641. /// 签证提成录入
  10642. /// 基础数据
  10643. /// </summary>
  10644. /// <returns></returns>
  10645. [HttpGet]
  10646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10647. public async Task<IActionResult> VisaCommissionInit()
  10648. {
  10649. return Ok(await _visaCommissionRep.Init());
  10650. }
  10651. /// <summary>
  10652. /// 签证提成录入
  10653. /// Item
  10654. /// </summary>
  10655. /// <param name="_dto"></param>
  10656. /// <returns></returns>
  10657. [HttpPost]
  10658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10659. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10660. {
  10661. var validator = new VisaCommissionItemDtoValidator();
  10662. var validatorRes = await validator.ValidateAsync(_dto);
  10663. if (!validatorRes.IsValid)
  10664. {
  10665. StringBuilder sb = new StringBuilder();
  10666. foreach (var item in validatorRes.Errors)
  10667. {
  10668. sb.AppendLine(item.ErrorMessage);
  10669. }
  10670. return Ok(JsonView(false, sb.ToString()));
  10671. }
  10672. return Ok(await _visaCommissionRep.Item(_dto));
  10673. }
  10674. /// <summary>
  10675. /// 签证提成录入
  10676. /// Save
  10677. /// </summary>
  10678. /// <param name="_dto"></param>
  10679. /// <returns></returns>
  10680. [HttpPost]
  10681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10682. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10683. {
  10684. //参数验证
  10685. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10686. foreach (var item in _dto.Items)
  10687. {
  10688. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10689. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10690. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10691. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10692. }
  10693. return Ok(await _visaCommissionRep.Save(_dto));
  10694. }
  10695. /// <summary>
  10696. /// 签证提成录入
  10697. /// Create
  10698. /// </summary>
  10699. /// <param name="_dto"></param>
  10700. /// <returns></returns>
  10701. [HttpPost]
  10702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10703. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10704. {
  10705. var validator = new VisaCommissionCreateDtoValidator();
  10706. var validatorRes = await validator.ValidateAsync(_dto);
  10707. if (!validatorRes.IsValid)
  10708. {
  10709. StringBuilder sb = new StringBuilder();
  10710. foreach (var item in validatorRes.Errors)
  10711. {
  10712. sb.AppendLine(item.ErrorMessage);
  10713. }
  10714. return Ok(JsonView(false, sb.ToString()));
  10715. }
  10716. return Ok(await _visaCommissionRep.Create(_dto));
  10717. }
  10718. /// <summary>
  10719. /// 签证提成录入
  10720. /// Put(编辑)
  10721. /// </summary>
  10722. /// <param name="id"></param>
  10723. /// <param name="_dto"></param>
  10724. /// <returns></returns>
  10725. [HttpPut]
  10726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10727. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10728. {
  10729. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10730. var validator = new VisaCommissionCreateDtoValidator();
  10731. var validatorRes = await validator.ValidateAsync(_dto);
  10732. if (!validatorRes.IsValid)
  10733. {
  10734. StringBuilder sb = new StringBuilder();
  10735. foreach (var item in validatorRes.Errors)
  10736. {
  10737. sb.AppendLine(item.ErrorMessage);
  10738. }
  10739. return Ok(JsonView(false, sb.ToString()));
  10740. }
  10741. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10742. }
  10743. /// <summary>
  10744. /// 签证提成录入
  10745. /// Del
  10746. /// </summary>
  10747. /// <param name="id"></param>
  10748. /// <param name="currUserId"></param>
  10749. /// <returns></returns>
  10750. [HttpPost]
  10751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10752. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10753. {
  10754. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10755. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10756. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10757. }
  10758. #endregion
  10759. #region op费用录入
  10760. /// <summary>
  10761. /// 根据diid查询op费用列表
  10762. /// </summary>
  10763. /// <param name="dto"></param>
  10764. /// <returns></returns>
  10765. [HttpPost]
  10766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10767. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10768. {
  10769. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10770. if (groupData.Code != 0)
  10771. {
  10772. return Ok(JsonView(false, groupData.Msg));
  10773. }
  10774. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10775. }
  10776. /// <summary>
  10777. /// 根据op费用Id查询单条数据及c表数据
  10778. /// </summary>
  10779. /// <param name="dto"></param>
  10780. /// <returns></returns>
  10781. [HttpPost]
  10782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10783. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10784. {
  10785. try
  10786. {
  10787. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10788. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10789. var data = new
  10790. {
  10791. CarTouristGuideGround = _groupData,
  10792. CreditCardPayment = _creditCardPayment
  10793. };
  10794. return Ok(JsonView(true, "查询成功!", data));
  10795. }
  10796. catch (Exception ex)
  10797. {
  10798. return Ok(JsonView(false, "程序错误!"));
  10799. }
  10800. }
  10801. /// <summary>
  10802. /// op费用删除
  10803. /// </summary>
  10804. /// <param name="dto"></param>
  10805. /// <returns></returns>
  10806. [HttpPost]
  10807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10808. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10809. {
  10810. try
  10811. {
  10812. _sqlSugar.BeginTran();
  10813. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10814. if (!res)
  10815. {
  10816. return Ok(JsonView(false, "删除失败"));
  10817. }
  10818. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10819. {
  10820. IsDel = 1,
  10821. DeleteUserId = dto.DeleteUserId,
  10822. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10823. }).ExecuteCommandAsync();
  10824. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10825. {
  10826. IsDel = 1,
  10827. DeleteUserId = dto.DeleteUserId,
  10828. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10829. }).ExecuteCommandAsync();
  10830. #region 删除超支相关数据
  10831. //删除导入的超支数据
  10832. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10833. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10834. {
  10835. IsDel = 1,
  10836. DeleteUserId = dto.DeleteUserId,
  10837. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10838. }).ExecuteCommand();
  10839. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10840. {
  10841. IsDel = 1,
  10842. DeleteUserId = dto.DeleteUserId,
  10843. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10844. }).ExecuteCommand();
  10845. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10846. {
  10847. IsDel = 1,
  10848. DeleteUserId = dto.DeleteUserId,
  10849. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10850. }).ExecuteCommand();
  10851. #endregion
  10852. _sqlSugar.CommitTran();
  10853. return Ok(JsonView(true, "删除成功!"));
  10854. }
  10855. catch (Exception ex)
  10856. {
  10857. _sqlSugar.RollbackTran();
  10858. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10859. }
  10860. }
  10861. /// <summary>
  10862. /// op费用录入操作(Status:1.新增,2.修改)
  10863. /// </summary>
  10864. /// <param name="dto"></param>
  10865. /// <returns></returns>
  10866. [HttpPost]
  10867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10868. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10869. {
  10870. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10871. if (groupData.Code != 0)
  10872. {
  10873. return Ok(JsonView(false, groupData.Msg));
  10874. }
  10875. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10876. }
  10877. /// <summary>
  10878. /// 填写费用详细页面初始化绑定
  10879. /// </summary>
  10880. /// <param name="dto"></param>
  10881. /// <returns></returns>
  10882. [HttpPost]
  10883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10884. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10885. {
  10886. try
  10887. {
  10888. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10889. if (groupData.Code != 0)
  10890. {
  10891. return Ok(JsonView(false, groupData.Msg));
  10892. }
  10893. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10894. }
  10895. catch (Exception ex)
  10896. {
  10897. return Ok(JsonView(false, ex.Message));
  10898. }
  10899. }
  10900. /// <summary>
  10901. /// 根据op费用Id查询详细数据
  10902. /// </summary>
  10903. /// <param name="dto"></param>
  10904. /// <returns></returns>
  10905. [HttpPost]
  10906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10907. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10908. {
  10909. try
  10910. {
  10911. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10912. if (groupData.Code != 0)
  10913. {
  10914. return Ok(JsonView(false, groupData.Msg));
  10915. }
  10916. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10917. }
  10918. catch (Exception ex)
  10919. {
  10920. return Ok(JsonView(false, ex.Message));
  10921. }
  10922. }
  10923. /// <summary>
  10924. /// OP费用录入填写详情
  10925. /// </summary>
  10926. /// <param name="dto"></param>
  10927. /// <returns></returns>
  10928. [HttpPost]
  10929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10930. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10931. {
  10932. try
  10933. {
  10934. #region 参数校验
  10935. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10936. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10937. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10938. #endregion
  10939. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10940. if (groupData.Code != 0)
  10941. {
  10942. return Ok(JsonView(false, groupData.Msg));
  10943. }
  10944. //自动审核
  10945. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10946. #region 应用推送
  10947. try
  10948. {
  10949. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10950. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10951. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10952. //2024-10-21 新增LZ UID
  10953. var userIds = new List<int>() { 21 };
  10954. string title = $"系统通知";
  10955. var diId = dto.DiId;
  10956. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10957. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10958. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  10959. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10960. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10961. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10962. }
  10963. catch (Exception ex)
  10964. {
  10965. }
  10966. #endregion
  10967. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10968. }
  10969. catch (Exception ex)
  10970. {
  10971. return Ok(JsonView(false, ex.Message));
  10972. }
  10973. }
  10974. /// <summary>
  10975. /// 获取三公详细所有城市
  10976. /// </summary>
  10977. /// <returns></returns>
  10978. [HttpGet]
  10979. public IActionResult OpCarCityResult()
  10980. {
  10981. var jw = JsonView(false);
  10982. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10983. {
  10984. x.Id,
  10985. x.Country,
  10986. x.City,
  10987. }).ToList();
  10988. if (data.Count > 0)
  10989. {
  10990. jw = JsonView(true, "获取成功!", data);
  10991. }
  10992. else
  10993. {
  10994. jw.Msg = "城市数据为空!";
  10995. jw.Data = new string[0];
  10996. }
  10997. return Ok(jw);
  10998. }
  10999. /// <summary>
  11000. /// 导出地接费用明细
  11001. /// </summary>
  11002. /// <param name="dto"></param>
  11003. /// <returns></returns>
  11004. [HttpPost]
  11005. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11006. {
  11007. var jw = JsonView(false);
  11008. if (dto.Diid < 1)
  11009. {
  11010. jw.Msg = "请输入正确的diid!";
  11011. return Ok(jw);
  11012. }
  11013. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11014. if (group == null)
  11015. {
  11016. jw.Msg = "未找到团组信息!";
  11017. return Ok(jw);
  11018. }
  11019. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11020. if (localGuideArr.Count == 0)
  11021. {
  11022. jw.Msg = "该团组暂无地接信息!";
  11023. return Ok(jw);
  11024. }
  11025. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11026. var overspendSoure = new Dictionary<int, int>
  11027. {
  11028. { 91, 982 }, //车
  11029. { 92 , 1059} ,//导游
  11030. { 994 , 1073}, //翻译
  11031. { 988 , 1074 }, //早餐
  11032. { 93 , 1075 }, //午餐
  11033. { 989 , 1076 }, //晚餐
  11034. };
  11035. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11036. foreach (var groupArr in localGroup)
  11037. {
  11038. var keyValue = groupArr.Key;
  11039. if (int.TryParse(keyValue, out int cityid))
  11040. {
  11041. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11042. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11043. }
  11044. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11045. foreach (var item in groupArr)
  11046. {
  11047. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11048. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11049. new Grp_CarTouristGuideGroundReservationsContentExtend
  11050. {
  11051. Count = a.Count,
  11052. CreateTime = a.CreateTime,
  11053. CreateUserId = a.CreateUserId,
  11054. CTGGRId = a.CTGGRId,
  11055. Currency = a.Currency,
  11056. DatePrice = a.DatePrice,
  11057. DeleteTime = a.DeleteTime,
  11058. DeleteUserId = a.DeleteUserId,
  11059. DiId = a.DiId,
  11060. Id = a.Id,
  11061. IsDel = a.IsDel,
  11062. Price = a.Price,
  11063. PriceContent = a.PriceContent,
  11064. Remark = a.Remark,
  11065. SId = a.SId,
  11066. SidName = b.Name,
  11067. Units = a.Units,
  11068. }
  11069. ).ToList();
  11070. if (content.Count > 0)
  11071. {
  11072. contentArr.Add(content);
  11073. }
  11074. }
  11075. //open excel
  11076. //set excel
  11077. //save excel
  11078. try
  11079. {
  11080. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11081. IWorkbook workbook;
  11082. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11083. {
  11084. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11085. }
  11086. else
  11087. {
  11088. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11089. }
  11090. ISheet sheet = workbook.GetSheetAt(0);
  11091. var rowStartIndex = 2;
  11092. var clounmCount = 10;
  11093. var initStyleRow = sheet.GetRow(2);
  11094. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11095. //var overspendArrDetail =
  11096. var existsId = new List<CarCompare>();
  11097. var lastElem = arr.Last();
  11098. var thisSid = -1;
  11099. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11100. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11101. {
  11102. Name = "未知币种!",
  11103. Remark = "未知币种!",
  11104. };
  11105. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11106. Action cloneRowFn = () =>
  11107. {
  11108. rowStartIndex++;
  11109. var cloneRow = sheet.CreateRow(rowStartIndex);
  11110. // 复制样式
  11111. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11112. {
  11113. ICell sourceCell = initStyleRow.GetCell(i);
  11114. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11115. // 确保单元格存在样式
  11116. if (sourceCell.CellStyle != null)
  11117. {
  11118. targetCell.CellStyle = sourceCell.CellStyle;
  11119. }
  11120. }
  11121. };
  11122. var mergeRow = () =>
  11123. {
  11124. for (int i = 2; i < sheet.LastRowNum; i++)
  11125. {
  11126. var row = sheet.GetRow(i);
  11127. var cellFirst = row.GetCell(0);
  11128. var thisIndex = i + 1;
  11129. while (thisIndex < sheet.LastRowNum)
  11130. {
  11131. var nextRow = sheet.GetRow(thisIndex);
  11132. var nextCellFirst = nextRow.GetCell(0);
  11133. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11134. {
  11135. thisIndex++;
  11136. }
  11137. else
  11138. {
  11139. break;
  11140. }
  11141. }
  11142. thisIndex--;
  11143. if (thisIndex != i)
  11144. {
  11145. //合并row
  11146. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11147. i, // 起始行索引(0-based)
  11148. thisIndex, // 结束行索引(0-based)
  11149. 0, // 起始列索引(0-based)
  11150. 0 // 结束列索引(0-based)
  11151. );
  11152. sheet.AddMergedRegion(cellRangeAddress);
  11153. i = thisIndex;
  11154. }
  11155. }
  11156. };
  11157. var chaoshiNumber = 0;
  11158. var totalNumber = 0.00M;
  11159. string lastStr = "";
  11160. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11161. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11162. {
  11163. b.IsAuditGM,
  11164. x.Id,
  11165. x.Area,
  11166. b.PayPercentage,
  11167. b.PayMoney,
  11168. }).ToList();
  11169. string yesPayment = "", noPayment = "";
  11170. foreach (var item in queryCarArrByCityAndDiid)
  11171. {
  11172. if (item.IsAuditGM == 1)
  11173. {
  11174. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11175. }
  11176. else
  11177. {
  11178. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11179. }
  11180. }
  11181. lastStr = yesPayment + noPayment;
  11182. foreach (var item in arr)
  11183. {
  11184. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11185. {
  11186. if (thisSid != item.SId)
  11187. {
  11188. if (thisSid == -1)
  11189. {
  11190. thisSid = item.SId;
  11191. }
  11192. else
  11193. {
  11194. //合并小计行
  11195. //创建合并区域的实例
  11196. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11197. rowStartIndex, // 起始行索引(0-based)
  11198. rowStartIndex, // 结束行索引(0-based)
  11199. 0, // 起始列索引(0-based)
  11200. 3 // 结束列索引(0-based)
  11201. );
  11202. sheet.AddMergedRegion(cellRangeAddress);
  11203. var CellStyle = workbook.CreateCellStyle();
  11204. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11205. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11206. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11207. for (int i = 0; i <= clounmCount; i++)
  11208. {
  11209. if (i > 6)
  11210. {
  11211. var CellStyle1 = workbook.CreateCellStyle();
  11212. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11213. IFont Font = workbook.CreateFont(); // 创建字体
  11214. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11215. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11216. CellStyle1.SetFont(Font);
  11217. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11218. }
  11219. else
  11220. {
  11221. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11222. }
  11223. }
  11224. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11225. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11226. //超时合计
  11227. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11228. //超时数
  11229. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11230. //超时合计费用
  11231. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11232. thisSid = item.SId;
  11233. cloneRowFn();
  11234. chaoshiNumber = 0;
  11235. totalNumber = 0;
  11236. }
  11237. }
  11238. IRow row = sheet.GetRow(rowStartIndex);
  11239. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11240. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11241. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11242. if (isOpenOverspendSoure)
  11243. {
  11244. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11245. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11246. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11247. }
  11248. for (int i = 0; i <= clounmCount; i++)
  11249. {
  11250. var cell = row.GetCell(i);
  11251. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11252. if (cell == null)
  11253. {
  11254. cell = row.CreateCell(i);
  11255. }
  11256. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11257. fontRed.CloneStyleFrom(cell.CellStyle);
  11258. IFont Font = workbook.CreateFont(); // 创建字体
  11259. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11260. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11261. fontRed.SetFont(Font);
  11262. byte[] rgb = new byte[3] { 255, 242, 204 };
  11263. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11264. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11265. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11266. if (workbook is XSSFWorkbook)
  11267. {
  11268. BackgroundColor255_242_204.FillForegroundColor = 0;
  11269. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11270. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  11271. }
  11272. else
  11273. {
  11274. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11275. }
  11276. if (i == 1 || i > 6)
  11277. {
  11278. if (i > 6)
  11279. {
  11280. fontRed.FillForegroundColor = 0;
  11281. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11282. fontRed.FillPattern = FillPattern.SolidForeground;
  11283. }
  11284. cell.CellStyle = fontRed;
  11285. }
  11286. if (i > 2 && i < 7)
  11287. {
  11288. cell.CellStyle = BackgroundColor255_242_204;
  11289. }
  11290. cell.SetCellValue(setCellValue); //写入单元格
  11291. }
  11292. if (overspendSoure.ContainsKey(thisSid))
  11293. {
  11294. var overspendId = overspendSoure[thisSid];
  11295. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11296. }
  11297. cloneRowFn();
  11298. existsId.Add(new CarCompare
  11299. {
  11300. DataPrice = item.DatePrice.ObjToDate(),
  11301. Sid = item.SId
  11302. });
  11303. }
  11304. if (item.Equals(lastElem))
  11305. {
  11306. //合并小计行
  11307. //创建合并区域的实例
  11308. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11309. rowStartIndex, // 起始行索引(0-based)
  11310. rowStartIndex, // 结束行索引(0-based)
  11311. 0, // 起始列索引(0-based)
  11312. 3 // 结束列索引(0-based)
  11313. );
  11314. sheet.AddMergedRegion(cellRangeAddress);
  11315. var CellStyle = workbook.CreateCellStyle();
  11316. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11317. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11318. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11319. for (int i = 0; i <= clounmCount; i++)
  11320. {
  11321. if (i > 6)
  11322. {
  11323. var CellStyle1 = workbook.CreateCellStyle();
  11324. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11325. IFont Font = workbook.CreateFont(); // 创建字体
  11326. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11327. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11328. CellStyle1.SetFont(Font);
  11329. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11330. }
  11331. else
  11332. {
  11333. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11334. }
  11335. }
  11336. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11337. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11338. //超时合计
  11339. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11340. //超时数
  11341. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11342. //超时合计费用
  11343. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11344. cloneRowFn();
  11345. // 创建合并区域的实例
  11346. cellRangeAddress = new CellRangeAddress(
  11347. rowStartIndex, // 起始行索引(0-based)
  11348. rowStartIndex, // 结束行索引(0-based)
  11349. 0, // 起始列索引(0-based)
  11350. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11351. );
  11352. // 添加合并区域
  11353. sheet.AddMergedRegion(cellRangeAddress);
  11354. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11355. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11356. }
  11357. }
  11358. mergeRow();
  11359. // 保存修改后的Excel文件到新文件
  11360. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11361. // new FileStream(newFilePath, FileMode.CreateNew)
  11362. using (var stream = new MemoryStream())
  11363. {
  11364. workbook.Write(stream, true);
  11365. stream.Flush();
  11366. stream.Seek(0, SeekOrigin.Begin);
  11367. MemoryStream memoryStream = new MemoryStream();
  11368. stream.CopyTo(memoryStream);
  11369. memoryStream.Seek(0, SeekOrigin.Begin);
  11370. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11371. }
  11372. workbook.Close();
  11373. workbook.Dispose();
  11374. }
  11375. catch (Exception ex)
  11376. {
  11377. jw.Msg = "出现异常!" + ex.Message;
  11378. return Ok(jw);
  11379. }
  11380. }
  11381. if (Zips.Count > 0)
  11382. {
  11383. IOOperatorHelper io = new IOOperatorHelper();
  11384. var byts = io.ConvertZipStream(Zips);
  11385. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11386. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11387. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11388. }
  11389. else
  11390. {
  11391. jw.Msg = "暂无生成文件!";
  11392. }
  11393. return Ok(jw);
  11394. }
  11395. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11396. {
  11397. string outStr = string.Empty;
  11398. switch (i)
  11399. {
  11400. case 0:
  11401. outStr = arr[0].SidName;
  11402. break;
  11403. case 1:
  11404. outStr = arr[0].DataPriceStr;
  11405. break;
  11406. case 2:
  11407. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11408. break;
  11409. case 4:
  11410. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11411. break;
  11412. case 7:
  11413. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11414. {
  11415. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11416. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11417. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11418. }
  11419. break;
  11420. case 8:
  11421. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11422. {
  11423. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11424. }
  11425. break;
  11426. case 9:
  11427. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11428. {
  11429. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11430. }
  11431. break;
  11432. case 10:
  11433. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11434. {
  11435. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11436. }
  11437. break;
  11438. }
  11439. return outStr;
  11440. }
  11441. #region OP行程单
  11442. /// <summary>
  11443. /// OP行程单初始化
  11444. /// </summary>
  11445. /// <param name="dto"></param>
  11446. /// <returns></returns>
  11447. [HttpPost]
  11448. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11449. {
  11450. var jw = JsonView(false);
  11451. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  11452. var group = groupList.First();
  11453. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11454. if (group == null)
  11455. {
  11456. jw.Msg = "暂无团组!";
  11457. return Ok(jw);
  11458. }
  11459. group = groupList.Find(x => x.Id == diid);
  11460. if (group == null)
  11461. {
  11462. jw.Msg = "请输入正确的团组ID!";
  11463. return Ok(jw);
  11464. }
  11465. string city = string.Empty;
  11466. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11467. if (blackCode.Count > 0)
  11468. {
  11469. var black = blackCode.First();
  11470. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11471. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11472. if (blackSp.Length > 0)
  11473. {
  11474. try
  11475. {
  11476. var cityArrCode = new List<string>(20);
  11477. foreach (var item in blackSp)
  11478. {
  11479. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11480. var IndexSelect = itemSp[2];
  11481. var cityArrCodeLength = cityArrCode.Count - 1;
  11482. var startCity = IndexSelect.Substring(0, 3);
  11483. if (cityArrCodeLength > 0)
  11484. {
  11485. var arrEndCity = cityArrCode[cityArrCodeLength];
  11486. if (arrEndCity != startCity)
  11487. {
  11488. cityArrCode.Add(startCity.ToUpper());
  11489. }
  11490. }
  11491. else
  11492. {
  11493. cityArrCode.Add(startCity.ToUpper());
  11494. }
  11495. var endCity = IndexSelect.Substring(3, 3);
  11496. cityArrCode.Add(endCity.ToUpper());
  11497. }
  11498. var cityThree = string.Empty;
  11499. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11500. cityThree = cityThree.TrimEnd(',');
  11501. if (string.IsNullOrWhiteSpace(cityThree))
  11502. {
  11503. throw new
  11504. Exception("error");
  11505. }
  11506. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11507. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11508. foreach (var item in cityArrCode)
  11509. {
  11510. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11511. if (find != null)
  11512. {
  11513. city += find.City + "/";
  11514. }
  11515. else
  11516. {
  11517. city += item + "三字码未收入/";
  11518. }
  11519. }
  11520. city = city.TrimEnd('/');
  11521. }
  11522. catch (Exception e)
  11523. {
  11524. city = "黑屏代码格式不正确!";
  11525. }
  11526. }
  11527. }
  11528. else
  11529. {
  11530. city = "未录入黑屏代码";
  11531. }
  11532. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11533. {
  11534. Date = x.Date,
  11535. Days = x.Days,
  11536. Diffgroup = x.Diffgroup,
  11537. Diid = x.Diid,
  11538. Traffic_First = x.Traffic_First,
  11539. Traffic_Second = x.Traffic_Second,
  11540. Trip = x.Trip,
  11541. WeekDay = x.WeekDay,
  11542. Id = x.Id
  11543. }).ToList();
  11544. jw.Data = new
  11545. {
  11546. groupList = groupList.Select(x => new
  11547. {
  11548. x.Id,
  11549. x.TeamName,
  11550. x.TourCode
  11551. }).ToList(),
  11552. groupInfo = new
  11553. {
  11554. group.VisitDays,
  11555. group.TourCode,
  11556. group.VisitPNumber,
  11557. group.TeamName,
  11558. city
  11559. },
  11560. OpTravelList
  11561. };
  11562. jw.Code = 200;
  11563. jw.Msg = "操作成功!";
  11564. return Ok(jw);
  11565. }
  11566. /// <summary>
  11567. /// 删除团组行程单
  11568. /// </summary>
  11569. /// <returns></returns>
  11570. [HttpPost]
  11571. public IActionResult DelTravel(DelOpTravelDto dto)
  11572. {
  11573. var jw = JsonView(false);
  11574. if (dto.UserId <= 0 || dto.Diid <= 0)
  11575. {
  11576. jw.Msg = "请输入正确的参数!";
  11577. return Ok(jw);
  11578. }
  11579. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11580. .SetColumns(x => new Grp_TravelList
  11581. {
  11582. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11583. DeleteUserId = dto.UserId,
  11584. IsDel = 1,
  11585. }).ExecuteCommand();
  11586. jw = JsonView(true);
  11587. return Ok(jw);
  11588. }
  11589. /// <summary>
  11590. /// 行程单保存
  11591. /// </summary>
  11592. /// <returns></returns>
  11593. [HttpPost]
  11594. public IActionResult TravelSave(TravelSaveDto dto)
  11595. {
  11596. var jw = JsonView(false);
  11597. if (dto.Arr.Count > 0)
  11598. {
  11599. try
  11600. {
  11601. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11602. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11603. .ToList();
  11604. _sqlSugar.BeginTran();
  11605. foreach (var item in dto.Arr)
  11606. {
  11607. if (item.Id == 0)
  11608. {
  11609. throw new Exception("请传入正确的Id");
  11610. }
  11611. //比较上一次的差异
  11612. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11613. if (findTravel != null)
  11614. {
  11615. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11616. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11617. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11618. }
  11619. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11620. .SetColumns(x => new Grp_TravelList
  11621. {
  11622. Trip = item.Trip
  11623. }).ExecuteCommand();
  11624. }
  11625. _sqlSugar.CommitTran();
  11626. jw = JsonView(true);
  11627. }
  11628. catch (Exception ex)
  11629. {
  11630. _sqlSugar.RollbackTran();
  11631. jw.Msg = "程序异常!" + ex.Message;
  11632. }
  11633. }
  11634. else
  11635. {
  11636. jw.Msg = "请传入正确的参数!";
  11637. }
  11638. return Ok(jw);
  11639. }
  11640. private string CheckStr(string original, string changed)
  11641. {
  11642. // 创建diff_match_patch对象
  11643. var dmp = new diff_match_patch();
  11644. // 计算差异
  11645. List<Diff> diffs = dmp.diff_main(original, changed);
  11646. // 清理和合并差异
  11647. dmp.diff_cleanupSemantic(diffs);
  11648. // 使用StringBuilder构建最终的字符串
  11649. StringBuilder finalString = new StringBuilder();
  11650. // 输出差异结果,并构建变动后的字符串
  11651. foreach (Diff diff in diffs)
  11652. {
  11653. switch (diff.operation)
  11654. {
  11655. case Operation.EQUAL:
  11656. // 相等的部分,直接添加到最终字符串
  11657. finalString.Append(diff.text);
  11658. break;
  11659. case Operation.INSERT:
  11660. // 插入的部分,添加标记并添加到最终字符串
  11661. finalString.Append("[++]" + diff.text + "[++]");
  11662. break;
  11663. case Operation.DELETE:
  11664. // 删除的部分,不添加到最终字符串
  11665. //finalString.Append("[++]" + diff.text + "[++]");
  11666. break;
  11667. }
  11668. }
  11669. // 输出变动后的字符串
  11670. return finalString.ToString();
  11671. }
  11672. private class tagContent
  11673. {
  11674. public DateTime Date { get; set; }
  11675. public string StartTag { get; set; }
  11676. public string EndTag { get; set; }
  11677. public string Content { get; set; }
  11678. public static int tagLength { get { return 3; } }
  11679. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11680. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11681. public bool IsFinally { get; set; }
  11682. }
  11683. private List<string> ExtractContentBetweenTags(string input, string tag)
  11684. {
  11685. List<string> results = new List<string>();
  11686. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11687. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11688. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11689. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11690. string[] strValueArr = new string[1];
  11691. foreach (System.Text.RegularExpressions.Match match in matches)
  11692. {
  11693. var strValue = match.Groups[1].Value;
  11694. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11695. }
  11696. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11697. return results;
  11698. }
  11699. /// <summary>
  11700. /// 导出行程单
  11701. /// </summary>
  11702. /// <param name="dto"></param>
  11703. /// <returns></returns>
  11704. [HttpPost]
  11705. public IActionResult ExportTravel(ExportTravelDto dto)
  11706. {
  11707. var jw = JsonView(false);
  11708. jw.Data = "";
  11709. int diid = 0;
  11710. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11711. if (Find == null)
  11712. {
  11713. jw.Msg = "请选择正确的团组!";
  11714. return Ok(jw);
  11715. }
  11716. else
  11717. {
  11718. diid = Find.Id;
  11719. }
  11720. //数据源
  11721. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11722. DataTable dtBlack = null;
  11723. try
  11724. {
  11725. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11726. }
  11727. catch (Exception)
  11728. {
  11729. jw.Msg = "机票黑屏代码有误!";
  11730. return Ok(jw);
  11731. }
  11732. string CityStr = string.Empty;
  11733. if (dtBlack.Rows.Count == 0)
  11734. {
  11735. jw.Msg = "机票黑屏代码有误!";
  11736. return Ok(jw);
  11737. }
  11738. else
  11739. {
  11740. foreach (DataRow row in dtBlack.Rows)
  11741. {
  11742. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11743. {
  11744. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11745. return Ok(jw);
  11746. }
  11747. }
  11748. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11749. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11750. }
  11751. // 指定的文字
  11752. var targetTextDic = new Dictionary<string, List<string>>();
  11753. //创建数据源Table
  11754. DataTable dtSource = new DataTable();
  11755. dtSource.Columns.Add("Days", typeof(string));
  11756. dtSource.Columns.Add("Date", typeof(string));
  11757. dtSource.Columns.Add("Week", typeof(string));
  11758. dtSource.Columns.Add("Traffic", typeof(string));
  11759. dtSource.Columns.Add("Trip", typeof(string));
  11760. //获取数据,放到datatable
  11761. foreach (var item in _travelList)
  11762. {
  11763. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11764. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11765. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11766. .Replace("[++]", string.Empty);
  11767. DataRow dr = dtSource.NewRow();
  11768. dr["Days"] = item.Days;
  11769. dr["Date"] = item.Date;
  11770. dr["Week"] = item.WeekDay;
  11771. dr["Traffic"] = item.Traffic_First
  11772. + "\r\n"
  11773. + item.Traffic_Second;
  11774. dr["Trip"] = item.Trip;
  11775. dtSource.Rows.Add(dr);
  11776. }
  11777. Dictionary<string, string> dic = new Dictionary<string, string>();
  11778. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11779. dic.Add("City", CityStr);
  11780. dic.Add("Days", Find.VisitDays.ToString());
  11781. dic.Add("DeleCode", Find.TourCode);
  11782. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11783. //模板路径
  11784. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11785. //载入模板
  11786. Document doc = null;
  11787. DocumentBuilder builder = null;
  11788. try
  11789. {
  11790. //载入模板
  11791. doc = new Document(tempPath);
  11792. builder = new DocumentBuilder(doc);
  11793. }
  11794. catch (Exception)
  11795. {
  11796. jw.Msg = "模板位置不存在!";
  11797. return Ok(jw);
  11798. }
  11799. foreach (var key in dic.Keys)
  11800. {
  11801. Bookmark bookmark = doc.Range.Bookmarks[key];
  11802. if (bookmark != null)
  11803. {
  11804. builder.MoveToBookmark(key);
  11805. builder.Write(dic[key]);
  11806. }
  11807. }
  11808. //获取word里所有表格
  11809. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11810. //获取所填表格的序数
  11811. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11812. try
  11813. {
  11814. //循环赋值
  11815. for (int i = 0; i < dtSource.Rows.Count; i++)
  11816. {
  11817. builder.MoveToCell(0, i + 1, 0, 0);
  11818. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11819. builder.MoveToCell(0, i + 1, 1, 0);
  11820. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11821. builder.MoveToCell(0, i + 1, 2, 0);
  11822. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11823. var trip = dtSource.Rows[i]["Trip"].ToString();
  11824. builder.MoveToCell(0, i + 1, 3, 0);
  11825. builder.Write(trip);
  11826. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11827. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11828. // 获取特定索引的段落
  11829. Paragraph paragraph = (Paragraph)paragraphs[0];
  11830. Run run = paragraph.Runs[0];
  11831. Aspose.Words.Font font = run.Font;
  11832. font.Name = "黑体";
  11833. //设置双休红色
  11834. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11835. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11836. paragraph = (Paragraph)paragraphs[1];
  11837. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11838. {
  11839. run = paragraph.Runs[0];
  11840. font = run.Font;
  11841. font.Color = Color.Red;
  11842. }
  11843. }
  11844. }
  11845. catch (Exception ex)
  11846. {
  11847. }
  11848. //删除多余行
  11849. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11850. {
  11851. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11852. }
  11853. var targetTextList = new List<string>();
  11854. // 遍历文档中的表格
  11855. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11856. {
  11857. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11858. {
  11859. var cellIndex = 0;
  11860. foreach (Cell cell in row.Cells)
  11861. {
  11862. if (cellIndex == 1 && row.Cells.Count == 4)
  11863. {
  11864. foreach (var target in targetTextDic.Keys)
  11865. {
  11866. if (cell.GetText().Contains(target))
  11867. {
  11868. targetTextList = targetTextDic[target];
  11869. break;
  11870. }
  11871. }
  11872. }
  11873. // 遍历单元格中的所有段落
  11874. foreach (Paragraph paragraph in cell.Paragraphs)
  11875. {
  11876. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11877. List<Run> runs = new List<Run>();
  11878. foreach (Run run in paragraph.Runs)
  11879. {
  11880. runs.Add(run);
  11881. }
  11882. foreach (Run run in runs)
  11883. {
  11884. foreach (var targetText in targetTextList)
  11885. {
  11886. // 检查文字是否包含指定文字
  11887. if (run.Text.Contains(targetText))
  11888. {
  11889. // 将包含的部分设置为红色
  11890. HighlightText(run, targetText, Color.Red);
  11891. }
  11892. }
  11893. }
  11894. }
  11895. cellIndex++;
  11896. }
  11897. }
  11898. }
  11899. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11900. if (!Directory.Exists(savePath))
  11901. {
  11902. try
  11903. {
  11904. Directory.CreateDirectory(savePath);
  11905. }
  11906. catch
  11907. {
  11908. }
  11909. }
  11910. string path = savePath + Find.TeamName + "出访日程";
  11911. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11912. try
  11913. {
  11914. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11915. string postfix = ".docx";
  11916. if (dto.IsPDF == 1)
  11917. {
  11918. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11919. postfix = ".pdf";
  11920. }
  11921. doc.Save(path + postfix, saveFormat);
  11922. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11923. }
  11924. catch (Exception)
  11925. {
  11926. jw = JsonView(false);
  11927. }
  11928. return Ok(jw);
  11929. }
  11930. /// <summary>
  11931. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11932. /// </summary>
  11933. /// <param name="num"></param>
  11934. /// <returns></returns>
  11935. string GetNum(string num)
  11936. {
  11937. string str = "";
  11938. switch (num)
  11939. {
  11940. case "1":
  11941. str = "一";
  11942. break;
  11943. case "2":
  11944. str = "二";
  11945. break;
  11946. case "3":
  11947. str = "三";
  11948. break;
  11949. case "4":
  11950. str = "四";
  11951. break;
  11952. case "5":
  11953. str = "五";
  11954. break;
  11955. case "6":
  11956. str = "六";
  11957. break;
  11958. case "7":
  11959. str = "七";
  11960. break;
  11961. case "8":
  11962. str = "八";
  11963. break;
  11964. case "9":
  11965. str = "九";
  11966. break;
  11967. case "10":
  11968. str = "十";
  11969. break;
  11970. case "11":
  11971. str = "十一";
  11972. break;
  11973. case "12":
  11974. str = "十二";
  11975. break;
  11976. case "一":
  11977. str = "1";
  11978. break;
  11979. case "二":
  11980. str = "2";
  11981. break;
  11982. case "三":
  11983. str = "3";
  11984. break;
  11985. case "四":
  11986. str = "4";
  11987. break;
  11988. case "五":
  11989. str = "5";
  11990. break;
  11991. case "六":
  11992. str = "6";
  11993. break;
  11994. case "七":
  11995. str = "7";
  11996. break;
  11997. case "八":
  11998. str = "8";
  11999. break;
  12000. case "九":
  12001. str = "9";
  12002. break;
  12003. case "十":
  12004. str = "10";
  12005. break;
  12006. case "十一":
  12007. str = "11";
  12008. break;
  12009. case "十二":
  12010. str = "12";
  12011. break;
  12012. }
  12013. return str;
  12014. }
  12015. // 高亮包含指定文字的部分
  12016. void HighlightText(Run run, string targetText, Color color)
  12017. {
  12018. string text = run.Text;
  12019. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12020. if (startIndex >= 0)
  12021. {
  12022. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12023. // 前部分
  12024. if (startIndex > 0)
  12025. {
  12026. Run beforeRun = (Run)run.Clone(true);
  12027. beforeRun.Text = text.Substring(0, startIndex);
  12028. parentParagraph.InsertBefore(beforeRun, run);
  12029. }
  12030. // 匹配部分
  12031. Run matchRun = (Run)run.Clone(true);
  12032. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12033. matchRun.Font.Color = color;
  12034. parentParagraph.InsertBefore(matchRun, run);
  12035. // 后部分
  12036. if (startIndex + targetText.Length < text.Length)
  12037. {
  12038. Run afterRun = (Run)run.Clone(true);
  12039. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12040. parentParagraph.InsertBefore(afterRun, run);
  12041. }
  12042. // 删除原始Run
  12043. run.Remove();
  12044. }
  12045. }
  12046. #endregion
  12047. #endregion
  12048. #region 团组成本
  12049. /// <summary>
  12050. /// 团组成本数据初始化
  12051. /// </summary>
  12052. /// <param name="dto"></param>
  12053. /// <returns></returns>
  12054. [HttpPost]
  12055. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12056. {
  12057. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12058. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12059. WHEN COUNT(*) >= 0 THEN 'True'
  12060. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12061. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12062. ").ToList(); //团组列表
  12063. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12064. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12065. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12066. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12067. if (groupinfoValue != null)
  12068. {
  12069. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12070. var spArr = new string[1] { countryArr };
  12071. if (countryArr.Contains("|"))
  12072. {
  12073. spArr = countryArr.Split("|");
  12074. }
  12075. else if (countryArr.Contains("、"))
  12076. {
  12077. spArr = countryArr.Split("、");
  12078. }
  12079. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12080. {
  12081. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12082. if (dbQueryCountry != null)
  12083. {
  12084. visaCountryInfoArr.Add(dbQueryCountry);
  12085. }
  12086. }
  12087. }
  12088. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12089. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12090. var create = _GroupCostRepository.
  12091. CreateGroupCostByBlackCode(dto.Diid);
  12092. if (groupCost.Count == 0 && create.Code == 0)
  12093. {
  12094. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12095. }
  12096. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12097. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12098. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12099. groupCostMap = groupCostMap.Select(x =>
  12100. {
  12101. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12102. {
  12103. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12104. }
  12105. return x;
  12106. }).ToList();
  12107. //GroupCostParameter.Add(new
  12108. // Grp_GroupCostParameter());
  12109. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12110. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12111. return Ok(JsonView(new
  12112. {
  12113. groupList,
  12114. groupInfo,
  12115. groupChecks,
  12116. groupCost = groupCostMap,
  12117. hotelNumber,
  12118. GroupCostParameter = GroupCostParameterMap,
  12119. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12120. {
  12121. x.VisaCountry,
  12122. x.VisaPrice,
  12123. x.Id,
  12124. }).ToList(),
  12125. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12126. blackCodeIsTrue = create.Code == 0 ? true : false,
  12127. hotelIsTrue = hotelIsTrue,
  12128. }));
  12129. }
  12130. /// <summary>
  12131. /// 团组成本信息保存
  12132. /// </summary>
  12133. /// <param name="dto"></param>
  12134. /// <returns></returns>
  12135. [HttpPost]
  12136. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12137. {
  12138. if (dto.Diid <= 0 || dto.Userid <= 0)
  12139. {
  12140. return Ok(JsonView(false));
  12141. }
  12142. JsonView jw = null;
  12143. bool isTrue = false;
  12144. #region 复制团组成本
  12145. //if (dto.Diid == 2581)
  12146. //{
  12147. // dto.Diid = 2599;
  12148. // dto.CheckBoxs.ForEach(x =>
  12149. // {
  12150. // x.Diid = 2599;
  12151. // });
  12152. // dto.GroupCosts.ForEach(x =>
  12153. // {
  12154. // x.Diid = 2599;
  12155. // });
  12156. // dto.CostTypeHotelNumbers.ForEach(x =>
  12157. // {
  12158. // x.Diid = 2599;
  12159. // });
  12160. // dto.GroupCostParameters.ForEach(x =>
  12161. // {
  12162. // x.DiId = 2599;
  12163. // });
  12164. //}
  12165. #endregion
  12166. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12167. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12168. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12169. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12170. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12171. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12172. try
  12173. {
  12174. _sqlSugar.BeginTran();
  12175. isTrue = await _GroupCostRepository.
  12176. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12177. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12178. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12179. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12180. _sqlSugar.CommitTran();
  12181. jw = JsonView(true, "保存成功!", isTrue);
  12182. }
  12183. catch (Exception)
  12184. {
  12185. _sqlSugar.RollbackTran();
  12186. jw = JsonView(false);
  12187. }
  12188. return Ok(jw);
  12189. }
  12190. /// <summary>
  12191. /// 司兼导数据
  12192. /// </summary>
  12193. /// <param name="dto"></param>
  12194. /// <returns></returns>
  12195. [HttpPost]
  12196. public IActionResult GetCarGuides(CarGuidesDto dto)
  12197. {
  12198. JsonView jw = null;
  12199. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12200. jw = JsonView(true, "获取成功!", Data);
  12201. return Ok(jw);
  12202. }
  12203. /// <summary>
  12204. /// 导游数据
  12205. /// </summary>
  12206. /// <param name="dto"></param>
  12207. /// <returns></returns>
  12208. [HttpPost]
  12209. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12210. {
  12211. JsonView jw = null;
  12212. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12213. // 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
  12214. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12215. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12216. jw = JsonView(true, "获取成功!", Data);
  12217. return Ok(jw);
  12218. }
  12219. /// <summary>
  12220. /// 成本车数据
  12221. /// </summary>
  12222. /// <param name="dto"></param>
  12223. /// <returns></returns>
  12224. [HttpPost]
  12225. public IActionResult GetCarInfo(CarGuidesDto dto)
  12226. {
  12227. JsonView jw = null;
  12228. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12229. jw = JsonView(true, "获取成功!", Data);
  12230. return Ok(jw);
  12231. }
  12232. /// <summary>
  12233. /// 景点数据
  12234. /// </summary>
  12235. /// <param name="dto"></param>
  12236. /// <returns></returns>
  12237. [HttpPost]
  12238. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12239. {
  12240. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12241. return Ok(JsonView(true, "获取成功!", Data));
  12242. }
  12243. /// <summary>
  12244. /// 成本通知
  12245. /// </summary>
  12246. /// <param name="dto"></param>
  12247. /// <returns></returns>
  12248. [HttpPost]
  12249. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12250. {
  12251. if (dto.Diid < 0)
  12252. {
  12253. return Ok(JsonView(false));
  12254. }
  12255. JsonView jw = null;
  12256. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12257. if (GroupCostParameter != null)
  12258. {
  12259. int IsShare = 0;
  12260. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12261. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12262. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12263. string msg = string.Empty;
  12264. if (isTrue)
  12265. {
  12266. if (IsShare == 0)
  12267. {
  12268. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12269. }
  12270. else
  12271. {
  12272. #region 企微通知对应岗位用户
  12273. try
  12274. {
  12275. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12276. }
  12277. catch (Exception ex)
  12278. {
  12279. }
  12280. #endregion
  12281. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12282. }
  12283. jw = JsonView(isTrue, msg, new { IsShare });
  12284. }
  12285. else
  12286. {
  12287. msg = "修改失败!";
  12288. jw = JsonView(isTrue, msg);
  12289. }
  12290. }
  12291. else
  12292. {
  12293. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12294. }
  12295. return Ok(jw);
  12296. }
  12297. /// <summary>
  12298. /// 导出报价单
  12299. /// </summary>
  12300. /// <param name="dto"></param>
  12301. /// <returns></returns>
  12302. [HttpPost]
  12303. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12304. {
  12305. if (dto.Diid == 0)
  12306. {
  12307. return Ok(JsonView(false, "请传递团组id"));
  12308. }
  12309. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12310. if (deleInfo.Code != 0)
  12311. {
  12312. return Ok(JsonView(false, "团组信息查询失败!"));
  12313. }
  12314. var di = deleInfo.Data as DelegationInfoWebView;
  12315. if (di != null)
  12316. {
  12317. di.TeamName = di.TeamName.Replace("|", "、");
  12318. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12319. //文件名
  12320. string strFileName = di.TeamName + "-收款账单.doc";
  12321. //获取模板
  12322. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12323. //载入模板
  12324. Document doc = new Document(tmppath);
  12325. decimal TotalPrice = 0.00M;
  12326. string itemStr = string.Empty;
  12327. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12328. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12329. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12330. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12331. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12332. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12333. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12334. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12335. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12336. foreach (var cost in groupCostType)
  12337. {
  12338. var List = cost.ToList();
  12339. if (cost.Key == "A")
  12340. {
  12341. foreach (var ListItem in List)
  12342. {
  12343. if (ListItem.number > 0)
  12344. {
  12345. if (ListItem.code.Contains("TBR"))
  12346. {
  12347. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12348. }
  12349. else
  12350. {
  12351. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12352. }
  12353. TotalPrice += (ListItem.number * ListItem.price);
  12354. }
  12355. }
  12356. }
  12357. else
  12358. {
  12359. itemStr = itemStr.Insert(0, "A段\r\n");
  12360. itemStr += "B段\r\n";
  12361. foreach (var ListItem in List)
  12362. {
  12363. if (ListItem.number > 0)
  12364. {
  12365. if (ListItem.code.Contains("TBR"))
  12366. {
  12367. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12368. }
  12369. else
  12370. {
  12371. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12372. }
  12373. TotalPrice += (ListItem.number * ListItem.price);
  12374. }
  12375. }
  12376. }
  12377. }
  12378. #region 替换Word模板书签内容
  12379. Dictionary<string, string> marks = new Dictionary<string, string>();
  12380. marks.Add("To", di.ClientUnit);//付款方
  12381. marks.Add("ToTel", di.TellPhone);//付款方电话
  12382. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12383. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12384. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12385. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12386. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12387. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12388. marks.Add("PayItemContent", itemStr);//详细信息
  12389. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12390. #endregion
  12391. ////注
  12392. //if (doc.Range.Bookmarks["Attention"] != null)
  12393. //{
  12394. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12395. // mark.Text = frList[0].Attention;
  12396. //}
  12397. foreach (var item in marks.Keys)
  12398. {
  12399. if (doc.Range.Bookmarks[item] != null)
  12400. {
  12401. Bookmark mark = doc.Range.Bookmarks[item];
  12402. mark.Text = marks[item];
  12403. }
  12404. }
  12405. byte[] bytes = null;
  12406. using (MemoryStream stream = new MemoryStream())
  12407. {
  12408. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12409. bytes = stream.ToArray();
  12410. }
  12411. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12412. return Ok(JsonView(true, "", new
  12413. {
  12414. Data = bytes,
  12415. strFileName,
  12416. }));
  12417. }
  12418. else
  12419. {
  12420. return Ok(JsonView(false, "团组信息不存在!"));
  12421. }
  12422. }
  12423. /// <summary>
  12424. /// 导出团组成本
  12425. /// </summary>
  12426. /// <param name="dto"></param>
  12427. /// <returns></returns>
  12428. [HttpPost]
  12429. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12430. {
  12431. var jw = JsonView(false);
  12432. if (dto.Diid == 0)
  12433. {
  12434. return Ok(JsonView(false, "请传递团组id"));
  12435. }
  12436. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12437. if (deleInfo.Code != 0)
  12438. {
  12439. return Ok(JsonView(false, "团组信息查询失败!"));
  12440. }
  12441. var di = deleInfo.Data as DelegationInfoWebView;
  12442. if (di == null)
  12443. {
  12444. return Ok(JsonView(false, "团组信息查询失败!"));
  12445. }
  12446. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12447. WorkbookDesigner designer = new WorkbookDesigner();
  12448. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12449. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12450. for (int i = 0; i < List_GC.Count; i++)
  12451. {
  12452. GroupCost_Excel gc = new GroupCost_Excel();
  12453. gc.Id = List_GC[i].Id;
  12454. gc.Diid = List_GC[i].Diid.ToString();
  12455. gc.DAY = List_GC[i].DAY;
  12456. string week = "";
  12457. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12458. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12459. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12460. gc.ITIN = List_GC[i].ITIN;
  12461. gc.CarType = List_GC[i].CarType;
  12462. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12463. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12464. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12465. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12466. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12467. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12468. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12469. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12470. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12471. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12472. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12473. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12474. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12475. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12476. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12477. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12478. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12479. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12480. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12481. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12482. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12483. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12484. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12485. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12486. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12487. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12488. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12489. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12490. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12491. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12492. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12493. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12494. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12495. List_GC1.Add(gc);
  12496. }
  12497. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12498. dt.TableName = "TB";
  12499. //报表标题等不用dt的值
  12500. designer.SetDataSource("TeamName", dto.title.TeamName);
  12501. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12502. designer.SetDataSource("Tax", dto.title.Tax);
  12503. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12504. designer.SetDataSource("Currency", dto.title.Currency);
  12505. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12506. designer.SetDataSource("Rate", dto.title.Rate);
  12507. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12508. var Aparams = hotels.Find(x => x.Type == "Default");
  12509. if (Aparams == null)
  12510. {
  12511. return Ok(jw);
  12512. }
  12513. //酒店数量
  12514. var txtSGRNumber = Aparams.SGR.ToString();
  12515. var txtTBRNumber = Aparams.TBR.ToString();
  12516. var txtJSESNumber = Aparams.JSES.ToString();
  12517. var txtSUITENumbe = Aparams.SUITE.ToString();
  12518. if (dto.costType == "B")
  12519. {
  12520. Aparams = hotels.Find(x => x.Type == "A");
  12521. var Bparams = hotels.Find(x => x.Type == "B");
  12522. if (Aparams == null || Bparams == null)
  12523. {
  12524. return Ok(jw);
  12525. }
  12526. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12527. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12528. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12529. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12530. }
  12531. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12532. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12533. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12534. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12535. var ws = designer.Workbook.Worksheets[0];
  12536. int Row = List_GC.Count;
  12537. int startIndex = 11;
  12538. int HideRows = 0;
  12539. List<int> hideRowsList = new List<int>();
  12540. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12541. #region A段left数据
  12542. var left = dto.leftInfo.Find(x => x.Type == "A");
  12543. if (left == null)
  12544. {
  12545. return Ok(jw);
  12546. }
  12547. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12548. if (leftBindData != null)
  12549. {
  12550. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12551. designer.SetDataSource("VisaRS", leftBindData.rs);
  12552. designer.SetDataSource("VisaXS", leftBindData.xs);
  12553. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12554. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12555. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12556. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12557. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12558. }
  12559. else
  12560. {
  12561. hideRowsList.Add(Row + startIndex + HideRows);
  12562. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12563. }
  12564. HideRows += 2;
  12565. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12566. if (leftBindData != null)
  12567. {
  12568. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12569. designer.SetDataSource("BXRS", leftBindData.rs);
  12570. designer.SetDataSource("BXXS", leftBindData.xs);
  12571. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12572. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12573. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12574. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12575. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12576. }
  12577. else
  12578. {
  12579. hideRowsList.Add(Row + startIndex + HideRows);
  12580. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12581. }
  12582. HideRows += 2;
  12583. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12584. if (leftBindData != null)
  12585. {
  12586. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12587. designer.SetDataSource("HSRS", leftBindData.rs);
  12588. designer.SetDataSource("HSXS", leftBindData.xs);
  12589. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12590. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12591. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12592. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12593. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12594. }
  12595. else
  12596. {
  12597. hideRowsList.Add(Row + startIndex + HideRows);
  12598. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12599. }
  12600. HideRows += 2;
  12601. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12602. if (leftBindData != null)
  12603. {
  12604. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12605. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12606. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12607. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12608. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12609. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12610. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12611. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12612. }
  12613. else
  12614. {
  12615. hideRowsList.Add(Row + startIndex + HideRows);
  12616. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12617. }
  12618. HideRows += 2;
  12619. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12620. if (leftBindData != null)
  12621. {
  12622. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12623. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12624. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12625. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12626. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12627. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12628. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12629. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12630. }
  12631. else
  12632. {
  12633. hideRowsList.Add(Row + startIndex + HideRows);
  12634. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12635. }
  12636. HideRows += 2;
  12637. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12638. if (leftBindData != null)
  12639. {
  12640. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12641. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12642. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12643. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12644. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12645. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12646. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12647. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12648. }
  12649. else
  12650. {
  12651. hideRowsList.Add(Row + startIndex + HideRows);
  12652. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12653. }
  12654. HideRows += 2;
  12655. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12656. if (leftBindData != null)
  12657. {
  12658. ////TBR
  12659. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12660. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12661. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12662. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12663. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12664. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12665. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12666. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12667. }
  12668. else
  12669. {
  12670. hideRowsList.Add(Row + startIndex + HideRows);
  12671. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12672. }
  12673. HideRows += 2;
  12674. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12675. if (leftBindData != null)
  12676. {
  12677. ////SGR
  12678. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12679. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12680. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12681. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12682. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12683. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12684. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12685. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12686. }
  12687. else
  12688. {
  12689. hideRowsList.Add(Row + startIndex + HideRows);
  12690. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12691. }
  12692. HideRows += 2;
  12693. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12694. if (leftBindData != null)
  12695. {
  12696. ////JS/ES
  12697. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12698. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12699. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12700. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12701. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12702. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12703. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12704. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12705. }
  12706. else
  12707. {
  12708. hideRowsList.Add(Row + startIndex + HideRows);
  12709. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12710. }
  12711. HideRows += 2;
  12712. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12713. if (leftBindData != null)
  12714. {
  12715. ////SUITE
  12716. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12717. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12718. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12719. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12720. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12721. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12722. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12723. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12724. }
  12725. else
  12726. {
  12727. hideRowsList.Add(Row + startIndex + HideRows);
  12728. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12729. }
  12730. HideRows += 2;
  12731. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12732. if (leftBindData != null)
  12733. {
  12734. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12735. designer.SetDataSource("DJRS", leftBindData.rs);
  12736. designer.SetDataSource("DJXS", leftBindData.xs);
  12737. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12738. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12739. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12740. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12741. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12742. }
  12743. else
  12744. {
  12745. hideRowsList.Add(Row + startIndex + HideRows);
  12746. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12747. }
  12748. HideRows += 2;
  12749. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12750. if (leftBindData != null)
  12751. {
  12752. designer.SetDataSource("HCPCB", leftBindData.cb);
  12753. designer.SetDataSource("HCPRS", leftBindData.rs);
  12754. designer.SetDataSource("HCPXS", leftBindData.xs);
  12755. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12756. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12757. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12758. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12759. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12760. }
  12761. else
  12762. {
  12763. hideRowsList.Add(Row + startIndex + HideRows);
  12764. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12765. }
  12766. HideRows += 2;
  12767. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12768. if (leftBindData != null)
  12769. {
  12770. designer.SetDataSource("CPCB", leftBindData.cb);
  12771. designer.SetDataSource("CPRS", leftBindData.rs);
  12772. designer.SetDataSource("CPXS", leftBindData.xs);
  12773. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12774. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12775. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12776. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12777. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12778. }
  12779. else
  12780. {
  12781. hideRowsList.Add(Row + startIndex + HideRows);
  12782. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12783. }
  12784. HideRows += 2;
  12785. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12786. if (leftBindData != null)
  12787. {
  12788. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12789. designer.SetDataSource("GWRS", leftBindData.rs);
  12790. designer.SetDataSource("GWXS", leftBindData.xs);
  12791. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12792. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12793. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12794. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12795. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12796. }
  12797. else
  12798. {
  12799. hideRowsList.Add(Row + startIndex + HideRows);
  12800. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12801. }
  12802. HideRows += 2;
  12803. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12804. if (leftBindData != null)
  12805. {
  12806. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12807. designer.SetDataSource("LYJRS", leftBindData.rs);
  12808. designer.SetDataSource("LYJXS", leftBindData.xs);
  12809. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12810. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12811. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12812. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12813. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12814. }
  12815. else
  12816. {
  12817. hideRowsList.Add(Row + startIndex + HideRows);
  12818. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12819. }
  12820. #endregion
  12821. #region A段Right信息
  12822. var right = dto.rightInfo.Find(x => x.Type == "A");
  12823. if (right == null)
  12824. {
  12825. return Ok(jw);
  12826. }
  12827. HideRows += 4;
  12828. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12829. if (rightBindData != null)
  12830. {
  12831. //经济舱 + 双人间 TBR
  12832. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12833. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12834. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12835. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12836. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12837. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12838. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12839. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12840. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12841. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12842. }
  12843. else
  12844. {
  12845. hideRowsList.Add(Row + startIndex + HideRows);
  12846. }
  12847. HideRows += 2;
  12848. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12849. if (rightBindData != null)
  12850. {
  12851. //经济舱 + 单人间 SGR
  12852. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12853. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12854. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12855. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12856. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12857. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12858. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12859. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12860. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12861. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12862. }
  12863. else
  12864. {
  12865. hideRowsList.Add(Row + startIndex + HideRows);
  12866. }
  12867. HideRows += 2;
  12868. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12869. if (rightBindData != null)
  12870. {
  12871. //公务舱 + 单人间 SGR
  12872. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12873. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12874. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12875. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12876. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12877. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12878. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12879. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12880. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12881. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12882. }
  12883. else
  12884. {
  12885. hideRowsList.Add(Row + startIndex + HideRows);
  12886. }
  12887. HideRows += 2;
  12888. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12889. if (rightBindData != null)
  12890. {
  12891. //公务舱 + 小套房 JSES
  12892. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12893. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12894. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12895. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12896. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12897. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12898. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12899. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12900. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12901. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12902. }
  12903. else
  12904. {
  12905. hideRowsList.Add(Row + startIndex + HideRows);
  12906. }
  12907. HideRows += 2;
  12908. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12909. if (rightBindData != null)
  12910. {
  12911. //公务舱 + 小套房 JSES
  12912. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12913. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12914. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12915. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12916. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12917. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12918. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12919. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12920. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12921. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12922. }
  12923. else
  12924. {
  12925. hideRowsList.Add(Row + startIndex + HideRows);
  12926. }
  12927. HideRows += 2;
  12928. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12929. if (rightBindData != null)
  12930. {
  12931. //经济舱 + 大套房
  12932. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12933. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12934. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12935. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12936. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12937. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12938. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12939. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12940. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12941. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12942. }
  12943. else
  12944. {
  12945. hideRowsList.Add(Row + startIndex + HideRows);
  12946. }
  12947. HideRows += 2;
  12948. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12949. if (rightBindData != null)
  12950. {
  12951. //头等舱 + 小套房 JSES
  12952. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12953. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12954. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12955. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12956. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12957. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12958. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12959. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12960. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12961. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12962. }
  12963. else
  12964. {
  12965. hideRowsList.Add(Row + startIndex + HideRows);
  12966. }
  12967. HideRows += 2;
  12968. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12969. if (rightBindData != null)
  12970. {
  12971. //头等舱 + 大套房
  12972. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12973. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12974. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12975. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12976. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12977. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12978. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12979. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12980. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12981. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12982. }
  12983. else
  12984. {
  12985. hideRowsList.Add(Row + startIndex + HideRows);
  12986. }
  12987. #endregion
  12988. #region B段标题清空
  12989. designer.SetDataSource("CostBDRCB", "");
  12990. designer.SetDataSource("CostBRS", "");
  12991. designer.SetDataSource("CostBXS", "");
  12992. designer.SetDataSource("CostBZCB", "");
  12993. designer.SetDataSource("CostBDRBJ", "");
  12994. designer.SetDataSource("CostBZBJ", "");
  12995. designer.SetDataSource("CostBDRLR", "");
  12996. designer.SetDataSource("CostBZLR", "");
  12997. designer.SetDataSource("CostBDRCBOM", "");
  12998. designer.SetDataSource("CostBRSOM", "");
  12999. designer.SetDataSource("CostBZCBOM", "");
  13000. designer.SetDataSource("CostBDRBJOM", "");
  13001. designer.SetDataSource("CostBZBJOM", "");
  13002. designer.SetDataSource("CostBDRLROM", "");
  13003. designer.SetDataSource("CostBZLROM", "");
  13004. #endregion
  13005. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13006. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13007. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13008. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13009. designer.SetDataSource("DJName", "地接(CNY)");
  13010. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13011. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13012. designer.SetDataSource("GWName", "公务(CNY)");
  13013. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13014. designer.SetDataSource("LYJName", "零用金(CNY)");
  13015. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13016. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13017. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13018. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13019. designer.SetDataSource("BXName", "保险(CNY)");
  13020. designer.SetDataSource("VisaName", "签证(CNY)");
  13021. #region B段基本数据
  13022. if (dto.costType == "B")
  13023. {
  13024. left = dto.leftInfo.Find(x => x.Type == "B");
  13025. if (left == null)
  13026. {
  13027. return Ok(jw);
  13028. }
  13029. #region B段left数据
  13030. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13031. if (leftBindData != null)
  13032. {
  13033. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13034. designer.SetDataSource("BHSRS", leftBindData.rs);
  13035. designer.SetDataSource("BHSXS", leftBindData.xs);
  13036. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13037. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13038. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13039. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13040. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13041. }
  13042. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13043. if (leftBindData != null)
  13044. {
  13045. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13046. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13047. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13048. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13049. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13050. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13051. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13052. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13053. }
  13054. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13055. if (leftBindData != null)
  13056. {
  13057. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13058. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13059. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13060. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13061. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13062. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13063. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13064. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13065. }
  13066. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13067. if (leftBindData != null)
  13068. {
  13069. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13070. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13071. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13072. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13073. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13074. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13075. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13076. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13077. }
  13078. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13079. if (leftBindData != null)
  13080. {
  13081. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13082. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13083. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13084. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13085. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13086. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13087. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13088. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13089. }
  13090. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13091. if (leftBindData != null)
  13092. {
  13093. designer.SetDataSource("BCPCB", leftBindData.cb);
  13094. designer.SetDataSource("BCPRS", leftBindData.rs);
  13095. designer.SetDataSource("BCPXS", leftBindData.xs);
  13096. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13097. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13098. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13099. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13100. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13101. }
  13102. //TBR
  13103. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13104. if (leftBindData != null)
  13105. {
  13106. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13107. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13108. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13109. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13110. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13111. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13112. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13113. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13114. }
  13115. //SGR
  13116. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13117. if (leftBindData != null)
  13118. {
  13119. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13120. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13121. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13122. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13123. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13124. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13125. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13126. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13127. }
  13128. //JS/ES
  13129. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13130. if (leftBindData != null)
  13131. {
  13132. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13133. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13134. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13135. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13136. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13137. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13138. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13139. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13140. }
  13141. //SUITE
  13142. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13143. if (leftBindData != null)
  13144. {
  13145. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13146. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13147. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13148. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13149. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13150. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13151. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13152. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13153. }
  13154. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13155. if (leftBindData != null)
  13156. {
  13157. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13158. designer.SetDataSource("BDJRS", leftBindData.rs);
  13159. designer.SetDataSource("BDJXS", leftBindData.xs);
  13160. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13161. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13162. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13163. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13164. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13165. }
  13166. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13167. if (leftBindData != null)
  13168. {
  13169. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13170. designer.SetDataSource("BGWRS", leftBindData.rs);
  13171. designer.SetDataSource("BGWXS", leftBindData.xs);
  13172. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13173. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13174. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13175. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13176. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13177. }
  13178. #region 优化方案
  13179. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13180. //excelBind.Add("零用金", new {
  13181. //cb="",
  13182. //rs="",
  13183. //xs ="",
  13184. //zcb = "",
  13185. //});
  13186. #endregion
  13187. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13188. if (leftBindData != null)
  13189. {
  13190. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13191. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13192. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13193. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13194. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13195. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13196. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13197. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13198. }
  13199. #endregion
  13200. #region B段Right信息
  13201. right = dto.rightInfo.Find(x => x.Type == "B");
  13202. if (right == null)
  13203. {
  13204. return Ok(jw);
  13205. }
  13206. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13207. if (rightBindData != null)
  13208. {
  13209. //经济舱 + 双人间 TBR
  13210. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13211. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13212. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13213. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13214. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13215. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13216. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13217. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13218. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13219. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13220. }
  13221. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13222. if (rightBindData != null)
  13223. {
  13224. //经济舱 + 单人间 SGR
  13225. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  13226. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13227. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13228. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13229. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13230. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13231. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13232. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13233. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13234. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13235. }
  13236. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13237. if (rightBindData != null)
  13238. {
  13239. //公务舱 + 单人间 SGR
  13240. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13241. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13242. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13243. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13244. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13245. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13246. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13247. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13248. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13249. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13250. }
  13251. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13252. if (rightBindData != null)
  13253. {
  13254. //公务舱 + 小套房 JSES
  13255. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13256. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13257. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13258. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13259. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13260. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13261. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13262. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13263. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13264. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13265. }
  13266. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13267. if (rightBindData != null)
  13268. {
  13269. //公务舱 + 小套房 JSES
  13270. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13271. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13272. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13273. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13274. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13275. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13276. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13277. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13278. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13279. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13280. }
  13281. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13282. if (rightBindData != null)
  13283. {
  13284. //经济舱 + 大套房
  13285. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13286. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13287. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13288. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13289. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13290. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13291. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13292. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13293. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13294. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13295. }
  13296. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13297. if (rightBindData != null)
  13298. {
  13299. //头等舱 + 小套房 JSES
  13300. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13301. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13302. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13303. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13304. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13305. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13306. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13307. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13308. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13309. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13310. }
  13311. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13312. if (rightBindData != null)
  13313. {
  13314. //头等舱 + 大套房
  13315. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13316. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13317. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13318. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13319. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13320. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13321. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13322. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13323. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13324. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13325. }
  13326. #endregion
  13327. #region 标题
  13328. designer.SetDataSource("CostBDRCB", "单人成本");
  13329. designer.SetDataSource("CostBRS", "人数");
  13330. designer.SetDataSource("CostBXS", "系数");
  13331. designer.SetDataSource("CostBZCB", "总成本");
  13332. designer.SetDataSource("CostBDRBJ", "单人报价");
  13333. designer.SetDataSource("CostBZBJ", "总报价");
  13334. designer.SetDataSource("CostBDRLR", "单人利润");
  13335. designer.SetDataSource("CostBZLR", "总利润");
  13336. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13337. designer.SetDataSource("CostBRSOM", "人数");
  13338. designer.SetDataSource("CostBZCBOM", "总成本");
  13339. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13340. designer.SetDataSource("CostBZBJOM", "总报价");
  13341. designer.SetDataSource("CostBDRLROM", "单人利润");
  13342. designer.SetDataSource("CostBZLROM", "总利润");
  13343. #endregion
  13344. }
  13345. #endregion
  13346. designer.SetDataSource("TzZCB2", TzZCB2);
  13347. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13348. designer.SetDataSource("TzZLR2", TzZLR2);
  13349. string[] dataSourceKeys = new string[]
  13350. {
  13351. "VF",
  13352. "TGS",
  13353. "TGOF",
  13354. "TGM",
  13355. "TGA",
  13356. "TGTF",
  13357. "TGEF",
  13358. "CFM",
  13359. "CFOF",
  13360. "B",
  13361. "L",
  13362. "D",
  13363. "TBR",
  13364. "SGR",
  13365. "JSES",
  13366. "Suite",
  13367. "TV",
  13368. "1L",
  13369. "IF",
  13370. "EF",
  13371. "BRF",
  13372. "TE",
  13373. "TGT",
  13374. "DRVT",
  13375. "PC",
  13376. "TLF",
  13377. "ECT"
  13378. };
  13379. foreach (var item in dataSourceKeys)
  13380. {
  13381. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13382. if (find != null)
  13383. {
  13384. designer.SetDataSource(item, find.text);
  13385. }
  13386. else
  13387. {
  13388. designer.SetDataSource(item, 0);
  13389. }
  13390. }
  13391. designer.SetDataSource(dt);
  13392. //根据数据源处理生成报表内容
  13393. designer.Process();
  13394. designer.Workbook.Worksheets[0].Name = "清单";
  13395. Worksheet sheet = designer.Workbook.Worksheets[0];
  13396. foreach (var Rowindex in hideRowsList)
  13397. {
  13398. ws.Cells.HideRows(Rowindex, 2);
  13399. }
  13400. byte[] bytes = null;
  13401. string strFileName = di.TeamName + "-团组-成本.xls";
  13402. using (MemoryStream stream = new MemoryStream())
  13403. {
  13404. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13405. bytes = stream.ToArray();
  13406. }
  13407. return Ok(JsonView(true, "", new
  13408. {
  13409. Data = bytes,
  13410. strFileName,
  13411. }));
  13412. }
  13413. /// <summary>
  13414. /// 导出客户报表
  13415. /// </summary>
  13416. /// <returns></returns>
  13417. [HttpPost]
  13418. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13419. {
  13420. var jw = JsonView(false);
  13421. if (dto.Diid == 0)
  13422. {
  13423. return Ok(JsonView(false, "请传递团组id"));
  13424. }
  13425. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13426. if (deleInfo.Code != 0)
  13427. {
  13428. return Ok(JsonView(false, "团组信息查询失败!"));
  13429. }
  13430. var di = deleInfo.Data as DelegationInfoWebView;
  13431. if (di == null)
  13432. {
  13433. return Ok(JsonView(false, "团组信息查询失败!"));
  13434. }
  13435. //文件名
  13436. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13437. //获取模板
  13438. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13439. //载入模板
  13440. Document doc = new Document(tmppath);
  13441. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13442. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13443. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13444. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13445. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13446. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13447. if (AParameter == null)
  13448. {
  13449. return Ok(JsonView(false, "系数不存在!"));
  13450. }
  13451. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13452. , TzAirDesc, TzZCost;
  13453. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13454. = TzAirDesc = TzZCost = string.Empty;
  13455. TzNumber = AParameter.CostTypenumber.ToString();
  13456. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13457. CarGuides1 = dto.CarGuides1;
  13458. Meal = dto.Meal;
  13459. SubsidizedMeals = dto.SubsidizedMeals;
  13460. NightRepair = dto.NightRepair;
  13461. AttractionsTickets = dto.AttractionsTickets;
  13462. MiscellaneousFees = dto.MiscellaneousFees;
  13463. ATip = dto.ATip;
  13464. TzHotelDesc = "";
  13465. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13466. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13467. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13468. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13469. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13470. TzAirDesc = "";
  13471. TzZCost = dto.TzZCost;
  13472. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13473. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13474. var index = 1;
  13475. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13476. foreach (var item in TzHotelDescArr)
  13477. {
  13478. if (AinfoArr != null)
  13479. {
  13480. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13481. if (Ainfo != null)
  13482. {
  13483. if (int.Parse(Ainfo.rs) <= 0)
  13484. {
  13485. continue;
  13486. }
  13487. var hotelText = string.Empty;
  13488. switch (item)
  13489. {
  13490. case "SGR":
  13491. hotelText = "单人间";
  13492. break;
  13493. case "JSES":
  13494. hotelText = "小套房";
  13495. break;
  13496. case "SUITE":
  13497. hotelText = "套房";
  13498. break;
  13499. case "TBR":
  13500. hotelText = "双人间";
  13501. break;
  13502. }
  13503. if (item != "TBR")
  13504. {
  13505. 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";
  13506. }
  13507. else
  13508. {
  13509. 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";
  13510. }
  13511. index++;
  13512. }
  13513. }
  13514. }
  13515. index = 1;
  13516. foreach (var item in TzAirDescArr)
  13517. {
  13518. if (AinfoArr != null)
  13519. {
  13520. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13521. if (Ainfo != null)
  13522. {
  13523. if (int.Parse(Ainfo.rs) <= 0)
  13524. {
  13525. continue;
  13526. }
  13527. 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";
  13528. index++;
  13529. }
  13530. }
  13531. }
  13532. if (dto.costType == "B")
  13533. {
  13534. if (BParameter == null)
  13535. {
  13536. return Ok(JsonView(false, "B段系数不存在!"));
  13537. }
  13538. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13539. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13540. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13541. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13542. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13543. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13544. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13545. foreach (var item in TzHotelDescArr)
  13546. {
  13547. if (AinfoArr != null)
  13548. {
  13549. TzHotelDesc += "B段信息 \r\n";
  13550. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13551. if (Ainfo != null)
  13552. {
  13553. if (int.Parse(Ainfo.rs) <= 0)
  13554. {
  13555. continue;
  13556. }
  13557. var hotelText = string.Empty;
  13558. switch (item)
  13559. {
  13560. case "SGR":
  13561. hotelText = "单人间";
  13562. break;
  13563. case "JSES":
  13564. hotelText = "小套房";
  13565. break;
  13566. case "SUITE":
  13567. hotelText = "套房";
  13568. break;
  13569. case "TBR":
  13570. hotelText = "双人间";
  13571. break;
  13572. }
  13573. if (item != "TBR")
  13574. {
  13575. 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";
  13576. }
  13577. else
  13578. {
  13579. 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";
  13580. }
  13581. index++;
  13582. }
  13583. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13584. }
  13585. }
  13586. index = 1;
  13587. foreach (var item in TzAirDescArr)
  13588. {
  13589. if (AinfoArr != null)
  13590. {
  13591. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13592. if (Ainfo != null)
  13593. {
  13594. if (int.Parse(Ainfo.rs) <= 0)
  13595. {
  13596. continue;
  13597. }
  13598. 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";
  13599. index++;
  13600. }
  13601. }
  13602. }
  13603. }
  13604. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13605. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13606. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13607. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13608. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13609. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13610. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13611. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13612. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13613. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13614. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13615. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13616. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13617. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13618. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13619. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13620. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13621. DickeyValue.Add("TzZCost", TzZCost);
  13622. foreach (var key in DickeyValue.Keys)
  13623. {
  13624. if (doc.Range.Bookmarks[key] != null)
  13625. {
  13626. Bookmark mark = doc.Range.Bookmarks[key];
  13627. mark.Text = DickeyValue[key];
  13628. }
  13629. }
  13630. byte[] bytes = null;
  13631. string strFileName = di.TeamName + "-客户报价.doc";
  13632. using (MemoryStream stream = new MemoryStream())
  13633. {
  13634. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13635. bytes = stream.ToArray();
  13636. }
  13637. return Ok(JsonView(true, "", new
  13638. {
  13639. Data = bytes,
  13640. strFileName,
  13641. }));
  13642. }
  13643. /// <summary>
  13644. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13645. /// </summary>
  13646. /// <param name="dto"></param>
  13647. /// <returns></returns>
  13648. [HttpPost]
  13649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13650. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13651. {
  13652. try
  13653. {
  13654. #region 参数验证
  13655. if (dto.DiId < 0)
  13656. {
  13657. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13658. }
  13659. List<int> cTableIds = new List<int>() {
  13660. 76 ,//酒店预订
  13661. 77 ,//行程
  13662. 79 ,//车/导游地接
  13663. 80 ,//签证
  13664. 81 ,//邀请/公务活
  13665. 82 ,//团组客户保险
  13666. 85 ,//机票预订
  13667. 98 ,//其他款项
  13668. 285 ,//收款退还
  13669. 751 ,//酒店早餐
  13670. 1015 // 超支费用
  13671. };
  13672. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13673. {
  13674. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13675. }
  13676. #endregion
  13677. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13678. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13679. if (_GroupCostParameters.Count <= 0)
  13680. {
  13681. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13682. }
  13683. if (_GroupCostParameters[0].IsShare == 0)
  13684. {
  13685. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13686. }
  13687. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13688. //处理date为空问题
  13689. if (_GroupCosts.Count > 0)
  13690. {
  13691. for (int i = 0; i < _GroupCosts.Count; i++)
  13692. {
  13693. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13694. {
  13695. if (i > 0)
  13696. {
  13697. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13698. }
  13699. }
  13700. }
  13701. }
  13702. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13703. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13704. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13705. string currCode = "";
  13706. #region currCode 验证
  13707. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13708. if (isInt)
  13709. {
  13710. var currData = currDatas.Find(it => it.Id == intCurrency);
  13711. if (currData != null)
  13712. {
  13713. currCode = currData.Name;
  13714. }
  13715. }
  13716. else
  13717. {
  13718. currCode = _GroupCostParameters[0].Currency.Trim();
  13719. }
  13720. #endregion
  13721. //op,酒店单段模式存储
  13722. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13723. {
  13724. CurrencyCode = currCode,
  13725. Rate = _GroupCostParameters[0].Rate,
  13726. CostType = _GroupCostParameters[0].CostType,
  13727. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13728. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13729. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13730. };
  13731. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13732. if (_GroupCostParameters.Count == 2)
  13733. {
  13734. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13735. }
  13736. foreach (var item in _GroupCostParameters)
  13737. {
  13738. decimal _rate = 1;
  13739. decimal _rate1 = item.Rate;
  13740. decimal _scale = 1;
  13741. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13742. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13743. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13744. //if (userInfo != null)
  13745. //{
  13746. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13747. // {
  13748. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13749. // {
  13750. // _scale = 1.00M;
  13751. // }
  13752. // }
  13753. //}
  13754. #endregion
  13755. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13756. {
  13757. CurrencyCode = currCode,
  13758. Rate = _rate1,
  13759. CostType = item.CostType,
  13760. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13761. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13762. CostTypeNumber = item.CostTypenumber
  13763. };
  13764. if (_GroupCostParameters.Count > 1)
  13765. {
  13766. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13767. }
  13768. else
  13769. {
  13770. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13771. }
  13772. if (dto.CTable == 79)//
  13773. {
  13774. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13775. modulePromptInfo.TotalCost = item.DJCB;
  13776. }
  13777. List<string> costTypes = new List<string>() { "A", "B" };
  13778. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13779. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13780. if (_GroupCostsDuplicates.Count() == 1)
  13781. {
  13782. _GroupCostsTypeData = _GroupCosts;
  13783. }
  13784. else
  13785. {
  13786. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13787. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13788. }
  13789. /*
  13790. * 76 酒店预订
  13791. * 77 行程
  13792. * 79 车/导游地接
  13793. * 80 签证
  13794. * 81 邀请/公务活动
  13795. * 82 团组客户保险
  13796. * 85 机票预订
  13797. * 98 其他款项
  13798. * 285 收款退还
  13799. * 751 酒店早餐
  13800. * 1015 超支费用
  13801. */
  13802. switch (dto.CTable)
  13803. {
  13804. case 76: // 酒店预订
  13805. _ModuleSubPromptInfo.AddRange(
  13806. _GroupCostsTypeData.Select(it => new
  13807. {
  13808. it.DAY,
  13809. it.Date,
  13810. it.ACCON,
  13811. it.ITIN,
  13812. it.SGR,
  13813. it.TBR,
  13814. it.JS_ES,
  13815. it.Suite
  13816. })
  13817. );
  13818. break;
  13819. case 79: // 车/导游地接
  13820. _ModuleSubPromptInfo.AddRange(
  13821. _GroupCostsTypeData.Select(it => new
  13822. {
  13823. Date = it.Date, //日期
  13824. CarFee = it.CarCost * _rate * _scale, //车费用
  13825. CarType = it.CarType, //车型
  13826. DriverFee = it.CFS * _rate * _scale, //司机工资
  13827. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13828. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13829. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13830. GuideFee = it.TGS * _rate * _scale, //导游费用
  13831. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13832. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13833. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13834. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13835. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13836. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13837. Breakfast = it.B * _rate * _scale, //早餐费
  13838. Lunch = it.L * _rate * _scale, //午餐费
  13839. Dinner = it.D * _rate * _scale, //晚餐费
  13840. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13841. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13842. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13843. TicketFee = it.EF * _rate * _scale, //门票费
  13844. TicketRemark = it.EFR, //门票费描述
  13845. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13846. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13847. SpentCash = it.PC * _rate * _scale, //零用金
  13848. LeadersFee = it.TLF * _rate * _scale, //领队费
  13849. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13850. })
  13851. );
  13852. break;
  13853. case 85: // 机票
  13854. List<dynamic> datas = new List<dynamic>();
  13855. datas.Add(
  13856. new
  13857. {
  13858. AirType = "经济舱",
  13859. AirNum = item.JJCRS,
  13860. AirDRCB = item.JJCCB,
  13861. AirZCB = (item.JJCRS * item.JJCCB)
  13862. }
  13863. );
  13864. datas.Add(
  13865. new
  13866. {
  13867. AirType = "公务舱",
  13868. AirNum = item.GWCRS,
  13869. AirDRCB = item.GWCCB,
  13870. AirZCB = (item.GWCRS * item.GWCCB)
  13871. }
  13872. );
  13873. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13874. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13875. modulePromptInfo.Data = new
  13876. {
  13877. airFeeData = datas,
  13878. airInitData = initDatas
  13879. };
  13880. _ModulePromptInfos.Add(modulePromptInfo);
  13881. break;
  13882. default:
  13883. break;
  13884. }
  13885. }
  13886. if (dto.CTable != 85)
  13887. {
  13888. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13889. _ModulePromptInfos.Add(_ModulePromptInfo);
  13890. }
  13891. _view.ModulePromptInfos = _ModulePromptInfos;
  13892. return Ok(JsonView(true, "操作成功!", _view));
  13893. }
  13894. catch (Exception ex)
  13895. {
  13896. return Ok(JsonView(false, ex.Message));
  13897. }
  13898. }
  13899. /// <summary>
  13900. /// 根据黑屏代码重新生成行程
  13901. /// </summary>
  13902. /// <param name="dto"></param>
  13903. /// <returns></returns>
  13904. [HttpPost]
  13905. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13906. {
  13907. var jw = JsonView(false);
  13908. var Create = _GroupCostRepository.
  13909. CreateGroupCostByBlackCode(dto.Diid);
  13910. jw.Msg = Create.Msg;
  13911. if (Create.Code == 0)
  13912. {
  13913. jw.Code = 200;
  13914. jw.Data = new
  13915. {
  13916. groupCost = Create.Data,
  13917. blackCodeIsTrue = true
  13918. };
  13919. }
  13920. else
  13921. {
  13922. jw.Code = 400;
  13923. jw.Data = new
  13924. {
  13925. groupCost = Create.Data,
  13926. blackCodeIsTrue = false,
  13927. };
  13928. }
  13929. return Ok(jw);
  13930. }
  13931. /// <summary>
  13932. /// 成本获取OP历史车费用
  13933. /// </summary>
  13934. /// <param name="dto"></param>
  13935. /// <returns></returns>
  13936. [HttpPost]
  13937. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13938. {
  13939. var jw = JsonView(false);
  13940. try
  13941. {
  13942. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13943. //获取现有所有车的数据
  13944. if (!dto.Param.IsNullOrWhiteSpace())
  13945. {
  13946. string sql = $@"
  13947. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13948. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13949. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13950. 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
  13951. AND gctggr.ServiceEndTime is not NULL
  13952. ORDER by gctggrc.id DESC
  13953. ";
  13954. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13955. var numeberResult = await Task.Run(() =>
  13956. {
  13957. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13958. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13959. return numberArr;
  13960. });
  13961. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13962. foreach (var item in numeberResult)
  13963. {
  13964. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13965. {
  13966. Country = "数据异常!",
  13967. City = string.Empty,
  13968. };
  13969. item.Area = find.Country + " " + find.City;
  13970. }
  13971. dbResult.AddRange(numeberResult);
  13972. if (dto.Param.Contains("、"))
  13973. {
  13974. var sp = dto.Param.Split("、");
  13975. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13976. .Where(x =>
  13977. {
  13978. return System.Array.Exists(sp, e =>
  13979. {
  13980. bool where = false;
  13981. if (x.Area != null)
  13982. {
  13983. where = x.Area.Contains(e);
  13984. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13985. {
  13986. return false;
  13987. }
  13988. }
  13989. if (x.PriceName != null && !where)
  13990. {
  13991. where = x.PriceName.Contains(e);
  13992. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13993. {
  13994. return false;
  13995. }
  13996. }
  13997. return where;
  13998. });
  13999. }).ToList();
  14000. }
  14001. else
  14002. {
  14003. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14004. .Where(x =>
  14005. {
  14006. bool where = false;
  14007. if (x.Area != null)
  14008. {
  14009. where = x.Area.Contains(dto.Param);
  14010. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14011. {
  14012. return false;
  14013. }
  14014. }
  14015. if (x.PriceName != null && !where)
  14016. {
  14017. where = x.PriceName.Contains(dto.Param);
  14018. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14019. {
  14020. return false;
  14021. }
  14022. }
  14023. return where;
  14024. }
  14025. )
  14026. .ToList();
  14027. }
  14028. }
  14029. var view = dbResult.Select(x =>
  14030. {
  14031. decimal dp = 0.00M;
  14032. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14033. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14034. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14035. {
  14036. if (startB && endB)
  14037. {
  14038. var timesp = endD.Subtract(startD);
  14039. if ((timesp.Days + 1) != 0)
  14040. {
  14041. dp = x.Price / (timesp.Days + 1);
  14042. }
  14043. }
  14044. }
  14045. else
  14046. {
  14047. dp = x.Price;
  14048. }
  14049. return new
  14050. {
  14051. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14052. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14053. x.Area,
  14054. x.id,
  14055. price = x.Price.ToString("F2"),
  14056. x.PriceName,
  14057. x.PriceContent,
  14058. x.TeamName,
  14059. x.DatePrice,
  14060. dayPrice = dp.ToString("F2"),
  14061. };
  14062. }).OrderByDescending(x => x.id).ToList();
  14063. jw = JsonView(true, "获取成功!", view);
  14064. }
  14065. catch (Exception e)
  14066. {
  14067. jw = JsonView(false, e.Message);
  14068. }
  14069. return Ok(jw);
  14070. }
  14071. #endregion
  14072. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14073. /// <summary>
  14074. /// 酒店预订
  14075. /// 酒店费用列表 根据团组Id查询
  14076. /// </summary>
  14077. /// <param name="_dto"></param>
  14078. /// <returns></returns>
  14079. [HttpPost]
  14080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14081. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14082. {
  14083. #region 参数验证
  14084. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14085. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14086. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14087. #region 团组操作权限验证 76 酒店预定模块
  14088. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14089. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14090. #endregion
  14091. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14092. #region 页面操作权限验证
  14093. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14094. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14095. #endregion
  14096. #endregion
  14097. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14098. }
  14099. /// <summary>
  14100. /// 酒店预订
  14101. /// 基础数据
  14102. /// </summary>
  14103. /// <param name="_dto"></param>
  14104. /// <returns></returns>
  14105. [HttpPost]
  14106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14107. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14108. {
  14109. #region 参数验证
  14110. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14111. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14112. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14113. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14114. #region 页面操作权限验证
  14115. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14116. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14117. #endregion
  14118. #region 团组操作权限验证 76 酒店预定模块
  14119. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14120. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14121. #endregion
  14122. #endregion
  14123. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14124. }
  14125. /// <summary>
  14126. /// 酒店预订
  14127. /// 创建 入住卷号码
  14128. /// </summary>
  14129. /// <param name="_dto"></param>
  14130. /// <returns></returns>
  14131. [HttpPost]
  14132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14133. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14134. {
  14135. #region 参数验证
  14136. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14137. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14138. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14139. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14140. #region 页面操作权限验证
  14141. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14142. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14143. #endregion
  14144. #region 团组操作权限验证 76 酒店预定模块
  14145. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14146. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14147. #endregion
  14148. #endregion
  14149. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14150. if (data.Code != 0)
  14151. {
  14152. return Ok(JsonView(false, data.Msg));
  14153. }
  14154. return Ok(JsonView(true, data.Msg, data.Data));
  14155. }
  14156. /// <summary>
  14157. /// 酒店预订
  14158. /// 详情
  14159. /// </summary>
  14160. /// <param name="_dto"></param>
  14161. /// <returns></returns>
  14162. [HttpPost]
  14163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14164. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14165. {
  14166. #region 参数验证
  14167. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14168. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14169. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14170. #region 团组操作权限验证 76 酒店预定模块
  14171. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14172. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14173. #endregion
  14174. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14175. #region 页面操作权限验证
  14176. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14177. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14178. #endregion
  14179. #endregion
  14180. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14181. }
  14182. /// <summary>
  14183. /// 酒店预订
  14184. /// Add Or Edit
  14185. /// </summary>
  14186. /// <param name="_dto"></param>
  14187. /// <returns></returns>
  14188. [HttpPost]
  14189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14190. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14191. {
  14192. #region 参数验证
  14193. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14194. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14195. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14196. #region 团组操作权限验证 76 酒店预定模块
  14197. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14198. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14199. #endregion
  14200. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14201. #region 页面操作权限验证
  14202. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14203. if (_dto.Id == 0) // Add
  14204. {
  14205. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14206. }
  14207. else if (_dto.Id > 1) // Edit
  14208. {
  14209. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14210. }
  14211. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14212. #endregion
  14213. #endregion
  14214. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14215. if (_view.Code != 200)
  14216. {
  14217. return Ok(_view);
  14218. }
  14219. #region 成本无酒店价格数据进入超支
  14220. _sqlSugar.BeginTran();
  14221. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14222. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14223. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14224. for (int i = 0; i < groupCost.Count; i++)
  14225. {
  14226. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14227. {
  14228. groupCost[i].Date = groupCost[i - 1].Date;
  14229. }
  14230. }
  14231. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14232. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14233. List<Fin_GroupExtraCostDto_OP>();
  14234. if (start_Bool && end_Bool)
  14235. {
  14236. while (start_Time < end_Time)
  14237. {
  14238. foreach (var item in groupCost_Grp)
  14239. {
  14240. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14241. {
  14242. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14243. {
  14244. extraCostList.Add(new
  14245. Fin_GroupExtraCostDto_OP
  14246. {
  14247. Area = _dto.AreaId,
  14248. coefficient = 1.5M,
  14249. createUser = _dto.UserId,
  14250. currency = _dto.CardPriceCurrency,
  14251. diId = _dto.DiId,
  14252. ManagerConfirm = 0,
  14253. SupervisorConfirm = 0,
  14254. SYsupervisorConfirm = 0,
  14255. editType = 1,
  14256. PortType = 1,
  14257. price = _dto.CardPrice,
  14258. PriceCount = 1,
  14259. priceType = 1027,
  14260. priceDetailType = 1044,
  14261. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14262. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14263. });
  14264. }
  14265. }
  14266. }
  14267. start_Time = start_Time.AddDays(1);
  14268. }
  14269. }
  14270. if (extraCostList.Any())
  14271. {
  14272. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14273. }
  14274. _sqlSugar.CommitTran();
  14275. #endregion
  14276. #region 应用推送
  14277. try
  14278. {
  14279. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14280. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14281. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14282. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14283. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14284. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14285. var diId = _dto.DiId;
  14286. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14287. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14288. #region 操作记录
  14289. var opInfo = new Crm_TableOperationRecord()
  14290. {
  14291. TableName = "Grp_HotelReservations",
  14292. PortType = _dto.PortType,
  14293. DataId = hotelId,
  14294. CreateUserId = _dto.UserId
  14295. };
  14296. //var opStatus = OperationEnum.NoOperation;
  14297. if (_dto.Id < 1) //添加操作
  14298. {
  14299. opInfo.OperationItem = OperationEnum.Add;
  14300. }
  14301. else if (_dto.Id > 0)
  14302. {
  14303. opInfo.OperationItem = OperationEnum.Edit;
  14304. }
  14305. string opRemark = string.Empty;
  14306. if (ccpInfo != null)
  14307. {
  14308. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14309. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14310. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14311. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14312. }
  14313. opInfo.Remark = opRemark;
  14314. await _tableorRep.AddAsync(opInfo);
  14315. #endregion
  14316. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14317. //2024-10-21 新增LZ UID
  14318. var userIds = new List<int>() { 21 };
  14319. string title = $"费用审核";
  14320. string content = "";
  14321. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14322. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14323. try
  14324. {
  14325. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14326. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14327. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14328. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14329. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14330. }
  14331. catch (Exception ex)
  14332. {
  14333. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14334. }
  14335. }
  14336. catch (Exception ex)
  14337. {
  14338. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14339. }
  14340. try
  14341. {
  14342. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14343. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14344. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14345. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14346. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14347. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14348. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14349. //自动审核
  14350. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14351. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14352. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14353. //2024-10-21 新增LZ UID
  14354. var userIds = new List<int>() { 21 };
  14355. string title = $"系统通知";
  14356. var diId = _dto.DiId;
  14357. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14358. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14359. string content = "";
  14360. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14361. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14362. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14363. }
  14364. catch (Exception ex)
  14365. {
  14366. }
  14367. #endregion
  14368. return Ok(_view);
  14369. }
  14370. /// <summary>
  14371. /// 酒店自动审核测试
  14372. /// Add Or Edit
  14373. /// </summary>
  14374. /// <param name="diid"></param>
  14375. /// <param name="dataId"></param>
  14376. /// <returns></returns>
  14377. [HttpPost]
  14378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14379. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14380. {
  14381. #region 应用推送
  14382. try
  14383. {
  14384. //自动审核
  14385. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14386. }
  14387. catch (Exception ex)
  14388. {
  14389. return Ok(JsonView(false, "操作失败"));
  14390. }
  14391. #endregion
  14392. return Ok(JsonView(false, "操作成功"));
  14393. }
  14394. /// <summary>
  14395. /// 酒店预订
  14396. /// Del
  14397. /// </summary>
  14398. /// <param name="_dto"></param>
  14399. /// <returns></returns>
  14400. [HttpPost]
  14401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14402. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14403. {
  14404. #region 参数验证
  14405. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14406. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14407. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14408. #region 团组操作权限验证 76 酒店预定模块
  14409. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14410. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14411. #endregion
  14412. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14413. #region 页面操作权限验证
  14414. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14415. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14416. #endregion
  14417. #endregion
  14418. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14419. #region 操作记录
  14420. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14421. {
  14422. TableName = "Grp_HotelReservations",
  14423. PortType = _dto.PortType,
  14424. OperationItem = OperationEnum.Del,
  14425. DataId = _dto.Id,
  14426. CreateUserId = _dto.UserId
  14427. });
  14428. #endregion
  14429. return Ok(data);
  14430. }
  14431. /// <summary>
  14432. /// 酒店预订
  14433. /// 生成VOUCHER
  14434. /// 2024.05.06 之前版本
  14435. /// </summary>
  14436. /// <param name="_dto"></param>
  14437. /// <returns></returns>
  14438. [HttpPost]
  14439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14440. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14441. {
  14442. try
  14443. {
  14444. #region 参数验证
  14445. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14446. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14447. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14448. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14449. #region 团组操作权限验证 76 酒店预定模块
  14450. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14451. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14452. #endregion
  14453. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14454. #region 页面操作权限验证
  14455. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14456. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14457. #endregion
  14458. #endregion
  14459. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14460. //判断数据是否完整
  14461. if (hr != null)
  14462. {
  14463. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14464. {
  14465. string strFileName = "HotelStatement/";
  14466. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14467. if (dele != null)
  14468. strFileName += dele.TourCode;
  14469. //载入模板
  14470. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14471. Document doc = new Document(sss);
  14472. DocumentBuilder builder = new DocumentBuilder(doc);
  14473. #region 替换Word模板书签内容
  14474. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14475. //入住卷预定号码
  14476. if (doc.Range.Bookmarks["VNO"] != null)
  14477. {
  14478. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14479. mark.Text = hr.CheckNumber;
  14480. }
  14481. //酒店时间
  14482. if (doc.Range.Bookmarks["Date"] != null)
  14483. {
  14484. Bookmark mark = doc.Range.Bookmarks["Date"];
  14485. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14486. }
  14487. //团号
  14488. if (doc.Range.Bookmarks["TNo"] != null)
  14489. {
  14490. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14491. mark.Text = dele.TourCode;
  14492. }
  14493. //预定号码
  14494. if (doc.Range.Bookmarks["BookingId"] != null)
  14495. {
  14496. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14497. mark.Text = hr.ReservationsNo;
  14498. }
  14499. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14500. {
  14501. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14502. mark.Text = hr.DetermineNo;
  14503. }
  14504. //酒店城市
  14505. if (doc.Range.Bookmarks["City"] != null)
  14506. {
  14507. Bookmark mark = doc.Range.Bookmarks["City"];
  14508. mark.Text = hr.City;
  14509. }
  14510. //酒店名称
  14511. if (doc.Range.Bookmarks["HName"] != null)
  14512. {
  14513. Bookmark mark = doc.Range.Bookmarks["HName"];
  14514. mark.Text = hr.HotelName;
  14515. }
  14516. //酒店地址
  14517. if (doc.Range.Bookmarks["Address"] != null)
  14518. {
  14519. Bookmark mark = doc.Range.Bookmarks["Address"];
  14520. mark.Text = hr.HotelAddress;
  14521. }
  14522. //酒店电话
  14523. if (doc.Range.Bookmarks["Tel"] != null)
  14524. {
  14525. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14526. mark.Text = hr.HotelTel;
  14527. }
  14528. //酒店传真
  14529. if (doc.Range.Bookmarks["Fax"] != null)
  14530. {
  14531. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14532. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14533. {
  14534. mark.Text = hr.HotelFax;
  14535. }
  14536. }
  14537. //入住时间
  14538. if (doc.Range.Bookmarks["CIn"] != null)
  14539. {
  14540. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14541. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14542. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14543. }
  14544. //退房时间
  14545. if (doc.Range.Bookmarks["COut"] != null)
  14546. {
  14547. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14548. Bookmark mark = doc.Range.Bookmarks["COut"];
  14549. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14550. }
  14551. //客户名称
  14552. if (doc.Range.Bookmarks["GName"] != null)
  14553. {
  14554. string guestName = "";
  14555. string[] clients = new string[] { };
  14556. if (hr.GuestName.Contains(","))
  14557. {
  14558. clients = hr.GuestName.Split(",");
  14559. }
  14560. else
  14561. {
  14562. clients = new string[] { hr.GuestName };
  14563. }
  14564. List<int> clientIds_int = new List<int>();
  14565. if (clients.Length > 0)
  14566. {
  14567. foreach (var item in clients)
  14568. {
  14569. if (item.IsNumeric())
  14570. {
  14571. clientIds_int.Add(int.Parse(item));
  14572. }
  14573. }
  14574. }
  14575. if (clientIds_int.Count > 0)
  14576. {
  14577. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14578. foreach (var client in _clientDatas)
  14579. {
  14580. //男
  14581. if (client.Sex == 0) guestName += $"Mr.";
  14582. //女
  14583. else if (client.Sex == 1) guestName += $"Ms.";
  14584. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14585. {
  14586. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14587. }
  14588. //guestName += $"{client.Pinyin},";
  14589. }
  14590. if (guestName.Length > 0)
  14591. {
  14592. guestName = guestName.Substring(0, guestName.Length - 1);
  14593. }
  14594. }
  14595. else
  14596. {
  14597. guestName = hr.GuestName;
  14598. }
  14599. Bookmark mark = doc.Range.Bookmarks["GName"];
  14600. mark.Text = guestName;
  14601. }
  14602. //房间介绍
  14603. if (doc.Range.Bookmarks["ROOM"] != null)
  14604. {
  14605. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14606. mark.Text = hr.RoomExplanation;
  14607. }
  14608. //报价描述
  14609. if (doc.Range.Bookmarks["NOTE"] != null)
  14610. {
  14611. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14612. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14613. if (ss != null)
  14614. mark.Text = ss.Name;
  14615. }
  14616. //入住时间
  14617. if (doc.Range.Bookmarks["CheckIn"] != null)
  14618. {
  14619. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14620. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14621. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14622. }
  14623. //退房时间
  14624. if (doc.Range.Bookmarks["CheckOut"] != null)
  14625. {
  14626. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14627. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14628. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14629. }
  14630. //日期
  14631. if (doc.Range.Bookmarks["DT"] != null)
  14632. {
  14633. Bookmark mark = doc.Range.Bookmarks["DT"];
  14634. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14635. }
  14636. //名称
  14637. if (doc.Range.Bookmarks["VName"] != null)
  14638. {
  14639. Bookmark mark = doc.Range.Bookmarks["VName"];
  14640. mark.Text = hr.HotelName;
  14641. }
  14642. //号码
  14643. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14644. {
  14645. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14646. mark.Text = hr.CheckNumber;
  14647. }
  14648. #endregion
  14649. strFileName += "VOUCHER.doc";
  14650. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14651. doc.Save(fileDir);
  14652. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14653. return Ok(JsonView(true, "操作成功!", Url));
  14654. }
  14655. else
  14656. {
  14657. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14658. }
  14659. }
  14660. else
  14661. {
  14662. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14663. }
  14664. }
  14665. catch (Exception ex)
  14666. {
  14667. return Ok(JsonView(false, ex.Message));
  14668. }
  14669. }
  14670. /// <summary>
  14671. /// 酒店预订
  14672. /// 生成VOUCHER
  14673. /// 2024.05.06 之后版本
  14674. /// </summary>
  14675. /// <param name="_dto"></param>
  14676. /// <returns></returns>
  14677. [HttpPost]
  14678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14679. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14680. {
  14681. #region 参数验证
  14682. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14683. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14684. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14685. #region 团组操作权限验证 76 酒店预定模块
  14686. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14687. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14688. #endregion
  14689. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14690. #region 页面操作权限验证
  14691. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14692. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14693. #endregion
  14694. #endregion
  14695. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14696. //判断数据是否完整
  14697. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14698. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14699. string strFileName = "HotelStatement/";
  14700. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14701. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14702. #region 数据处理
  14703. List<int> guestIds = new List<int>();
  14704. //int index = 0;
  14705. foreach (var item in hrDtas)
  14706. {
  14707. if (item.GuestName.Contains(","))
  14708. {
  14709. string[] guestIdArr = item.GuestName.Split(',');
  14710. foreach (var guestIdStr in guestIdArr)
  14711. {
  14712. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14713. if (guestBool)
  14714. {
  14715. guestIds.Add(guestId);
  14716. }
  14717. }
  14718. }
  14719. else guestNames += item.GuestName;
  14720. var voucherInfo = new HotelVoucherInfoView()
  14721. {
  14722. HotelName = item.HotelName,
  14723. CheckInDate = item.CheckInDate,
  14724. CheckOutDate = item.CheckOutDate,
  14725. ConfirmationNumber = item.DetermineNo.Trim(),
  14726. RoomType = item.RoomExplanation
  14727. };
  14728. vouchers.Add(voucherInfo);
  14729. }
  14730. if (guestIds.Count > 0)
  14731. {
  14732. guestIds = guestIds.Distinct().ToList();
  14733. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14734. if (guestDatas.Count > 0)
  14735. {
  14736. guestNames = "";
  14737. foreach (var guest in guestDatas)
  14738. {
  14739. string guestName = "";
  14740. if (guest.Sex == 0) guestName += @"MR.";
  14741. else if (guest.Sex == 1) guestName += @"MS.";
  14742. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14743. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14744. guestNames += @$"{guestName.Trim()}、";
  14745. }
  14746. if (guestNames.Length > 0)
  14747. {
  14748. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14749. }
  14750. }
  14751. }
  14752. #endregion
  14753. //载入模板
  14754. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14755. Document doc = new Document(sss);
  14756. DocumentBuilder builder = new DocumentBuilder(doc);
  14757. if (doc.Range.Bookmarks["GuestName"] != null)
  14758. {
  14759. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14760. mark.Text = guestNames;
  14761. }
  14762. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14763. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14764. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14765. for (int i = 1; i <= vouchers.Count; i++)
  14766. {
  14767. HotelVoucherInfoView hviv = vouchers[i - 1];
  14768. builder.MoveToCell(0, i, 0, 0);
  14769. builder.Write(hviv.HotelName);
  14770. builder.MoveToCell(0, i, 1, 0);
  14771. builder.Write(hviv.CheckInDate);
  14772. builder.MoveToCell(0, i, 2, 0);
  14773. builder.Write(hviv.CheckOutDate);
  14774. builder.MoveToCell(0, i, 3, 0);
  14775. builder.Write(hviv.RoomType);
  14776. builder.MoveToCell(0, i, 4, 0);
  14777. builder.Write(hviv.ConfirmationNumber);
  14778. }
  14779. //删除多余行
  14780. int currRowIndex = vouchers.Count + 1;
  14781. int delRows = 21 - currRowIndex;
  14782. if (delRows > 0)
  14783. {
  14784. for (int i = 0; i < delRows; i++)
  14785. {
  14786. table.Rows.RemoveAt(currRowIndex);
  14787. //cultivateRowIndex++;
  14788. }
  14789. }
  14790. strFileName += "VOUCHER.docx";
  14791. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14792. doc.Save(fileDir);
  14793. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14794. return Ok(JsonView(true, "操作成功!", Url));
  14795. }
  14796. /// <summary>
  14797. /// 酒店预订
  14798. /// 生成VOUCHER 批量生成
  14799. /// New
  14800. /// </summary>
  14801. /// <param name="_dto"></param>
  14802. /// <returns></returns>
  14803. [HttpPost]
  14804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14805. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14806. {
  14807. #region 参数验证
  14808. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14809. if (_dto.PageId < 1) _dto.PageId = 28;
  14810. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14811. #region 团组操作权限验证 76 酒店预定模块
  14812. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14813. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14814. #endregion
  14815. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14816. #region 页面操作权限验证
  14817. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14818. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14819. #endregion
  14820. #endregion
  14821. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14822. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14823. .OrderBy(x => x.CheckInDate)
  14824. .ToListAsync();
  14825. //判断数据是否完整
  14826. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14827. string strFileName = "HotelStatement/";
  14828. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14829. if (dele != null)
  14830. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14831. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14832. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14833. .Where(it => it.IsDel == 0)
  14834. .ToListAsync();
  14835. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14836. for (int i = 0; i < hrDtas.Count; i++)
  14837. {
  14838. string guestNames = string.Empty;
  14839. List<int> guestIds = new List<int>();
  14840. var item = hrDtas[i];
  14841. //处理客户姓名
  14842. if (item.GuestName.Contains(","))
  14843. {
  14844. string[] guestIdArr = item.GuestName.Split(',');
  14845. foreach (var guestIdStr in guestIdArr)
  14846. if (int.TryParse(guestIdStr, out int guestId))
  14847. guestIds.Add(guestId);
  14848. }
  14849. else
  14850. {
  14851. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14852. if (guestIdBool)
  14853. {
  14854. guestIds.Add(guestId);
  14855. }
  14856. //NaN
  14857. if (item.GuestName.Contains("NaN"))
  14858. {
  14859. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14860. }
  14861. }
  14862. if (guestIds.Count > 0)
  14863. {
  14864. guestIds = guestIds.Distinct().ToList();
  14865. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14866. if (guestDatas1.Count > 0)
  14867. {
  14868. guestNames = "";
  14869. foreach (var guest in guestDatas1)
  14870. {
  14871. string guestName = "";
  14872. if (guest.Sex == 0) guestName += @"MR.";
  14873. else if (guest.Sex == 1) guestName += @"MS.";
  14874. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14875. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14876. guestNames += @$"{guestName.Trim()}、";
  14877. }
  14878. if (guestNames.Length > 0)
  14879. {
  14880. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14881. }
  14882. }
  14883. }
  14884. //if (!string.IsNullOrEmpty(guestNames))
  14885. //{
  14886. hrDtas[i].GuestName = guestNames;
  14887. //}
  14888. }
  14889. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14890. Document doc = new Document();
  14891. DocumentBuilder builder = new DocumentBuilder(doc);
  14892. try
  14893. {
  14894. builder.MoveToDocumentStart();
  14895. foreach (var item in hrDtas)
  14896. {
  14897. //标题
  14898. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14899. builder.ParagraphFormat.LineSpacing = 1;
  14900. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14901. builder.ParagraphFormat.Style.Font.Size = 9;
  14902. builder.ParagraphFormat.Style.Font.Bold = true;
  14903. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14904. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14905. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14906. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14907. builder.ParagraphFormat.LineSpacing = 1;
  14908. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14909. builder.ParagraphFormat.Style.Font.Size = 9;
  14910. builder.ParagraphFormat.Style.Font.Bold = true;
  14911. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14912. builder.StartTable();
  14913. // 设置边框颜色
  14914. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14915. //设置边框样式
  14916. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14917. //表格
  14918. #region 第一行
  14919. builder.InsertCell();
  14920. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14921. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14922. //builder.CellFormat.AllowAutoFit = false;
  14923. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14924. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14925. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14926. builder.CellFormat.WrapText = true; //自动换行
  14927. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14928. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14929. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14930. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14931. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14932. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14933. builder.Write("TOUR NO:");
  14934. builder.InsertCell();
  14935. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14936. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14937. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14938. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14939. builder.ParagraphFormat.Style.Font.Bold = false;
  14940. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14941. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14942. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14943. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14944. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14945. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14946. builder.Write($"{dele?.TourCode ?? "-"}");
  14947. builder.InsertCell();
  14948. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14949. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14950. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14951. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14952. builder.ParagraphFormat.Style.Font.Bold = false;
  14953. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14954. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14955. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14956. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14957. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14958. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14959. builder.Write($"CITY:");
  14960. builder.InsertCell();
  14961. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14962. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14963. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14964. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14965. builder.ParagraphFormat.Style.Font.Bold = false;
  14966. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14967. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14968. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14969. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14970. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14971. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14972. builder.Write($"{item.City}");
  14973. builder.EndRow();
  14974. #endregion
  14975. #region 第二行
  14976. builder.InsertCell();
  14977. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14978. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14979. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14980. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14981. builder.ParagraphFormat.Style.Font.Bold = false;
  14982. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14983. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14984. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14985. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14986. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14987. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14988. builder.Write("CONFIRMATION NO:");
  14989. builder.InsertCell();
  14990. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14991. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14992. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14993. builder.ParagraphFormat.Style.Font.Bold = false;
  14994. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14995. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14996. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14997. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14998. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14999. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15000. builder.CellFormat.VerticalMerge = CellMerge.None;
  15001. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15002. builder.Write($"{item.DetermineNo}");
  15003. builder.InsertCell();
  15004. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15005. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15006. builder.InsertCell();
  15007. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15008. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15009. builder.EndRow();
  15010. #endregion
  15011. #region 第三行
  15012. builder.InsertCell();
  15013. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15014. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15015. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15016. builder.ParagraphFormat.Style.Font.Bold = false;
  15017. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15018. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15019. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15020. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15021. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15022. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15023. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15024. builder.Write($"HOTEL NAME:");
  15025. builder.InsertCell();
  15026. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15027. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15028. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15029. builder.ParagraphFormat.Style.Font.Bold = false;
  15030. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15031. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15032. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15033. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15034. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15035. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15036. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15037. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15038. builder.Write($"{item.HotelName}");
  15039. builder.InsertCell();
  15040. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15041. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15042. builder.InsertCell();
  15043. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15044. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15045. builder.EndRow();
  15046. #endregion
  15047. #region 第四行
  15048. builder.InsertCell();
  15049. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15050. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15051. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15052. builder.ParagraphFormat.Style.Font.Bold = false;
  15053. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15054. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15055. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15056. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15057. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15058. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15059. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15060. builder.Write($"HOTEL ADDRESS:");
  15061. builder.InsertCell();
  15062. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15063. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15064. builder.ParagraphFormat.Style.Font.Size = 8;
  15065. builder.ParagraphFormat.Style.Font.Bold = false;
  15066. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15067. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15068. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15069. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15070. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15071. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15072. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15073. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15074. builder.Write($"{item.HotelAddress}");
  15075. builder.InsertCell();
  15076. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15077. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15078. builder.InsertCell();
  15079. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15080. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15081. builder.EndRow();
  15082. #endregion
  15083. #region 第五行
  15084. builder.InsertCell();
  15085. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15086. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15087. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15088. builder.ParagraphFormat.Style.Font.Bold = false;
  15089. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15090. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15091. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15092. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15093. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15094. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15095. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15096. builder.Write("TEL:");
  15097. builder.InsertCell();
  15098. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15099. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15100. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15101. builder.ParagraphFormat.Style.Font.Bold = false;
  15102. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15103. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15104. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15105. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15106. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15107. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15108. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15109. builder.Write($"{item.HotelTel}");
  15110. builder.InsertCell();
  15111. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15112. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15113. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15114. builder.ParagraphFormat.Style.Font.Bold = false;
  15115. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15116. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15117. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15118. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15119. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15120. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15121. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15122. builder.Write($"FAX:");
  15123. builder.InsertCell();
  15124. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15125. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15126. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15127. builder.ParagraphFormat.Style.Font.Bold = false;
  15128. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15129. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15130. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15131. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15132. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15133. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15134. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15135. builder.Write($"{item.HotelFax}");
  15136. builder.EndRow();
  15137. #endregion
  15138. #region 第六行
  15139. builder.InsertCell();
  15140. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15141. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15142. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15143. builder.ParagraphFormat.Style.Font.Bold = false;
  15144. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15145. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15146. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15147. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15148. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15149. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15150. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15151. builder.Write("CHECK IN:");
  15152. builder.InsertCell();
  15153. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15154. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15155. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15156. builder.ParagraphFormat.Style.Font.Bold = false;
  15157. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15158. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15159. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15160. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15161. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15162. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15163. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15164. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15165. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15166. builder.Write($"{checkInStr}");
  15167. builder.InsertCell();
  15168. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15169. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15170. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15171. builder.ParagraphFormat.Style.Font.Bold = false;
  15172. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15173. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15174. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15175. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15176. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15177. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15178. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15179. builder.Write($"CHECK OUT:");
  15180. builder.InsertCell();
  15181. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15182. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15183. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15184. builder.ParagraphFormat.Style.Font.Bold = false;
  15185. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15186. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15187. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15188. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15189. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15190. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15191. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15192. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15193. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15194. builder.Write($"{checkOutStr}");
  15195. builder.EndRow();
  15196. #endregion
  15197. #region 第七行
  15198. builder.InsertCell();
  15199. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15200. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15201. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15202. builder.ParagraphFormat.Style.Font.Bold = false;
  15203. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15204. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15205. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15206. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15207. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15208. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15209. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15210. builder.Write($"GUEST NAME:");
  15211. builder.InsertCell();
  15212. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15213. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15214. builder.ParagraphFormat.Style.Font.Size = 8;
  15215. builder.ParagraphFormat.Style.Font.Bold = false;
  15216. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15217. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15218. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15219. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15220. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15221. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15222. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15223. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15224. builder.Write($"{item.GuestName}");
  15225. builder.InsertCell();
  15226. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15227. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15228. builder.InsertCell();
  15229. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15230. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15231. builder.EndRow();
  15232. #endregion
  15233. #region 第八行
  15234. builder.InsertCell();
  15235. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15236. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15237. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15238. builder.ParagraphFormat.Style.Font.Bold = false;
  15239. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15240. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15241. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15242. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15243. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15244. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15245. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15246. builder.Write($"ROOM TYPE:");
  15247. builder.InsertCell();
  15248. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15249. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15250. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15251. builder.ParagraphFormat.Style.Font.Bold = false;
  15252. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15253. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15254. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15255. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15256. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15257. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15258. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15259. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15260. builder.Write($"{item.RoomExplanation}");
  15261. builder.InsertCell();
  15262. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15263. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15264. builder.InsertCell();
  15265. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15266. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15267. builder.EndRow();
  15268. #endregion
  15269. #region 第九行
  15270. builder.InsertCell();
  15271. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15272. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15273. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15274. builder.ParagraphFormat.Style.Font.Bold = false;
  15275. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15276. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15277. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15278. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15279. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15280. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15281. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15282. builder.Write($"NOTE:");
  15283. builder.InsertCell();
  15284. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15285. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15286. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15287. builder.ParagraphFormat.Style.Font.Bold = false;
  15288. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15289. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15290. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15291. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15292. 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.");
  15293. builder.InsertCell();
  15294. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15295. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15296. builder.InsertCell();
  15297. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15298. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15299. builder.EndRow();
  15300. #endregion
  15301. builder.EndTable();
  15302. //换行
  15303. builder.Writeln("");
  15304. builder.Writeln("");
  15305. }
  15306. #region 获取文档中的所有表格 设置文字自适应
  15307. // 获取文档中的所有表格。
  15308. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15309. {
  15310. // 遍历表格中的所有行。
  15311. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15312. {
  15313. foreach (Cell cell in row.Cells)
  15314. {
  15315. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15316. cellFormat.Width = 0;
  15317. }
  15318. }
  15319. }
  15320. #endregion
  15321. #region 设置页眉
  15322. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15323. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15324. if (System.IO.File.Exists(voucherHeaderPath))
  15325. {
  15326. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15327. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15328. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15329. Shape shape = builder.InsertImage(imageBytes);
  15330. // 调整图片位置
  15331. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15332. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15333. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15334. shape.Left = 0; // 将图片距离页面左边缘的距离
  15335. shape.Width = 81; // 设置图片宽度
  15336. shape.Height = 36; // 设置图片高度
  15337. }
  15338. //靠右
  15339. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15340. //// 设置页脚上下边距
  15341. //builder.PageSetup.HeaderDistance = 42;
  15342. // 添加页眉线
  15343. Aspose.Words.Border borderHeader = null;
  15344. try
  15345. {
  15346. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15347. }
  15348. catch (Exception e)
  15349. {
  15350. // TODO Auto-generated catch block
  15351. //e.printStackTrace();
  15352. }
  15353. borderHeader.Shadow = true;
  15354. borderHeader.DistanceFromText = 2;
  15355. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15356. #endregion
  15357. }
  15358. catch (Exception ex)
  15359. {
  15360. }
  15361. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15362. doc.Save(fileDir);
  15363. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15364. return Ok(JsonView(true, "操作成功!", Url));
  15365. }
  15366. /// <summary>
  15367. /// 酒店预订
  15368. /// 生成 预定成本 Excel
  15369. /// </summary>
  15370. /// <param name="_dto"></param>
  15371. /// <returns></returns>
  15372. [HttpPost]
  15373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15374. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15375. {
  15376. #region 参数验证
  15377. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15378. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15379. if (!vadalitorRes.IsValid)
  15380. {
  15381. var errors = new StringBuilder();
  15382. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15383. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15384. }
  15385. #region 团组操作权限验证 76 酒店预定模块
  15386. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15387. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15388. #endregion
  15389. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15390. #region 页面操作权限验证
  15391. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15392. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15393. #endregion
  15394. #endregion
  15395. decimal _rate = 1.00M;
  15396. string _currency = string.Empty;
  15397. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15398. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15399. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15400. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15401. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15402. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15403. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15404. if (_GroupCostParameter == null)
  15405. {
  15406. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15407. bool isIntType = int.TryParse(_currency, out int currId);
  15408. if (isIntType)
  15409. {
  15410. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15411. }
  15412. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15413. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15414. if (currInfo == null)
  15415. {
  15416. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15417. }
  15418. else _rate = currInfo.Rate;
  15419. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15420. {
  15421. _rate = _GroupCostParameter.Rate;
  15422. }
  15423. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15424. //string strFileName = "HotelStatement/";
  15425. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15426. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15427. var rateDatas = new List<dynamic>();
  15428. #region 数据处理
  15429. foreach (var item in hrDtas)
  15430. {
  15431. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15432. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15433. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15434. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15435. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15436. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15437. {
  15438. continue;
  15439. }
  15440. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15441. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15442. string singleRoomFeeStr = string.Empty,
  15443. doubleRoomFeeStr = string.Empty,
  15444. suiteRoomFeeStr = string.Empty,
  15445. otherRoomFeeStr = string.Empty,
  15446. payMoneyStr = string.Empty,
  15447. cardPriceStr = string.Empty;
  15448. if (roomCurr.Equals("CNY"))
  15449. {
  15450. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15451. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15452. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15453. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15454. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15455. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15456. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15457. }
  15458. else
  15459. {
  15460. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15461. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15462. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15463. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15464. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15465. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15466. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15467. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15468. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15469. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15470. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15471. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15472. if (ccpPaymentCurrency.Equals("CNY"))
  15473. {
  15474. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15475. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15476. }
  15477. else
  15478. {
  15479. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15480. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15481. }
  15482. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15483. if (hotelcardPriceCurrency.Equals("CNY"))
  15484. {
  15485. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15486. }
  15487. else
  15488. {
  15489. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15490. }
  15491. }
  15492. string breakfastPriceStr = string.Empty,
  15493. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15494. governmentRentStr = string.Empty,
  15495. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15496. cityTaxStr = string.Empty,
  15497. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15498. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15499. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15500. {
  15501. if (breakfastCurrency1.Equals("CNY"))
  15502. {
  15503. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15504. }
  15505. else
  15506. {
  15507. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15508. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15509. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15510. }
  15511. }
  15512. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15513. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15514. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15515. {
  15516. if (governmentRentCurrency.Equals("CNY"))
  15517. {
  15518. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15519. }
  15520. else
  15521. {
  15522. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15523. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15524. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15525. }
  15526. }
  15527. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15528. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15529. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15530. {
  15531. if (cityTaxStrCurrency1.Equals("CNY"))
  15532. {
  15533. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15534. }
  15535. else
  15536. {
  15537. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15538. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15539. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15540. }
  15541. }
  15542. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15543. int payDId = roomInfo?.PayDId ?? 0;
  15544. pcfds.Add(new HotelReservations_PCFD_View()
  15545. {
  15546. City = item.City,
  15547. HotelName = item.HotelName,
  15548. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15549. // SingleRoomCount = item.SingleRoomCount,
  15550. SingleRoomPrice = singleRoomFeeStr,
  15551. // DoubleRoomCount = item.DoubleRoomCount,
  15552. DoubleRoomPrice = doubleRoomFeeStr,
  15553. //SuiteRoomCount = item.SuiteRoomCount,
  15554. SuiteRoomPrice = suiteRoomFeeStr,
  15555. OtherRoomPrice = otherRoomFeeStr,
  15556. //OtherRoomCount = item.OtherRoomCount,
  15557. BreakfastPrice = breakfastPriceStr,
  15558. GovernmentRent = governmentRentStr,
  15559. CityTax = cityTaxStr,
  15560. RoomExplanation = item.RoomExplanation,
  15561. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15562. PayTime = roomInfo?.ConsumptionDate,
  15563. BankNo = roomInfo?.BankNo,
  15564. PayMoney = payMoneyStr,
  15565. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15566. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15567. CardPrice = cardPriceStr,
  15568. Remark = ccpInfo.Remark
  15569. });
  15570. }
  15571. #endregion
  15572. //载入模板
  15573. WorkbookDesigner designer = new WorkbookDesigner();
  15574. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15575. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15576. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15577. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15578. var rateDatas1 = rateDatas.Distinct();
  15579. var rateStr = string.Empty;
  15580. foreach (var item in rateDatas1)
  15581. {
  15582. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15583. }
  15584. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15585. designer.SetDataSource("Opertor", userInfo.CnName);
  15586. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15587. dt.TableName = "ViewMyHotelReservations";
  15588. designer.SetDataSource(dt);
  15589. designer.Process();
  15590. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15591. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15592. designer.Workbook.Save(serverPath);
  15593. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15594. #region 删除指定行
  15595. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15596. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15597. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15598. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15599. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15600. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15601. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15602. cssIndex = dt.Columns["CityTax"].Ordinal,
  15603. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15604. remarkIndex = dt.Columns["Remark"].Ordinal;
  15605. //删除指定列
  15606. foreach (DataRow item in dt.Rows)
  15607. {
  15608. string singleStr = item["SingleRoomPrice"].ToString();
  15609. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15610. if (containsDigitButNotZero1) singleDel = false;
  15611. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15612. string doubleStr = item["DoubleRoomPrice"].ToString();
  15613. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15614. if (containsDigitButNotZero2) doubleDel = false;
  15615. string suiteStr = item["SuiteRoomPrice"].ToString();
  15616. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15617. if (containsDigitButNotZero3) suiteDel = false;
  15618. string otherStr = item["OtherRoomPrice"].ToString();
  15619. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15620. if (containsDigitButNotZero4) otherDel = false;
  15621. string zcStr = item["BreakfastPrice"].ToString();
  15622. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15623. if (containsDigitButNotZero5) zcDel = false;
  15624. string dsStr = item["GovernmentRent"].ToString();
  15625. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15626. if (containsDigitButNotZero6) dsDel = false;
  15627. string cssStr = item["CityTax"].ToString();
  15628. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15629. if (containsDigitButNotZero7) cssDel = false;
  15630. string cpStr = item["ConsumptionPatterns"].ToString();
  15631. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15632. string remarkStr = item["Remark"].ToString();
  15633. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15634. }
  15635. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15636. DeleteColumn(serverPath, cpIndex, cpDel);
  15637. DeleteColumn(serverPath, dsIndex, dsDel);
  15638. DeleteColumn(serverPath, cssIndex, cssDel);
  15639. DeleteColumn(serverPath, zcIndex, zcDel);
  15640. DeleteColumn(serverPath, otherIndex, otherDel);
  15641. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15642. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15643. DeleteColumn(serverPath, singleIndex, singleDel);
  15644. #endregion
  15645. //只保留第一个表格
  15646. DeleteSheet(serverPath);
  15647. return Ok(JsonView(true, "操作成功", url = rst));
  15648. }
  15649. else
  15650. {
  15651. _currency = _GroupCostParameter.Currency;
  15652. bool isIntType = int.TryParse(_currency, out int currId);
  15653. if (isIntType)
  15654. {
  15655. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15656. }
  15657. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15658. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15659. if (currInfo == null)
  15660. {
  15661. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15662. }
  15663. if (!_currency.ToUpper().Equals("CNY"))
  15664. {
  15665. _rate = _GroupCostParameter.Rate;
  15666. }
  15667. _rate = currInfo.Rate;
  15668. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15669. //string strFileName = "HotelStatement/";
  15670. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15671. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15672. #region 数据处理
  15673. foreach (var item in hrDtas)
  15674. {
  15675. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15676. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15677. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15678. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15679. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15680. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15681. string singleRoomFeeStr = string.Empty,
  15682. doubleRoomFeeStr = string.Empty,
  15683. suiteRoomFeeStr = string.Empty,
  15684. otherRoomFeeStr = string.Empty,
  15685. payMoneyStr = string.Empty,
  15686. cardPriceStr = string.Empty;
  15687. if (roomCurr.Equals(_currency))
  15688. {
  15689. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15690. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15691. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15692. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15693. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15694. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15695. }
  15696. else
  15697. {
  15698. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15699. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15700. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15701. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15702. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15703. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15704. }
  15705. string breakfastPriceStr = string.Empty,
  15706. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15707. governmentRentStr = string.Empty,
  15708. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15709. cityTaxStrStr = string.Empty,
  15710. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15711. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15712. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15713. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15714. int payDId = roomInfo?.PayDId ?? 0;
  15715. pcfds.Add(new HotelReservations_PCFD_View()
  15716. {
  15717. City = item.City,
  15718. HotelName = item.HotelName,
  15719. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15720. // SingleRoomCount = item.SingleRoomCount,
  15721. SingleRoomPrice = singleRoomFeeStr,
  15722. // DoubleRoomCount = item.DoubleRoomCount,
  15723. DoubleRoomPrice = doubleRoomFeeStr,
  15724. //SuiteRoomCount = item.SuiteRoomCount,
  15725. SuiteRoomPrice = suiteRoomFeeStr,
  15726. OtherRoomPrice = otherRoomFeeStr,
  15727. //OtherRoomCount = item.OtherRoomCount,
  15728. BreakfastPrice = breakfastPriceStr,
  15729. GovernmentRent = governmentRentStr,
  15730. CityTax = cityTaxStrStr,
  15731. RoomExplanation = item.RoomExplanation,
  15732. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15733. PayTime = roomInfo?.ConsumptionDate,
  15734. BankNo = roomInfo?.BankNo,
  15735. PayMoney = payMoneyStr,
  15736. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15737. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15738. CardPrice = cardPriceStr,
  15739. Remark = ccpInfo.Remark
  15740. });
  15741. }
  15742. #endregion
  15743. //载入模板
  15744. WorkbookDesigner designer = new WorkbookDesigner();
  15745. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15746. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15747. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15748. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15749. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15750. designer.SetDataSource("Opertor", userInfo.CnName);
  15751. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15752. dt.TableName = "ViewMyHotelReservations";
  15753. designer.SetDataSource(dt);
  15754. designer.Process();
  15755. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15756. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15757. designer.Workbook.Save(serverPath);
  15758. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15759. #region 删除指定行
  15760. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15761. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15762. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15763. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15764. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15765. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15766. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15767. cssIndex = dt.Columns["CityTax"].Ordinal,
  15768. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15769. remarkIndex = dt.Columns["Remark"].Ordinal;
  15770. //删除指定列
  15771. foreach (DataRow item in dt.Rows)
  15772. {
  15773. string singleStr = item["SingleRoomPrice"].ToString();
  15774. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15775. if (containsDigitButNotZero1) singleDel = false;
  15776. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15777. string doubleStr = item["DoubleRoomPrice"].ToString();
  15778. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15779. if (containsDigitButNotZero2) doubleDel = false;
  15780. string suiteStr = item["SuiteRoomPrice"].ToString();
  15781. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15782. if (containsDigitButNotZero3) suiteDel = false;
  15783. string otherStr = item["OtherRoomPrice"].ToString();
  15784. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15785. if (containsDigitButNotZero4) otherDel = false;
  15786. string zcStr = item["BreakfastPrice"].ToString();
  15787. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15788. if (containsDigitButNotZero5) zcDel = false;
  15789. string dsStr = item["GovernmentRent"].ToString();
  15790. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15791. if (containsDigitButNotZero6) dsDel = false;
  15792. string cssStr = item["CityTax"].ToString();
  15793. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15794. if (containsDigitButNotZero7) cssDel = false;
  15795. string cpStr = item["ConsumptionPatterns"].ToString();
  15796. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15797. string remarkStr = item["Remark"].ToString();
  15798. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15799. }
  15800. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15801. DeleteColumn(serverPath, cpIndex, cpDel);
  15802. DeleteColumn(serverPath, dsIndex, dsDel);
  15803. DeleteColumn(serverPath, cssIndex, cssDel);
  15804. DeleteColumn(serverPath, zcIndex, zcDel);
  15805. DeleteColumn(serverPath, otherIndex, otherDel);
  15806. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15807. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15808. DeleteColumn(serverPath, singleIndex, singleDel);
  15809. #endregion
  15810. //只保留第一个表格
  15811. DeleteSheet(serverPath);
  15812. return Ok(JsonView(true, "操作成功", url = rst));
  15813. }
  15814. //return Ok(JsonView(false));
  15815. }
  15816. /// <summary>
  15817. /// 删除指定列
  15818. /// </summary>
  15819. /// <param name="file"></param>
  15820. /// <param name="columnIndex"></param>
  15821. /// <param name="isDel"></param>
  15822. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15823. {
  15824. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15825. //wb.Save(file);
  15826. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15827. if (sheet1 != null)
  15828. {
  15829. if (isDel)
  15830. {
  15831. Cells cells = sheet1.Cells;
  15832. cells.DeleteColumn(columnIndex);
  15833. }
  15834. }
  15835. wb.Save(file);
  15836. }
  15837. /// <summary>
  15838. /// 删除sheet
  15839. /// </summary>
  15840. /// <param name="file"></param>
  15841. /// <param name="sheetName"></param>
  15842. private void DeleteSheet(string file, string sheetName = "")
  15843. {
  15844. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15845. //wb.Save(file);
  15846. List<string> sheets = new List<string>();
  15847. foreach (var item in wb.Worksheets)
  15848. {
  15849. sheets.Add(item.Name);
  15850. }
  15851. if (sheets.Count > 0)
  15852. {
  15853. sheets.RemoveAt(0);//不删除第一个sheet
  15854. foreach (var item in sheets)
  15855. {
  15856. wb.Worksheets.RemoveAt(item);
  15857. }
  15858. }
  15859. wb.Save(file);
  15860. }
  15861. /// <summary>
  15862. /// 酒店预订
  15863. /// 确认单
  15864. /// </summary>
  15865. /// <param name="_dto"></param>
  15866. /// <returns></returns>
  15867. [HttpPost]
  15868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15869. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15870. {
  15871. try
  15872. {
  15873. #region 参数验证
  15874. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15875. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15876. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15877. #region 团组操作权限验证 76 酒店预定模块
  15878. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15879. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15880. #endregion
  15881. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15882. #region 页面操作权限验证
  15883. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15884. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15885. #endregion
  15886. #endregion
  15887. //团组信息
  15888. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15889. //酒店数据
  15890. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15891. if (listhoteldata.Count < 0)
  15892. {
  15893. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15894. }
  15895. //利datatable存储
  15896. DataTable dt = new DataTable();
  15897. dt.Columns.Add("CheckInDate", typeof(string));
  15898. dt.Columns.Add("City", typeof(string));
  15899. dt.Columns.Add("Hotel", typeof(string));
  15900. dt.Columns.Add("Room", typeof(string));
  15901. for (int i = 0; i < listhoteldata.Count; i++)
  15902. {
  15903. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15904. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15905. while (dayStart < dayEnd)
  15906. {
  15907. string temp = "";
  15908. DataRow row = dt.NewRow();
  15909. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15910. row["City"] = listhoteldata[i].City;
  15911. row["Hotel"] = listhoteldata[i].HotelName;
  15912. if (listhoteldata[i].SingleRoomCount > 0)
  15913. {
  15914. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15915. }
  15916. if (listhoteldata[i].DoubleRoomCount > 0)
  15917. {
  15918. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15919. }
  15920. if (listhoteldata[i].SuiteRoomCount > 0)
  15921. {
  15922. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15923. }
  15924. if (listhoteldata[i].OtherRoomCount > 0)
  15925. {
  15926. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15927. }
  15928. row["Room"] = temp;
  15929. dt.Rows.Add(row);
  15930. dayStart = dayStart.AddDays(1);
  15931. }
  15932. }
  15933. Dictionary<string, string> dic = new Dictionary<string, string>();
  15934. dic.Add("Dele", di.TeamName);
  15935. dic.Add("City", di.VisitCountry);
  15936. //模板路径
  15937. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15938. //载入模板
  15939. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15940. DocumentBuilder builder = new DocumentBuilder(doc);
  15941. foreach (var key in dic.Keys)
  15942. {
  15943. builder.MoveToBookmark(key);
  15944. builder.Write(dic[key]);
  15945. }
  15946. //获取word里所有表格
  15947. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15948. //获取所填表格的序数
  15949. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15950. var rowStart = tableOne.Rows[0]; //获取第1行
  15951. //循环赋值
  15952. for (int i = 0; i < dt.Rows.Count; i++)
  15953. {
  15954. builder.MoveToCell(0, i + 1, 0, 0);
  15955. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15956. builder.MoveToCell(0, i + 1, 1, 0);
  15957. builder.Write(dt.Rows[i]["City"].ToString());
  15958. builder.MoveToCell(0, i + 1, 2, 0);
  15959. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15960. builder.MoveToCell(0, i + 1, 3, 0);
  15961. builder.Write(dt.Rows[i]["Room"].ToString());
  15962. }
  15963. //删除多余行
  15964. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15965. {
  15966. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15967. }
  15968. string strFileName = di.TeamName + "酒店确认单.doc";
  15969. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15970. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15971. return Ok(JsonView(true, "成功", url));
  15972. }
  15973. catch (Exception ex)
  15974. {
  15975. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15976. }
  15977. }
  15978. #endregion
  15979. #region 团组状态
  15980. /// <summary>
  15981. /// 团组状态列表 Page
  15982. /// </summary>
  15983. /// <param name="dto">团组列表请求dto</param>
  15984. /// <returns></returns>
  15985. [HttpPost]
  15986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15987. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15988. {
  15989. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15990. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15991. {
  15992. string sqlWhere = string.Empty;
  15993. if (dto.IsSure == 0) //未完成
  15994. {
  15995. sqlWhere += string.Format(@" And IsSure = 0");
  15996. }
  15997. else if (dto.IsSure == 1) //已完成
  15998. {
  15999. sqlWhere += string.Format(@" And IsSure = 1");
  16000. }
  16001. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16002. {
  16003. string tj = dto.SearchCriteria;
  16004. 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}%')",
  16005. tj, tj, tj, tj, tj);
  16006. }
  16007. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16008. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16009. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16010. From (
  16011. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16012. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16013. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16014. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16015. From Grp_DelegationInfo gdi
  16016. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16017. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16018. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16019. Where gdi.IsDel = 0 {0}
  16020. ) temp ", sqlWhere);
  16021. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16022. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16023. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16024. }
  16025. else
  16026. {
  16027. return Ok(JsonView(false, "查询失败"));
  16028. }
  16029. }
  16030. /// <summary>
  16031. /// 团组状态
  16032. /// 设置操作完成
  16033. /// </summary>
  16034. /// <param name="dto">团组列表请求dto</param>
  16035. /// <returns></returns>
  16036. [HttpPost]
  16037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16038. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16039. {
  16040. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16041. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16042. {
  16043. Id = dto.Id,
  16044. IsSure = 1
  16045. };
  16046. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16047. .UpdateColumns(it => new { it.IsSure })
  16048. .WhereColumns(it => new { it.Id })
  16049. .ExecuteCommandAsync();
  16050. if (result > 0)
  16051. {
  16052. return Ok(JsonView(true, "操作完成!"));
  16053. }
  16054. return Ok(JsonView(false, "操作失败!"));
  16055. }
  16056. #endregion
  16057. #region 保险费用录入
  16058. /// <summary>
  16059. /// 根据团组Id查询保险费用列表
  16060. /// </summary>
  16061. /// <param name="dto"></param>
  16062. /// <returns></returns>
  16063. [HttpPost]
  16064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16065. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16066. {
  16067. Result groupData = await _customersRep.CustomersByDiId(dto);
  16068. if (groupData.Code != 0)
  16069. {
  16070. return Ok(JsonView(false, groupData.Msg));
  16071. }
  16072. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16073. }
  16074. /// <summary>
  16075. /// 根据保险费用Id查询保险费用详细
  16076. /// </summary>
  16077. /// <param name="dto"></param>
  16078. /// <returns></returns>
  16079. [HttpPost]
  16080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16081. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16082. {
  16083. try
  16084. {
  16085. Result groupData = await _customersRep.CustomersById(dto);
  16086. if (groupData.Code != 0)
  16087. {
  16088. return Ok(JsonView(false, groupData.Msg));
  16089. }
  16090. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16091. }
  16092. catch (Exception ex)
  16093. {
  16094. return Ok(JsonView(false, ex.Message));
  16095. }
  16096. }
  16097. /// <summary>
  16098. /// 保险费用录入页面初始化绑定
  16099. /// </summary>
  16100. /// <param name="dto"></param>
  16101. /// <returns></returns>
  16102. [HttpPost]
  16103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16104. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16105. {
  16106. try
  16107. {
  16108. Result groupData = await _customersRep.CustomersInitialize(dto);
  16109. if (groupData.Code != 0)
  16110. {
  16111. return Ok(JsonView(false, groupData.Msg));
  16112. }
  16113. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16114. }
  16115. catch (Exception ex)
  16116. {
  16117. return Ok(JsonView(false, ex.Message));
  16118. }
  16119. }
  16120. /// <summary>
  16121. /// 保险费用操作(Status:1.新增,2.修改)
  16122. /// </summary>
  16123. /// <param name="dto"></param>
  16124. /// <returns></returns>
  16125. [HttpPost]
  16126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16127. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16128. {
  16129. Result groupData = await _customersRep.OpCustomers(dto);
  16130. if (groupData.Code != 0)
  16131. {
  16132. return Ok(JsonView(false, groupData.Msg));
  16133. }
  16134. #region 应用推送
  16135. try
  16136. {
  16137. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16138. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16139. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16140. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16141. //自动审核
  16142. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16143. //2024-10-21 新增LZ UID
  16144. var userIds = new List<int>() { 21 };
  16145. string title = $"系统通知";
  16146. var diId = dto.DiId;
  16147. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16148. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16149. string content = "";
  16150. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16151. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16152. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16153. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16154. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16155. }
  16156. catch (Exception ex)
  16157. {
  16158. }
  16159. #endregion
  16160. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16161. }
  16162. /// <summary>
  16163. /// 保险文件上传
  16164. /// </summary>
  16165. /// <param name="file"></param>
  16166. /// <returns></returns>
  16167. [HttpPost]
  16168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16169. public async Task<IActionResult> UploadCus(IFormFile file)
  16170. {
  16171. try
  16172. {
  16173. if (file != null)
  16174. {
  16175. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16176. //文件名称
  16177. string projectFileName = file.FileName;
  16178. //上传的文件的路径
  16179. string filePath = "";
  16180. if (!Directory.Exists(fileDir))
  16181. {
  16182. Directory.CreateDirectory(fileDir);
  16183. }
  16184. //上传的文件的路径
  16185. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16186. using (FileStream fs = System.IO.File.Create(filePath))
  16187. {
  16188. file.CopyTo(fs);
  16189. fs.Flush();
  16190. }
  16191. return Ok(JsonView(true, "上传成功!", projectFileName));
  16192. }
  16193. else
  16194. {
  16195. return Ok(JsonView(false, "上传失败!"));
  16196. }
  16197. }
  16198. catch (Exception ex)
  16199. {
  16200. return Ok(JsonView(false, "程序错误!"));
  16201. throw;
  16202. }
  16203. }
  16204. /// <summary>
  16205. /// 保险删除指定文件
  16206. /// </summary>
  16207. /// <param name="dto"></param>
  16208. /// <returns></returns>
  16209. [HttpPost]
  16210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16211. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16212. {
  16213. try
  16214. {
  16215. string filePath = "";
  16216. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16217. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16218. //int id = 0;
  16219. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16220. // 删除该文件
  16221. try
  16222. {
  16223. System.IO.File.Delete(filePath);
  16224. 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()
  16225. {
  16226. Attachment = "",
  16227. }).ExecuteCommandAsync();
  16228. if (result != 0)
  16229. {
  16230. return Ok(JsonView(true, "成功!"));
  16231. }
  16232. else
  16233. {
  16234. return Ok(JsonView(false, "失败!"));
  16235. }
  16236. }
  16237. catch (Exception)
  16238. {
  16239. 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()
  16240. {
  16241. Attachment = "",
  16242. }).ExecuteCommandAsync();
  16243. if (result != 0)
  16244. {
  16245. return Ok(JsonView(true, "成功!"));
  16246. }
  16247. else
  16248. {
  16249. return Ok(JsonView(false, "失败!"));
  16250. }
  16251. }
  16252. }
  16253. catch (Exception ex)
  16254. {
  16255. return Ok(JsonView(false, "程序错误!"));
  16256. throw;
  16257. }
  16258. }
  16259. /// <summary>
  16260. /// 保险费用操作(删除)
  16261. /// </summary>
  16262. /// <param name="dto"></param>
  16263. /// <returns></returns>
  16264. [HttpPost]
  16265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16266. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16267. {
  16268. try
  16269. {
  16270. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16271. if (!res)
  16272. {
  16273. return Ok(JsonView(false, "删除失败"));
  16274. }
  16275. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16276. {
  16277. IsDel = 1,
  16278. DeleteUserId = dto.DeleteUserId,
  16279. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16280. }).ExecuteCommandAsync();
  16281. return Ok(JsonView(true, "删除成功!"));
  16282. }
  16283. catch (Exception ex)
  16284. {
  16285. return Ok(JsonView(false, "程序错误!"));
  16286. throw;
  16287. }
  16288. }
  16289. #endregion
  16290. #region 接团客户名单 PageId 104
  16291. /// <summary>
  16292. /// 接团客户名单
  16293. /// 迁移数据(慎用!)
  16294. /// </summary>
  16295. /// <returns></returns>
  16296. [HttpPost]
  16297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16298. public async Task<IActionResult> PostTourClientListChange()
  16299. {
  16300. try
  16301. {
  16302. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16303. //var groupClinetData1
  16304. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16305. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16306. int updateCount = 0;
  16307. if (oldOAClientList.Count > 0)
  16308. {
  16309. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16310. _sqlSugar.BeginTran();
  16311. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16312. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16313. foreach (var item in oldOAClientList)
  16314. {
  16315. int comId = 0;
  16316. string format = "yyyy-MM-dd HH:mm:ss";
  16317. string data11 = "1990-01-01 00:00";
  16318. var data1 = IsValidDate(item.OPdate, format);
  16319. if (data1) data11 = item.OPdate;
  16320. //客户公司验证
  16321. if (!string.IsNullOrEmpty(item.Company))
  16322. {
  16323. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16324. if (clientComInfo == null) // add
  16325. {
  16326. var addInfo = new Crm_CustomerCompany()
  16327. {
  16328. CompanyAbbreviation = "",
  16329. CompanyFullName = item.Company,
  16330. Address = "",
  16331. PostCodes = "",
  16332. LastedOpUserId = item.OPer,
  16333. LastedOpDt = Convert.ToDateTime(data11),
  16334. CreateUserId = item.OPer,
  16335. CreateTime = Convert.ToDateTime(data11),
  16336. IsDel = 0
  16337. };
  16338. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16339. if (comId1 > 0) comId = comId1;
  16340. }
  16341. else comId = clientComInfo.Id;
  16342. }
  16343. //客户人员验证
  16344. int clientId = 0;
  16345. string name = item.LastName + item.Name;
  16346. if (!string.IsNullOrEmpty(name))
  16347. {
  16348. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16349. if (clientInfo == null)
  16350. {
  16351. DateTime? dateTime = null;
  16352. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16353. if (isDt) dateTime = birthDayDt;
  16354. var addInfo1 = new Crm_DeleClient()
  16355. {
  16356. CrmCompanyId = comId,
  16357. DiId = -1,
  16358. LastName = item.LastName,
  16359. FirstName = item.Name,
  16360. OldName = "",
  16361. Pinyin = item.Pinyin,
  16362. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16363. Marriage = 0,
  16364. Phone = item.Phone,
  16365. Job = item.Job,
  16366. BirthDay = dateTime
  16367. };
  16368. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16369. if (clientId1 > 0) clientId = clientId1;
  16370. }
  16371. else clientId = clientInfo.Id;
  16372. }
  16373. if (clientId < 1)
  16374. {
  16375. continue;
  16376. }
  16377. int airType = 0;
  16378. if (item.AirType == "超经舱") airType = 459;
  16379. else if (item.AirType == "公务舱") airType = 458;
  16380. else if (item.AirType == "经济舱") airType = 460;
  16381. else if (item.AirType == "其他") airType = 565;
  16382. else if (item.AirType == "头等舱") airType = 457;
  16383. var _TourClientListEntity = new Grp_TourClientList()
  16384. {
  16385. DiId = item.Diid,
  16386. ClientId = clientId,
  16387. CreateUserId = item.OPer,
  16388. CreateTime = Convert.ToDateTime(data11),
  16389. Remark = item.Remark,
  16390. IsDel = item.Isdel,
  16391. ShippingSpaceTypeId = airType,
  16392. ShippingSpaceSpecialNeeds = item.AirRemark,
  16393. HotelSpecialNeeds = item.RoomType
  16394. };
  16395. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16396. if (_TourClientList > 0)
  16397. {
  16398. updateCount++;
  16399. }
  16400. }
  16401. _sqlSugar.CommitTran();
  16402. }
  16403. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16404. }
  16405. catch (Exception ex)
  16406. {
  16407. _sqlSugar.RollbackTran();
  16408. return Ok(JsonView(false, ex.Message));
  16409. }
  16410. //return Ok(JsonView(true));
  16411. }
  16412. private bool IsValidDate(string dateString, string format)
  16413. {
  16414. DateTime dateValue;
  16415. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16416. return valid;
  16417. }
  16418. /// <summary>
  16419. /// 接团客户名单
  16420. /// 根据团组Id查询List
  16421. /// </summary>
  16422. /// <param name="_dto"></param>
  16423. /// <returns></returns>
  16424. [HttpPost]
  16425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16426. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16427. {
  16428. #region 参数验证
  16429. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16430. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16431. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16432. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16433. #region 页面操作权限验证
  16434. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16435. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16436. #endregion
  16437. #endregion
  16438. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16439. if (viewData.Code != 0)
  16440. {
  16441. return Ok(JsonView(false, viewData.Msg));
  16442. }
  16443. return Ok(JsonView(viewData.Data));
  16444. }
  16445. /// <summary>
  16446. /// 接团客户名单
  16447. /// 基础数据 Init
  16448. /// </summary>
  16449. /// <param name="_dto"></param>
  16450. /// <returns></returns>
  16451. [HttpPost]
  16452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16453. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16454. {
  16455. #region 参数验证
  16456. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16457. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16458. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16459. #region 页面操作权限验证
  16460. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16461. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16462. #endregion
  16463. #endregion
  16464. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16465. }
  16466. /// <summary>
  16467. /// 接团客户名单
  16468. /// 根据 Id查询 Details
  16469. /// </summary>
  16470. /// <param name="_dto"></param>
  16471. /// <returns></returns>
  16472. [HttpPost]
  16473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16474. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16475. {
  16476. #region 参数验证
  16477. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16478. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16479. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16480. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16481. #region 页面操作权限验证
  16482. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16483. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16484. #endregion
  16485. #endregion
  16486. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16487. if (viewData.Code != 0)
  16488. {
  16489. return Ok(JsonView(false, viewData.Msg));
  16490. }
  16491. return Ok(JsonView(viewData.Data));
  16492. }
  16493. /// <summary>
  16494. /// 接团客户名单
  16495. /// Add Or Edit
  16496. /// </summary>
  16497. /// <param name="_dto"></param>
  16498. /// <returns></returns>
  16499. [HttpPost]
  16500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16501. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16502. {
  16503. #region 参数验证
  16504. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16505. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16506. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16507. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16508. #region 页面操作权限验证
  16509. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16510. if (_dto.Id == 0) //添加
  16511. {
  16512. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16513. }
  16514. else if (_dto.Id >= 0) //修改
  16515. {
  16516. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16517. }
  16518. #endregion
  16519. #endregion
  16520. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16521. if (viewData.Code != 0)
  16522. {
  16523. return Ok(JsonView(false, viewData.Msg));
  16524. }
  16525. return Ok(JsonView(true));
  16526. }
  16527. /// <summary>
  16528. /// 接团客户名单
  16529. /// json字符串 AddMultiple(添加多个)
  16530. /// </summary>
  16531. /// <param name="_dto"></param>
  16532. /// <returns></returns>
  16533. [HttpPost]
  16534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16535. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16536. {
  16537. #region 参数验证
  16538. string jsonLabel = _dto.JsonLabel;
  16539. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16540. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16541. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16542. #region 页面操作权限验证
  16543. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16544. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16545. #endregion
  16546. #endregion
  16547. var request = new TourClientListAddMultipleDto();
  16548. request.DiId = _dto.DiId;
  16549. request.UserId = _dto.UserId;
  16550. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16551. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16552. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16553. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16554. var infos = new List<TourClientListInfo>();
  16555. foreach (var data in datas)
  16556. {
  16557. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16558. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16559. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16560. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16561. {
  16562. continue;
  16563. }
  16564. infos.Add(new TourClientListInfo()
  16565. {
  16566. IsAccompany = 1,
  16567. LastName = lastName,
  16568. FirstName = firstName,
  16569. Pinyin = lastNameEn + @"/" + firstNameEn,
  16570. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16571. CompanyFullName = data.CompanyFullName,
  16572. Job = data.Job
  16573. });
  16574. }
  16575. if (infos.Any())
  16576. {
  16577. var viewData = await _tourClientListRep._AddMultiple(request);
  16578. if (viewData.Code != 0)
  16579. {
  16580. return Ok(JsonView(false, viewData.Msg));
  16581. }
  16582. return Ok(JsonView(true));
  16583. }
  16584. return Ok(JsonView(false));
  16585. }
  16586. /// <summary>
  16587. /// 接团客户名单
  16588. /// AddMultiple(添加多个)
  16589. /// </summary>
  16590. /// <param name="_dto"></param>
  16591. /// <returns></returns>
  16592. [HttpPost]
  16593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16594. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16595. {
  16596. #region 参数验证
  16597. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16598. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16599. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16600. #region 页面操作权限验证
  16601. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16602. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16603. #endregion
  16604. #endregion
  16605. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16606. if (viewData.Code != 0)
  16607. {
  16608. return Ok(JsonView(false, viewData.Msg));
  16609. }
  16610. return Ok(JsonView(true));
  16611. }
  16612. /// <summary>
  16613. /// 接团客户名单
  16614. /// Del
  16615. /// </summary>
  16616. /// <param name="_dto"></param>
  16617. /// <returns></returns>
  16618. [HttpPost]
  16619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16620. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16621. {
  16622. #region 参数验证
  16623. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16624. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16625. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16626. #region 页面操作权限验证
  16627. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16628. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16629. #endregion
  16630. #endregion
  16631. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16632. if (viewData.Code != 0)
  16633. {
  16634. return Ok(JsonView(false, viewData.Msg));
  16635. }
  16636. return Ok(JsonView(true));
  16637. }
  16638. /// <summary>
  16639. /// 接团客户名单
  16640. /// 文件下载 客户名单
  16641. /// </summary>
  16642. /// <param name="_dto"></param>
  16643. /// <returns></returns>
  16644. [HttpPost]
  16645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16646. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16647. {
  16648. #region 参数验证
  16649. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16650. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16651. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16652. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16653. #region 页面操作权限验证
  16654. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16655. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16656. #endregion
  16657. #endregion
  16658. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16659. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16660. From Grp_TourClientList tcl
  16661. Left Join
  16662. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16663. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16664. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16665. From Crm_DeleClient dc
  16666. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16667. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16668. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16669. Where dc.IsDel = 0) temp
  16670. On temp.DcId =tcl.ClientId
  16671. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16672. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16673. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16674. //载入模板
  16675. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16676. if (_dto.Language == 1)
  16677. {
  16678. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16679. }
  16680. //载入模板
  16681. var doc = new Document(tempPath);
  16682. DocumentBuilder builder = new DocumentBuilder(doc);
  16683. //获取word里所有表格
  16684. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16685. //获取所填表格的序数
  16686. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16687. var rowStart = tableOne.Rows[0]; //获取第1行
  16688. if (_dto.Language == 0)
  16689. {
  16690. //循环赋值
  16691. for (int i = 0; i < DcList.Count; i++)
  16692. {
  16693. EncryptionProcessor.DecryptProperties(DcList[i]);
  16694. builder.MoveToCell(0, i + 1, 0, 0);
  16695. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16696. builder.MoveToCell(0, i + 1, 1, 0);
  16697. int sex = DcList[i].Sex;
  16698. string sexStr = string.Empty;
  16699. if (sex == 0) sexStr = "男";
  16700. else if (sex == 1) sexStr = "女";
  16701. else sexStr = "未设置";
  16702. builder.Write(sexStr);
  16703. builder.MoveToCell(0, i + 1, 2, 0);
  16704. string birthDay = DcList[i].BirthDay;
  16705. string birthDayStr = string.Empty;
  16706. if (!string.IsNullOrEmpty(birthDay))
  16707. {
  16708. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16709. }
  16710. builder.Write(birthDayStr);
  16711. builder.MoveToCell(0, i + 1, 3, 0);
  16712. string company = "";
  16713. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16714. {
  16715. company = DcList[i].CompanyFullName.ToString();
  16716. }
  16717. builder.Write(company);
  16718. builder.MoveToCell(0, i + 1, 4, 0);
  16719. builder.Write(DcList[i].Job);
  16720. }
  16721. }
  16722. else if (_dto.Language == 1)
  16723. {
  16724. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16725. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16726. List<string> transArrayStr = new List<string>();
  16727. string transStrRes1 = "";
  16728. for (int i = 0; i < DcList.Count; i++)
  16729. {
  16730. var dc = DcList[i];
  16731. EncryptionProcessor.DecryptProperties(dc);
  16732. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16733. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16734. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16735. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16736. else transStrRes1 += $"{str1}|";
  16737. }
  16738. //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";
  16739. string transStrRes = "";
  16740. if (transStrRes1.Length > 0)
  16741. {
  16742. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16743. }
  16744. //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
  16745. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16746. //List<string> transArray = new List<string> { };
  16747. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16748. if (transStrRes.Contains("|"))
  16749. {
  16750. string[] transArray1 = transStrRes.Split('|');
  16751. if (transArray1.Length > 0)
  16752. {
  16753. foreach (var item in transArray1)
  16754. {
  16755. if (item.Contains("&"))
  16756. {
  16757. string[] transArray2 = item.Split('&');
  16758. int index = 0;
  16759. string companyName = "", job = "";
  16760. if (transArray2.Length > 0)
  16761. {
  16762. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16763. if (1 < transArray2.Length) companyName = transArray2[1];
  16764. if (2 < transArray2.Length) job = transArray2[2];
  16765. }
  16766. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16767. }
  16768. }
  16769. }
  16770. }
  16771. //循环赋值
  16772. for (int i = 0; i < DcList.Count; i++)
  16773. {
  16774. string PYName = "";
  16775. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16776. {
  16777. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16778. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16779. PYName = PY_First + " " + PY_Last;
  16780. }
  16781. else
  16782. {
  16783. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16784. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16785. PYName = PY_First + " " + PY_Last;
  16786. }
  16787. builder.MoveToCell(0, i + 1, 0, 0);
  16788. builder.Write(PYName);
  16789. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16790. builder.MoveToCell(0, i + 1, 1, 0);
  16791. builder.Write(sex);
  16792. DateTime birthDt;
  16793. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16794. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16795. builder.MoveToCell(0, i + 1, 2, 0);
  16796. builder.Write(birthday);
  16797. string company = string.Empty, job = string.Empty;
  16798. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16799. if (dcTransInfo != null)
  16800. {
  16801. company = dcTransInfo.CompanyName;
  16802. job = dcTransInfo.Job;
  16803. }
  16804. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16805. {
  16806. //查询对照表
  16807. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16808. if (tempCec != null)
  16809. {
  16810. company = tempCec.enName;
  16811. }
  16812. //翻译
  16813. else
  16814. {
  16815. }
  16816. }
  16817. builder.MoveToCell(0, i + 1, 3, 0);
  16818. builder.Write(company);
  16819. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16820. {
  16821. //查询对照表
  16822. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16823. if (tempPec != null)
  16824. {
  16825. job = tempPec.enName;
  16826. }
  16827. //翻译
  16828. else
  16829. {
  16830. }
  16831. }
  16832. builder.MoveToCell(0, i + 1, 4, 0);
  16833. builder.Write(job);
  16834. }
  16835. }
  16836. //删除多余行
  16837. while (tableOne.Rows.Count > DcList.Count + 1)
  16838. {
  16839. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16840. }
  16841. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16842. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16843. doc.Save(fileDir);
  16844. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16845. return Ok(JsonView(true, "操作成功!", Url));
  16846. }
  16847. private class TranslateInfo
  16848. {
  16849. public int Index { get; set; }
  16850. public string CompanyName { get; set; }
  16851. public string Job { get; set; }
  16852. }
  16853. #endregion
  16854. #region 团组倒推表
  16855. /// <summary>
  16856. /// 倒推表基础数据
  16857. /// Init
  16858. /// </summary>
  16859. /// <returns></returns>
  16860. [HttpPost]
  16861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16862. public async Task<IActionResult> PostInvertedListInit()
  16863. {
  16864. var viewData = await _invertedListRep._Init();
  16865. if (viewData.Code != 0)
  16866. {
  16867. return Ok(JsonView(false, viewData.Msg));
  16868. }
  16869. return Ok(JsonView(viewData.Data));
  16870. }
  16871. /// <summary>
  16872. /// 倒推表
  16873. /// Info
  16874. /// </summary>
  16875. /// <param name="dto"></param>
  16876. /// <returns></returns>
  16877. [HttpPost]
  16878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16879. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16880. {
  16881. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16882. if (viewData.Code != 0)
  16883. {
  16884. return Ok(JsonView(false, viewData.Msg));
  16885. }
  16886. return Ok(JsonView(viewData.Data));
  16887. }
  16888. /// <summary>
  16889. /// 倒推表
  16890. /// Create
  16891. /// </summary>
  16892. /// <param name="dto"></param>
  16893. /// <returns></returns>
  16894. [HttpPost]
  16895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16896. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16897. {
  16898. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16899. if (viewData.Code != 0)
  16900. {
  16901. return Ok(JsonView(false, viewData.Msg));
  16902. }
  16903. return Ok(JsonView(viewData.Data));
  16904. }
  16905. /// <summary>
  16906. /// 倒推表
  16907. /// Update
  16908. /// </summary>
  16909. /// <param name="dto"></param>
  16910. /// <returns></returns>
  16911. [HttpPost]
  16912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16913. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16914. {
  16915. var viewData = await _invertedListRep._Update(dto);
  16916. if (viewData.Code != 0)
  16917. {
  16918. return Ok(JsonView(false, viewData.Msg));
  16919. }
  16920. return Ok(JsonView(viewData.Data));
  16921. }
  16922. /// <summary>
  16923. /// 倒推表
  16924. /// File Download
  16925. /// </summary>
  16926. /// <param name="dto"></param>
  16927. /// <returns></returns>
  16928. [HttpPost]
  16929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16930. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16931. {
  16932. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16933. if (info2.Code != 0)
  16934. {
  16935. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16936. }
  16937. var info1 = info2.Data as InvertedListInfoView;
  16938. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16939. string teamName = "";
  16940. if (info != null) teamName = info.TeamName;
  16941. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  16942. var doc = new Document();
  16943. var builder = new DocumentBuilder(doc);
  16944. #region old insert
  16945. ////载入模板
  16946. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  16947. //Document doc = new Document(tempPath);
  16948. //DocumentBuilder builder = new DocumentBuilder(doc);
  16949. //利用键值对存放数据
  16950. //Dictionary<string, string> dic = new Dictionary<string, string>();
  16951. //dic.Add("TeamName", teamName);
  16952. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16953. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16954. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  16955. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16956. //dic.Add("SQRemark", info1.ApprovalRemark);
  16957. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16958. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16959. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16960. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  16961. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16962. //dic.Add("QZRemark", info1.VisaInformationRemark);
  16963. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16964. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  16965. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16966. //dic.Add("CQRemark", info1.IssueVisaRemark);
  16967. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16968. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16969. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16970. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16971. //#region 填充word模板书签内容
  16972. //foreach (var key in dic.Keys)
  16973. //{
  16974. // builder.MoveToBookmark(key);
  16975. // builder.Write(dic[key]);
  16976. //}
  16977. //#endregion
  16978. #endregion
  16979. #region New Insert
  16980. string titleFont = $"仿宋",
  16981. contentFont = $"仿宋";
  16982. var fontColor = Color.FromArgb(64, 64, 64);
  16983. //设置标题 团组名称
  16984. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16985. builder.Font.Name = titleFont;
  16986. builder.Font.Color = fontColor;
  16987. builder.Font.Size = 12;
  16988. builder.Font.Bold = true;
  16989. builder.Writeln(teamName);
  16990. //设置副标题 团组出访时间
  16991. builder.Font.Size = 12;
  16992. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  16993. builder.Writeln();
  16994. var backgroundColor = Color.FromArgb(199, 199, 199);
  16995. var table = builder.StartTable();
  16996. builder.InsertCell();
  16997. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  16998. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  16999. builder.CellFormat.Borders.LineWidth = 1;
  17000. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17001. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17002. builder.RowFormat.Height = 40;
  17003. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17004. builder.Font.Name = contentFont;
  17005. builder.Font.Size = 12;
  17006. builder.Font.Bold = true;
  17007. builder.Font.Color = fontColor;
  17008. builder.Write("时间");
  17009. builder.InsertCell();
  17010. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17011. builder.Write("流程");
  17012. builder.InsertCell();
  17013. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17014. builder.Write("说明");
  17015. builder.EndRow();
  17016. //报批资料准备
  17017. if (info1.IsSelectedAirportd)
  17018. {
  17019. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17020. }
  17021. //报批/提供送签资料
  17022. if (info1.IsSelectedApprovalData)
  17023. {
  17024. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17025. }
  17026. //出批件护照办理
  17027. if (info1.IsSelectedIssueApproval)
  17028. {
  17029. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17030. }
  17031. //签证资料准备
  17032. if (info1.IsSelectedVisaInfo)
  17033. {
  17034. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17035. }
  17036. //送签
  17037. if (info1.IsSelectedSendVisa)
  17038. {
  17039. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17040. }
  17041. //出签
  17042. if (info1.IsSelectedIssueVisa)
  17043. {
  17044. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17045. }
  17046. //机票
  17047. if (info1.IsSelectedAirTicket)
  17048. {
  17049. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17050. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17051. }
  17052. //酒店
  17053. if (info1.IsSelectedHotel)
  17054. {
  17055. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17056. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17057. }
  17058. //开行前会
  17059. if (info1.IsSelectedPreTripMeeting)
  17060. {
  17061. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17062. }
  17063. //送机
  17064. if (info1.IsSelectedAirportdDropOff)
  17065. {
  17066. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17067. }
  17068. builder.EndTable();
  17069. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17070. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17071. for (int i = 0; i < table.Rows.Count; i++)
  17072. {
  17073. var row = table.Rows[i];
  17074. //设置宽度
  17075. row.Cells[0].CellFormat.Width = 20.00;
  17076. row.Cells[1].CellFormat.Width = 30.00;
  17077. row.Cells[2].CellFormat.Width = 50.00;
  17078. if (i != 0)
  17079. {
  17080. //边框设置
  17081. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17082. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17083. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17084. }
  17085. }
  17086. #region 页脚插入图片
  17087. // 创建页脚
  17088. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17089. doc.FirstSection.HeadersFooters.Add(footer);
  17090. Paragraph para = new Paragraph(doc);
  17091. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17092. footer.AppendChild(para);
  17093. builder.MoveTo(para);
  17094. string imagePath = "./Images/FMGJ_Log.png";
  17095. builder.InsertImage(imagePath);
  17096. #endregion
  17097. #endregion
  17098. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17099. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17100. string filePath = fileDir + $@"InvertedList/{fileName}";
  17101. doc.Save(filePath);
  17102. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17103. return Ok(JsonView(true, "操作成功!", Url));
  17104. }
  17105. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  17106. {
  17107. var fontColor = Color.FromArgb(64, 64, 64);
  17108. builder.InsertCell();
  17109. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17110. builder.RowFormat.Height = 40;
  17111. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17112. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17113. builder.Font.Name = fontName;
  17114. builder.Font.Size = 8;
  17115. builder.Font.Bold = true;
  17116. builder.Font.Color = fontColor;
  17117. builder.Write(dateTime);
  17118. builder.InsertCell();
  17119. builder.Font.Size = 9;
  17120. builder.Font.Bold = true;
  17121. builder.Font.Color = fontColor;
  17122. builder.Write(content);
  17123. builder.InsertCell();
  17124. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17125. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17126. builder.Font.Size = 9;
  17127. builder.Font.Bold = false;
  17128. builder.Font.Color = fontColor;
  17129. builder.Write(reamrk);
  17130. builder.EndRow();
  17131. }
  17132. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  17133. {
  17134. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17135. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17136. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17137. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17138. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17139. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17140. }
  17141. #endregion
  17142. #region 会务倒推表
  17143. /// <summary>
  17144. /// 会务倒推表
  17145. /// Init
  17146. /// </summary>
  17147. /// <returns></returns>
  17148. [HttpPost]
  17149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17150. public async Task<IActionResult> InforRetrogressTableInit()
  17151. {
  17152. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17153. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17154. return Ok(JsonView(false, groupData.Msg));
  17155. }
  17156. /// <summary>
  17157. /// 会务倒推表
  17158. /// ExcelDownload
  17159. /// </summary>
  17160. /// <param name="dto"></param>
  17161. /// <returns></returns>
  17162. [HttpPost]
  17163. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17165. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17166. {
  17167. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17168. var validatorRes = await validator.ValidateAsync(dto);
  17169. if (!validatorRes.IsValid)
  17170. {
  17171. StringBuilder sb = new StringBuilder();
  17172. foreach (var item in validatorRes.Errors)
  17173. {
  17174. sb.AppendLine(item.ErrorMessage);
  17175. }
  17176. return Ok(JsonView(false, sb.ToString()));
  17177. }
  17178. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17179. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17180. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17181. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17182. #region Excel
  17183. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17184. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17185. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17186. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17187. var fileNamePrefix = string.Empty;
  17188. if (days >= 30)
  17189. {
  17190. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17191. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17192. }
  17193. else if (days < 30 && days > 7)
  17194. {
  17195. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17196. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17197. }
  17198. else if (days <= 7)
  17199. {
  17200. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17201. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17202. }
  17203. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17204. fileName = CommonFun.ValidFileName(fileName);
  17205. //载入模板
  17206. WorkbookDesigner designer = new WorkbookDesigner();
  17207. designer.Workbook = new Workbook(tempPath);
  17208. designer.Process();
  17209. if (!Directory.Exists(savePath))
  17210. {
  17211. Directory.CreateDirectory(savePath);
  17212. }
  17213. string serverPath = $"{savePath}{fileName}";
  17214. designer.Workbook.Save(serverPath);
  17215. string rst = $"{servicePath}{ftpPath}{fileName}";
  17216. #endregion
  17217. return Ok(JsonView(new { url = rst }));
  17218. }
  17219. #endregion
  17220. #region 三公签证费用(签证费、代办费)
  17221. /// <summary>
  17222. /// 三公签证费用(签证费、代办费)
  17223. /// List
  17224. /// </summary>
  17225. /// <returns></returns>
  17226. [HttpPost]
  17227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17228. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17229. {
  17230. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17231. if (_view.Code != 0)
  17232. {
  17233. return Ok(JsonView(false, _view.Msg));
  17234. }
  17235. return Ok(JsonView(true, "操作成功!", _view.Data));
  17236. }
  17237. /// <summary>
  17238. /// 三公签证费用(签证费、代办费)
  17239. /// Add Or Update
  17240. /// </summary>
  17241. /// <returns></returns>
  17242. [HttpPost]
  17243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17244. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17245. {
  17246. var _view = await _visaFeeInfoRep._Update(_dto);
  17247. if (_view.Code != 0)
  17248. {
  17249. return Ok(JsonView(false, _view.Msg));
  17250. }
  17251. return Ok(JsonView(true, _view.Msg));
  17252. }
  17253. #endregion
  17254. #region 酒店询价
  17255. /// <summary>
  17256. /// 酒店询价
  17257. /// Init
  17258. /// </summary>
  17259. /// <returns></returns>
  17260. [HttpPost]
  17261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17262. public async Task<IActionResult> PostHotelInquiryInit()
  17263. {
  17264. var res = await _hotelInquiryRep._Init();
  17265. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17266. return Ok(JsonView(true, res.Msg, res.Data));
  17267. }
  17268. /// <summary>
  17269. /// 酒店询价
  17270. /// page Item
  17271. /// </summary>
  17272. /// <param name="_dto"></param>
  17273. /// <returns></returns>
  17274. [HttpPost]
  17275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17276. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17277. {
  17278. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17279. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17280. var view = res.Data as PageDataViewBase;
  17281. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17282. }
  17283. /// <summary>
  17284. /// 酒店询价
  17285. /// info
  17286. /// </summary>
  17287. /// <param name="_dto"></param>
  17288. /// <returns></returns>
  17289. [HttpPost]
  17290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17291. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17292. {
  17293. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17294. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17295. return Ok(JsonView(true, res.Msg, res.Data));
  17296. }
  17297. /// <summary>
  17298. /// 酒店询价
  17299. /// Add Or Edit
  17300. /// </summary>
  17301. /// <param name="_dto"></param>
  17302. /// <returns></returns>
  17303. [HttpPost]
  17304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17305. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17306. {
  17307. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17308. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17309. return Ok(JsonView(true, res.Msg, res.Data));
  17310. }
  17311. /// <summary>
  17312. /// 酒店询价
  17313. /// Del
  17314. /// </summary>
  17315. /// <param name="_dto"></param>
  17316. /// <returns></returns>
  17317. [HttpPost]
  17318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17319. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17320. {
  17321. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17322. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17323. return Ok(JsonView(true, res.Msg, res.Data));
  17324. }
  17325. #endregion
  17326. #region 下载匹配op行程单
  17327. /// <summary>
  17328. /// 匹配op行程单
  17329. /// Init
  17330. /// </summary>
  17331. /// <param name="dto">团组列表请求dto</param>
  17332. /// <returns></returns>
  17333. [HttpPost]
  17334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17335. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17336. {
  17337. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17338. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17339. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17340. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17341. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17342. .Where(it => it.IsDel == 0)
  17343. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17344. .OrderByDescending(it => it.VisitStartDate)
  17345. .ToList();
  17346. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17347. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17348. var diids = groupInfos.Select(it => it.Id).ToList();
  17349. List<string> countrys = new List<string>();
  17350. foreach (var item in country)
  17351. {
  17352. var data = _groupRepository.FormartTeamName(item);
  17353. var dataArray = _groupRepository.GroupSplitCountry(data);
  17354. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17355. }
  17356. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17357. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17358. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17359. foreach (var item in areaItem)
  17360. {
  17361. string areaStr = item.Value;
  17362. if (!string.IsNullOrEmpty(areaStr))
  17363. {
  17364. string[] str1 = areaStr.Split("-");
  17365. if (str1.Length > 0)
  17366. {
  17367. areaArray.AddRange(str1);
  17368. }
  17369. }
  17370. }
  17371. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17372. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17373. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17374. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17375. .ToList();
  17376. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17377. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17378. .Where(it => countriesIds.Contains(it.Id))
  17379. .Select(it => new { it.Id, Name = it.Name_CN })
  17380. .ToList();
  17381. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17382. .Select(it => it.TeamName).ToList();
  17383. stopwatch.Stop();
  17384. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17385. }
  17386. ///// <summary>
  17387. ///// 匹配op行程单
  17388. ///// Init 查询区域数据
  17389. ///// </summary>
  17390. ///// <param name="dto">团组列表请求dto</param>
  17391. ///// <returns></returns>
  17392. //[HttpPost]
  17393. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17394. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17395. //{
  17396. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17397. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17398. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17399. // if (string.IsNullOrEmpty(countriesDataStr))
  17400. // {
  17401. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17402. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17403. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17404. // }
  17405. // else
  17406. // {
  17407. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17408. // }
  17409. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17410. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17411. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17412. // List<dynamic> childList = new List<dynamic>();
  17413. // int parentId = dto.CountriesId;
  17414. // if (provinceData.Count > 1)
  17415. // {
  17416. // foreach (var item1 in provinceData)
  17417. // {
  17418. // List<dynamic> childList1 = new List<dynamic>();
  17419. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17420. // foreach (var item2 in citiesData1)
  17421. // {
  17422. // List<dynamic> childList2 = new List<dynamic>();
  17423. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17424. // foreach (var item3 in countiesData1)
  17425. // {
  17426. // childList2.Add(new
  17427. // {
  17428. // id = item3.Id,
  17429. // parentId = item2.Id,
  17430. // level = "district",
  17431. // name = item3.Name_CN,
  17432. // });
  17433. // }
  17434. // childList1.Add(new
  17435. // {
  17436. // id = item2.Id,
  17437. // parentId = item1.Id,
  17438. // level = "city",
  17439. // name = item2.Name_CN,
  17440. // childList = childList2
  17441. // });
  17442. // }
  17443. // childList.Add(new
  17444. // {
  17445. // id = item1.Id,
  17446. // parentId = parentId,
  17447. // level = "province",
  17448. // name = item1.Name_CN,
  17449. // childList = childList1
  17450. // });
  17451. // }
  17452. // //城市
  17453. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17454. // foreach (var item2 in citiesData2)
  17455. // {
  17456. // List<dynamic> childList22 = new List<dynamic>();
  17457. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17458. // foreach (var item3 in countiesData1)
  17459. // {
  17460. // childList22.Add(new
  17461. // {
  17462. // id = item3.Id,
  17463. // parentId = item2.Id,
  17464. // level = "district",
  17465. // name = item3.Name_CN,
  17466. // });
  17467. // }
  17468. // childList.Add(new
  17469. // {
  17470. // id = item2.Id,
  17471. // parentId = parentId,
  17472. // level = "city",
  17473. // name = item2.Name_CN,
  17474. // childList = childList22
  17475. // });
  17476. // }
  17477. // }
  17478. // else
  17479. // {
  17480. // foreach (var item2 in citiesData)
  17481. // {
  17482. // string cname = item2.Name_CN;
  17483. // List<dynamic> childList1 = new List<dynamic>();
  17484. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17485. // foreach (var item3 in countiesData1)
  17486. // {
  17487. // childList1.Add(new
  17488. // {
  17489. // Id = item3.Id,
  17490. // parentId = item2.Id,
  17491. // level = "district",
  17492. // name = item3.Name_CN
  17493. // });
  17494. // }
  17495. // childList.Add(new
  17496. // {
  17497. // id = item2.Id,
  17498. // parentId = parentId,
  17499. // level = "city",
  17500. // name = item2.Name_CN,
  17501. // childList = childList1
  17502. // });
  17503. // }
  17504. // }
  17505. // stopwatch.Stop();
  17506. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17507. //}
  17508. /// <summary>
  17509. /// 匹配op行程单
  17510. /// 接团信息列表 Page
  17511. /// </summary>
  17512. /// <param name="dto">团组列表请求dto</param>
  17513. /// <returns></returns>
  17514. [HttpPost]
  17515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17516. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17517. {
  17518. var swatch = new Stopwatch();
  17519. swatch.Start();
  17520. #region 参数验证
  17521. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17522. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17523. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17524. #region 页面操作权限验证
  17525. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17526. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17527. #endregion
  17528. #endregion
  17529. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17530. {
  17531. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17532. //string sqlWhere = "";
  17533. if (!string.IsNullOrEmpty(dto.Country))
  17534. {
  17535. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17536. }
  17537. if (!string.IsNullOrEmpty(dto.Area))
  17538. {
  17539. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17540. }
  17541. if (!string.IsNullOrEmpty(dto.TeamName))
  17542. {
  17543. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17544. }
  17545. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17546. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17547. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17548. swatch.Stop();
  17549. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17550. }
  17551. else
  17552. {
  17553. return Ok(JsonView(false, "查询失败"));
  17554. }
  17555. }
  17556. /// <summary>
  17557. /// 匹配op行程单
  17558. /// 行程单下载
  17559. /// </summary>
  17560. /// <param name="dto">团组列表请求dto</param>
  17561. /// <returns></returns>
  17562. [HttpPost]
  17563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17564. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17565. {
  17566. #region 参数验证
  17567. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17568. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17569. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17570. #region 页面操作权限验证
  17571. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17572. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17573. #endregion
  17574. #endregion
  17575. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17576. {
  17577. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17578. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17579. }
  17580. else
  17581. {
  17582. return Ok(JsonView(false, "下载失败!"));
  17583. }
  17584. }
  17585. #endregion
  17586. #region 国家信息 数据 注释
  17587. //[HttpPost]
  17588. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17589. //{
  17590. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17591. // foreach (var item in dto)
  17592. // {
  17593. // infos.Add(new Grp_GroupsTaskAssignment()
  17594. // {
  17595. // DIId = item,
  17596. // CTId = 82,
  17597. // UId = 248,
  17598. // IsEnable = 1,
  17599. // CreateUserId = 233,
  17600. // CreateTime = DateTime.Now,
  17601. // IsDel = 0
  17602. // });
  17603. // infos.Add(new Grp_GroupsTaskAssignment()
  17604. // {
  17605. // DIId = item,
  17606. // CTId = 82,
  17607. // UId = 286,
  17608. // IsEnable = 1,
  17609. // CreateUserId = 233,
  17610. // CreateTime = DateTime.Now,
  17611. // IsDel = 0
  17612. // });
  17613. // }
  17614. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17615. // return Ok("操作成功");
  17616. //}
  17617. //public class paramJsonDto
  17618. //{
  17619. // public List<CountriesInfo> str { get; set; }
  17620. //}
  17621. //[HttpPost]
  17622. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17623. //{
  17624. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17625. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17626. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17627. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17628. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17629. // _sqlSugar.BeginTran();
  17630. // int countitiesIndex = 0;
  17631. // foreach (var item in dto.str)
  17632. // {
  17633. // dynamic data = item.c;
  17634. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17635. // if (data != null)
  17636. // {
  17637. // countitiesIndex++;
  17638. // foreach (var item1 in data)
  17639. // {
  17640. // string cnname = item1.cn;
  17641. // string enname = item1.en;
  17642. // Sys_Cities provinceInfo = new Sys_Cities()
  17643. // {
  17644. // CountriesId = countriesId,
  17645. // Name_CN = cnname,
  17646. // Name_EN = enname,
  17647. // ParentId = 0,
  17648. // IsCapital = 1,
  17649. // CreateUserId = 208,
  17650. // CreateTime = DateTime.Now,
  17651. // IsDel = 0
  17652. // };
  17653. // if (item1.lv == "province") //省份
  17654. // {
  17655. // provinceInfo.Level = 1;
  17656. // int provinceId = 0;
  17657. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17658. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17659. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17660. // var data1 = item1.c;
  17661. // foreach (var item2 in data1)
  17662. // {
  17663. // if (item2.lv == "city")
  17664. // {
  17665. // string citycnname = item2.cn;
  17666. // string cityenname = item2.en;
  17667. // Sys_Cities cityInfo = new Sys_Cities()
  17668. // {
  17669. // CountriesId = countriesId,
  17670. // ParentId = provinceId,
  17671. // Level = 2,
  17672. // Name_CN = citycnname,
  17673. // Name_EN = cityenname,
  17674. // IsCapital = 1,
  17675. // CreateUserId = 208,
  17676. // CreateTime = DateTime.Now,
  17677. // IsDel = 0
  17678. // };
  17679. // if (item2.c != null)
  17680. // {
  17681. // int cityId = 0;
  17682. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17683. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17684. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17685. // foreach (var item3 in item2.c)
  17686. // {
  17687. // if (item3.lv == "district")
  17688. // {
  17689. // var districtInfo = new Sys_Cities()
  17690. // {
  17691. // CountriesId = countriesId,
  17692. // Name_CN = item3.cn,
  17693. // Name_EN = item3.en,
  17694. // Level = 3,
  17695. // ParentId = cityId,
  17696. // IsCapital = 1,
  17697. // CreateUserId = 208,
  17698. // CreateTime = DateTime.Now,
  17699. // IsDel = 0
  17700. // };
  17701. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17702. // //{
  17703. // districts.Add(districtInfo);
  17704. // //}
  17705. // }
  17706. // }
  17707. // }
  17708. // else
  17709. // {
  17710. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17711. // //{
  17712. // cities.Add(cityInfo);
  17713. // //}
  17714. // }
  17715. // }
  17716. // }
  17717. // }
  17718. // else if (item1.lv == "city")//城市
  17719. // {
  17720. // provinceInfo.Level = 2;
  17721. // if (item1.c != null)
  17722. // {
  17723. // int cityId = 0;
  17724. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17725. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17726. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17727. // foreach (var item3 in item1.c)
  17728. // {
  17729. // if (item3.lv == "district")
  17730. // {
  17731. // var districtInfo = new Sys_Cities()
  17732. // {
  17733. // CountriesId = countriesId,
  17734. // Name_CN = item3.cn,
  17735. // Name_EN = item3.en,
  17736. // Level = 3,
  17737. // ParentId = cityId,
  17738. // IsCapital = 1,
  17739. // CreateUserId = 208,
  17740. // CreateTime = DateTime.Now,
  17741. // IsDel = 0
  17742. // };
  17743. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17744. // //{
  17745. // districts.Add(districtInfo);
  17746. // //}
  17747. // }
  17748. // }
  17749. // }
  17750. // else
  17751. // {
  17752. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17753. // //{
  17754. // cities.Add(provinceInfo);
  17755. // //}
  17756. // }
  17757. // }
  17758. // }
  17759. // }
  17760. // }
  17761. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17762. // cities = cities.Distinct().ToList();
  17763. // districts = districts.Distinct().ToList();
  17764. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17765. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17766. // cities.AddRange(districts);
  17767. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17768. // //_sqlSugar.RollbackTran();
  17769. // _sqlSugar.CommitTran();
  17770. // return Ok(JsonView(false, "操作成功!"));
  17771. //}
  17772. //[HttpPost]
  17773. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17774. //{
  17775. // List<CountitiesInfo> infos = dto.MyProperty;
  17776. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17777. // _sqlSugar.BeginTran();
  17778. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17779. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17780. // foreach (var item in infos)
  17781. // {
  17782. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17783. // if (countryInfo != null)
  17784. // {
  17785. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17786. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17787. // if (cityInfo1 != null)
  17788. // {
  17789. // cityInfo1.IsCapital = 0;
  17790. // cityInfos.Add(cityInfo1);
  17791. // }
  17792. // }
  17793. // }
  17794. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17795. // .UpdateColumns(it => it.IsCapital)
  17796. // .WhereColumns(it => it.Id)
  17797. // .ExecuteCommand();
  17798. // //_sqlSugar.RollbackTran();
  17799. // _sqlSugar.CommitTran();
  17800. // return Ok(JsonView(false, "操作成功!"));
  17801. //}
  17802. //public class CounrtiesDto
  17803. //{
  17804. // public List<CountitiesInfo> MyProperty { get; set; }
  17805. //}
  17806. //public class CountitiesInfo
  17807. //{
  17808. // /// <summary>
  17809. // /// 圣约翰
  17810. // /// </summary>
  17811. // public string capital_name_chinese { get; set; }
  17812. // /// <summary>
  17813. // ///
  17814. // /// </summary>
  17815. // public string capital_name { get; set; }
  17816. // /// <summary>
  17817. // ///
  17818. // /// </summary>
  17819. // public string country_type { get; set; }
  17820. // /// <summary>
  17821. // /// 安提瓜和巴布达
  17822. // /// </summary>
  17823. // public string country_name_chinese { get; set; }
  17824. // /// <summary>
  17825. // /// 安提瓜和巴布达
  17826. // /// </summary>
  17827. // public string country_name_chinese_short { get; set; }
  17828. // /// <summary>
  17829. // /// 安提瓜和巴布达
  17830. // /// </summary>
  17831. // public string country_name_chinese_UN { get; set; }
  17832. // /// <summary>
  17833. // ///
  17834. // /// </summary>
  17835. // public string country_name_english_abbreviation { get; set; }
  17836. // /// <summary>
  17837. // ///
  17838. // /// </summary>
  17839. // public string country_name_english_formal { get; set; }
  17840. // /// <summary>
  17841. // ///
  17842. // /// </summary>
  17843. // public string country_name_english_UN { get; set; }
  17844. // /// <summary>
  17845. // ///
  17846. // /// </summary>
  17847. // public string continent_name { get; set; }
  17848. // /// <summary>
  17849. // ///
  17850. // /// </summary>
  17851. // public string subregion_name { get; set; }
  17852. // /// <summary>
  17853. // ///
  17854. // /// </summary>
  17855. // public string country_code2 { get; set; }
  17856. // /// <summary>
  17857. // ///
  17858. // /// </summary>
  17859. // public string country_code3 { get; set; }
  17860. // /// <summary>
  17861. // ///
  17862. // /// </summary>
  17863. // public string phone_code { get; set; }
  17864. //}
  17865. //public class CountriesInfo : BasicInfo
  17866. //{
  17867. // public List<CitiesInfo> c { get; set; }
  17868. //}
  17869. //public class CitiesInfo : BasicInfo
  17870. //{
  17871. // public List<AreaInfo> c { get; set; }
  17872. //}
  17873. //public class AreaInfo : BasicInfo
  17874. //{
  17875. // public List<AreaInfo> c { get; set; }
  17876. //}
  17877. //public class BasicInfo
  17878. //{
  17879. // public string code { get; set; }
  17880. // public string cn { get; set; }
  17881. // public string lv { get; set; }
  17882. // public string en { get; set; }
  17883. //}
  17884. #endregion
  17885. #region 查看邀请方
  17886. /// <summary>
  17887. /// 查看邀请方
  17888. /// 邀请方信息 Init
  17889. /// </summary>
  17890. /// <param name="dto"></param>
  17891. /// <returns></returns>
  17892. [HttpPost]
  17893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17894. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17895. {
  17896. string sqlWhere = string.Empty;
  17897. if (!string.IsNullOrEmpty(dto.Search))
  17898. {
  17899. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17900. }
  17901. string sql = string.Format($@"Select
  17902. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17903. Id,
  17904. UnitName
  17905. From Res_InvitationOfficialActivityData
  17906. Where IsDel = 0
  17907. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17908. RefAsync<int> total = 0;
  17909. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17910. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17911. }
  17912. /// <summary>
  17913. /// 查看邀请方
  17914. /// 国家信息 Init
  17915. /// </summary>
  17916. /// <param name="dto"></param>
  17917. /// <returns></returns>
  17918. [HttpPost]
  17919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17920. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17921. {
  17922. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17923. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17924. var diids = groupInfos.Select(it => it.Id).ToList();
  17925. List<string> countrys = new List<string>();
  17926. foreach (var item in country)
  17927. {
  17928. var data = _groupRepository.FormartTeamName(item);
  17929. var dataArray = _groupRepository.GroupSplitCountry(data);
  17930. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17931. }
  17932. countrys = countrys.Distinct().ToList();
  17933. for (int i = 0; i < countrys.Count; i++)
  17934. {
  17935. string item = countrys[i];
  17936. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17937. {
  17938. countrys.Remove(item);
  17939. i--;
  17940. }
  17941. }
  17942. RefAsync<int> total = 0;
  17943. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17944. .Where(it => countrys.Contains(it.Name_CN))
  17945. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17946. .Select(it => new { id = it.Id, name = it.Name_CN })
  17947. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17948. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17949. }
  17950. /// <summary>
  17951. /// 查看邀请方
  17952. /// 城市信息 Init
  17953. /// </summary>
  17954. /// <param name="dto"></param>
  17955. /// <returns></returns>
  17956. [HttpPost]
  17957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17958. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17959. {
  17960. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17961. RefAsync<int> total = 0;
  17962. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17963. .Where(it => it.CountriesId == dto.CountiesId)
  17964. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17965. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17966. .Select(it => new { id = it.Id, name = it.Name_CN })
  17967. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17968. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17969. }
  17970. /// <summary>
  17971. /// 查看邀请方
  17972. /// 团组名称 Init
  17973. /// </summary>
  17974. /// <param name="dto"></param>
  17975. /// <returns></returns>
  17976. [HttpPost]
  17977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17978. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17979. {
  17980. var watch = new Stopwatch();
  17981. watch.Start();
  17982. RefAsync<int> total = 0;
  17983. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17984. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17985. .Where((oa, di) => oa.IsDel == 0)
  17986. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17987. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17988. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17989. .Distinct()
  17990. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17991. watch.Stop();
  17992. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17993. }
  17994. /// <summary>
  17995. /// 查看邀请方
  17996. /// 团组 & 邀请方信息
  17997. /// </summary>
  17998. /// <param name="dto"></param>
  17999. /// <returns></returns>
  18000. [HttpPost]
  18001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18002. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18003. {
  18004. var watch = new Stopwatch();
  18005. watch.Start();
  18006. RefAsync<int> total = 0;
  18007. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18008. .AS("Grp_DelegationInfo")
  18009. .Includes(x => x.InvitingInfos)
  18010. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18011. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18012. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18013. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18014. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18015. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18016. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18017. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18018. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18019. infos.ForEach(x =>
  18020. {
  18021. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18022. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18023. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18024. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18025. });
  18026. watch.Stop();
  18027. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18028. }
  18029. #endregion
  18030. #region 报批行程
  18031. /// <summary>
  18032. /// 报批行程初始化
  18033. /// </summary>
  18034. /// <param name="dto"></param>
  18035. /// <returns></returns>
  18036. [HttpPost]
  18037. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18038. {
  18039. const int chiNumber = 5;
  18040. var jw = JsonView(false);
  18041. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18042. var group = groupList.First();
  18043. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18044. group = groupList.First(x => x.Id == diid);
  18045. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18046. .Where(x => x.DiId == diid && x.IsDel == 0)
  18047. .ToArray();
  18048. var count = 1;
  18049. foreach (var item in blackCodeList)
  18050. {
  18051. if (string.IsNullOrWhiteSpace(item.Title))
  18052. {
  18053. item.Title = "未设置名称数据" + count;
  18054. }
  18055. count++;
  18056. };
  18057. if (group == null)
  18058. {
  18059. jw.Msg = "暂无团组!";
  18060. return Ok(jw);
  18061. }
  18062. var data = new
  18063. {
  18064. groupList = groupList.Select(x => new
  18065. {
  18066. x.TeamName,
  18067. x.Id
  18068. }),
  18069. content = new ArrayList(),
  18070. groupInfo = new
  18071. {
  18072. group.VisitDays,
  18073. group.TourCode,
  18074. group.VisitPNumber,
  18075. group.TeamName,
  18076. group.Id,
  18077. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18078. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18079. },
  18080. blackCodeList = blackCodeList.Select(x => new
  18081. {
  18082. x.Title,
  18083. x.Id
  18084. }),
  18085. FileTempList = new ArrayList()
  18086. {
  18087. new { Index = 1,FileName = "旧模板" },
  18088. new { Index = 2,FileName = "省外办" },
  18089. new { Index = 3,FileName = "市外办" },
  18090. }
  18091. };
  18092. var resultArr = new ArrayList();
  18093. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18094. #region 默认不生成行程
  18095. //if (content.Count == 0)
  18096. //{
  18097. // var stay = "-";
  18098. // var cityPath = "-";
  18099. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18100. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18101. // .ToList();
  18102. // //添加城市路径以及住宿地
  18103. // //黑屏代码数据
  18104. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18105. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18106. // {
  18107. // jw = JsonView(true, "黑屏代码有误!", data);
  18108. // return Ok(jw);
  18109. // }
  18110. // data = data with
  18111. // {
  18112. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18113. // {
  18114. // x.Title,
  18115. // x.Id,
  18116. // }).ToArray())
  18117. // };
  18118. // foreach (DataRow row in dtBlack.Rows)
  18119. // {
  18120. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18121. // {
  18122. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18123. // return Ok(jw);
  18124. // }
  18125. // }
  18126. // //黑屏代码获取时间区间
  18127. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18128. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18129. // _sqlSugar.BeginTran();
  18130. // for (int i = 0; i < timeArr.Count; i++)
  18131. // {
  18132. // stay = "-";
  18133. // cityPath = "-";
  18134. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18135. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18136. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18137. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18138. // if (tbSelect.Length > 0)
  18139. // {
  18140. // List<string> threeCodeStr = new List<string>();
  18141. // foreach (var item in tbSelect)
  18142. // {
  18143. // var threeCode = item["Three"].ToString() ?? "";
  18144. // if (threeCode.Length == 6)
  18145. // {
  18146. // var start = threeCode.Substring(0, 3);
  18147. // var end = threeCode.Substring(3, 3);
  18148. // if (threeCodeStr.Count == 0)
  18149. // {
  18150. // threeCodeStr.Add(start);
  18151. // threeCodeStr.Add(end);
  18152. // }
  18153. // else
  18154. // {
  18155. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18156. // {
  18157. // threeCodeStr.Add(end);
  18158. // }
  18159. // else
  18160. // {
  18161. // threeCodeStr.Add(start);
  18162. // threeCodeStr.Add(end);
  18163. // }
  18164. // }
  18165. // }
  18166. // }
  18167. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18168. // var last = threeCodeStr.Last();
  18169. // foreach (var item in threeCodeStr)
  18170. // {
  18171. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18172. // if (item.Equals(last))
  18173. // {
  18174. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18175. // }
  18176. // }
  18177. // cityPath = cityPath.Trim('-');
  18178. // }
  18179. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18180. // appro.Diid = diid ?? -1;
  18181. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18182. // appro.Id = thisId;
  18183. // appro.CreateUserId = dto.UserId;
  18184. // appro.CreateTime = DateTime.Now;
  18185. // content.Add(appro);
  18186. // }
  18187. // _sqlSugar.CommitTran();
  18188. //}
  18189. #endregion
  18190. foreach (var x in content)
  18191. {
  18192. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18193. if (chiList.Count < chiNumber)
  18194. {
  18195. for (int i = chiList.Count; i < chiNumber; i++)
  18196. {
  18197. chiList.Add(new Grp_ApprovalTravelDetails());
  18198. }
  18199. }
  18200. resultArr.Add(new
  18201. {
  18202. x.Id,
  18203. x.Date,
  18204. x.Diid,
  18205. chiList = chiList.Select(x1 => new
  18206. {
  18207. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18208. x1.Details,
  18209. x1.ParentId,
  18210. x1.Id
  18211. })
  18212. });
  18213. }
  18214. data = data with
  18215. {
  18216. content = resultArr,
  18217. };
  18218. jw = JsonView(true, "获取成功!", data);
  18219. return Ok(jw);
  18220. }
  18221. /// <summary>
  18222. /// 报批行程删除
  18223. /// </summary>
  18224. /// <param name="dto"></param>
  18225. /// <returns></returns>
  18226. [HttpPost]
  18227. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18228. {
  18229. var jw = JsonView(false);
  18230. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18231. if (group == null)
  18232. {
  18233. jw.Msg = "团组参数有误!";
  18234. return Ok(jw);
  18235. }
  18236. try
  18237. {
  18238. _sqlSugar.BeginTran();
  18239. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18240. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18241. {
  18242. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18243. DeleteUserId = dto.uesrId,
  18244. IsDel = 1
  18245. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18246. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18247. {
  18248. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18249. DeleteUserId = dto.uesrId,
  18250. IsDel = 1
  18251. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18252. _sqlSugar.CommitTran();
  18253. jw = JsonView(true, "删除成功");
  18254. }
  18255. catch (Exception ex)
  18256. {
  18257. jw = JsonView(false, ex.Message);
  18258. }
  18259. return Ok(jw);
  18260. }
  18261. /// <summary>
  18262. /// 报批行程保存
  18263. /// </summary>
  18264. /// <param name="dto"></param>
  18265. /// <returns></returns>
  18266. [HttpPost]
  18267. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18268. {
  18269. var jw = JsonView(false);
  18270. var Find = dto.Arr.Find(x => x.id == 0);
  18271. if (Find != null)
  18272. {
  18273. jw.Msg = "生成的ID为0!";
  18274. return Ok(jw);
  18275. }
  18276. foreach (var item in dto.Arr)
  18277. {
  18278. foreach (var chi in item.chiList)
  18279. {
  18280. if (chi.parentId == 0)
  18281. {
  18282. chi.parentId = item.id;
  18283. }
  18284. }
  18285. }
  18286. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18287. _sqlSugar.BeginTran();
  18288. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18289. {
  18290. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18291. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18292. {
  18293. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18294. DeleteUserId = dto.UserId,
  18295. IsDel = 1
  18296. }).ExecuteCommand();
  18297. }
  18298. try
  18299. {
  18300. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18301. {
  18302. CreateTime = DateTime.Now,
  18303. CreateUserId = dto.UserId,
  18304. Details = x.details,
  18305. ParentId = x.parentId,
  18306. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18307. Remark = "",
  18308. IsDel = 0
  18309. }).ToList()).ExecuteCommand();
  18310. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18311. {
  18312. Id = x.id,
  18313. Details = x.details,
  18314. ParentId = x.parentId,
  18315. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18316. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18317. {
  18318. Details = x.Details,
  18319. ParentId = x.ParentId,
  18320. Time = x.Time
  18321. }).ExecuteCommand();
  18322. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18323. {
  18324. Id = x.id,
  18325. Date = x.date,
  18326. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18327. {
  18328. Date = x.Date
  18329. }).ExecuteCommand();
  18330. _sqlSugar.CommitTran();
  18331. jw = JsonView(true, "保存成功!");
  18332. }
  18333. catch (Exception ex)
  18334. {
  18335. _sqlSugar.RollbackTran();
  18336. jw = JsonView(false, "保存失败!" + ex.Message);
  18337. }
  18338. return Ok(jw);
  18339. }
  18340. /// <summary>
  18341. /// 报批行程生成
  18342. /// </summary>
  18343. /// <param name="dto"></param>
  18344. /// <returns></returns>
  18345. [HttpPost]
  18346. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18347. {
  18348. var jw = JsonView(false);
  18349. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18350. if (group == null)
  18351. {
  18352. jw.Msg = "暂无该团组!";
  18353. return Ok(jw);
  18354. }
  18355. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18356. //黑屏代码数据
  18357. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18358. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18359. {
  18360. jw.Msg = "黑屏代码有误!";
  18361. return Ok(jw);
  18362. }
  18363. foreach (DataRow row in dtBlack.Rows)
  18364. {
  18365. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18366. {
  18367. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18368. return Ok(jw);
  18369. }
  18370. }
  18371. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18372. var resultArr = new ArrayList();
  18373. //if (officialActivitiesArr.Count == 0)
  18374. //{
  18375. // jw.Msg = "暂无公务出访信息!";
  18376. // return Ok(jw);
  18377. //}
  18378. try
  18379. {
  18380. _sqlSugar.BeginTran();
  18381. DeleteApprovalJourney(new
  18382. Domain.Dtos.Groups.DeleteApprovalJourney
  18383. {
  18384. Diid = dto.Diid,
  18385. uesrId = dto.Userid
  18386. });
  18387. var stay = "-";
  18388. var cityPath = "-";
  18389. //添加城市路径以及住宿地
  18390. //黑屏代码获取时间区间
  18391. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18392. var empty = "【未收入该三字码!请机票同事录入】";
  18393. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18394. for (int i = 0; i < timeArr.Count; i++)
  18395. {
  18396. stay = "-";
  18397. cityPath = "-";
  18398. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18399. DateTime NewData = DateTime.Parse(timeArr[i]);
  18400. //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();
  18401. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18402. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18403. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18404. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18405. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18406. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18407. if (tbSelect.Length > 0)
  18408. {
  18409. List<string> threeCodeStr = new List<string>();
  18410. bool isTrade = false;
  18411. string trip = string.Empty;
  18412. var rowLast = tbSelect.Last();
  18413. var rowFirst = tbSelect.First();
  18414. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18415. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18416. var takeOffTime = DateTime.Parse(timeArr[i]);
  18417. var fallToTime = DateTime.Parse(timeArr[i]);
  18418. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18419. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18420. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18421. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18422. foreach (var item in tbSelect)
  18423. {
  18424. var start = string.Empty;
  18425. var end = string.Empty;
  18426. var threeCode = item["Three"].ToString() ?? "";
  18427. if (threeCode.Length == 6)
  18428. {
  18429. start = threeCode.Substring(0, 3);
  18430. end = threeCode.Substring(3, 3);
  18431. if (threeCodeStr.Count == 0)
  18432. {
  18433. threeCodeStr.Add(start);
  18434. threeCodeStr.Add(end);
  18435. }
  18436. else
  18437. {
  18438. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18439. {
  18440. threeCodeStr.Add(end);
  18441. }
  18442. else
  18443. {
  18444. threeCodeStr.Add(start);
  18445. threeCodeStr.Add(end);
  18446. }
  18447. }
  18448. }
  18449. //处理机票信息
  18450. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18451. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18452. if (start_Object == null)
  18453. {
  18454. start_Object = new Res_ThreeCode()
  18455. {
  18456. AirPort = empty,
  18457. AirPort_En = empty,
  18458. City = empty,
  18459. Country = empty,
  18460. Four = empty,
  18461. Three = empty,
  18462. };
  18463. }
  18464. if (end_Object == null)
  18465. {
  18466. end_Object = new Res_ThreeCode()
  18467. {
  18468. AirPort = empty,
  18469. AirPort_En = empty,
  18470. City = empty,
  18471. Country = empty,
  18472. Four = empty,
  18473. Three = empty,
  18474. };
  18475. }
  18476. //机型判断
  18477. string airModel = item["AirModel"].ToString();
  18478. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18479. string flightTime = item["FlightTime"].ToString();
  18480. if (flightTime!.Contains(":"))
  18481. {
  18482. flightTime = flightTime.Replace(":", "小时");
  18483. flightTime += "分钟";
  18484. }
  18485. if (flightTime.Contains("H"))
  18486. {
  18487. flightTime = flightTime.Replace("H", "小时");
  18488. }
  18489. if (flightTime.Contains("M"))
  18490. {
  18491. flightTime = flightTime.Replace("M", "分钟");
  18492. }
  18493. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18494. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18495. {
  18496. flightTime = flightDataTime.Hour > 0
  18497. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18498. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18499. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18500. }
  18501. //航班号
  18502. string flightcode = item["Fliagtcode"].ToString();
  18503. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18504. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18505. if (aircompany == null)
  18506. {
  18507. aircompany = new Res_AirCompany
  18508. {
  18509. CnName = hsEmpty,
  18510. EnName = hsEmpty,
  18511. ShortCode = hsEmpty,
  18512. };
  18513. }
  18514. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18515. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18516. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18517. if (isTrade)
  18518. {
  18519. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18520. }
  18521. else
  18522. {
  18523. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18524. }
  18525. }
  18526. chiarr.Add(new Grp_ApprovalTravelDetails
  18527. {
  18528. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18529. CreateTime = DateTime.Now,
  18530. CreateUserId = dto.Userid,
  18531. ParentId = 0,
  18532. Details = trip
  18533. });
  18534. //添加乘车语句
  18535. chiarr.Add(new Grp_ApprovalTravelDetails
  18536. {
  18537. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  18538. CreateTime = DateTime.Now,
  18539. CreateUserId = dto.Userid,
  18540. ParentId = 0,
  18541. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  18542. });
  18543. if (i != timeArr.Count - 1)
  18544. {
  18545. fallToTime = fallToTime.AddHours(2.5);
  18546. foreach (var item in Times)
  18547. {
  18548. //排列公务时间
  18549. if (fallToTime.Hour < item.Item1)
  18550. {
  18551. chiarr.Add(new Grp_ApprovalTravelDetails
  18552. {
  18553. Time = $"{item.Item2} - {item.Item3}",
  18554. CreateTime = DateTime.Now,
  18555. CreateUserId = dto.Userid,
  18556. ParentId = 0,
  18557. Details = "公务活动"
  18558. });
  18559. }
  18560. }
  18561. }
  18562. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18563. var last = threeCodeStr.Last();
  18564. foreach (var item in threeCodeStr)
  18565. {
  18566. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18567. if (item.Equals(last))
  18568. {
  18569. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18570. }
  18571. }
  18572. cityPath = cityPath.Trim('-');
  18573. }
  18574. else
  18575. {
  18576. foreach (var item in Times)
  18577. {
  18578. chiarr.Add(new Grp_ApprovalTravelDetails
  18579. {
  18580. Time = $"{item.Item2} - {item.Item3}",
  18581. CreateTime = DateTime.Now,
  18582. CreateUserId = dto.Userid,
  18583. ParentId = 0,
  18584. Details = "公务活动"
  18585. });
  18586. }
  18587. }
  18588. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18589. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18590. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")"+ "第" + intToString(i + 1) + "天 ";
  18591. appro.Diid = dto.Diid;
  18592. appro.CreateUserId = dto.Userid;
  18593. appro.CreateTime = DateTime.Now;
  18594. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18595. appro.Id = thisId;
  18596. //foreach (var item in gwinfo)
  18597. //{
  18598. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18599. // chi.Details = "拜访" + item.Client;
  18600. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18601. // {
  18602. // chi.Details += "," + item.ReqSample;
  18603. // }
  18604. // chi.ParentId = thisId;
  18605. // chi.Time = item.Time;
  18606. // chiarr.Add(chi);
  18607. //}
  18608. if (chiarr.Count < 6)
  18609. {
  18610. for (int j = chiarr.Count; j < 6; j++)
  18611. {
  18612. chiarr.Add(new
  18613. Grp_ApprovalTravelDetails());
  18614. }
  18615. }
  18616. resultArr.Add(new
  18617. {
  18618. appro.Id,
  18619. appro.Date,
  18620. appro.Diid,
  18621. chiList = chiarr.Select(x1 => new
  18622. {
  18623. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18624. x1.Details,
  18625. x1.ParentId,
  18626. x1.Id
  18627. })
  18628. });
  18629. }
  18630. _sqlSugar.CommitTran();
  18631. jw = JsonView(true, "生成成功!", resultArr);
  18632. }
  18633. catch (Exception ex)
  18634. {
  18635. jw.Code = 400;
  18636. jw.Msg = "生成失败!" + ex.Message;
  18637. }
  18638. return Ok(jw);
  18639. }
  18640. /// <summary>
  18641. /// 报批行程word导出
  18642. /// </summary>
  18643. /// <param name="dto"></param>
  18644. /// <returns></returns>
  18645. [HttpPost]
  18646. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18647. {
  18648. var jw = JsonView(false);
  18649. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18650. if (group == null)
  18651. {
  18652. jw.Msg = "暂无该团组!";
  18653. return Ok(jw);
  18654. }
  18655. //模板路径
  18656. string tempPath = AppSettingsHelper.Get("WordBasePath")+ "Template/";
  18657. var fileName = string.Empty;
  18658. string titleFont = string.Empty,timeFont = string.Empty, contentFont = string.Empty;
  18659. bool bold = false;
  18660. if (dto.FileIndex == 1)
  18661. {
  18662. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18663. }
  18664. else if (dto.FileIndex == 2)
  18665. {
  18666. fileName = "省外办-报批.docx";
  18667. bold = false;
  18668. titleFont = "方正黑体简体";
  18669. timeFont = "Times New Roman";
  18670. contentFont = "方正仿宋_GBK";
  18671. }
  18672. else if (dto.FileIndex == 3)
  18673. {
  18674. fileName = "市外办-报批.docx";
  18675. titleFont = "方正黑体简体";
  18676. timeFont = "Times New Roman";
  18677. contentFont = "方正仿宋简体";
  18678. }
  18679. tempPath = tempPath + fileName;
  18680. //载入模板
  18681. Document doc = new Document(tempPath);
  18682. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18683. //获取所填表格的序数
  18684. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18685. Aspose.Words.Tables.Row titleRowClone = null;
  18686. Aspose.Words.Tables.Row CenterRowClone = null;
  18687. int index = 0;
  18688. int indexChi = 0;
  18689. int SetIndex = 0;
  18690. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18691. //获取数据,放到datatable
  18692. foreach (var item in ApprovalTravelArr)
  18693. {
  18694. if (index > 0)
  18695. {
  18696. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18697. tableOne.AppendChild(titleRowClone);
  18698. }
  18699. var textTime = item.Date;
  18700. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18701. SetCells(tableOne, doc, SetIndex, 0, textTime,titleFont,bold);
  18702. SetIndex++;
  18703. if (ChiRep.Count > 0)
  18704. {
  18705. foreach (var itemChi in ChiRep)
  18706. {
  18707. var txtTime = itemChi.Time;
  18708. var txtDetail = itemChi.Details;
  18709. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18710. {
  18711. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  18712. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18713. //indexChi++;
  18714. //SetIndex++;
  18715. break;
  18716. }
  18717. if (indexChi > 0)
  18718. {
  18719. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18720. tableOne.AppendChild(CenterRowClone);
  18721. }
  18722. SetCells(tableOne, doc, SetIndex, 0, txtTime,timeFont,bold);
  18723. SetCells(tableOne, doc, SetIndex, 1, txtDetail,contentFont, bold);
  18724. indexChi++;
  18725. SetIndex++;
  18726. }
  18727. }
  18728. //else
  18729. //{
  18730. // if (indexChi > 0)
  18731. // {
  18732. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18733. // tableOne.AppendChild(CenterRowClone);
  18734. // }
  18735. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  18736. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18737. // indexChi++;
  18738. // SetIndex++;
  18739. //}
  18740. index++;
  18741. }
  18742. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  18743. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName,Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18744. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18745. jw.Code = 200;
  18746. jw.Msg = "";
  18747. return Ok(jw);
  18748. }
  18749. private string intToString(int numberVal)
  18750. {
  18751. string numberval = numberVal.ToString();
  18752. Dictionary<char, string> Number = new Dictionary<char, string>();
  18753. Number.Add('1', "一");
  18754. Number.Add('2', "二");
  18755. Number.Add('3', "三");
  18756. Number.Add('4', "四");
  18757. Number.Add('5', "五");
  18758. Number.Add('6', "六");
  18759. Number.Add('7', "七");
  18760. Number.Add('8', "八");
  18761. Number.Add('9', "九");
  18762. string stringNumberVal = string.Empty;
  18763. for (int i = 0; i < numberval.Length; i++)
  18764. {
  18765. if (i == 0)
  18766. {
  18767. stringNumberVal += Number[numberval[i]];
  18768. }
  18769. else if (i >= 1)
  18770. {
  18771. if (numberval[i] == '0')
  18772. {
  18773. stringNumberVal = "十";
  18774. }
  18775. else
  18776. {
  18777. stringNumberVal += "十" + Number[numberval[i]];
  18778. }
  18779. }
  18780. }
  18781. return stringNumberVal;
  18782. }
  18783. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val,string font ,bool bold)
  18784. {
  18785. //获取table中的某个单元格,从0开始
  18786. Cell lshCell = table.Rows[rows].Cells[cells];
  18787. //将单元格中段落移除
  18788. foreach (Paragraph item in lshCell.Paragraphs)
  18789. {
  18790. lshCell.Paragraphs.Remove(item);
  18791. }
  18792. if (val.Contains("\r\n"))
  18793. {
  18794. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18795. foreach (var item in spArr)
  18796. {
  18797. //新建一个段落
  18798. Paragraph p = new Paragraph(doc);
  18799. var r = new Run(doc, item);
  18800. //设置字体
  18801. if (!string.IsNullOrEmpty(font))
  18802. {
  18803. r.Font.Name = font;
  18804. }
  18805. r.Font.Bold = bold;
  18806. //把设置的值赋给之前新建的段落
  18807. p.AppendChild(r);
  18808. //将此段落加到单元格内
  18809. lshCell.AppendChild(p);
  18810. }
  18811. }
  18812. else
  18813. {
  18814. //新建一个段落
  18815. Paragraph p = new Paragraph(doc);
  18816. var r = new Run(doc, val);
  18817. //设置字体
  18818. if (!string.IsNullOrEmpty(font))
  18819. {
  18820. r.Font.Name = font;
  18821. }
  18822. r.Font.Bold = bold;
  18823. //把设置的值赋给之前新建的段落
  18824. p.AppendChild(r);
  18825. //将此段落加到单元格内
  18826. lshCell.AppendChild(p);
  18827. }
  18828. }
  18829. [HttpPost]
  18830. public async Task<IActionResult> ServerHttp(string paramStr)
  18831. {
  18832. paramStr = paramStr.TrimEnd('\'');
  18833. paramStr = paramStr.TrimStart('\'');
  18834. JsonView jw = JsonView(false);
  18835. JObject param = JObject.Parse(paramStr);
  18836. if (!param.ContainsKey("url"))
  18837. {
  18838. jw.Msg = "url null";
  18839. return Ok(jw);
  18840. }
  18841. string url = param["url"]!.ToString();
  18842. var methon = "get";
  18843. Dictionary<string, string> headValues = null;
  18844. string bodyStr = string.Empty;
  18845. if (param.ContainsKey("methon"))
  18846. {
  18847. methon = param["methon"]!.ToString().ToLower();
  18848. }
  18849. if (param.ContainsKey("header"))
  18850. {
  18851. var header = param["header"]!.ToString();
  18852. JObject headerJobject = JObject.Parse(header);
  18853. headValues = new Dictionary<string, string>();
  18854. foreach (JProperty item in headerJobject.Properties())
  18855. {
  18856. var value = item.Value.ToString();
  18857. var head = item.Path;
  18858. headValues.Add(head, value);
  18859. }
  18860. }
  18861. HttpClient client = new HttpClient();
  18862. string responseString = string.Empty;
  18863. StringContent content = null;
  18864. if (headValues != null)
  18865. {
  18866. foreach (var item in headValues.Keys)
  18867. {
  18868. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18869. {
  18870. if (param.ContainsKey("body"))
  18871. {
  18872. bodyStr = param["body"]!.ToString();
  18873. }
  18874. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18875. }
  18876. else
  18877. {
  18878. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18879. }
  18880. }
  18881. }
  18882. try
  18883. {
  18884. if (methon == "get")
  18885. {
  18886. responseString = await client.GetStringAsync(url);
  18887. }
  18888. else if (methon == "post")
  18889. {
  18890. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18891. {
  18892. Content = content
  18893. };
  18894. var response = await client.SendAsync(request);
  18895. try
  18896. {
  18897. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18898. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18899. {
  18900. using (StreamReader reader = new StreamReader(gzipStream))
  18901. {
  18902. responseString = await reader.ReadToEndAsync();
  18903. }
  18904. }
  18905. }
  18906. catch (Exception)
  18907. {
  18908. responseString = await response.Content.ReadAsStringAsync();
  18909. }
  18910. }
  18911. else
  18912. {
  18913. responseString = "methon error";
  18914. }
  18915. jw = JsonView(true, "success", responseString);
  18916. }
  18917. catch (Exception ex)
  18918. {
  18919. jw.Msg = "error " + ex.Message;
  18920. jw.Data = ex.StackTrace;
  18921. }
  18922. finally
  18923. {
  18924. client.Dispose();
  18925. }
  18926. return Ok(jw);
  18927. }
  18928. #endregion
  18929. #region 团组接待意见调查
  18930. /// <summary>
  18931. /// 团组接待意见调查 - 信息管理
  18932. /// 基础数据(团组)
  18933. /// </summary>
  18934. /// <returns></returns>
  18935. [HttpGet]
  18936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18937. public async Task<IActionResult> OpinionaireInit()
  18938. {
  18939. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18940. .Select(x => new
  18941. {
  18942. x.Id,
  18943. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18944. })
  18945. .OrderByDescending(x => x.Id)
  18946. .ToListAsync();
  18947. return Ok(JsonView(groupData, groupData.Count));
  18948. }
  18949. /// <summary>
  18950. /// 团组接待意见调查 - 信息管理
  18951. /// 列表
  18952. /// </summary>
  18953. /// <param name="groupId"></param>
  18954. /// <returns></returns>
  18955. [HttpGet("{groupId}")]
  18956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18957. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18958. {
  18959. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18960. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18961. .Select(x => new
  18962. {
  18963. x.Id,
  18964. x.TourGuideName,
  18965. x.CityName,
  18966. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18967. x.CreateTime
  18968. })
  18969. .OrderBy(x => x.Id)
  18970. .ToListAsync();
  18971. return Ok(JsonView(data));
  18972. }
  18973. /// <summary>
  18974. /// 团组接待意见调查 - 信息管理
  18975. /// 保存
  18976. /// </summary>
  18977. /// <param name="dto"></param>
  18978. /// <returns></returns>
  18979. [HttpPost]
  18980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18981. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18982. {
  18983. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18984. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18985. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18986. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18987. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18988. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18989. _opinionaireRep.BeginTran();
  18990. if (addData != null && addData.Count > 0)
  18991. {
  18992. foreach (var item in addData)
  18993. {
  18994. item.CreateUserId = currUserInfo.UserId;
  18995. item.DiId = dto.DiId;
  18996. }
  18997. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18998. }
  18999. if (updData != null && updData.Count > 0)
  19000. {
  19001. var upd = await _opinionaireRep._sqlSugar
  19002. .Updateable(updData)
  19003. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19004. .WhereColumns(x => new { x.Id })
  19005. .ExecuteCommandAsync();
  19006. }
  19007. _opinionaireRep.CommitTran();
  19008. return Ok(JsonView("操作成功!"));
  19009. }
  19010. /// <summary>
  19011. /// 团组接待意见调查 - 信息管理
  19012. /// 删除
  19013. /// </summary>
  19014. /// <param name="id"></param>
  19015. /// <returns></returns>
  19016. [HttpDelete("{id}")]
  19017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19018. public async Task<IActionResult> OpinionaireManageDel(int id)
  19019. {
  19020. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19021. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19022. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19023. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19024. if (!del) return Ok(JsonView("操作失败!"));
  19025. return Ok(JsonView("操作成功!"));
  19026. }
  19027. /// <summary>
  19028. /// 团组接待意见调查 - 用户
  19029. /// 列表
  19030. /// </summary>
  19031. /// <param name="diId"></param>
  19032. /// <returns></returns>
  19033. [HttpGet("{diId}")]
  19034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19035. public async Task<IActionResult> OpinionaireUserList(int diId)
  19036. {
  19037. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19038. var sql = string.Format(@"
  19039. SELECT
  19040. o.Id,
  19041. o.DiId,
  19042. di.TeamName AS 'GroupName',
  19043. di.VisitPNumber AS 'PeopleNumber',
  19044. di.ClientName AS 'LeadGroup',
  19045. di.VisitCountry AS 'Travel',
  19046. di.VisitDays AS 'Days',
  19047. o.CityName,
  19048. o.TourGuideName,
  19049. o.Catering,
  19050. o.CateringReason,
  19051. o.Stay,
  19052. o.StayReason,
  19053. o.[Route],
  19054. o.RouteReason,
  19055. o.OfficialActivity,
  19056. o.OfficialActivityReason,
  19057. o.TourGuide,
  19058. o.TourGuideReason,
  19059. o.[Translate],
  19060. o.TranslateReason,
  19061. o.Trip,
  19062. o.TripReason,
  19063. o.ESFileName,
  19064. o.SignatureDate,
  19065. o.Remark
  19066. FROM
  19067. Grp_Opinionaire o
  19068. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19069. WHERE
  19070. o.IsDel = 0
  19071. AND o.DiId = {0}
  19072. ORDER BY
  19073. o.Id ASC", diId);
  19074. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19075. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19076. return Ok(JsonView(data));
  19077. }
  19078. /// <summary>
  19079. /// 团组接待意见调查 - 用户
  19080. /// 保存
  19081. /// </summary>
  19082. /// <param name="dto"></param>
  19083. /// <returns></returns>
  19084. [HttpPost]
  19085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19086. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19087. {
  19088. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19089. foreach (var item in dto)
  19090. {
  19091. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19092. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19093. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19094. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19095. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19096. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19097. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19098. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19099. }
  19100. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19101. if (!Directory.Exists(filePathBase))
  19102. {
  19103. Directory.CreateDirectory(filePathBase);
  19104. }
  19105. #region 上传文件
  19106. var filePaths = new List<string>();
  19107. foreach (var item in dto)
  19108. {
  19109. var file = item.File;
  19110. // 将文件保存到指定位置
  19111. var filePath = Path.Combine(filePathBase, file.FileName);
  19112. using (var stream = new FileStream(filePath, FileMode.Create))
  19113. {
  19114. await file.CopyToAsync(stream);
  19115. }
  19116. //验证文件是否上传成功
  19117. if (!System.IO.File.Exists(filePath))
  19118. {
  19119. foreach (var filePathStr in filePaths)
  19120. {
  19121. System.IO.File.Delete(filePathStr);
  19122. }
  19123. return Ok(JsonView(false, "文件上传失败!"));
  19124. }
  19125. item.ESFileName = file.FileName;
  19126. }
  19127. #endregion
  19128. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19129. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19130. .UpdateColumns(x => new
  19131. {
  19132. x.Catering,
  19133. x.CateringReason,
  19134. x.Stay,
  19135. x.StayReason,
  19136. x.Route,
  19137. x.RouteReason,
  19138. x.OfficialActivity,
  19139. x.OfficialActivityReason,
  19140. x.TourGuide,
  19141. x.TourGuideReason,
  19142. x.Translate,
  19143. x.TranslateReason,
  19144. x.Trip,
  19145. x.TripReason,
  19146. x.ESFileName,
  19147. x.SignatureDate,
  19148. x.Remark
  19149. })
  19150. .WhereColumns(x => new { x.Id })
  19151. .ExecuteCommandAsync();
  19152. if (upd < 1)
  19153. {
  19154. foreach (var filePathStr in filePaths)
  19155. {
  19156. System.IO.File.Delete(filePathStr);
  19157. }
  19158. return Ok(JsonView(false));
  19159. }
  19160. return Ok(JsonView(true));
  19161. }
  19162. #endregion
  19163. #region 团组餐厅相关信息
  19164. /// <summary>
  19165. /// 团组相关餐厅信息
  19166. /// 基础数据(团组)
  19167. /// </summary>
  19168. /// <returns></returns>
  19169. [HttpGet]
  19170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19171. public async Task<IActionResult> RestaurantInit()
  19172. {
  19173. return Ok(await _restaurantRep.InitAsync());
  19174. }
  19175. /// <summary>
  19176. /// 团组相关餐厅信息
  19177. /// Item
  19178. /// </summary>
  19179. /// <param name="dto"></param>
  19180. /// <returns></returns>
  19181. [HttpPost]
  19182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19183. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19184. {
  19185. int portType = dto.PortType,
  19186. groupId = dto.GroupId;
  19187. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19188. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19189. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19190. }
  19191. /// <summary>
  19192. /// 团组相关餐厅信息
  19193. /// List
  19194. /// </summary>
  19195. /// <param name="dto"></param>
  19196. /// <returns></returns>
  19197. [HttpPost]
  19198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19199. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19200. {
  19201. int portType = dto.PortType,
  19202. groupId = dto.GroupId;
  19203. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19204. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19205. var sql = string.Format(@" SELECT
  19206. ri.Id,
  19207. ri.GroupId,
  19208. ri.Date,
  19209. ri.StartTime,
  19210. ri.EndTime,
  19211. CASE WHEN ri.Type = 1 THEN '早餐'
  19212. WHEN ri.Type = 2 THEN '午餐'
  19213. WHEN ri.Type = 3 THEN '晚餐'
  19214. ELSE '其他'
  19215. END AS 'Type',
  19216. ri.Name,
  19217. ri.Address,
  19218. ri.Tel,
  19219. ri.Remark,
  19220. ri.CreateTime,
  19221. u.CnName AS CreateUserName
  19222. FROM
  19223. Grp_RestaurantInfo ri
  19224. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19225. WHERE
  19226. ri.IsDel = 0
  19227. AND ri.GroupId = {0}
  19228. ORDER BY
  19229. ri.Date ASC
  19230. ", groupId);
  19231. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19232. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19233. return Ok(JsonView(infos));
  19234. }
  19235. /// <summary>
  19236. /// 团组相关餐厅信息
  19237. /// Info
  19238. /// </summary>
  19239. /// <param name="dto"></param>
  19240. /// <returns></returns>
  19241. [HttpPost]
  19242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19243. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19244. {
  19245. int portType = dto.PortType,
  19246. id = dto.Id;
  19247. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19248. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19249. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19250. }
  19251. /// <summary>
  19252. /// 团组相关餐厅信息
  19253. /// Op
  19254. /// </summary>
  19255. /// <param name="dto"></param>
  19256. /// <returns></returns>
  19257. [HttpPost]
  19258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19259. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19260. {
  19261. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19262. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19263. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19264. return Ok(await _restaurantRep.OpAsync(dto));
  19265. }
  19266. /// <summary>
  19267. /// 团组相关餐厅信息
  19268. /// Del
  19269. /// </summary>
  19270. /// <param name="dto"></param>
  19271. /// <returns></returns>
  19272. [HttpPost]
  19273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19274. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19275. {
  19276. int userId = dto.DeleteUserId;
  19277. var id = dto.Id;
  19278. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19279. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19280. return Ok(await _restaurantRep.DelAsync(dto));
  19281. }
  19282. #endregion
  19283. // /// <summary>
  19284. // ///
  19285. // /// </summary>
  19286. // /// <param name="_dto"></param>
  19287. // /// <returns></returns>
  19288. // [HttpPost]
  19289. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19290. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19291. // {
  19292. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19293. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19294. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19295. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19296. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19297. // dic_psg.Add("客人", 974);
  19298. // dic_psg.Add("司机", 975);
  19299. // dic_psg.Add("导游", 976);
  19300. // dic_psg.Add("公司内部人员", 977);
  19301. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19302. // foreach (var item in list_visa)
  19303. // {
  19304. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19305. // temp.Id = item.Id;
  19306. // temp.DIId = item.DIId;
  19307. // temp.VisaClient = item.VisaClient;
  19308. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19309. // temp.VisaCurrency = item.VisaCurrency;
  19310. // temp.IsThird = item.IsThird;
  19311. // if (dic_psg.ContainsKey(item.PassengerType))
  19312. // {
  19313. // temp.PassengerType = dic_psg[item.PassengerType];
  19314. // }
  19315. // else {
  19316. // temp.PassengerType = -1;
  19317. // }
  19318. // temp.VisaNumber = item.VisaNumber;
  19319. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19320. // temp.CreateUserId = item.Operators;
  19321. // DateTime dt_ct;
  19322. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19323. // if (b_ct)
  19324. // {
  19325. // temp.CreateTime = dt_ct;
  19326. // }
  19327. // else
  19328. // {
  19329. // temp.CreateTime = DateTime.Now;
  19330. // }
  19331. // temp.DeleteTime = "";
  19332. // temp.DeleteUserId = 0;
  19333. // temp.Remark = item.Remark;
  19334. // if (string.IsNullOrEmpty(temp.Remark)) {
  19335. // temp.Remark = "";
  19336. // }
  19337. // temp.IsDel = item.IsDel;
  19338. // temp.VisaDescription = item.VisaAttachment;
  19339. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19340. //([Id]
  19341. // ,[DIId]
  19342. // ,[VisaClient]
  19343. // ,[VisaPrice]
  19344. // ,[VisaCurrency]
  19345. // ,[IsThird]
  19346. // ,[PassengerType]
  19347. // ,[VisaNumber]
  19348. // ,[VisaFreeNumber]
  19349. // ,[CreateUserId]
  19350. // ,[CreateTime]
  19351. // ,[DeleteTime]
  19352. // ,[DeleteUserId]
  19353. // ,[Remark]
  19354. // ,[IsDel]
  19355. // ,[visaDescription])
  19356. // VALUES
  19357. // ({0},{1},'{2}',{3},{4}
  19358. //,{5},{6},{7},{8},{9}
  19359. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19360. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19361. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19362. //);
  19363. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19364. // }
  19365. // return Ok(JsonView(true, "操作成功!"));
  19366. // }
  19367. /// <summary>
  19368. /// 123132123
  19369. /// </summary>
  19370. /// <param name="_dto"></param>
  19371. /// <returns></returns>
  19372. [HttpPost]
  19373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19374. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19375. {
  19376. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19377. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19378. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19379. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19380. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19381. dicDetail.Add(789, 1034);
  19382. dicDetail.Add(790, 1035);
  19383. dicDetail.Add(791, 1036);
  19384. dicDetail.Add(792, 1037);
  19385. dicDetail.Add(793, 1038);
  19386. dicDetail.Add(794, 1039);
  19387. dicDetail.Add(795, 1040);
  19388. dicDetail.Add(796, 1041);
  19389. dicDetail.Add(797, 1042);
  19390. dicDetail.Add(798, 1043);
  19391. dicDetail.Add(801, 1044);
  19392. dicDetail.Add(802, 1045);
  19393. dicDetail.Add(803, 1046);
  19394. Dictionary<int, int> dic = new Dictionary<int, int>();
  19395. dic.Add(806, 1027);
  19396. dic.Add(807, 1028);
  19397. dic.Add(808, 1029);
  19398. dic.Add(809, 1030);
  19399. dic.Add(810, 1031);
  19400. dic.Add(811, 1032);
  19401. dic.Add(812, 1033);
  19402. foreach (var item in list_visa)
  19403. {
  19404. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19405. temp.Coefficient = item.coefficient;
  19406. DateTime dtCrt;
  19407. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19408. if (b1)
  19409. {
  19410. temp.CreateTime = dtCrt;
  19411. }
  19412. else
  19413. {
  19414. temp.CreateTime = DateTime.Now;
  19415. }
  19416. temp.CreateUserId = item.Operators;
  19417. temp.DeleteTime = "";
  19418. temp.DeleteUserId = 0;
  19419. temp.DiId = int.Parse(item.DIID);
  19420. temp.FilePath = item.FilePath;
  19421. temp.IsDel = item.IsDel;
  19422. temp.Price = item.Price;
  19423. temp.PriceCount = 1;
  19424. temp.PriceCurrency = item.Currency;
  19425. int detailId = 0;
  19426. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19427. {
  19428. detailId = dicDetail[item.PriceTypeDetail];
  19429. }
  19430. temp.PriceDetailType = detailId;
  19431. temp.PriceDt = DateTime.Now;
  19432. temp.PriceName = item.PriceName;
  19433. temp.PriceSum = item.Price;
  19434. int tid = 0;
  19435. if (dic.ContainsKey(item.PriceType))
  19436. {
  19437. tid = dic[item.PriceType];
  19438. }
  19439. temp.PriceType = tid;
  19440. temp.Remark = item.Remark;
  19441. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19442. }
  19443. return Ok(JsonView(true, "操作成功!"));
  19444. }
  19445. [HttpPost]
  19446. public IActionResult TimeTest()
  19447. {
  19448. var jw = JsonView(false, "error");
  19449. _sqlSugar.BeginTran();
  19450. try
  19451. {
  19452. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19453. .Select(x => new Crm_NewClientData
  19454. {
  19455. Id = x.Id,
  19456. Client = x.Client,
  19457. Contact = x.Contact,
  19458. Location = x.Location,
  19459. })
  19460. .ToList();
  19461. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19462. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19463. Stopwatch stopwatch = new Stopwatch();
  19464. // 开始计时
  19465. stopwatch.Start();
  19466. foreach (var item in clientList)
  19467. {
  19468. EncryptionProcessor.DecryptProperties(item);
  19469. }
  19470. stopwatch.Stop();
  19471. jw.Code = 200;
  19472. jw.Data = stopwatch.ElapsedMilliseconds;
  19473. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19474. }
  19475. catch (Exception ex)
  19476. {
  19477. jw.Code = 400;
  19478. jw.Msg = ex.Message;
  19479. }
  19480. return Ok(jw);
  19481. }
  19482. }
  19483. }