GroupsController.cs 1.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638
  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 Org.BouncyCastle.Crypto;
  39. using Quartz.Util;
  40. using SqlSugar.Extensions;
  41. using System.Collections;
  42. using System.Data;
  43. using System.Diagnostics;
  44. using System.Globalization;
  45. using System.IO.Compression;
  46. using System.Text.Json;
  47. using TencentCloud.Ocr.V20181119.Models;
  48. using static OASystem.API.OAMethodLib.JWTHelper;
  49. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  50. using Bookmark = Aspose.Words.Bookmark;
  51. using Cell = Aspose.Words.Tables.Cell;
  52. using Table = Aspose.Words.Tables.Table;
  53. namespace OASystem.API.Controllers
  54. {
  55. /// <summary>
  56. /// 团组相关
  57. /// </summary>
  58. //[Authorize]
  59. [Route("api/[controller]/[action]")]
  60. public class GroupsController : ControllerBase
  61. {
  62. private readonly ILogger<GroupsController> _logger;
  63. private readonly GrpScheduleRepository _grpScheduleRep;
  64. private readonly IMapper _mapper;
  65. private readonly DelegationInfoRepository _groupRepository;
  66. private readonly TaskAssignmentRepository _taskAssignmentRep;
  67. private readonly AirTicketResRepository _airTicketResRep;
  68. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  69. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  70. private readonly DelegationEnDataRepository _delegationEnDataRep;
  71. private readonly DelegationVisaRepository _delegationVisaRep;
  72. private readonly VisaPriceRepository _visaPriceRep;
  73. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  74. private readonly HotelPriceRepository _hotelPriceRep;
  75. private readonly CustomersRepository _customersRep;
  76. private readonly MessageRepository _message;
  77. private readonly SqlSugarClient _sqlSugar;
  78. private readonly TourClientListRepository _tourClientListRep;
  79. private readonly TeamRateRepository _teamRateRep;
  80. #region 成本相关
  81. private readonly CheckBoxsRepository _checkBoxs;
  82. private readonly GroupCostRepository _GroupCostRepository;
  83. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  84. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  85. #endregion
  86. private readonly SetDataRepository _setDataRep;
  87. private string url;
  88. private string path;
  89. private readonly EnterExitCostRepository _enterExitCostRep;
  90. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  91. private readonly UsersRepository _usersRep;
  92. private readonly IJuHeApiService _juHeApi;
  93. private readonly InvertedListRepository _invertedListRep;
  94. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  95. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  96. private readonly ThreeCodeRepository _threeCodeRepository;
  97. private readonly HotelInquiryRepository _hotelInquiryRep;
  98. private readonly FeeAuditRepository _feeAuditRep;
  99. private readonly VisaCommissionRepository _visaCommissionRep;
  100. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  101. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  102. private readonly List<CurrencyInfo> _currencyInit;
  103. private readonly List<int> _portTypeData;
  104. private readonly TableOperationRecordRepository _tableorRep;
  105. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  106. private readonly RestaurantRepository _restaurantRep;
  107. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  108. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  109. /// <summary>
  110. /// 构造函数
  111. /// </summary>
  112. /// <param name="logger"></param>
  113. /// <param name="mapper"></param>
  114. /// <param name="hubContext"></param>
  115. /// <param name="sqlSugar"></param>
  116. /// <param name="grpScheduleRep"></param>
  117. /// <param name="groupRepository"></param>
  118. /// <param name="taskAssignmentRep"></param>
  119. /// <param name="airTicketResRep"></param>
  120. /// <param name="decreasePaymentsRep"></param>
  121. /// <param name="InvitationOfficialActivitiesRep"></param>
  122. /// <param name="delegationEnDataRep"></param>
  123. /// <param name="enterExitCostRep"></param>
  124. /// <param name="delegationVisaRep"></param>
  125. /// <param name="message"></param>
  126. /// <param name="visaPriceRep"></param>
  127. /// <param name="carTouristGuideGroundRep"></param>
  128. /// <param name="checkBoxs"></param>
  129. /// <param name="GroupCostRepository"></param>
  130. /// <param name="CostTypeHotelNumberRepository"></param>
  131. /// <param name="GroupCostParameterRepository"></param>
  132. /// <param name="hotelPriceRep"></param>
  133. /// <param name="customersRep"></param>
  134. /// <param name="setDataRep"></param>
  135. /// <param name="tourClientListRep"></param>
  136. /// <param name="teamRateRep"></param>
  137. /// <param name="usersRep"></param>
  138. /// <param name="juHeApi"></param>
  139. /// <param name="invertedListRep"></param>
  140. /// <param name="visaFeeInfoRep"></param>
  141. /// <param name="ticketBlackCodeRep"></param>
  142. /// <param name="hotelInquiryRep"></param>
  143. /// <param name="threeCodeRepository"></param>
  144. /// <param name="feeAuditRep"></param>
  145. /// <param name="visaCommissionRep"></param>
  146. /// <param name="ffrRep"></param>
  147. /// <param name="opinionaireRep"></param>
  148. /// <param name="tableorRep"></param>
  149. /// <param name="enterExitCostDraftRep"></param>
  150. /// <param name="restaurantRep"></param>
  151. /// <param name="enterExitCostQuoteRep"></param>
  152. public GroupsController(
  153. ILogger<GroupsController> logger,
  154. IMapper mapper,
  155. IHubContext<ChatHub, IChatClient> hubContext,
  156. SqlSugarClient sqlSugar,
  157. GrpScheduleRepository grpScheduleRep,
  158. DelegationInfoRepository groupRepository,
  159. TaskAssignmentRepository taskAssignmentRep,
  160. AirTicketResRepository airTicketResRep,
  161. DecreasePaymentsRepository decreasePaymentsRep,
  162. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  163. DelegationEnDataRepository delegationEnDataRep,
  164. EnterExitCostRepository enterExitCostRep,
  165. DelegationVisaRepository delegationVisaRep,
  166. MessageRepository message,
  167. VisaPriceRepository visaPriceRep,
  168. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  169. CheckBoxsRepository checkBoxs,
  170. GroupCostRepository GroupCostRepository,
  171. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  172. GroupCostParameterRepository GroupCostParameterRepository,
  173. HotelPriceRepository hotelPriceRep,
  174. CustomersRepository customersRep,
  175. SetDataRepository setDataRep,
  176. TourClientListRepository tourClientListRep,
  177. TeamRateRepository teamRateRep,
  178. UsersRepository usersRep, IJuHeApiService juHeApi,
  179. InvertedListRepository invertedListRep,
  180. VisaFeeInfoRepository visaFeeInfoRep,
  181. TicketBlackCodeRepository ticketBlackCodeRep,
  182. HotelInquiryRepository hotelInquiryRep,
  183. ThreeCodeRepository threeCodeRepository,
  184. FeeAuditRepository feeAuditRep,
  185. VisaCommissionRepository visaCommissionRep,
  186. ForeignReceivablesRepository ffrRep,
  187. OpinionaireRepository opinionaireRep,
  188. TableOperationRecordRepository tableorRep,
  189. EnterExitCostDraftRepository enterExitCostDraftRep,
  190. RestaurantRepository restaurantRep,
  191. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  192. GroupOrderPreInfoRepository grpOrderPreInfoRep
  193. )
  194. {
  195. _logger = logger;
  196. _mapper = mapper;
  197. _grpScheduleRep = grpScheduleRep;
  198. _groupRepository = groupRepository;
  199. _taskAssignmentRep = taskAssignmentRep;
  200. _airTicketResRep = airTicketResRep;
  201. _sqlSugar = sqlSugar;
  202. url = AppSettingsHelper.Get("ExcelBaseUrl");
  203. path = AppSettingsHelper.Get("ExcelBasePath");
  204. if (!System.IO.Directory.Exists(path))
  205. {
  206. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  207. }
  208. _decreasePaymentsRep = decreasePaymentsRep;
  209. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  210. _delegationEnDataRep = delegationEnDataRep;
  211. _enterExitCostRep = enterExitCostRep;
  212. _delegationVisaRep = delegationVisaRep;
  213. _message = message;
  214. _visaPriceRep = visaPriceRep;
  215. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  216. _checkBoxs = checkBoxs;
  217. _GroupCostRepository = GroupCostRepository;
  218. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  219. _GroupCostParameterRepository = GroupCostParameterRepository;
  220. _hotelPriceRep = hotelPriceRep;
  221. _customersRep = customersRep;
  222. _setDataRep = setDataRep;
  223. _tourClientListRep = tourClientListRep;
  224. _teamRateRep = teamRateRep;
  225. _hubContext = hubContext;
  226. _usersRep = usersRep;
  227. _juHeApi = juHeApi;
  228. _invertedListRep = invertedListRep;
  229. _visaFeeInfoRep = visaFeeInfoRep;
  230. _ticketBlackCodeRep = ticketBlackCodeRep;
  231. _hotelInquiryRep = hotelInquiryRep;
  232. _threeCodeRepository = threeCodeRepository;
  233. _feeAuditRep = feeAuditRep;
  234. _visaCommissionRep = visaCommissionRep;
  235. _ffrRep = ffrRep;
  236. _opinionaireRep = opinionaireRep;
  237. _currencyInit = new List<CurrencyInfo>()
  238. {
  239. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  240. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  241. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  242. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  243. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  244. };
  245. _portTypeData = new List<int>() { 2, 3 };
  246. _tableorRep = tableorRep;
  247. _enterExitCostDraftRep = enterExitCostDraftRep;
  248. _restaurantRep = restaurantRep;
  249. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  250. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  251. }
  252. #region 流程管控
  253. /// <summary>
  254. /// 获取团组流程管控信息
  255. /// </summary>
  256. /// <param name="_jsonDto"></param>
  257. /// <returns></returns>
  258. [HttpPost]
  259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  260. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  261. {
  262. if (string.IsNullOrEmpty(_jsonDto.Paras))
  263. {
  264. return Ok(JsonView(false, "参数为空"));
  265. }
  266. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  267. if (_ScheduleDto != null)
  268. {
  269. if (_ScheduleDto.SearchType == 2)//获取列表
  270. {
  271. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  272. return Ok(JsonView(_grpScheduleViewList));
  273. }
  274. else//获取对象
  275. {
  276. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  277. if (_grpScheduleView != null)
  278. {
  279. return Ok(JsonView(_grpScheduleView));
  280. }
  281. }
  282. }
  283. else
  284. {
  285. return Ok(JsonView(false, "参数反序列化失败"));
  286. }
  287. return Ok(JsonView(false, "暂无数据!"));
  288. }
  289. /// <summary>
  290. /// 修改团组流程管控详细表数据
  291. /// </summary>
  292. /// <param name="dto"></param>
  293. /// <returns></returns>
  294. [HttpPost]
  295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  296. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  297. {
  298. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  299. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  300. .SetColumns(it => it.Duty == _detail.Duty)
  301. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  302. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  303. .SetColumns(it => it.JobContent == _detail.JobContent)
  304. .SetColumns(it => it.Remark == _detail.Remark)
  305. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  306. .Where(s => s.Id == dto.Id)
  307. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  308. .ExecuteCommandAsync();
  309. if (result > 0)
  310. {
  311. return Ok(JsonView(true, "保存成功!"));
  312. }
  313. return Ok(JsonView(false, "保存失败!"));
  314. }
  315. /// <summary>
  316. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  317. /// </summary>
  318. /// <param name="dto"></param>
  319. /// <returns></returns>
  320. [HttpPost]
  321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  322. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  323. {
  324. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  325. _detail.IsDel = 1;
  326. _detail.DeleteUserId = dto.Duty;
  327. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  328. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  329. .SetColumns(it => it.IsDel == _detail.IsDel)
  330. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  331. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  332. .Where(it => it.Id == dto.Id)
  333. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  334. //.WhereColumns(s => s.Id == dto.Id)
  335. .ExecuteCommandAsync();
  336. if (result > 0)
  337. {
  338. return Ok(JsonView(true, "删除成功!"));
  339. }
  340. return Ok(JsonView(false, "删除失败!"));
  341. }
  342. /// <summary>
  343. /// 增加团组流程管控详细表数据
  344. /// </summary>
  345. /// <param name="dto"></param>
  346. /// <returns></returns>
  347. [HttpPost]
  348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  349. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  350. {
  351. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  352. if (DateTime.Now < _detail.ExpectBeginDt)
  353. {
  354. _detail.StepStatus = 0;
  355. }
  356. else
  357. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  358. _detail.StepStatus = 1;
  359. }
  360. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  361. if (result > 0)
  362. {
  363. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  364. return Ok(JsonView(true, "添加成功!", _result));
  365. }
  366. return Ok(JsonView(false, "添加失败!"));
  367. }
  368. #endregion
  369. #region 团组前期信息
  370. /// <summary>
  371. /// 团组前期信息 Init
  372. /// </summary>
  373. /// <returns></returns>
  374. [HttpGet]
  375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  376. public async Task<IActionResult> GroupOrderPreInfo()
  377. {
  378. return Ok(await _grpOrderPreInfoRep.DataInit());
  379. }
  380. /// <summary>
  381. /// 国家数据源
  382. /// </summary>
  383. /// <returns></returns>
  384. [HttpGet]
  385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  386. public async Task<IActionResult> CountryInit()
  387. {
  388. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  389. return Ok(JsonView(countrys));
  390. }
  391. /// <summary>
  392. /// 城市数据源
  393. /// </summary>
  394. /// <returns></returns>
  395. [HttpGet("{countryLabel}")]
  396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  397. public async Task<IActionResult> CityByCountry(string countryLabel)
  398. {
  399. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  400. var citys = Array.Empty<string?>();
  401. if (countryList.Any())
  402. {
  403. var cityDatas = await _sqlSugar
  404. .Queryable<Grp_NationalTravelFee>()
  405. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City) && !x.City.Contains("城市"))
  406. .Select(x => new { x.Country,x.City })
  407. .OrderBy(x => x.Country)
  408. .ToArrayAsync();
  409. citys = cityDatas.Select(x => x.City).ToArray();
  410. }
  411. return Ok(JsonView(citys));
  412. }
  413. /// <summary>
  414. /// 团组前期信息 Info
  415. /// </summary>
  416. /// <param name="id">Id</param>
  417. /// <param name="tempId">Id</param>
  418. /// <returns></returns>
  419. [HttpGet("{id}/{tempId}")]
  420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  421. public async Task<IActionResult> GroupOrderPreInfo(int id,int tempId = 1404)
  422. {
  423. return Ok(await _grpOrderPreInfoRep.InfoAsync(id, tempId));
  424. }
  425. /// <summary>
  426. /// 团组前期信息 Save
  427. /// </summary>
  428. /// <param name="dto">Id</param>
  429. /// <returns></returns>
  430. [HttpPost]
  431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  432. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  433. {
  434. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  435. }
  436. #endregion
  437. #region 团组基本信息
  438. /// <summary>
  439. /// 接团信息列表
  440. /// </summary>
  441. /// <param name="dto">团组列表请求dto</param>
  442. /// <returns></returns>
  443. [HttpPost]
  444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  445. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  446. {
  447. var groupData = await _groupRepository.GetGroupList(dto);
  448. if (groupData.Code != 0)
  449. {
  450. return Ok(JsonView(false, groupData.Msg));
  451. }
  452. return Ok(JsonView(groupData.Data));
  453. }
  454. /// <summary>
  455. /// 分页查询团组列表
  456. /// </summary>
  457. /// <param name="dto"></param>
  458. /// <returns></returns>
  459. [HttpPost]
  460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  461. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  462. {
  463. var watch = new Stopwatch();
  464. watch.Start();
  465. RefAsync<int> total = 0;
  466. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  467. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  468. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  469. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  470. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  471. .Distinct()
  472. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  473. watch.Stop();
  474. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  475. }
  476. /// <summary>
  477. /// 接团信息列表 Page Init
  478. /// </summary>
  479. /// <returns></returns>
  480. [HttpPost]
  481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  482. public async Task<IActionResult> PostGroupPageListInit()
  483. {
  484. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  485. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  486. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  487. var _view = new
  488. {
  489. depData = depDatas,
  490. rankData = rankDatas
  491. };
  492. return Ok(JsonView(true, "查询成功!", _view));
  493. }
  494. /// <summary>
  495. /// 接团信息列表 Page
  496. /// </summary>
  497. /// <param name="dto">团组列表请求dto</param>
  498. /// <returns></returns>
  499. [HttpPost]
  500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  501. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  502. {
  503. #region 参数验证
  504. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  505. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  506. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  507. #region 页面操作权限验证
  508. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  509. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  510. #endregion
  511. #endregion
  512. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  513. {
  514. string sqlWhere = string.Empty;
  515. if (dto.IsSure == 0) //未完成
  516. {
  517. sqlWhere += string.Format(@" And IsSure = 0");
  518. }
  519. else if (dto.IsSure == 1) //已完成
  520. {
  521. sqlWhere += string.Format(@" And IsSure = 1");
  522. }
  523. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  524. {
  525. string tj = dto.SearchCriteria;
  526. 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}%')",
  527. tj, tj, tj, tj, tj);
  528. }
  529. if (int.TryParse(dto.Rank, out int rankId))
  530. {
  531. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  532. }
  533. string sqlWhere1 = string.Empty;
  534. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  535. {
  536. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  537. }
  538. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  539. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  540. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  541. JietuanOperator,IsSure,CreateTime,IsBid
  542. From (
  543. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  544. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  545. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  546. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  547. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  548. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  549. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  550. From Grp_DelegationInfo gdi
  551. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  552. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  553. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  554. Where gdi.IsDel = 0 {0}
  555. ) temp {1}", sqlWhere, sqlWhere1);
  556. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  557. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  558. var _view = new
  559. {
  560. PageFuncAuth = pageFunAuthView,
  561. Data = _DelegationList
  562. };
  563. return Ok(JsonView(true, "查询成功!", _view, total));
  564. }
  565. else
  566. {
  567. return Ok(JsonView(false, "查询失败"));
  568. }
  569. }
  570. /// <summary>
  571. /// 团组列表
  572. /// </summary>
  573. /// <returns></returns>
  574. [HttpPost]
  575. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  576. {
  577. #region 参数验证
  578. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  579. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  580. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  581. #region 页面操作权限验证
  582. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  583. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  584. #endregion
  585. #endregion
  586. if (dto.PortType != 1 && dto.PortType != 2)
  587. {
  588. return Ok(JsonView(false, "查询失败!"));
  589. }
  590. string orderbyStr = "order by gdi.CreateTime Desc";
  591. string sqlWhere = string.Empty;
  592. if (dto.IsSure == 0) //未完成
  593. {
  594. sqlWhere += string.Format(@" And IsSure = 0");
  595. }
  596. else if (dto.IsSure == 1) //已完成
  597. {
  598. sqlWhere += string.Format(@" And IsSure = 1");
  599. }
  600. //团组类型
  601. if (dto.TeamDid > 0)
  602. {
  603. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  604. }
  605. //团组名称
  606. if (!string.IsNullOrEmpty(dto.TeamName))
  607. {
  608. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  609. }
  610. //客户名称
  611. if (!string.IsNullOrEmpty(dto.ClientName))
  612. {
  613. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  614. }
  615. //客户单位
  616. if (!string.IsNullOrEmpty(dto.ClientUnit))
  617. {
  618. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  619. }
  620. //出访时间
  621. if (!string.IsNullOrEmpty(dto.visitDataTime))
  622. {
  623. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  624. orderbyStr = "order by gdi.VisitDate";
  625. }
  626. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  627. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  628. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  629. JietuanOperator,IsSure,CreateTime
  630. From (
  631. Select row_number() over({0}) as Row_Number,
  632. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  633. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  634. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  635. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  636. From Grp_DelegationInfo gdi
  637. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  638. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  639. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  640. Where gdi.IsDel = 0 {1}
  641. ) temp ", orderbyStr, sqlWhere);
  642. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  643. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  644. #region 处理所属部门
  645. /*
  646. * 1.sq 和 gyy 等显示 市场部
  647. * 2.王鸽和主管及张总还有管理员号统一国交部
  648. * 2-1. 4 管理员 ,21 张海麟
  649. */
  650. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  651. List<int> userIds1 = new List<int>() { 4, 21 };
  652. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  653. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  654. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  655. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  656. .ToList();
  657. foreach (var item in _DelegationList)
  658. {
  659. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  660. }
  661. #endregion
  662. var _view = new
  663. {
  664. PageFuncAuth = pageFunAuthView,
  665. Data = _DelegationList
  666. };
  667. return Ok(JsonView(true, "查询成功!", _view, total));
  668. }
  669. /// <summary>
  670. /// 接团信息详情
  671. /// </summary>
  672. /// <param name="dto">团组info请求dto</param>
  673. /// <returns></returns>
  674. [HttpPost]
  675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  676. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  677. {
  678. var groupData = await _groupRepository.GetGroupInfo(dto);
  679. if (groupData.Code != 0)
  680. {
  681. return Ok(JsonView(false, groupData.Msg));
  682. }
  683. return Ok(JsonView(groupData.Data));
  684. }
  685. /// <summary>
  686. /// 接团信息 编辑添加
  687. /// 基础信息数据源
  688. /// </summary>
  689. /// <param name="dto"></param>
  690. /// <returns></returns>
  691. [HttpPost]
  692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  693. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  694. {
  695. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  696. if (groupData.Code != 0)
  697. {
  698. return Ok(JsonView(false, groupData.Msg));
  699. }
  700. return Ok(JsonView(groupData.Data));
  701. }
  702. /// <summary>
  703. /// 接团信息 操作(增改)
  704. /// </summary>
  705. /// <param name="dto"></param>
  706. /// <returns></returns>
  707. [HttpPost]
  708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  709. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  710. {
  711. // 创建 Stopwatch 实例
  712. Stopwatch stopwatch = Stopwatch.StartNew();
  713. decimal ffrPrice = 0.00M;
  714. DateTime? visitDt = null;
  715. if (dto.Status == 2)
  716. {
  717. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  718. if (groupInfo != null)
  719. {
  720. ffrPrice = groupInfo.PaymentMoney;
  721. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  722. }
  723. }
  724. var groupData = await _groupRepository.GroupOperation(dto);
  725. if (groupData.Code != 0)
  726. {
  727. return Ok(JsonView(false, groupData.Msg));
  728. }
  729. int diId = 0;
  730. try
  731. {
  732. //添加时 默认加入团组汇率
  733. if (dto.Status == 1) //添加
  734. {
  735. diId = groupData.Data;
  736. //添加默认币种
  737. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  738. //默认分配权限
  739. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  740. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  741. var _managerIds = new List<int>() { 22, 32, 21 };
  742. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  743. if (userIds.Count > 0)
  744. {
  745. userIds.Add(208);
  746. //创建团组管控
  747. GroupStepForDelegation.CreateWorkStep(diId);
  748. //发送消息
  749. string groupName = dto.TeamName;
  750. string createGroupUser = string.Empty;
  751. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  752. if (userInfo != null) createGroupUser = userInfo.CnName;
  753. string title = $"系统通知";
  754. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  755. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  756. }
  757. //默认创建倒推表
  758. await _invertedListRep._Create(dto.UserId, diId);
  759. }
  760. else if (dto.Status == 2)
  761. {
  762. diId = dto.Id;
  763. }
  764. #region 签证人员团组时间通知
  765. #region 计算出访起止时间
  766. var startTime = new DateTime();
  767. var endTime = new DateTime();
  768. if (DateTime.TryParse(dto.VisitDate, out startTime))
  769. {
  770. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  771. }
  772. #endregion
  773. #endregion
  774. #region 团组操作默认添加/修改收款账单
  775. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  776. {
  777. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  778. .Where(x => x.IsDel == 0 &&
  779. x.Diid == diId &&
  780. x.Remark.Equals("预付款")
  781. )
  782. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  783. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  784. .FirstAsync();
  785. ffrInfo = new Fin_ForeignReceivables()
  786. {
  787. Diid = diId,
  788. PriceName = dto.ClientUnit,
  789. Price = dto.PaymentMoney,
  790. Count = 1,
  791. Unit = $"元",
  792. ItemSumPrice = dto.PaymentMoney,
  793. Rate = 1.0000M,
  794. Currency = 836,
  795. AddingWay = 0,
  796. CreateUserId = dto.UserId,
  797. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  798. Remark = $"预付款"
  799. };
  800. if (ffrInfo == null) //Add
  801. {
  802. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  803. }
  804. else //修改
  805. {
  806. await _sqlSugar.Updateable(ffrInfo)
  807. .UpdateColumns(x => new
  808. {
  809. x.PriceName,
  810. x.Price,
  811. x.ItemSumPrice,
  812. x.CreateTime,
  813. x.CreateUserId
  814. })
  815. .WhereColumns(x => x.Id)
  816. .ExecuteCommandAsync();
  817. }
  818. }
  819. #endregion
  820. if (diId > 0)
  821. {
  822. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  823. }
  824. // 停止计时
  825. stopwatch.Stop();
  826. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  827. }
  828. catch (Exception ex)
  829. {
  830. // 停止计时
  831. stopwatch.Stop();
  832. Logs("[response]" + JsonConvert.SerializeObject(dto));
  833. Logs(ex.Message);
  834. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  835. }
  836. // 停止计时
  837. stopwatch.Stop();
  838. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  839. }
  840. /// <summary>
  841. /// 接团流程操作(增改)
  842. /// 安卓端使用 建团时添加客户名单
  843. /// </summary>
  844. /// <param name="dto"></param>
  845. /// <returns></returns>
  846. [HttpPost]
  847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  848. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  849. {
  850. #region 参数验证
  851. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  852. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  853. #region 页面操作权限验证
  854. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  855. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  856. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  857. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  858. #endregion
  859. #endregion
  860. try
  861. {
  862. //_sqlSugar.BeginTran();
  863. decimal ffrPrice = 0.00M;
  864. DateTime? visitDt = null;
  865. if (dto.Status == 2)
  866. {
  867. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  868. if (groupInfo != null)
  869. {
  870. ffrPrice = groupInfo.PaymentMoney;
  871. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  872. }
  873. }
  874. var _dto = new GroupOperationDto();
  875. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  876. var groupData = await _groupRepository.GroupOperation(_dto);
  877. if (groupData.Code != 0)
  878. {
  879. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  880. }
  881. int diId = 0;
  882. //添加时 默认加入团组汇率
  883. if (dto.Status == 1) //添加
  884. {
  885. diId = groupData.Data;
  886. //添加默认币种
  887. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  888. //默认分配权限
  889. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  890. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  891. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  892. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  893. if (userIds.Count > 0)
  894. {
  895. userIds.Add(208);
  896. //创建团组管控
  897. GroupStepForDelegation.CreateWorkStep(diId);
  898. //发送消息
  899. string groupName = dto.TeamName;
  900. string createGroupUser = string.Empty;
  901. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  902. if (userInfo != null) createGroupUser = userInfo.CnName;
  903. string title = $"系统通知";
  904. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  905. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  906. }
  907. #region 应用推送
  908. try
  909. {
  910. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  911. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  912. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  913. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  914. {
  915. List<string> userList = new List<string>() { users.QiyeChatUserId };
  916. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  917. }
  918. }
  919. catch (Exception ex)
  920. {
  921. }
  922. #endregion
  923. //默认创建倒推表
  924. await _invertedListRep._Create(dto.UserId, diId);
  925. }
  926. if (dto.Status == 2)
  927. {
  928. diId = dto.Id;
  929. if (diId == 0)
  930. {
  931. //_sqlSugar.RollbackTran();
  932. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  933. }
  934. }
  935. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  936. if (viewData.Code != 0)
  937. {
  938. //_sqlSugar.RollbackTran();
  939. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  940. }
  941. #region 团组操作默认添加/修改收款账单
  942. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  943. {
  944. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  945. .Where(x => x.IsDel == 0 &&
  946. x.Diid == diId &&
  947. x.Remark.Equals("预付款")
  948. )
  949. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  950. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  951. .FirstAsync();
  952. ffrInfo = new Fin_ForeignReceivables()
  953. {
  954. Diid = diId,
  955. PriceName = dto.ClientUnit,
  956. Price = dto.PaymentMoney,
  957. Count = 1,
  958. Unit = $"元",
  959. ItemSumPrice = dto.PaymentMoney,
  960. Rate = 1.0000M,
  961. Currency = 836,
  962. AddingWay = 0,
  963. CreateUserId = dto.UserId,
  964. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  965. Remark = $"预付款"
  966. };
  967. if (ffrInfo == null) //Add
  968. {
  969. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  970. }
  971. else //修改
  972. {
  973. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  974. .UpdateColumns(x => new
  975. {
  976. x.PriceName,
  977. x.Price,
  978. x.ItemSumPrice,
  979. x.CreateTime,
  980. x.CreateUserId
  981. })
  982. .WhereColumns(x => x.Id)
  983. .ExecuteCommandAsync();
  984. }
  985. }
  986. #endregion
  987. #region 签证人员团组时间通知
  988. #region 计算出访起止时间
  989. var startTime = new DateTime();
  990. var endTime = new DateTime();
  991. if (DateTime.TryParse(dto.VisitDate, out startTime))
  992. {
  993. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  994. }
  995. #endregion
  996. if (diId > 0)
  997. {
  998. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  999. }
  1000. #endregion
  1001. //_sqlSugar.CommitTran();
  1002. return Ok(JsonView(true, "添加成功"));
  1003. }
  1004. catch (Exception ex)
  1005. {
  1006. _sqlSugar.RollbackTran();
  1007. return Ok(JsonView(false, ex.Message));
  1008. }
  1009. }
  1010. /// <summary>
  1011. /// 接团流程操作(增改)
  1012. /// 安卓端使用 建团时添加客户名单
  1013. /// </summary>
  1014. /// <param name="dto"></param>
  1015. /// <returns></returns>
  1016. [HttpPost]
  1017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1018. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1019. {
  1020. #region 参数验证
  1021. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1022. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1023. #region 页面操作权限验证
  1024. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1025. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1026. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1027. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1028. #endregion
  1029. #endregion
  1030. _sqlSugar.BeginTran();
  1031. decimal ffrPrice = 0.00M;
  1032. DateTime? visitDt = null;
  1033. if (dto.Status == 2)
  1034. {
  1035. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1036. if (groupInfo != null)
  1037. {
  1038. ffrPrice = groupInfo.PaymentMoney;
  1039. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1040. }
  1041. }
  1042. var _dto = new GroupOperationDto();
  1043. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1044. var groupData = await _groupRepository.GroupOperation(_dto);
  1045. if (groupData.Code != 0)
  1046. {
  1047. _sqlSugar.RollbackTran();
  1048. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1049. }
  1050. try
  1051. {
  1052. int diId = 0;
  1053. //添加时 默认加入团组汇率
  1054. if (dto.Status == 1) //添加
  1055. {
  1056. diId = groupData.Data;
  1057. //添加默认币种
  1058. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1059. //默认分配权限
  1060. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1061. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1062. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1063. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1064. if (userIds.Count > 0)
  1065. {
  1066. userIds.Add(208);
  1067. //创建团组管控
  1068. GroupStepForDelegation.CreateWorkStep(diId);
  1069. //发送消息
  1070. string groupName = dto.TeamName;
  1071. string createGroupUser = string.Empty;
  1072. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1073. if (userInfo != null) createGroupUser = userInfo.CnName;
  1074. string title = $"系统通知";
  1075. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1076. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1077. }
  1078. #region 应用推送
  1079. try
  1080. {
  1081. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1082. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1083. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1084. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1085. {
  1086. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1087. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1088. }
  1089. }
  1090. catch (Exception ex)
  1091. {
  1092. _sqlSugar.CommitTran();
  1093. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1094. }
  1095. #endregion
  1096. //默认创建倒推表
  1097. await _invertedListRep._Create(dto.UserId, diId);
  1098. }
  1099. else if (dto.Status == 2)
  1100. {
  1101. diId = dto.Id;
  1102. if (diId == 0)
  1103. {
  1104. _sqlSugar.RollbackTran();
  1105. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1106. }
  1107. }
  1108. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1109. if (viewData.Code != 0)
  1110. {
  1111. _sqlSugar.RollbackTran();
  1112. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1113. }
  1114. #region 团组操作默认添加/修改收款账单
  1115. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1116. {
  1117. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1118. .Where(x => x.IsDel == 0 &&
  1119. x.Diid == diId &&
  1120. x.Remark.Equals("预付款")
  1121. )
  1122. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1123. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1124. .FirstAsync();
  1125. ffrInfo = new Fin_ForeignReceivables()
  1126. {
  1127. Diid = diId,
  1128. PriceName = dto.ClientUnit,
  1129. Price = dto.PaymentMoney,
  1130. Count = 1,
  1131. Unit = $"元",
  1132. ItemSumPrice = dto.PaymentMoney,
  1133. Rate = 1.0000M,
  1134. Currency = 836,
  1135. AddingWay = 0,
  1136. CreateUserId = dto.UserId,
  1137. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1138. Remark = $"预付款"
  1139. };
  1140. if (ffrInfo == null) //Add
  1141. {
  1142. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1143. }
  1144. else //修改
  1145. {
  1146. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1147. .UpdateColumns(x => new
  1148. {
  1149. x.PriceName,
  1150. x.Price,
  1151. x.ItemSumPrice,
  1152. x.CreateTime,
  1153. x.CreateUserId
  1154. })
  1155. .WhereColumns(x => x.Id)
  1156. .ExecuteCommandAsync();
  1157. }
  1158. }
  1159. #endregion
  1160. #region 签证人员团组时间通知
  1161. #region 计算出访起止时间
  1162. var startTime = new DateTime();
  1163. var endTime = new DateTime();
  1164. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1165. {
  1166. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1167. }
  1168. #endregion
  1169. if (diId > 0)
  1170. {
  1171. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1172. }
  1173. #endregion
  1174. _sqlSugar.CommitTran();
  1175. return Ok(JsonView(true));
  1176. }
  1177. catch (Exception ex)
  1178. {
  1179. _sqlSugar.RollbackTran();
  1180. return Ok(JsonView(false, ex.Message));
  1181. }
  1182. }
  1183. /// <summary>
  1184. /// 接团信息 操作(删除)
  1185. /// </summary>
  1186. /// <param name="dto"></param>
  1187. /// <returns></returns>
  1188. [HttpPost]
  1189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1190. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1191. {
  1192. var diId = dto.Id;
  1193. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1194. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1195. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1196. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1197. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1198. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1199. #endregion
  1200. var groupData = await _groupRepository.GroupDel(dto);
  1201. if (groupData.Code != 0)
  1202. {
  1203. return Ok(JsonView(false, groupData.Msg));
  1204. }
  1205. return Ok(JsonView(true));
  1206. }
  1207. /// <summary>
  1208. /// 获取团组销售报价号
  1209. /// 团组添加时 使用
  1210. /// </summary>
  1211. /// <returns></returns>
  1212. [HttpPost]
  1213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1214. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1215. {
  1216. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1217. if (groupData.Code != 0)
  1218. {
  1219. return Ok(JsonView(false, groupData.Msg));
  1220. }
  1221. object salesQuoteNo = new
  1222. {
  1223. SalesQuoteNo = groupData.Data
  1224. };
  1225. return Ok(JsonView(salesQuoteNo));
  1226. }
  1227. /// <summary>
  1228. /// 设置确认出团
  1229. /// </summary>
  1230. /// <param name="dto"></param>
  1231. /// <returns></returns>
  1232. [HttpPost]
  1233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1234. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1235. {
  1236. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1237. if (groupData.Code != 0)
  1238. {
  1239. return Ok(JsonView(false, groupData.Msg));
  1240. }
  1241. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1242. #region OA消息推送
  1243. try
  1244. {
  1245. string groupName = groupInfo.TeamName;
  1246. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1247. string title = $"系统通知";
  1248. string content = $"团组[{groupName}]已确认出团!";
  1249. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1250. }
  1251. catch (Exception ex)
  1252. {
  1253. }
  1254. #endregion
  1255. #region 应用推送
  1256. try
  1257. {
  1258. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1259. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1260. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1261. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1262. {
  1263. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1264. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1265. }
  1266. }
  1267. catch (Exception ex)
  1268. {
  1269. }
  1270. #endregion
  1271. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1272. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1273. }
  1274. /// <summary>
  1275. /// 获取团组名称data And 签证国别Data
  1276. /// </summary>
  1277. /// <param name="dto"></param>
  1278. /// <returns></returns>
  1279. [HttpPost]
  1280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1281. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1282. {
  1283. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1284. if (groupData.Code != 0)
  1285. {
  1286. return Ok(JsonView(false, groupData.Msg));
  1287. }
  1288. return Ok(JsonView(groupData.Data));
  1289. }
  1290. /// <summary>
  1291. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1292. /// </summary>
  1293. /// <returns></returns>
  1294. [HttpPost]
  1295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1296. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1297. {
  1298. try
  1299. {
  1300. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1301. if (groupData.Code != 0)
  1302. {
  1303. return Ok(JsonView(false, groupData.Msg));
  1304. }
  1305. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1306. }
  1307. catch (Exception ex)
  1308. {
  1309. return Ok(JsonView(false, "程序错误!"));
  1310. throw;
  1311. }
  1312. }
  1313. /// <summary>
  1314. /// 团组清单 Excel
  1315. /// </summary>
  1316. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1317. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1318. /// <returns></returns>
  1319. [HttpGet]
  1320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1321. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1322. {
  1323. DateTime _beginDt, _endDt;
  1324. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1325. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1326. if (!beginBool && !endBool)
  1327. {
  1328. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1329. }
  1330. string sql = string.Format(@"
  1331. SELECT
  1332. ROW_NUMBER,
  1333. Id,
  1334. SalesQuoteNo,
  1335. TourCode,
  1336. TeamTypeId,
  1337. TeamType,
  1338. TeamLevId,
  1339. TeamLev,
  1340. TeamName,
  1341. ClientName,
  1342. ClientUnit,
  1343. VisitDate,
  1344. VisitDays,
  1345. VisitPNumber,
  1346. JietuanOperatorId,
  1347. JietuanOperator,
  1348. IsSure,
  1349. CreateUserName,
  1350. IsBid
  1351. FROM
  1352. (
  1353. SELECT
  1354. ROW_NUMBER() OVER(
  1355. ORDER BY
  1356. gdi.CreateTime Desc
  1357. ) AS ROW_NUMBER,
  1358. gdi.Id,
  1359. SalesQuoteNo,
  1360. TourCode,
  1361. ssd.Id TeamTypeId,
  1362. ssd.Name TeamType,
  1363. ssd1.Id TeamLevId,
  1364. ssd1.Name TeamLev,
  1365. TeamName,
  1366. ClientName,
  1367. ClientUnit,
  1368. VisitDate,
  1369. VisitDays,
  1370. VisitPNumber,
  1371. JietuanOperator JietuanOperatorId,
  1372. su.CnName JietuanOperator,
  1373. IsSure,
  1374. gdi.CreateTime,
  1375. su1.CnName As CreateUserName,
  1376. gdi.IsBid
  1377. FROM
  1378. Grp_DelegationInfo gdi
  1379. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1380. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1381. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1382. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1383. WHERE
  1384. gdi.IsDel = 0
  1385. AND gdi.IsBid = 0
  1386. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1387. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1388. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1389. #region 处理所属部门
  1390. /*
  1391. * 1.sq 和 gyy 等显示 市场部
  1392. * 2.王鸽和主管及张总还有管理员号统一国交部
  1393. * 2-1. 4 管理员 ,21 张海麟
  1394. */
  1395. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1396. List<int> userIds1 = new List<int>() { 4, 21 };
  1397. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1398. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1399. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1400. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1401. .ToListAsync();
  1402. var droupIds = groupList.Select(it => it.Id).ToList();
  1403. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1404. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1405. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1406. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1407. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1408. {
  1409. DiId = tcl.DiId,
  1410. LastName = dc.LastName,
  1411. FirstName = dc.FirstName,
  1412. Sex = dc.Sex,
  1413. Birthday = dc.BirthDay,
  1414. Company = cc.CompanyFullName,
  1415. Job = dc.Job,
  1416. CreateTime = tcl.CreateTime,
  1417. })
  1418. .ToList();
  1419. foreach (var item in groupList)
  1420. {
  1421. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1422. string groupFirstName = "";
  1423. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1424. if (currDatas.Any())
  1425. {
  1426. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1427. }
  1428. item.GroupFirst = groupFirstName;
  1429. }
  1430. #endregion
  1431. #region Excel
  1432. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1433. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1434. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1435. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1436. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1437. //载入模板
  1438. WorkbookDesigner designer = new WorkbookDesigner();
  1439. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1440. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1441. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1442. dt.TableName = "GroupList";
  1443. designer.SetDataSource(dt);
  1444. designer.Process();
  1445. if (!Directory.Exists(savePath))
  1446. {
  1447. Directory.CreateDirectory(savePath);
  1448. }
  1449. string serverPath = $"{savePath}{fileName}";
  1450. designer.Workbook.Save(serverPath);
  1451. string rst = $"{servicePath}{ftpPath}{fileName}";
  1452. #endregion
  1453. return Ok(JsonView(true, "操作成功!", rst));
  1454. }
  1455. #endregion
  1456. #region 团组&签证
  1457. /// <summary>
  1458. /// 根据团组Id获取签证客户信息List
  1459. /// </summary>
  1460. /// <param name="dto">请求dto</param>
  1461. /// <returns></returns>
  1462. [HttpPost]
  1463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1464. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1465. {
  1466. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1467. if (groupData.Code != 0)
  1468. {
  1469. return Ok(JsonView(false, groupData.Msg));
  1470. }
  1471. return Ok(JsonView(groupData.Data));
  1472. }
  1473. /// <summary>
  1474. /// IOS获取团组签证拍照上传进度01(团组列表)
  1475. /// </summary>
  1476. /// <param name="dto">请求dto</param>
  1477. /// <returns></returns>
  1478. [HttpPost]
  1479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1480. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1481. {
  1482. if (dto == null)
  1483. {
  1484. return Ok(JsonView(false, "参数为空"));
  1485. }
  1486. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1487. return Ok(JsonView(visaList));
  1488. }
  1489. /// <summary>
  1490. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1491. /// </summary>
  1492. /// <returns></returns>
  1493. [HttpPost]
  1494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1495. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1496. {
  1497. if (dto == null)
  1498. {
  1499. return Ok(JsonView(false, "请求错误:"));
  1500. }
  1501. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1502. return Ok(JsonView(list));
  1503. }
  1504. /// <summary>
  1505. /// IOS获取团组签证拍照上传进度03(相册)
  1506. /// </summary>
  1507. /// <returns></returns>
  1508. [HttpPost]
  1509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1510. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1511. {
  1512. if (dto == null)
  1513. {
  1514. return Ok(JsonView(false, "请求错误:"));
  1515. }
  1516. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1517. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1518. list.ForEach(s => s.url = url);
  1519. return Ok(JsonView(list));
  1520. }
  1521. /// <summary>
  1522. /// IOS获取团组签证拍照上传进度04(图片上传)
  1523. /// </summary>
  1524. /// <param name="dto"></param>
  1525. /// <returns></returns>
  1526. [HttpPost]
  1527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1528. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1529. {
  1530. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1531. //if (!string.IsNullOrEmpty(result))
  1532. //{
  1533. //}
  1534. //else {
  1535. // return Ok(JsonView(false, "上传失败"));
  1536. //}
  1537. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1538. int sucNum = 0;
  1539. try
  1540. {
  1541. foreach (var item in dto.base64DataList)
  1542. {
  1543. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1544. string result = DecodeBase64ToImage(item, imageName);
  1545. if (!string.IsNullOrEmpty(result))
  1546. {
  1547. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1548. pic.CreateUserId = dto.CreateUserId;
  1549. pic.PicName = imageName;
  1550. pic.PicPath = result;
  1551. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1552. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1553. if (insertResult > 0)
  1554. {
  1555. sucNum++;
  1556. }
  1557. }
  1558. }
  1559. }
  1560. catch (Exception ex)
  1561. {
  1562. return Ok(JsonView(false, ex.Message));
  1563. }
  1564. string msg = string.Format(@"成功上传{0}张", sucNum);
  1565. return Ok(JsonView(true, msg));
  1566. }
  1567. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1568. {
  1569. string filename = "";//声明一个string类型的相对路径
  1570. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1571. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1572. try//会有异常抛出,try,catch一下
  1573. {
  1574. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1575. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1576. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1577. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1578. //文件名称
  1579. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1580. //上传的文件的路径
  1581. string filePath = "";
  1582. if (!Directory.Exists(fileDir))
  1583. {
  1584. Directory.CreateDirectory(fileDir);
  1585. }
  1586. //上传的文件的路径
  1587. filePath = fileDir + filename;
  1588. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1589. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1590. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1591. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1592. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1593. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1594. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1595. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1596. bitmap.Dispose();
  1597. }
  1598. catch (Exception e)
  1599. {
  1600. string massage = e.Message;
  1601. Logs("IOS图片上传Error:" + massage);
  1602. //filename = e.Message;
  1603. }
  1604. return filename;//返回相对路径
  1605. }
  1606. /// <summary>
  1607. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1608. /// </summary>
  1609. /// <param name="dto"></param>
  1610. /// <returns></returns>
  1611. [HttpPost]
  1612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1613. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1614. {
  1615. if (dto == null)
  1616. {
  1617. return Ok(JsonView(false, "请求错误:"));
  1618. }
  1619. string msg = "参数错误";
  1620. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1621. {
  1622. try
  1623. {
  1624. //_delegationVisaRep.BeginTran();
  1625. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1626. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1627. .Where(s => s.Id == dto.visaProgressCustomerId)
  1628. .ExecuteCommandAsync();
  1629. if (updCount > 0 && dto.publishCode == 1)
  1630. {
  1631. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1632. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1633. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1634. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1635. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1636. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1637. if (groupData == null)
  1638. {
  1639. _delegationVisaRep.RollbackTran();
  1640. }
  1641. string title = string.Format(@"[签证进度更新]");
  1642. string content = string.Format(@"测试文本");
  1643. bool rst = await _message.AddMsg(new MessageDto()
  1644. {
  1645. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1646. IssuerId = dto.publisher,
  1647. Title = title,
  1648. Content = content,
  1649. ReleaseTime = DateTime.Now,
  1650. UIdList = new List<int> {
  1651. 234
  1652. }
  1653. });
  1654. if (rst)
  1655. {
  1656. return Ok(JsonView(true, "发送通知成功"));
  1657. }
  1658. }
  1659. //_delegationVisaRep.CommitTran();
  1660. }
  1661. catch (Exception)
  1662. {
  1663. //_delegationVisaRep.RollbackTran();
  1664. }
  1665. }
  1666. return Ok(JsonView(true, msg));
  1667. }
  1668. #endregion
  1669. #region 团组任务分配
  1670. /// <summary>
  1671. /// 团组任务分配初始化
  1672. /// </summary>
  1673. /// <returns></returns>
  1674. [HttpPost]
  1675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1676. public async Task<IActionResult> GetTaskAssignmen()
  1677. {
  1678. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1679. if (groupData.Code != 0)
  1680. {
  1681. return Ok(JsonView(false, groupData.Msg));
  1682. }
  1683. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1684. }
  1685. /// <summary>
  1686. /// 团组任务分配查询
  1687. /// </summary>
  1688. /// <param name="dto"></param>
  1689. /// <returns></returns>
  1690. [HttpPost]
  1691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1692. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1693. {
  1694. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1695. if (groupData.Code != 0)
  1696. {
  1697. return Ok(JsonView(false, groupData.Msg));
  1698. }
  1699. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1700. }
  1701. /// <summary>
  1702. /// 团组任务分配操作
  1703. /// </summary>
  1704. /// <param name="dto"></param>
  1705. /// <returns></returns>
  1706. [HttpPost]
  1707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1708. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1709. {
  1710. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1711. if (groupData.Code != 0)
  1712. {
  1713. return Ok(JsonView(false, groupData.Msg));
  1714. }
  1715. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1716. }
  1717. /// <summary>
  1718. /// 团组任务分配
  1719. /// 批量分配
  1720. /// 查询团组
  1721. /// </summary>
  1722. /// <param name="dto"></param>
  1723. /// <returns></returns>
  1724. [HttpPost]
  1725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1726. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1727. {
  1728. //参数验证
  1729. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1730. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1731. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1732. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1733. }
  1734. /// <summary>
  1735. /// 团组任务分配
  1736. /// 批量分配
  1737. /// </summary>
  1738. /// <param name="dto"></param>
  1739. /// <returns></returns>
  1740. [HttpPost]
  1741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1742. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1743. {
  1744. //参数验证
  1745. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1746. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1747. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1748. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1749. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1750. }
  1751. #endregion
  1752. #region 团组费用审核
  1753. /// <summary>
  1754. /// 费用审核
  1755. /// 团组列表 Page
  1756. /// </summary>
  1757. /// <param name="_dto">团组列表请求dto</param>
  1758. /// <returns></returns>
  1759. [HttpPost]
  1760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1761. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1762. {
  1763. #region 参数验证
  1764. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1765. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1766. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1767. #region 页面操作权限验证
  1768. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1769. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1770. #endregion
  1771. #endregion
  1772. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1773. {
  1774. string sqlWhere = string.Empty;
  1775. if (_dto.IsSure == 0) //未完成
  1776. {
  1777. sqlWhere += string.Format(@" And IsSure = 0");
  1778. }
  1779. else if (_dto.IsSure == 1) //已完成
  1780. {
  1781. sqlWhere += string.Format(@" And IsSure = 1");
  1782. }
  1783. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1784. {
  1785. string tj = _dto.SearchCriteria;
  1786. 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}%')",
  1787. tj, tj, tj, tj, tj);
  1788. }
  1789. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1790. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1791. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1792. From (
  1793. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1794. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1795. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1796. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1797. From Grp_DelegationInfo gdi
  1798. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1799. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1800. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1801. Where gdi.IsDel = 0 {0}
  1802. ) temp ", sqlWhere);
  1803. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1804. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1805. var _view = new
  1806. {
  1807. PageFuncAuth = pageFunAuthView,
  1808. Data = _DelegationList
  1809. };
  1810. return Ok(JsonView(true, "查询成功!", _view, total));
  1811. }
  1812. else
  1813. {
  1814. return Ok(JsonView(false, "查询失败"));
  1815. }
  1816. }
  1817. /// <summary>
  1818. /// 获取团组费用审核
  1819. /// </summary>
  1820. /// <param name="_dto"></param>
  1821. /// <returns></returns>
  1822. [HttpPost]
  1823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1824. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1825. {
  1826. try
  1827. {
  1828. #region 参数验证
  1829. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1830. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1831. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1832. #region 页面操作权限验证
  1833. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1834. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1835. #endregion
  1836. #endregion
  1837. var _view = new Grp_CreditCardPaymentView();
  1838. var clientNameList = getSimplClientList(_dto.DiId);
  1839. #region 费用清单
  1840. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1841. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1842. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1843. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1844. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1845. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1846. /*
  1847. * 76://酒店预订
  1848. */
  1849. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1850. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1851. /*
  1852. * 79://车/导游地接
  1853. */
  1854. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1855. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1856. /*
  1857. * 80: //签证
  1858. */
  1859. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1860. /*
  1861. *81: //邀请/公务活动
  1862. */
  1863. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1864. /*
  1865. * 82: //团组客户保险
  1866. */
  1867. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1868. /*
  1869. * Lable = 85 机票预订
  1870. */
  1871. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1872. /*
  1873. * 85 机票预定
  1874. */
  1875. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1876. /*
  1877. * 98 其他款项
  1878. */
  1879. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1880. /*
  1881. * 285:收款退还
  1882. */
  1883. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1884. /*
  1885. * 1015: //超支费用
  1886. */
  1887. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1888. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1889. /*
  1890. * 币种信息
  1891. */
  1892. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1893. /*
  1894. * 车/导游地接 费用类型
  1895. */
  1896. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1897. /*
  1898. * 车/导游地接 费用类型
  1899. */
  1900. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1901. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1902. /*
  1903. * 用户信息
  1904. */
  1905. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1906. /*
  1907. * 费用模块
  1908. */
  1909. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1910. string priceModule = string.Empty;
  1911. if (sdPriceName != null)
  1912. {
  1913. priceModule = sdPriceName.Name;
  1914. }
  1915. /*
  1916. * 成本信息
  1917. */
  1918. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1919. decimal _groupRate = 0.0000M;
  1920. string _groupCurrencyCode = "-";
  1921. if (groupCost != null)
  1922. {
  1923. _groupRate = groupCost.Rate;
  1924. if (int.TryParse(groupCost.Currency, out int _currency))
  1925. {
  1926. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1927. }
  1928. else _groupCurrencyCode = groupCost.Currency;
  1929. }
  1930. string costContentSql = $"Select * From Grp_GroupCost";
  1931. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1932. //处理日期为空的天数
  1933. for (int i = 0; i < groupCostDetails.Count; i++)
  1934. if (i != 0)
  1935. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1936. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1937. /*
  1938. * 处理详情数据
  1939. */
  1940. foreach (var entity in entityList)
  1941. {
  1942. var _detail = new Grp_CreditCardPaymentDetailView();
  1943. _detail.Id = entity.Id;
  1944. _detail.PriceName = priceModule;
  1945. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1946. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1947. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1948. //处理金额
  1949. if (entity.CTable == 1015)
  1950. {
  1951. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1952. if (czInfo != null)
  1953. {
  1954. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1955. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1956. }
  1957. }
  1958. /*
  1959. * 应付款金额
  1960. */
  1961. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1962. string PaymentCurrency_WaitPay = "Unknown";
  1963. string hotelCurrncyCode = "Unknown";
  1964. string hotelCurrncyName = "Unknown";
  1965. if (sdPaymentCurrency_WaitPay != null)
  1966. {
  1967. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1968. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1969. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1970. if (hotelCurrncyCode.Equals("CNY"))
  1971. {
  1972. entity.DayRate = 1.0000M;
  1973. }
  1974. }
  1975. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1976. /*
  1977. * 此次付款金额
  1978. */
  1979. decimal CurrPayStr = 0.00M,
  1980. OriginalCurrPay = 0.00M;
  1981. if (entity.PayPercentage == 0)
  1982. {
  1983. if (entity.PayThenMoney != 0)
  1984. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1985. }
  1986. else
  1987. {
  1988. if (entity.PayMoney != 0)
  1989. {
  1990. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1991. }
  1992. }
  1993. //if (_dto.Label == 79)
  1994. //{
  1995. // string original = string.Empty;
  1996. // if (hotelCurrncyCode.Equals("CNY"))
  1997. // {
  1998. // OriginalCurrPay = CurrPayStr;
  1999. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2000. // }
  2001. // else
  2002. // {
  2003. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2004. // //760 EUR(7600.00 CNY)
  2005. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2006. // }
  2007. //}
  2008. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2009. string original = string.Empty;
  2010. if (hotelCurrncyCode.Equals("CNY"))
  2011. {
  2012. OriginalCurrPay = CurrPayStr;
  2013. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2014. }
  2015. else
  2016. {
  2017. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2018. //760 EUR(7600.00 CNY)
  2019. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2020. }
  2021. /*
  2022. * 剩余尾款
  2023. */
  2024. decimal BalanceStr = 0;
  2025. if (CurrPayStr != 0)
  2026. {
  2027. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2028. BalanceStr = 0;
  2029. else
  2030. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2031. }
  2032. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2033. /*
  2034. * Bus名称
  2035. */
  2036. _detail.BusName = "待增加";
  2037. /*
  2038. *费用所属
  2039. */
  2040. switch (entity.CTable)
  2041. {
  2042. case 76://酒店预订
  2043. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2044. if (hotelReservations != null)
  2045. {
  2046. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2047. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2048. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2049. string roomFeeStr = "", roomFeestr1 = "";
  2050. //是否比较房型价格
  2051. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2052. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2053. roomFeeStr += $"<br/>";
  2054. var roomTotal = 0.00M;
  2055. if (hotelReservations.SingleRoomPrice > 0)
  2056. {
  2057. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2058. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2059. //__isSingle = true;
  2060. roomTotal += fee;
  2061. }
  2062. if (hotelReservations.DoubleRoomPrice > 0)
  2063. {
  2064. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2065. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2066. // __isDouble = true;
  2067. roomTotal += fee;
  2068. }
  2069. if (hotelReservations.SuiteRoomPrice > 0)
  2070. {
  2071. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2072. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2073. //__isSuite = true;
  2074. roomTotal += fee;
  2075. }
  2076. if (hotelReservations.OtherRoomPrice > 0)
  2077. {
  2078. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2079. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2080. //__isOther = true;
  2081. roomTotal += fee;
  2082. }
  2083. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2084. else roomFeeStr += " 0.00 * 0";
  2085. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2086. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2087. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2088. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2089. /*
  2090. * 费用类型
  2091. * 1:房费
  2092. * 2:早餐
  2093. * 3:地税
  2094. * 4:城市税
  2095. * </summary>
  2096. */
  2097. //地税
  2098. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2099. if (governmentRentData != null)
  2100. {
  2101. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2102. governmentRentFee = governmentRentData.Price;
  2103. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2104. if (governmentRentCurrData != null)
  2105. {
  2106. governmentRentCode = governmentRentCurrData.Name;
  2107. governmentRentName = $"({governmentRentCurrData.Remark})";
  2108. }
  2109. }
  2110. //城市税
  2111. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2112. if (cityTaxData != null)
  2113. {
  2114. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2115. cityTaxFee = cityTaxData.Price;
  2116. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2117. if (cityTaxCurrData != null)
  2118. {
  2119. cityTaxCode = cityTaxCurrData.Name;
  2120. cityTaxName = $"({cityTaxCurrData.Remark})";
  2121. }
  2122. }
  2123. //酒店早餐
  2124. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2125. if (breakfastData != null)
  2126. {
  2127. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2128. breakfastFee = breakfastData.Price;
  2129. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2130. if (breakfastCurrData != null)
  2131. {
  2132. breakfastCode = breakfastCurrData.Name;
  2133. breakfastName = $"({breakfastCurrData.Remark})";
  2134. }
  2135. }
  2136. //房间费用
  2137. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2138. if (roomData != null)
  2139. {
  2140. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2141. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2142. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2143. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2144. roomFee = roomData.Price;
  2145. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2146. if (roomCurrData != null)
  2147. {
  2148. roomCode = roomCurrData.Name;
  2149. roomName = $"({roomCurrData.Remark})";
  2150. }
  2151. }
  2152. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2153. string hotelCostStr = "";
  2154. decimal hotelCsotTotal = 0.00M;
  2155. if (groupCost != null)
  2156. {
  2157. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2158. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2159. }
  2160. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2161. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2162. string hotelCost_day = "";
  2163. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2164. foreach (var item in hotelCostDetails1)
  2165. {
  2166. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2167. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2168. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2169. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2170. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2171. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2172. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2173. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2174. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2175. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2176. hotelCost_day += @$"<br/>";
  2177. }
  2178. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2179. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2180. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2181. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2182. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2183. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2184. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2185. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2186. $"房间说明: {hotelReservations.Remark} <br/>" +
  2187. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2188. $"{hotelBreakfastStr}" +
  2189. $"{hotelGovernmentRentStr}" +
  2190. $"{hotelCityTaxStr}";
  2191. _detail.PriceNameContent = hotelReservations.HotelName;
  2192. }
  2193. break;
  2194. case 79://车/导游地接
  2195. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2196. if (touristGuideGroundReservations != null)
  2197. {
  2198. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2199. {
  2200. _detail.BusName = touristGuideGroundReservations.BusName;
  2201. }
  2202. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2203. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2204. //if (isInt)
  2205. //{
  2206. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2207. // if (cityInfo != null)
  2208. // {
  2209. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2210. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2211. // if (carFeeItem != null)
  2212. // {
  2213. // nameContent += $@"({carFeeItem.Name})";
  2214. // }
  2215. // _detail.PriceNameContent = nameContent;
  2216. // }
  2217. //}
  2218. //else
  2219. //{
  2220. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2221. //}
  2222. var touristGuideGroundReservationsContents =
  2223. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2224. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2225. foreach (var item in touristGuideGroundReservationsContents)
  2226. {
  2227. string typeName = "Unknown";
  2228. string carCurrencyCode = "Unknown";
  2229. string carCurrencyName = "Unknown";
  2230. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2231. if (carTypeData != null) typeName = carTypeData.Name;
  2232. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2233. if (currencyData != null)
  2234. {
  2235. carCurrencyCode = currencyData.Name;
  2236. carCurrencyName = currencyData.Remark;
  2237. }
  2238. //op、成本 币种是否一致
  2239. bool IsCurrencyAgreement = false;
  2240. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2241. string opCostStr = string.Empty;
  2242. decimal opCostTypePrice = 0.00M;
  2243. #region 处理成本各项费用
  2244. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2245. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2246. if (opCost.Count > 0)
  2247. {
  2248. switch (item.SId)
  2249. {
  2250. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2251. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2252. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2253. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2254. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2255. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2256. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2257. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2258. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2259. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2260. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2261. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2262. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2263. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2264. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2265. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2266. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2267. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2268. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2269. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2270. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2271. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2272. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2273. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2274. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2275. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2276. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2277. }
  2278. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2279. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2280. }
  2281. #endregion
  2282. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2283. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2284. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2285. $"{opTypeStr} {opCostStr}<br/>" +
  2286. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2287. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2288. }
  2289. _detail.PriceMsgContent = priceMsg;
  2290. }
  2291. break;
  2292. case 80: //签证
  2293. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2294. if (visaInfo != null)
  2295. {
  2296. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2297. _detail.PriceNameContent = visaInfo.VisaDescription;
  2298. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2299. }
  2300. break;
  2301. case 81: //邀请/公务活动
  2302. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2303. if (_ioa != null)
  2304. {
  2305. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2306. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2307. sendCurrName = "Unknown", //快递费用币种 Name
  2308. sendCurrCode = "Unknown", //快递费用币种 Code
  2309. eventsCurrName = "Unknown", //公务活动费币种 Name
  2310. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2311. translateCurrName = "Unknown", //公务翻译费 Name
  2312. translateCurrCode = "Unknown"; //公务翻译费 Code
  2313. #region 处理费用币种
  2314. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2315. if (inviteCurrData != null)
  2316. {
  2317. inviteCurrName = inviteCurrData.Remark;
  2318. inviteCurrCode = inviteCurrData.Name;
  2319. }
  2320. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2321. if (sendCurrData != null)
  2322. {
  2323. sendCurrName = sendCurrData.Remark;
  2324. sendCurrCode = sendCurrData.Name;
  2325. }
  2326. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2327. if (eventsCurrData != null)
  2328. {
  2329. eventsCurrName = eventsCurrData.Remark;
  2330. eventsCurrCode = eventsCurrData.Name;
  2331. }
  2332. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2333. if (translateCurrData != null)
  2334. {
  2335. translateCurrName = translateCurrData.Remark;
  2336. translateCurrCode = translateCurrData.Name;
  2337. }
  2338. #endregion
  2339. _detail.PriceNameContent = _ioa.InviterArea;
  2340. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2341. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2342. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2343. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2344. $@"备注:" + _ioa.Remark + "<br/>";
  2345. }
  2346. break;
  2347. case 82: //团组客户保险
  2348. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2349. if (customers != null)
  2350. {
  2351. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2352. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2353. }
  2354. break;
  2355. case 85: //机票预订
  2356. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2357. if (jpRes != null)
  2358. {
  2359. string FlightsDescription = jpRes.FlightsDescription;
  2360. string PriceDescription = jpRes.PriceDescription;
  2361. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2362. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2363. }
  2364. break;
  2365. case 98://其他款项
  2366. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2367. if (gdpRes != null)
  2368. {
  2369. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2370. _detail.PriceNameContent = gdpRes.PriceName;
  2371. }
  2372. break;
  2373. case 285://收款退还
  2374. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2375. if (refundAndOtherMoney != null)
  2376. {
  2377. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2378. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2379. }
  2380. break;
  2381. case 751://酒店早餐
  2382. break;
  2383. case 1015://超支费用
  2384. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2385. if (groupExtraCost != null)
  2386. {
  2387. _detail.PriceNameContent = groupExtraCost.PriceName;
  2388. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2389. }
  2390. break;
  2391. default:
  2392. break;
  2393. }
  2394. /*
  2395. * 申请人
  2396. */
  2397. string operatorName = " - ";
  2398. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2399. if (_opUser != null)
  2400. {
  2401. operatorName = _opUser.CnName;
  2402. }
  2403. _detail.OperatorName = operatorName;
  2404. /*
  2405. * 审核人
  2406. */
  2407. string auditOperatorName = "Unknown";
  2408. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2409. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2410. else
  2411. {
  2412. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2413. if (_adUser != null)
  2414. {
  2415. auditOperatorName = _adUser.CnName;
  2416. }
  2417. }
  2418. _detail.AuditOperatorName = auditOperatorName;
  2419. /*
  2420. * 超预算比例
  2421. */
  2422. string overBudgetStr = "";
  2423. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2424. else if (entity.ExceedBudget == 0)
  2425. {
  2426. if (entity.CTable == 76 || entity.CTable == 79)
  2427. {
  2428. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2429. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2430. }
  2431. else
  2432. {
  2433. overBudgetStr = "未超预算";
  2434. }
  2435. }
  2436. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2437. _detail.OverBudget = overBudgetStr;
  2438. decimal auditFee = 0.00M; //已审核金额 人名币
  2439. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2440. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2441. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2442. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2443. {
  2444. auditedFeeOriginal = entity.PayMoney;
  2445. auditFee = CurrPayStr;
  2446. }
  2447. else if (entity.IsAuditGM == 0)
  2448. {
  2449. unAuditFeeCNY = CurrPayStr;
  2450. unAuditFeeOriginal = OriginalCurrPay;
  2451. OriginalCurrPay = 0.00M;
  2452. }
  2453. /*
  2454. * 费用总计
  2455. */
  2456. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2457. {
  2458. CurrencyId = entity.PaymentCurrency,
  2459. CurrencyName = PaymentCurrency_WaitPay,
  2460. AmountPayable = entity.PayMoney,
  2461. ThisPayment = OriginalCurrPay,
  2462. BalancePayment = BalanceStr,
  2463. AuditedFunds = auditFee,
  2464. AuditedFundsOriginal = auditedFeeOriginal,
  2465. UnAuditFundsCNY = unAuditFeeCNY,
  2466. UnAuditFundsOriginal = unAuditFeeOriginal
  2467. });
  2468. _detail.IsAuditGM = entity.IsAuditGM;
  2469. detailList.Add(_detail);
  2470. }
  2471. #endregion
  2472. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2473. /*
  2474. * 下方描述处理
  2475. */
  2476. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2477. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2478. if (ccpCurrencyPrice != null)
  2479. {
  2480. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2481. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2482. }
  2483. else
  2484. {
  2485. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2486. }
  2487. string amountPayableStr = string.Format(@"应付款总金额: ");
  2488. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2489. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2490. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2491. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2492. foreach (var item in nonDuplicat)
  2493. {
  2494. var currencyName = item.CurrencyName;
  2495. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2496. if (strs.Count > 0)
  2497. {
  2498. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2499. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2500. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2501. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2502. //单独处理此次付款金额
  2503. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2504. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2505. //单独处理已审核费用
  2506. //if (item.CurrencyId == 836) //人民币
  2507. //{
  2508. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2509. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2510. //}
  2511. //else
  2512. //{
  2513. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2514. //}
  2515. if (currencyName.Equals("CNY"))
  2516. {
  2517. //已审核费用
  2518. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2519. //未审核费用
  2520. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2521. }
  2522. else
  2523. {
  2524. //已审核费用
  2525. 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"));
  2526. //未审核费用
  2527. 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"));
  2528. }
  2529. }
  2530. }
  2531. _view.TotalStr1 = amountPayableStr[..^1];
  2532. _view.TotalStr2 = thisPaymentStr[..^1];
  2533. _view.TotalStr3 = balancePaymentStr[..^1];
  2534. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2535. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2536. var _view1 = new
  2537. {
  2538. PageFuncAuth = pageFunAuthView,
  2539. Data = _view
  2540. };
  2541. return Ok(JsonView(_view1));
  2542. }
  2543. catch (Exception ex)
  2544. {
  2545. return Ok(JsonView(false, ex.Message));
  2546. }
  2547. }
  2548. /// <summary>
  2549. /// 费用审核
  2550. /// 修改团组费用审核状态
  2551. /// </summary>
  2552. /// <param name="_dto">参数Json字符串</param>
  2553. /// <returns></returns>
  2554. [HttpPost]
  2555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2556. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2557. {
  2558. #region 参数验证
  2559. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2560. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2561. #endregion
  2562. #region 页面操作权限验证
  2563. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2564. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2565. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2566. #endregion
  2567. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2568. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2569. DateTime dtNow = DateTime.Now;
  2570. _groupRepository.BeginTran();
  2571. int rst = 0;
  2572. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2573. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2574. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2575. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2576. List<dynamic> msgDatas = new List<dynamic>();
  2577. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2578. foreach (var item in idList)
  2579. {
  2580. int CreditId = int.Parse(item);
  2581. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2582. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2583. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2584. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2585. .Where(s => s.Id == CreditId)
  2586. .ExecuteCommandAsync();
  2587. if (result < 1)
  2588. {
  2589. rst = -1;
  2590. _groupRepository.RollbackTran();
  2591. return Ok(JsonView(false, "操作失败并回滚!"));
  2592. }
  2593. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2594. if (creditData != null)
  2595. {
  2596. #region 应用通知配置
  2597. try
  2598. {
  2599. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2600. }
  2601. catch (Exception ex)
  2602. {
  2603. }
  2604. #endregion
  2605. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2606. string groupNameStr = string.Empty;
  2607. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2608. if (groupData != null) groupNameStr = groupData.TeamName;
  2609. string creditTypeStr = string.Empty;
  2610. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2611. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2612. string creditCurrency = string.Empty;
  2613. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2614. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2615. if (creditCurrency.Equals("CNY"))
  2616. {
  2617. creditData.DayRate = 1.0000M;
  2618. }
  2619. if (creditData.PayPercentage == 0.00M)
  2620. {
  2621. creditData.PayPercentage = 100M;
  2622. }
  2623. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2624. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2625. string msgContent = "";
  2626. if (creditCurrency.Equals("CNY"))
  2627. {
  2628. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2629. }
  2630. else
  2631. {
  2632. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2633. }
  2634. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2635. }
  2636. }
  2637. if (rst == 0)
  2638. {
  2639. _groupRepository.CommitTran();
  2640. foreach (var item in msgDatas)
  2641. {
  2642. //发送消息
  2643. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2644. }
  2645. #region 应用推送
  2646. try
  2647. {
  2648. foreach (var ccpId in dic_ccp_user.Keys)
  2649. {
  2650. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2651. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2652. }
  2653. }
  2654. catch (Exception)
  2655. {
  2656. }
  2657. #endregion
  2658. return Ok(JsonView(true, "操作成功!"));
  2659. }
  2660. return Ok(JsonView(false, "操作失败!"));
  2661. }
  2662. #endregion
  2663. #region 机票费用录入
  2664. /// <summary>
  2665. /// 机票录入当前登录人可操作团组
  2666. /// </summary>
  2667. /// <param name="dto"></param>
  2668. /// <returns></returns>
  2669. [HttpPost]
  2670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2671. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2672. {
  2673. try
  2674. {
  2675. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2676. if (groupData.Code != 0)
  2677. {
  2678. return Ok(JsonView(false, groupData.Msg));
  2679. }
  2680. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2681. }
  2682. catch (Exception ex)
  2683. {
  2684. return Ok(JsonView(false, "程序错误!"));
  2685. throw;
  2686. }
  2687. }
  2688. /// <summary>
  2689. /// 机票费用录入列表
  2690. /// </summary>
  2691. /// <param name="dto"></param>
  2692. /// <returns></returns>
  2693. [HttpPost]
  2694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2695. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2696. {
  2697. try
  2698. {
  2699. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2700. if (groupData.Code != 0)
  2701. {
  2702. return Ok(JsonView(false, groupData.Msg));
  2703. }
  2704. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2705. }
  2706. catch (Exception ex)
  2707. {
  2708. return Ok(JsonView(false, ex.Message));
  2709. throw;
  2710. }
  2711. }
  2712. /// <summary>
  2713. /// 根据id查询费用录入信息
  2714. /// </summary>
  2715. /// <param name="dto"></param>
  2716. /// <returns></returns>
  2717. [HttpPost]
  2718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2719. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2720. {
  2721. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2722. if (groupData.Code != 0)
  2723. {
  2724. return Ok(JsonView(false, groupData.Msg));
  2725. }
  2726. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2727. }
  2728. /// <summary>
  2729. /// 机票费用录入操作(Status:1.新增,2.修改)
  2730. /// </summary>
  2731. /// <param name="dto"></param>
  2732. /// <returns></returns>
  2733. [HttpPost]
  2734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2735. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2736. {
  2737. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2738. if (groupData.Code != 0)
  2739. {
  2740. return Ok(JsonView(false, groupData.Msg));
  2741. }
  2742. #region 应用推送
  2743. try
  2744. {
  2745. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2746. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2747. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2748. //2024-10-21 新增LZ UID
  2749. var userIds = new List<int>() { 21 };
  2750. string title = $"系统通知";
  2751. string content = "";
  2752. var diId = dto.AirTicketResOpData.DiId;
  2753. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2754. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2755. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2756. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2757. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2758. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2759. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2760. }
  2761. catch (Exception ex)
  2762. {
  2763. }
  2764. #endregion
  2765. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2766. }
  2767. /// <summary>
  2768. /// 根据舱位类型查询接团客户名单信息
  2769. /// </summary>
  2770. /// <param name="dto"></param>
  2771. /// <returns></returns>
  2772. [HttpPost]
  2773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2774. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2775. {
  2776. try
  2777. {
  2778. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2779. if (crm_Groups.Count != 0)
  2780. {
  2781. List<dynamic> Customer = new List<dynamic>();
  2782. foreach (var item in crm_Groups)
  2783. {
  2784. var data = new
  2785. {
  2786. Id = item.Id,
  2787. Pinyin = item.Pinyin,
  2788. Name = item.LastName + item.FirstName
  2789. };
  2790. Customer.Add(data);
  2791. }
  2792. return Ok(JsonView(true, "查询成功!", Customer));
  2793. }
  2794. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2795. }
  2796. catch (Exception ex)
  2797. {
  2798. return Ok(JsonView(false, "程序错误!"));
  2799. throw;
  2800. }
  2801. }
  2802. /// <summary>
  2803. /// 根据团号获取客户信息
  2804. /// </summary>
  2805. /// <param name="dto"></param>
  2806. /// <returns></returns>
  2807. [HttpPost]
  2808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2809. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2810. {
  2811. var jw = JsonView(false);
  2812. if (dto.DIID < 1)
  2813. {
  2814. jw.Msg += "请输入正确的diid";
  2815. return Ok(jw);
  2816. }
  2817. var arr = getSimplClientList(dto.DIID);
  2818. jw = JsonView(true, "获取成功!", arr);
  2819. return Ok(jw);
  2820. }
  2821. private List<SimplClientInfo> getSimplClientList(int diId)
  2822. {
  2823. 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);
  2824. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2825. foreach (var item in arr)
  2826. {
  2827. EncryptionProcessor.DecryptProperties(item);
  2828. }
  2829. return arr;
  2830. }
  2831. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2832. {
  2833. string result = origin;
  2834. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2835. {
  2836. string[] temparr = origin.Split(',');
  2837. string fistrStr = temparr[0];
  2838. int count = temparr.Count();
  2839. int tempId;
  2840. bool success = int.TryParse(fistrStr, out tempId);
  2841. if (success)
  2842. {
  2843. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2844. if (tempInfo != null)
  2845. {
  2846. if (count > 1)
  2847. {
  2848. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2849. }
  2850. else
  2851. {
  2852. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2853. }
  2854. }
  2855. }
  2856. }
  2857. return result;
  2858. }
  2859. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2860. {
  2861. string result = origin;
  2862. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2863. {
  2864. string[] temparr = origin.Split(',');
  2865. result = "";
  2866. foreach (var item in temparr)
  2867. {
  2868. int tempId;
  2869. bool success = int.TryParse(item, out tempId);
  2870. if (success)
  2871. {
  2872. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2873. if (tempInfo != null)
  2874. {
  2875. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2876. }
  2877. }
  2878. }
  2879. }
  2880. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2881. return result;
  2882. }
  2883. /// <summary>
  2884. /// 机票费用录入,删除
  2885. /// </summary>
  2886. /// <param name="dto"></param>
  2887. /// <returns></returns>
  2888. [HttpPost]
  2889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2890. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2891. {
  2892. try
  2893. {
  2894. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2895. if (res)
  2896. {
  2897. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2898. {
  2899. IsDel = 1,
  2900. DeleteUserId = dto.DeleteUserId,
  2901. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2902. }).ExecuteCommandAsync();
  2903. return Ok(JsonView(true, "删除成功!"));
  2904. }
  2905. return Ok(JsonView(false, "删除失败!"));
  2906. }
  2907. catch (Exception ex)
  2908. {
  2909. return Ok(JsonView(false, "程序错误!"));
  2910. throw;
  2911. }
  2912. }
  2913. /// <summary>
  2914. /// 导出机票录入报表
  2915. /// </summary>
  2916. /// <param name="dto"></param>
  2917. /// <returns></returns>
  2918. [HttpPost]
  2919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2920. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2921. {
  2922. try
  2923. {
  2924. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2925. if (groupData.Code != 0)
  2926. {
  2927. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2928. }
  2929. else
  2930. {
  2931. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2932. if (AirTicketReservations.Count != 0)
  2933. {
  2934. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2935. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2936. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2937. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2938. WorkbookDesigner designer = new WorkbookDesigner();
  2939. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2940. decimal countCost = 0;
  2941. foreach (var item in AirTicketReservations)
  2942. {
  2943. #region 处理客人姓名
  2944. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2945. item.ClientName = clientNames;
  2946. #endregion
  2947. if (item.BankType == "其他")
  2948. {
  2949. item.BankNo = "--";
  2950. }
  2951. else
  2952. {
  2953. if (!string.IsNullOrEmpty(item.BankType))
  2954. {
  2955. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2956. }
  2957. }
  2958. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2959. item.Price = System.Decimal.Round(item.Price, 2);
  2960. countCost += Convert.ToDecimal(item.Price);
  2961. }
  2962. designer.SetDataSource("Export", AirTicketReservations);
  2963. designer.SetDataSource("ExportDiCode", diCode);
  2964. designer.SetDataSource("ExportDiName", diName);
  2965. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2966. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2967. designer.Process();
  2968. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2969. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2970. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2971. return Ok(JsonView(true, "成功", url = rst));
  2972. }
  2973. else
  2974. {
  2975. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2976. }
  2977. }
  2978. }
  2979. catch (Exception ex)
  2980. {
  2981. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2982. throw;
  2983. }
  2984. }
  2985. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2986. /// <summary>
  2987. /// 行程单导出
  2988. /// </summary>
  2989. /// <param name="dto"></param>
  2990. /// <returns></returns>
  2991. [HttpPost]
  2992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2993. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2994. {
  2995. try
  2996. {
  2997. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2998. if (groupData.Code != 0)
  2999. {
  3000. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3001. }
  3002. else
  3003. {
  3004. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3005. if (dto.Language == "CN")
  3006. {
  3007. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3008. DocumentBuilder builder = new DocumentBuilder(doc);
  3009. int tableIndex = 0;//表格索引
  3010. //得到文档中的第一个表格
  3011. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3012. foreach (var item in _AirTicketReservations)
  3013. {
  3014. #region 处理固定数据
  3015. string[] FlightsCode = item.FlightsCode.Split('/');
  3016. if (FlightsCode.Length != 0)
  3017. {
  3018. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3019. if (_AirCompany != null)
  3020. {
  3021. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3022. }
  3023. else
  3024. {
  3025. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3026. }
  3027. }
  3028. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3029. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3030. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3031. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3032. string name = "";
  3033. foreach (string clientName in nameArray)
  3034. {
  3035. if (!name.Contains(clientName))
  3036. {
  3037. name += clientName + ",";
  3038. }
  3039. }
  3040. if (!string.IsNullOrWhiteSpace(name))
  3041. {
  3042. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3043. }
  3044. else
  3045. {
  3046. table.Range.Bookmarks["ClientName"].Text = "--";
  3047. }
  3048. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3049. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3050. table.Range.Bookmarks["JointTicket"].Text = "--";
  3051. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3052. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3053. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3054. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3055. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3056. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3057. #endregion
  3058. #region 循环数据处理
  3059. List<AirInfo> airs = new List<AirInfo>();
  3060. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3061. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3062. for (int i = 0; i < FlightsCode.Length; i++)
  3063. {
  3064. AirInfo air = new AirInfo();
  3065. string[] tempstr = DayArray[i]
  3066. .Replace("\r\n", string.Empty)
  3067. .Replace("\\r\\n", string.Empty)
  3068. .TrimStart().TrimEnd()
  3069. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3070. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3071. string starCity = "";
  3072. if (star_Three != null)
  3073. {
  3074. starCity = star_Three.AirPort;
  3075. }
  3076. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3077. string EndCity = "";
  3078. if (End_Three != null)
  3079. {
  3080. EndCity = End_Three.AirPort;
  3081. }
  3082. air.Destination = starCity + "/" + EndCity;
  3083. air.Flight = FlightsCode[i];
  3084. air.SeatingClass = item.CTypeName;
  3085. string dateTime = tempstr[2];
  3086. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3087. air.FlightDate = DateTemp;
  3088. air.DepartureTime = tempstr[5];
  3089. air.LandingTime = tempstr[6];
  3090. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3091. air.TicketStatus = "--";
  3092. air.Luggage = "--";
  3093. air.DepartureTerminal = "--";
  3094. air.LandingTerminal = "--";
  3095. airs.Add(air);
  3096. }
  3097. int row = 13;
  3098. for (int i = 0; i < airs.Count; i++)
  3099. {
  3100. if (airs.Count > 2)
  3101. {
  3102. for (int j = 0; j < airs.Count - 2; j++)
  3103. {
  3104. var CopyRow = table.Rows[12].Clone(true);
  3105. table.Rows.Add(CopyRow);
  3106. }
  3107. }
  3108. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3109. int index = 0;
  3110. foreach (PropertyInfo property in properties)
  3111. {
  3112. string value = property.GetValue(airs[i]).ToString();
  3113. Cell ishcel0 = table.Rows[row].Cells[index];
  3114. Paragraph p = new Paragraph(doc);
  3115. string s = value;
  3116. p.AppendChild(new Run(doc, s));
  3117. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3118. ishcel0.AppendChild(p);
  3119. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3120. index++;
  3121. }
  3122. row++;
  3123. }
  3124. #endregion
  3125. Paragraph lastParagraph = new Paragraph(doc);
  3126. //第一个表格末尾加段落
  3127. table.ParentNode.InsertAfter(lastParagraph, table);
  3128. //复制第一个表格
  3129. Table cloneTable = (Table)table.Clone(true);
  3130. //在文档末尾段落后面加入复制的表格
  3131. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3132. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3133. {
  3134. int rownewsIndex = 13;
  3135. for (int i = 0; i < 2; i++)
  3136. {
  3137. var CopyRow = table.Rows[12].Clone(true);
  3138. table.Rows.RemoveAt(13);
  3139. table.Rows.Add(CopyRow);
  3140. rownewsIndex++;
  3141. }
  3142. }
  3143. else
  3144. {
  3145. table.Rows.RemoveAt(12);
  3146. }
  3147. cloneTable.Rows.RemoveAt(12);
  3148. }
  3149. if (_AirTicketReservations.Count != 0)
  3150. {
  3151. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3152. if (FlightsCode.Length != 0)
  3153. {
  3154. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3155. if (_AirCompany != null)
  3156. {
  3157. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3158. }
  3159. else
  3160. {
  3161. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3162. }
  3163. }
  3164. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3165. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3166. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3167. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3168. string name = "";
  3169. foreach (string clientName in nameArray)
  3170. {
  3171. if (!name.Contains(clientName))
  3172. {
  3173. name += clientName + ",";
  3174. }
  3175. }
  3176. if (!string.IsNullOrWhiteSpace(name))
  3177. {
  3178. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3179. }
  3180. else
  3181. {
  3182. table.Range.Bookmarks["ClientName"].Text = "--";
  3183. }
  3184. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3185. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3186. table.Range.Bookmarks["JointTicket"].Text = "--";
  3187. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3188. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3189. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3190. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3191. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3192. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3193. }
  3194. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3195. //保存合并后的文档
  3196. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3197. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3198. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3199. return Ok(JsonView(true, "成功!", rst));
  3200. }
  3201. else
  3202. {
  3203. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3204. DocumentBuilder builder = new DocumentBuilder(doc);
  3205. int tableIndex = 0;//表格索引
  3206. //得到文档中的第一个表格
  3207. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3208. List<string> texts = new List<string>();
  3209. foreach (var item in _AirTicketReservations)
  3210. {
  3211. string[] FlightsCode = item.FlightsCode.Split('/');
  3212. if (FlightsCode.Length != 0)
  3213. {
  3214. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3215. if (_AirCompany != null)
  3216. {
  3217. if (!transDic.ContainsKey(_AirCompany.CnName))
  3218. {
  3219. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3220. }
  3221. }
  3222. else
  3223. {
  3224. if (!transDic.ContainsKey("--"))
  3225. {
  3226. transDic.Add("--", "--");
  3227. }
  3228. }
  3229. }
  3230. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3231. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3232. string name = "";
  3233. foreach (string clientName in nameArray)
  3234. {
  3235. name += clientName + ",";
  3236. }
  3237. if (!texts.Contains(name))
  3238. {
  3239. texts.Add(name);
  3240. }
  3241. List<AirInfo> airs = new List<AirInfo>();
  3242. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3243. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3244. for (int i = 0; i < FlightsCode.Length; i++)
  3245. {
  3246. AirInfo air = new AirInfo();
  3247. string[] tempstr = DayArray[i]
  3248. .Replace("\r\n", string.Empty)
  3249. .Replace("\\r\\n", string.Empty)
  3250. .TrimStart().TrimEnd()
  3251. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3252. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3253. if (star_Three != null)
  3254. {
  3255. if (!transDic.ContainsKey(star_Three.AirPort))
  3256. {
  3257. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3258. }
  3259. }
  3260. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3261. if (End_Three != null)
  3262. {
  3263. if (!transDic.ContainsKey(End_Three.AirPort))
  3264. {
  3265. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3266. }
  3267. }
  3268. if (!texts.Contains(item.CTypeName))
  3269. {
  3270. texts.Add(item.CTypeName);
  3271. }
  3272. }
  3273. }
  3274. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3275. if (transData.Count > 0)
  3276. {
  3277. foreach (TranslateResult item in transData)
  3278. {
  3279. if (!transDic.ContainsKey(item.Query))
  3280. {
  3281. transDic.Add(item.Query, item.Translation);
  3282. }
  3283. }
  3284. }
  3285. foreach (var item in _AirTicketReservations)
  3286. {
  3287. #region 处理固定数据
  3288. string[] FlightsCode = item.FlightsCode.Split('/');
  3289. if (FlightsCode.Length != 0)
  3290. {
  3291. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3292. if (_AirCompany != null)
  3293. {
  3294. string str = "--";
  3295. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3296. if (!string.IsNullOrEmpty(translateResult))
  3297. {
  3298. str = translateResult;
  3299. str = _airTicketResRep.Processing(str);
  3300. }
  3301. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3302. }
  3303. else
  3304. {
  3305. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3306. }
  3307. }
  3308. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3309. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3310. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3311. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3312. string names = "";
  3313. foreach (string clientName in nameArray)
  3314. {
  3315. names += clientName + ",";
  3316. }
  3317. if (!string.IsNullOrWhiteSpace(names))
  3318. {
  3319. string str = "--";
  3320. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3321. if (!string.IsNullOrEmpty(translateResult))
  3322. {
  3323. str = translateResult;
  3324. str = _airTicketResRep.Processing(str);
  3325. }
  3326. table.Range.Bookmarks["ClientName"].Text = str;
  3327. }
  3328. else
  3329. {
  3330. table.Range.Bookmarks["ClientName"].Text = "--";
  3331. }
  3332. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3333. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3334. table.Range.Bookmarks["JointTicket"].Text = "--";
  3335. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3336. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3337. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3338. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3339. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3340. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3341. #endregion
  3342. #region 循环数据处理
  3343. List<AirInfo> airs = new List<AirInfo>();
  3344. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3345. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3346. for (int i = 0; i < FlightsCode.Length; i++)
  3347. {
  3348. AirInfo air = new AirInfo();
  3349. string[] tempstr = DayArray[i]
  3350. .Replace("\r\n", string.Empty)
  3351. .Replace("\\r\\n", string.Empty)
  3352. .TrimStart().TrimEnd()
  3353. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3354. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3355. string starCity = "";
  3356. if (star_Three != null)
  3357. {
  3358. string str2 = "--";
  3359. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3360. if (!string.IsNullOrEmpty(translateResult2))
  3361. {
  3362. str2 = translateResult2;
  3363. str2 = _airTicketResRep.Processing(str2);
  3364. }
  3365. starCity = str2;
  3366. }
  3367. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3368. string EndCity = "";
  3369. if (End_Three != null)
  3370. {
  3371. string str1 = "--";
  3372. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3373. if (!string.IsNullOrEmpty(translateResult1))
  3374. {
  3375. str1 = translateResult1;
  3376. str1 = _airTicketResRep.Processing(str1);
  3377. }
  3378. EndCity = str1;
  3379. }
  3380. air.Destination = starCity + "/" + EndCity;
  3381. air.Flight = FlightsCode[i];
  3382. string str = "--";
  3383. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3384. if (!string.IsNullOrEmpty(translateResult))
  3385. {
  3386. str = translateResult;
  3387. str = _airTicketResRep.Processing(str);
  3388. }
  3389. air.SeatingClass = str;
  3390. string dateTime = tempstr[2];
  3391. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3392. air.FlightDate = DateTemp;
  3393. air.DepartureTime = tempstr[5];
  3394. air.LandingTime = tempstr[6];
  3395. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3396. air.TicketStatus = "--";
  3397. air.Luggage = "--";
  3398. air.DepartureTerminal = "--";
  3399. air.LandingTerminal = "--";
  3400. airs.Add(air);
  3401. }
  3402. int row = 13;
  3403. for (int i = 0; i < airs.Count; i++)
  3404. {
  3405. if (airs.Count > 2)
  3406. {
  3407. for (int j = 0; j < airs.Count - 2; j++)
  3408. {
  3409. var CopyRow = table.Rows[12].Clone(true);
  3410. table.Rows.Add(CopyRow);
  3411. }
  3412. }
  3413. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3414. int index = 0;
  3415. foreach (PropertyInfo property in properties)
  3416. {
  3417. string value = property.GetValue(airs[i]).ToString();
  3418. Cell ishcel0 = table.Rows[row].Cells[index];
  3419. Paragraph p = new Paragraph(doc);
  3420. string s = value;
  3421. p.AppendChild(new Run(doc, s));
  3422. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3423. ishcel0.AppendChild(p);
  3424. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3425. //ishcel0.CellFormat.VerticalAlignment=
  3426. index++;
  3427. }
  3428. row++;
  3429. }
  3430. #endregion
  3431. Paragraph lastParagraph = new Paragraph(doc);
  3432. //第一个表格末尾加段落
  3433. table.ParentNode.InsertAfter(lastParagraph, table);
  3434. //复制第一个表格
  3435. Table cloneTable = (Table)table.Clone(true);
  3436. //在文档末尾段落后面加入复制的表格
  3437. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3438. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3439. {
  3440. int rownewsIndex = 13;
  3441. for (int i = 0; i < 2; i++)
  3442. {
  3443. var CopyRow = table.Rows[12].Clone(true);
  3444. table.Rows.RemoveAt(13);
  3445. table.Rows.Add(CopyRow);
  3446. rownewsIndex++;
  3447. }
  3448. }
  3449. else
  3450. {
  3451. table.Rows.RemoveAt(12);
  3452. }
  3453. cloneTable.Rows.RemoveAt(12);
  3454. }
  3455. if (_AirTicketReservations.Count != 0)
  3456. {
  3457. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3458. if (FlightsCode.Length != 0)
  3459. {
  3460. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3461. if (_AirCompany != null)
  3462. {
  3463. string str = "--";
  3464. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3465. if (!string.IsNullOrEmpty(translateResult))
  3466. {
  3467. str = translateResult;
  3468. str = _airTicketResRep.Processing(str);
  3469. }
  3470. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3471. }
  3472. else
  3473. {
  3474. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3475. }
  3476. }
  3477. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3478. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3479. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3480. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3481. string names = "";
  3482. foreach (string clientName in nameArray)
  3483. {
  3484. names += clientName + ",";
  3485. }
  3486. if (!string.IsNullOrWhiteSpace(names))
  3487. {
  3488. string str = "--";
  3489. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3490. if (!string.IsNullOrEmpty(translateResult))
  3491. {
  3492. str = translateResult;
  3493. str = _airTicketResRep.Processing(str);
  3494. }
  3495. table.Range.Bookmarks["ClientName"].Text = str;
  3496. }
  3497. else
  3498. {
  3499. table.Range.Bookmarks["ClientName"].Text = "--";
  3500. }
  3501. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3502. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3503. table.Range.Bookmarks["JointTicket"].Text = "--";
  3504. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3505. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3506. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3507. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3508. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3509. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3510. }
  3511. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3512. //保存合并后的文档
  3513. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3514. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3515. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3516. return Ok(JsonView(true, "成功!", rst));
  3517. }
  3518. }
  3519. }
  3520. catch (Exception ex)
  3521. {
  3522. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3523. throw;
  3524. }
  3525. }
  3526. #endregion
  3527. #region 团组增减款项 --> 其他款项
  3528. /// <summary>
  3529. /// 团组增减款项下拉框绑定
  3530. /// </summary>
  3531. /// <param name="dto"></param>
  3532. /// <returns></returns>
  3533. [HttpPost]
  3534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3535. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3536. {
  3537. #region 参数验证
  3538. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3539. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3540. #endregion
  3541. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3542. }
  3543. /// <summary>
  3544. /// 根据团组Id查询团组增减款项
  3545. /// </summary>
  3546. /// <param name="dto"></param>
  3547. /// <returns></returns>
  3548. [HttpPost]
  3549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3550. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3551. {
  3552. #region 参数验证
  3553. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3554. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3555. #endregion
  3556. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3557. }
  3558. /// <summary>
  3559. /// 团组增减款项操作(Status:1.新增,2.修改)
  3560. /// </summary>
  3561. /// <param name="dto"></param>
  3562. /// <returns></returns>
  3563. [HttpPost]
  3564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3565. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3566. {
  3567. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3568. if (groupData.Code != 200)
  3569. {
  3570. return Ok(JsonView(false, groupData.Msg));
  3571. }
  3572. #region 应用推送
  3573. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3574. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3575. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3576. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3577. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3578. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3579. //自动审核
  3580. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3581. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3582. //2024-10-21 新增LZ UID
  3583. var userIds = new List<int>() { 21 };
  3584. string title = $"系统通知";
  3585. string content = "";
  3586. var diId = dto.DiId;
  3587. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3588. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3589. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3590. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3591. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3592. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3593. #endregion
  3594. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3595. }
  3596. /// <summary>
  3597. /// 团组增减款项操作 删除
  3598. /// </summary>
  3599. /// <param name="dto"></param>
  3600. /// <returns></returns>
  3601. [HttpPost]
  3602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3603. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3604. {
  3605. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3606. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3607. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3608. if (res.Code == 0)
  3609. {
  3610. return Ok(JsonView(true, "删除成功!"));
  3611. }
  3612. return Ok(JsonView(false, "删除失败!"));
  3613. }
  3614. /// <summary>
  3615. /// 根据团组增减款项Id查询
  3616. /// </summary>
  3617. /// <param name="dto"></param>
  3618. /// <returns></returns>
  3619. [HttpPost]
  3620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3621. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3622. {
  3623. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3624. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3625. }
  3626. /// <summary>
  3627. /// 查询供应商名称
  3628. /// </summary>
  3629. /// <param name="dto"></param>
  3630. /// <returns></returns>
  3631. [HttpPost]
  3632. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3633. {
  3634. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3635. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3636. ?? new List<Grp_DecreasePayments>();
  3637. dbResult = dbResult.Distinct(new
  3638. ProductComparer()).ToList();
  3639. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3640. {
  3641. x.Id,
  3642. x.SupplierAddress,
  3643. x.SupplierArea,
  3644. x.SupplierContact,
  3645. x.SupplierContactNumber,
  3646. x.SupplierEmail,
  3647. x.SupplierName,
  3648. x.SupplierSocialAccount,
  3649. x.SupplierTypeId,
  3650. }).ToList());
  3651. return Ok(jw);
  3652. }
  3653. /// <summary>
  3654. /// 团组增减款项 OTA匹配
  3655. /// </summary>
  3656. /// <param name="file"></param>
  3657. /// <returns></returns>
  3658. [HttpPost]
  3659. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3660. {
  3661. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3662. string fileName = file.FileName;
  3663. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3664. {
  3665. return Ok(JsonView(false, "请上传Excel文件!"));
  3666. }
  3667. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3668. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3669. if (!Directory.Exists(path))
  3670. {
  3671. Directory.CreateDirectory(path);
  3672. }
  3673. var filePath = @$"{path}/{fileName}";
  3674. //保存文件
  3675. using (FileStream fs = System.IO.File.Create(filePath))
  3676. {
  3677. file.CopyTo(fs);
  3678. fs.Flush();
  3679. }
  3680. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3681. //读取ExcelFile
  3682. DataTable dt = ConvertExcelToDataTable(filePath);
  3683. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3684. dt.TableName = "TB";
  3685. //修改table列名
  3686. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3687. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3688. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3689. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3690. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3691. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3692. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3693. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3694. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3695. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3696. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3697. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3698. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3699. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3700. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3701. var otaOrderNos = new List<string>();
  3702. foreach (DataRow item in dt.Rows)
  3703. {
  3704. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3705. }
  3706. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3707. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3708. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3709. .Select((dp, di) => new
  3710. {
  3711. dp.PriceName,
  3712. dp.OTAOrderNo,
  3713. dp.FeeTotal,
  3714. di.TeamName,
  3715. })
  3716. .ToListAsync();
  3717. foreach (DataRow item in dt.Rows)
  3718. {
  3719. var otaOrderNo = item["OTAOrderNo"].ToString();
  3720. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3721. if (oaData == null) continue;
  3722. item["GroupName"] = oaData.TeamName;
  3723. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3724. }
  3725. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3726. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3727. List<DataTable> datas = new List<DataTable>();
  3728. datas.Add(dt);
  3729. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3730. return Ok(JsonView(true, "操作成功", new { url = url }));
  3731. }
  3732. #region
  3733. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3734. {
  3735. // 创建Workbook对象
  3736. Workbook workbook = new Workbook(excelFilePath);
  3737. // 获取第一个工作表
  3738. Worksheet worksheet = workbook.Worksheets[0];
  3739. // 将工作表转换为DataTable
  3740. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3741. return dataTable;
  3742. }
  3743. #endregion
  3744. #endregion
  3745. #region 文件上传、删除
  3746. /// <summary>
  3747. /// region 文件上传 可以带参数
  3748. /// </summary>
  3749. /// <param name="file"></param>
  3750. /// <returns></returns>
  3751. [HttpPost]
  3752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3753. public async Task<IActionResult> UploadProject(IFormFile file)
  3754. {
  3755. //var TypeName = Request.Headers["TypeName"].ToString();
  3756. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3757. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3758. ////文件名称
  3759. //string projectFileName = file.FileName;
  3760. ////上传的文件的路径
  3761. //string filePath = $"{fileDir}/{projectFileName}";
  3762. //if (TypeName == "A")//A代表团组增减款项
  3763. //{
  3764. // filePath = fileDir + $@"\团组增减款项相关文件";
  3765. // if (!Directory.Exists(filePath))
  3766. // {
  3767. // Directory.CreateDirectory(filePath);
  3768. // }
  3769. // //上传的文件的路径
  3770. // filePath += $@"\{projectFileName}";
  3771. //}
  3772. //else if (TypeName == "B")//B代表商邀相关文件
  3773. //{
  3774. // //上传的文件的路径
  3775. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3776. // if (!Directory.Exists(filePath))
  3777. // {
  3778. // Directory.CreateDirectory(filePath);
  3779. // }
  3780. // //上传的文件的路径
  3781. // filePath = $@"\{projectFileName}";
  3782. //}
  3783. //try
  3784. //{
  3785. // using (FileStream fs = System.IO.File.Create(filePath))
  3786. // {
  3787. // file.CopyTo(fs);
  3788. // fs.Flush();
  3789. // }
  3790. //}
  3791. //catch (Exception ex)
  3792. //{
  3793. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3794. //}
  3795. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3796. try
  3797. {
  3798. var TypeName = Request.Headers["TypeName"].ToString();
  3799. if (file != null)
  3800. {
  3801. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3802. //文件名称
  3803. string projectFileName = file.FileName;
  3804. //上传的文件的路径
  3805. string filePath = $"{fileDir}/{projectFileName}";
  3806. if (TypeName == "A")//A代表团组增减款项
  3807. {
  3808. if (!Directory.Exists(fileDir))
  3809. {
  3810. Directory.CreateDirectory(fileDir);
  3811. }
  3812. //上传的文件的路径
  3813. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3814. }
  3815. else if (TypeName == "B")//B代表商邀相关文件
  3816. {
  3817. if (!Directory.Exists(fileDir))
  3818. {
  3819. Directory.CreateDirectory(fileDir);
  3820. }
  3821. //上传的文件的路径
  3822. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3823. }
  3824. using (FileStream fs = System.IO.File.Create(filePath))
  3825. {
  3826. file.CopyTo(fs);
  3827. fs.Flush();
  3828. }
  3829. return Ok(JsonView(true, "上传成功!", projectFileName));
  3830. }
  3831. else
  3832. {
  3833. return Ok(JsonView(false, "上传失败!"));
  3834. }
  3835. }
  3836. catch (Exception ex)
  3837. {
  3838. return Ok(JsonView(false, "程序错误!"));
  3839. }
  3840. }
  3841. /// <summary>
  3842. /// 删除指定文件
  3843. /// </summary>
  3844. /// <param name="dto"></param>
  3845. /// <returns></returns>
  3846. [HttpPost]
  3847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3848. public async Task<IActionResult> DelFile(DelFileDto dto)
  3849. {
  3850. try
  3851. {
  3852. var TypeName = Request.Headers["TypeName"].ToString();
  3853. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3854. string filePath = "";
  3855. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3856. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3857. int id = 0;
  3858. if (TypeName == "A")
  3859. {
  3860. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3861. // 删除该文件
  3862. System.IO.File.Delete(filePath);
  3863. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3864. .Where(a => a.Id == dto.Id)
  3865. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3866. .ExecuteCommandAsync();
  3867. }
  3868. else if (TypeName == "B")
  3869. {
  3870. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3871. // 删除该文件
  3872. System.IO.File.Delete(filePath);
  3873. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3874. if (info != null)
  3875. {
  3876. string[] files = new string[] { };
  3877. if (!string.IsNullOrEmpty(info.Attachment))
  3878. {
  3879. try
  3880. {
  3881. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3882. }
  3883. catch (Exception)
  3884. {
  3885. files = new List<string>() { info.Attachment }.ToArray();
  3886. }
  3887. }
  3888. if (files.Length > 0)
  3889. {
  3890. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3891. string filePath2 = string.Empty;
  3892. if (files1.Length > 0)
  3893. {
  3894. filePath2 = JsonConvert.SerializeObject(files1);
  3895. }
  3896. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3897. .Where(a => a.Id == dto.Id)
  3898. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3899. .ExecuteCommandAsync();
  3900. }
  3901. }
  3902. }
  3903. if (id != 0)
  3904. {
  3905. return Ok(JsonView(true, "成功!"));
  3906. }
  3907. else
  3908. {
  3909. return Ok(JsonView(false, "失败!"));
  3910. }
  3911. }
  3912. catch (Exception ex)
  3913. {
  3914. return Ok(JsonView(false, "程序错误!"));
  3915. throw;
  3916. }
  3917. }
  3918. /// <summary>
  3919. /// 文件上传多个文件 可以带参数
  3920. /// </summary>
  3921. /// <param name="files"></param>
  3922. /// <returns></returns>
  3923. [HttpPost]
  3924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3925. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3926. {
  3927. try
  3928. {
  3929. var TypeName = Request.Headers["TypeName"].ToString();
  3930. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3931. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3932. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3933. var filePahts = new List<string>();
  3934. foreach (var file in files)
  3935. {
  3936. //文件名称
  3937. string projectFileName = file.FileName;
  3938. //上传的文件的路径
  3939. string filePath = $"{fileDir}/{projectFileName}";
  3940. if (TypeName == "A")//A代表团组增减款项
  3941. {
  3942. if (!Directory.Exists(fileDir))
  3943. {
  3944. Directory.CreateDirectory(fileDir);
  3945. }
  3946. //上传的文件的路径
  3947. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3948. }
  3949. else if (TypeName == "B")//B代表商邀相关文件
  3950. {
  3951. if (!Directory.Exists(fileDir))
  3952. {
  3953. Directory.CreateDirectory(fileDir);
  3954. }
  3955. //上传的文件的路径
  3956. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3957. }
  3958. using (FileStream fs = System.IO.File.Create(filePath))
  3959. {
  3960. file.CopyTo(fs);
  3961. fs.Flush();
  3962. }
  3963. filePahts.Add(projectFileName);
  3964. }
  3965. return Ok(JsonView(true, "上传成功!", filePahts));
  3966. }
  3967. catch (Exception ex)
  3968. {
  3969. return Ok(JsonView(false, "程序错误!"));
  3970. }
  3971. }
  3972. #endregion
  3973. #region 商邀费用录入
  3974. /// <summary>
  3975. /// 根据团组Id查询商邀费用列表
  3976. /// </summary>
  3977. /// <param name="dto"></param>
  3978. /// <returns></returns>
  3979. [HttpPost]
  3980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3981. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3982. {
  3983. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3984. if (groupData.Code != 0)
  3985. {
  3986. return Ok(JsonView(false, groupData.Msg));
  3987. }
  3988. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3989. }
  3990. /// <summary>
  3991. /// 商邀费用列表
  3992. /// 下载文件
  3993. /// </summary>
  3994. /// <param name="id"></param>
  3995. /// <returns></returns>
  3996. [HttpGet("{id}")]
  3997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3998. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3999. {
  4000. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4001. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4002. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4003. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4004. var filePaths = new List<string>();
  4005. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4006. try
  4007. {
  4008. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4009. }
  4010. catch (Exception ex)
  4011. {
  4012. filePaths.Add(info.Attachment);
  4013. }
  4014. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4015. for (int i = 0; i < filePaths.Count; i++)
  4016. {
  4017. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4018. }
  4019. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4020. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4021. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4022. {
  4023. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4024. {
  4025. foreach (string filePath in filePaths)
  4026. {
  4027. if (System.IO.File.Exists(filePath))
  4028. {
  4029. // 获取文件名
  4030. string fileName = Path.GetFileName(filePath);
  4031. // 将文件添加到ZIP归档中
  4032. zipArchive.CreateEntryFromFile(filePath, fileName);
  4033. }
  4034. }
  4035. }
  4036. }
  4037. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4038. }
  4039. /// <summary>
  4040. /// 商邀费用 Info Page 基础数据源
  4041. /// </summary>
  4042. /// <returns></returns>
  4043. [HttpPost]
  4044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4045. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4046. {
  4047. try
  4048. {
  4049. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4050. if (groupData.Code != 0)
  4051. {
  4052. return Ok(JsonView(false, groupData.Msg));
  4053. }
  4054. return Ok(JsonView(true, "操作成功", groupData.Data));
  4055. }
  4056. catch (Exception ex)
  4057. {
  4058. return Ok(JsonView(false, ex.Message));
  4059. throw;
  4060. }
  4061. }
  4062. /// <summary>
  4063. /// 根据商邀费用ID查询C表和商邀费用数据
  4064. /// </summary>
  4065. /// <param name="dto"></param>
  4066. /// <returns></returns>
  4067. [HttpPost]
  4068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4069. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4070. {
  4071. try
  4072. {
  4073. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4074. if (groupData.Code != 0)
  4075. {
  4076. return Ok(JsonView(false, groupData.Msg));
  4077. }
  4078. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4079. }
  4080. catch (Exception ex)
  4081. {
  4082. return Ok(JsonView(false, ex.Message));
  4083. throw;
  4084. }
  4085. }
  4086. /// <summary>
  4087. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4088. /// </summary>
  4089. /// <param name="dto"></param>
  4090. /// <returns></returns>
  4091. [HttpPost]
  4092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4093. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4094. {
  4095. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4096. if (groupData.Code != 0)
  4097. {
  4098. return Ok(JsonView(false, groupData.Msg));
  4099. }
  4100. #region 应用推送
  4101. try
  4102. {
  4103. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4104. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4105. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4106. //2024-10-21 新增LZ UID
  4107. var userIds = new List<int>() { 21 };
  4108. string title = $"系统通知";
  4109. string content = "";
  4110. var diId = dto.DiId;
  4111. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4112. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4113. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4114. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4115. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4116. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4117. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4118. }
  4119. catch (Exception ex)
  4120. {
  4121. }
  4122. #endregion
  4123. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4124. }
  4125. /// <summary>
  4126. /// 商邀删除
  4127. /// </summary>
  4128. /// <param name="dto"></param>
  4129. /// <returns></returns>
  4130. [HttpPost]
  4131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4132. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4133. {
  4134. try
  4135. {
  4136. _sqlSugar.BeginTran();
  4137. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4138. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4139. {
  4140. IsDel = 1,
  4141. DeleteUserId = dto.DeleteUserId,
  4142. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4143. })
  4144. .Where(it => it.Id == dto.Id)
  4145. .ExecuteCommand();
  4146. if (res1 > 0)
  4147. {
  4148. int _diId = 0;
  4149. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4150. if (_ioaInfo != null)
  4151. {
  4152. _diId = _ioaInfo.DiId;
  4153. }
  4154. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4155. .SetColumns(a => new Grp_CreditCardPayment()
  4156. {
  4157. IsDel = 1,
  4158. DeleteUserId = dto.DeleteUserId,
  4159. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4160. })
  4161. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4162. .ExecuteCommand();
  4163. if (res2 > 0)
  4164. {
  4165. _sqlSugar.CommitTran();
  4166. return Ok(JsonView(true, "删除成功!"));
  4167. }
  4168. }
  4169. _sqlSugar.RollbackTran();
  4170. return Ok(JsonView(false, "删除失败"));
  4171. }
  4172. catch (Exception ex)
  4173. {
  4174. _sqlSugar.RollbackTran();
  4175. return Ok(JsonView(false, ex.Message));
  4176. }
  4177. }
  4178. /// <summary>
  4179. /// 团组模块文件上传
  4180. /// </summary>
  4181. /// <param name="dto"></param>
  4182. /// <returns></returns>
  4183. [HttpPost]
  4184. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4185. {
  4186. var jw = JsonView(false);
  4187. long M = 1024 * 1024;
  4188. if (dto.Files == null || dto.Files.Count == 0)
  4189. {
  4190. jw.Msg = "无文件信息!";
  4191. return Ok(jw);
  4192. }
  4193. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4194. {
  4195. jw.Msg = "文件大小超过20M!";
  4196. return Ok(jw);
  4197. }
  4198. //var nameSp = dto.File.FileName.Split(".");
  4199. //if (nameSp.Length < 2)
  4200. //{
  4201. // jw.Msg = "拓展名称有误!";
  4202. // return Ok(jw);
  4203. //}
  4204. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4205. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4206. //{
  4207. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4208. // return Ok(jw);
  4209. //}
  4210. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4211. if (Ctable == null)
  4212. {
  4213. jw.Msg = "Ctable指向有误!";
  4214. return Ok(jw);
  4215. }
  4216. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4217. if (groupInfo == null)
  4218. {
  4219. jw.Msg = "团组信息不存在!";
  4220. return Ok(jw);
  4221. }
  4222. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4223. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4224. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4225. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4226. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4227. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4228. try
  4229. {
  4230. if (!Directory.Exists(fileBase))
  4231. {
  4232. Directory.CreateDirectory(fileBase);
  4233. }
  4234. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4235. foreach (var fileStream in dto.Files)
  4236. {
  4237. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4238. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4239. {
  4240. Cid = dto.Cid,
  4241. CreateTime = DateTime.Now,
  4242. CreateUserId = dto.Userid,
  4243. Ctable = dto.Ctable,
  4244. Diid = dto.Diid,
  4245. IsDel = 0,
  4246. FilePath = saveFilePath,
  4247. FileName = fileStream.FileName
  4248. };
  4249. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4250. {
  4251. fileStream.CopyTo(fs);
  4252. fs.Flush();
  4253. }
  4254. saveArr.Add(file);
  4255. }
  4256. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4257. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4258. jw = JsonView(true, "保存成功!", new
  4259. {
  4260. count = addResult,
  4261. filesName = saveArr.Select(x => x.FileName)
  4262. });
  4263. }
  4264. catch (Exception ex)
  4265. {
  4266. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4267. {
  4268. count = 0,
  4269. filesName = new string[0],
  4270. });
  4271. }
  4272. return Ok(jw);
  4273. }
  4274. /// <summary>
  4275. /// 查询各模块已保存文件
  4276. /// </summary>
  4277. /// <param name="dto"></param>
  4278. /// <returns></returns>
  4279. [HttpPost]
  4280. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4281. {
  4282. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4283. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4284. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4285. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4286. {
  4287. expression = Expressionable.Create<Grp_GroupModelFile>()
  4288. .And(x => visaIds.Contains(x.CreateUserId));
  4289. }
  4290. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4291. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4292. .Where(expression.ToExpression())
  4293. .ToList();
  4294. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4295. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4296. {
  4297. x.FileName,
  4298. x.Id,
  4299. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4300. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4301. })));
  4302. }
  4303. /// <summary>
  4304. /// 下载该团组下的所有文件
  4305. /// </summary>
  4306. /// <param name="dto"></param>
  4307. /// <returns></returns>
  4308. [HttpPost]
  4309. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4310. {
  4311. var jw = JsonView(false);
  4312. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4313. if (groupInfo == null)
  4314. {
  4315. jw.Msg = "团组信息不存在!";
  4316. return Ok(jw);
  4317. }
  4318. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4319. var isModule = Convert.ToBoolean(dto.isModule);
  4320. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4321. IOOperatorHelper io = new IOOperatorHelper();
  4322. if (isModule)
  4323. {
  4324. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4325. foreach (var moduleArr in moduleGroup)
  4326. {
  4327. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4328. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4329. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4330. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4331. foreach (var item in moduleArr)
  4332. {
  4333. if (System.IO.File.Exists(item.FilePath))
  4334. {
  4335. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4336. {
  4337. byte[] bytes = new byte[fileStream.Length];
  4338. fileStream.Read(bytes, 0, bytes.Length);
  4339. fileStream.Close();
  4340. Stream stream = new MemoryStream(bytes);
  4341. chiZips.Add(item.FileName, stream);
  4342. }
  4343. }
  4344. }
  4345. if (chiZips.Count > 0)
  4346. {
  4347. var byts = io.ConvertZipStream(chiZips);
  4348. Stream stream = new MemoryStream(byts);
  4349. Zips.Add(key.Name + "_.zip", stream);
  4350. }
  4351. }
  4352. }
  4353. else
  4354. {
  4355. foreach (var item in dbQuery)
  4356. {
  4357. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4358. {
  4359. byte[] bytes = new byte[fileStream.Length];
  4360. fileStream.Read(bytes, 0, bytes.Length);
  4361. fileStream.Close();
  4362. Stream stream = new MemoryStream(bytes);
  4363. while (Zips.Keys.Contains(item.FileName))
  4364. {
  4365. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4366. }
  4367. Zips.Add(item.FileName, stream);
  4368. }
  4369. }
  4370. }
  4371. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4372. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4373. if (Zips.Count > 0)
  4374. {
  4375. var byts = io.ConvertZipStream(Zips);
  4376. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4377. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4378. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4379. }
  4380. else
  4381. {
  4382. jw.Msg = "暂无生成文件!";
  4383. }
  4384. return Ok(jw);
  4385. }
  4386. /// <summary>
  4387. /// 下载该团组下此模块的所有文件
  4388. /// </summary>
  4389. /// <param name="dto"></param>
  4390. /// <returns></returns>
  4391. [HttpPost]
  4392. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4393. {
  4394. var jw = JsonView(false);
  4395. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4396. if (groupInfo == null)
  4397. {
  4398. jw.Msg = "团组信息不存在!";
  4399. return Ok(jw);
  4400. }
  4401. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4402. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4403. && x.IsDel == 0);
  4404. if (key == null)
  4405. {
  4406. jw.Msg = "Ctable指向错误!";
  4407. return Ok(jw);
  4408. }
  4409. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4410. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4411. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4412. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4413. IOOperatorHelper io = new IOOperatorHelper();
  4414. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4415. foreach (var item in dbQuery)
  4416. {
  4417. if (System.IO.File.Exists(item.FilePath))
  4418. {
  4419. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4420. {
  4421. byte[] bytes = new byte[fileStream.Length];
  4422. fileStream.Read(bytes, 0, bytes.Length);
  4423. fileStream.Close();
  4424. Stream stream = new MemoryStream(bytes);
  4425. while (Zips.Keys.Contains(item.FileName))
  4426. {
  4427. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4428. }
  4429. Zips.Add(item.FileName, stream);
  4430. }
  4431. }
  4432. }
  4433. if (Zips.Count > 0)
  4434. {
  4435. var byts = io.ConvertZipStream(Zips);
  4436. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4437. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4438. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4439. }
  4440. else
  4441. {
  4442. jw.Msg = "暂无生成文件!";
  4443. }
  4444. return Ok(jw);
  4445. }
  4446. /// <summary>
  4447. /// 删除该团组下的指定文件
  4448. /// </summary>
  4449. /// <param name="dto"></param>
  4450. /// <returns></returns>
  4451. [HttpPost]
  4452. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4453. {
  4454. var jw = JsonView(false);
  4455. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4456. if (sing == null)
  4457. {
  4458. jw.Msg = "暂无";
  4459. return Ok(jw);
  4460. }
  4461. if (System.IO.File.Exists(sing.FilePath))
  4462. {
  4463. try
  4464. {
  4465. System.IO.File.Delete(sing.FilePath);
  4466. }
  4467. catch (Exception ex)
  4468. {
  4469. jw.Msg = "删除失败!" + ex.Message;
  4470. return Ok(jw);
  4471. }
  4472. }
  4473. sing.IsDel = 1;
  4474. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4475. sing.DeleteUserId = dto.UserId;
  4476. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4477. jw = JsonView(true, "删除成功!");
  4478. return Ok(jw);
  4479. }
  4480. #endregion
  4481. #region 团组英文资料
  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> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4490. {
  4491. try
  4492. {
  4493. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4494. if (groupData.Code != 0)
  4495. {
  4496. return Ok(JsonView(false, groupData.Msg));
  4497. }
  4498. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4499. }
  4500. catch (Exception ex)
  4501. {
  4502. return Ok(JsonView(false, "程序错误!"));
  4503. throw;
  4504. }
  4505. }
  4506. /// <summary>
  4507. /// 团组英文资料操作(Status:1.新增,2.修改)
  4508. /// </summary>
  4509. /// <param name="dto"></param>
  4510. /// <returns></returns>
  4511. [HttpPost]
  4512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4513. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4514. {
  4515. try
  4516. {
  4517. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4518. if (groupData.Code != 0)
  4519. {
  4520. return Ok(JsonView(false, groupData.Msg));
  4521. }
  4522. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4523. }
  4524. catch (Exception ex)
  4525. {
  4526. return Ok(JsonView(false, "程序错误!"));
  4527. throw;
  4528. }
  4529. }
  4530. /// <summary>
  4531. /// 团组英文资料Id查询数据
  4532. /// </summary>
  4533. /// <param name="dto"></param>
  4534. /// <returns></returns>
  4535. [HttpPost]
  4536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4537. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4538. {
  4539. try
  4540. {
  4541. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4542. if (_DelegationEnData != null)
  4543. {
  4544. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4545. }
  4546. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4547. }
  4548. catch (Exception ex)
  4549. {
  4550. return Ok(JsonView(false, "程序错误!"));
  4551. throw;
  4552. }
  4553. }
  4554. /// <summary>
  4555. /// 团组英文资料删除
  4556. /// </summary>
  4557. /// <param name="dto"></param>
  4558. /// <returns></returns>
  4559. [HttpPost]
  4560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4561. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4562. {
  4563. try
  4564. {
  4565. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4566. if (!res)
  4567. {
  4568. return Ok(JsonView(false, "删除失败"));
  4569. }
  4570. return Ok(JsonView(true, "删除成功!"));
  4571. }
  4572. catch (Exception ex)
  4573. {
  4574. return Ok(JsonView(false, "程序错误!"));
  4575. throw;
  4576. }
  4577. }
  4578. #endregion
  4579. #region 导出邀请函
  4580. /// <summary>
  4581. /// 导出邀请函页面初始化
  4582. /// </summary>
  4583. /// <param name="dto"></param>
  4584. /// <returns></returns>
  4585. [HttpPost]
  4586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4587. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4588. {
  4589. try
  4590. {
  4591. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  4592. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4593. if (dto.DiId == 0)
  4594. {
  4595. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4596. }
  4597. else
  4598. {
  4599. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4600. }
  4601. return Ok(JsonView(true, "查询成功!", new
  4602. {
  4603. deleClient = crm_Deles,
  4604. delegations = grp_Delegations
  4605. }));
  4606. }
  4607. catch (Exception ex)
  4608. {
  4609. return Ok(JsonView(false, "程序错误!"));
  4610. throw;
  4611. }
  4612. }
  4613. /// <summary>
  4614. /// 导出邀请函
  4615. /// </summary>
  4616. /// <param name="dto"></param>
  4617. /// <returns></returns>
  4618. [HttpPost]
  4619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4620. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4621. {
  4622. #region 参数验证
  4623. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4624. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4625. #endregion
  4626. try
  4627. {
  4628. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4629. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4630. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4631. From Grp_TourClientList tcl
  4632. Left Join
  4633. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4634. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4635. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4636. From Crm_DeleClient dc
  4637. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4638. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4639. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4640. Where dc.IsDel = 0) temp
  4641. On temp.DcId =tcl.ClientId
  4642. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4643. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4644. List<string> texts = new List<string>();
  4645. if (datas.Count != 0)
  4646. {
  4647. foreach (TourClientListDetailsView item in datas)
  4648. {
  4649. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4650. {
  4651. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4652. }
  4653. else
  4654. {
  4655. string name = item.LastName + item.FirstName;
  4656. texts.Add(name);
  4657. }
  4658. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4659. {
  4660. if (!transDic.ContainsKey(item.Job))
  4661. {
  4662. texts.Add(item.Job);
  4663. }
  4664. }
  4665. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4666. {
  4667. texts.Add(item.CompanyFullName);
  4668. }
  4669. }
  4670. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4671. if (transData.Count > 0)
  4672. {
  4673. foreach (TranslateResult item in transData)
  4674. {
  4675. if (!transDic.ContainsKey(item.Query))
  4676. {
  4677. transDic.Add(item.Query, item.Translation);
  4678. }
  4679. }
  4680. }
  4681. List<GuestList> list = new List<GuestList>();
  4682. foreach (TourClientListDetailsView dele in datas)
  4683. {
  4684. GuestList guestList = new GuestList();
  4685. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4686. {
  4687. guestList.Name = dele.Pinyin;
  4688. }
  4689. else
  4690. {
  4691. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4692. guestList.Name = Name;
  4693. }
  4694. if (dele.Sex == 0)
  4695. {
  4696. guestList.Sex = "Male";
  4697. }
  4698. else if (dele.Sex == 1)
  4699. {
  4700. guestList.Sex = "Female";
  4701. }
  4702. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4703. if (!string.IsNullOrEmpty(dele.Job))
  4704. {
  4705. guestList.Job = dele.Job;
  4706. }
  4707. list.Add(guestList);
  4708. }
  4709. //载入模板
  4710. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4711. DocumentBuilder builder = new DocumentBuilder(doc);
  4712. //获取word里所有表格
  4713. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4714. //获取所填表格的序数
  4715. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4716. var rowStart = tableOne.Rows[0]; //获取第1行
  4717. //循环赋值
  4718. for (int i = 0; i < list.Count; i++)
  4719. {
  4720. builder.MoveToCell(0, i + 1, 0, 0);
  4721. builder.Write(list[i].Name.ToString());
  4722. builder.MoveToCell(0, i + 1, 1, 0);
  4723. builder.Write(list[i].Sex.ToString());
  4724. builder.MoveToCell(0, i + 1, 2, 0);
  4725. builder.Write(list[i].DOB.ToString());
  4726. builder.MoveToCell(0, i + 1, 3, 0);
  4727. builder.Write(list[i].Job.ToString());
  4728. }
  4729. //删除多余行
  4730. while (tableOne.Rows.Count > list.Count + 1)
  4731. {
  4732. tableOne.Rows.RemoveAt(list.Count + 1);
  4733. }
  4734. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4735. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4736. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4737. doc.Save(filePath);
  4738. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4739. return Ok(JsonView(true, "操作成功!", Url));
  4740. }
  4741. else
  4742. {
  4743. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4744. }
  4745. }
  4746. catch (Exception ex)
  4747. {
  4748. return Ok(JsonView(false, ex.Message));
  4749. throw;
  4750. }
  4751. }
  4752. #endregion
  4753. #region 团组经理模块 出入境费用
  4754. /// <summary>
  4755. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4756. /// </summary>
  4757. /// <returns></returns>
  4758. [HttpPost]
  4759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4760. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4761. {
  4762. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4763. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4764. //SetDataInfoView
  4765. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4766. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4767. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4768. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4769. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4770. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4771. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4772. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4773. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4774. return Ok(JsonView(true, "查询成功!", new
  4775. {
  4776. GroupNameData = groupNameData.Data,
  4777. CurrencyData = _CurrencyData,
  4778. WordTypeData = _WordTypeData,
  4779. ExcelTypeData = _ExcelTypeData,
  4780. CurrencyInit = _currencyInfos,
  4781. ViewPermissionData = viewPermissionData
  4782. }));
  4783. }
  4784. /// <summary>
  4785. /// 团组模块 - 出入境费用
  4786. /// 实时汇率 tips
  4787. /// 签证费用 tips
  4788. /// 机票费用 tips
  4789. /// </summary>
  4790. /// <returns></returns>
  4791. [HttpPost]
  4792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4793. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4794. {
  4795. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4796. //默认币种显示
  4797. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4798. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  4799. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4800. return Ok(JsonView(true, "查询成功!", new
  4801. {
  4802. //GroupNameData = groupNameData.Data,
  4803. visaData = visaData.Data,
  4804. airData = airData.Data,
  4805. reteInfos = reteInfos
  4806. }));
  4807. }
  4808. /// <summary>
  4809. /// 团组模块 - 出入境费用 - Info
  4810. /// </summary>
  4811. /// <returns></returns>
  4812. [HttpPost]
  4813. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4815. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4816. {
  4817. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4818. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4819. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4820. }
  4821. /// <summary>
  4822. /// 团组模块 - 出入境费用 - 设置view权限
  4823. /// </summary>
  4824. /// <returns></returns>
  4825. [HttpPost]
  4826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4827. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4828. {
  4829. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4830. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4831. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4832. var permissions = new List<Grp_EnterExitCostPermission>();
  4833. foreach (var userId in dto.UserIds)
  4834. {
  4835. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4836. }
  4837. if (permissions.Any())
  4838. {
  4839. _sqlSugar.BeginTran();
  4840. try
  4841. {
  4842. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4843. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4844. if (result < 1)
  4845. {
  4846. _sqlSugar.RollbackTran();
  4847. return Ok(JsonView(false));
  4848. }
  4849. }
  4850. catch (Exception ex)
  4851. {
  4852. _sqlSugar.RollbackTran();
  4853. return Ok(JsonView(false, ex.Message));
  4854. }
  4855. _sqlSugar.CommitTran();
  4856. return Ok(JsonView(true));
  4857. }
  4858. return Ok(JsonView(false));
  4859. }
  4860. /// <summary>
  4861. /// 团组模块 - 出入境费用 - Add And Update
  4862. /// </summary>
  4863. /// <returns></returns>
  4864. [HttpPost]
  4865. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  4866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4867. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4868. {
  4869. try
  4870. {
  4871. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4872. if (dto.DayOtherPriceData.Any())
  4873. {
  4874. var inserList = dto.DayOtherPriceData
  4875. .Where(x => x.Id == 0)
  4876. .Select(x => new Grp_DayOtherPrice
  4877. {
  4878. Cost = x.Cost,
  4879. Id = x.Id,
  4880. CreateTime = DateTime.Now,
  4881. CreateUserId = dto.UserId,
  4882. Currency = x.Currency,
  4883. Diid = x.DiId,
  4884. Index = x.Index,
  4885. IsDel = 0,
  4886. SetDataId = x.SetDataId,
  4887. SubTotal = x.SubTotal,
  4888. Remark = x.Remark
  4889. })
  4890. .ToList();
  4891. var updateList = dto.DayOtherPriceData
  4892. .Where(x => x.Id != 0)
  4893. .Select(x => new Grp_DayOtherPrice
  4894. {
  4895. Cost = x.Cost,
  4896. Id = x.Id,
  4897. CreateTime = DateTime.Now,
  4898. CreateUserId = dto.UserId,
  4899. Currency = x.Currency,
  4900. Diid = x.DiId,
  4901. Index = x.Index,
  4902. IsDel = 0,
  4903. SetDataId = x.SetDataId,
  4904. SubTotal = x.SubTotal,
  4905. Remark = x.Remark
  4906. })
  4907. .ToList();
  4908. //添加
  4909. _sqlSugar.BeginTran();
  4910. if (inserList.Any())
  4911. {
  4912. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4913. }
  4914. if (updateList.Any())
  4915. {
  4916. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4917. }
  4918. _sqlSugar.CommitTran();
  4919. }
  4920. if (data.Code != 0)
  4921. {
  4922. return Ok(JsonView(false, data.Msg));
  4923. }
  4924. //生成默认文件pdf并且通知人员
  4925. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4926. {
  4927. DiId = dto.DiId,
  4928. ExportType = 1,
  4929. SubTypeId = 1005
  4930. }, "pdf");
  4931. //发送通知
  4932. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4933. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4934. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4935. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4936. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4937. //汇率信息记录
  4938. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4939. return Ok(JsonView(true, data.Msg, data.Data));
  4940. }
  4941. catch (Exception ex)
  4942. {
  4943. return Ok(JsonView(false, ex.Message));
  4944. }
  4945. }
  4946. /// <summary>
  4947. /// 团组模块 - 出入境费用 - Confirm 费用
  4948. /// </summary>
  4949. /// <returns></returns>
  4950. [HttpPost]
  4951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4952. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4953. {
  4954. //TODO:测试完毕需把对应的用户ID更改
  4955. //1、数据表添加字段
  4956. //2、更改字段接口()
  4957. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4958. //3、确认成功 给财务发送消息
  4959. if (_view.Code == 200)
  4960. {
  4961. if (dto.Type == 1)
  4962. {
  4963. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4964. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4965. }
  4966. }
  4967. return Ok(_view);
  4968. }
  4969. /// <summary>
  4970. /// 团组模块 - 出入境费用 - File download
  4971. /// </summary>
  4972. /// <param name="dto"></param>
  4973. /// <returns></returns>
  4974. [HttpPost]
  4975. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  4976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4977. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4978. {
  4979. try
  4980. {
  4981. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4982. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4983. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4984. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4985. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4986. 3 团组成员名单 1 团组成员名单", ""));
  4987. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4988. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4989. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4990. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  4991. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  4992. //数据源
  4993. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4994. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4995. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4996. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4997. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4998. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4999. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5000. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5001. .Select((x, a, b) => new
  5002. {
  5003. x.Index,
  5004. itemName = a.Name,
  5005. CurrencyStr = b.Name,
  5006. x.Cost,
  5007. x.SubTotal,
  5008. x.Remark
  5009. })
  5010. .OrderBy((x) => x.Index)
  5011. .ToList(); //其他款项费用
  5012. var peiceItemCurrencys = new List<string>();
  5013. if (_DayAndCosts.Any())
  5014. {
  5015. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5016. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5017. }
  5018. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5019. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5020. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5021. {
  5022. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5023. }
  5024. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5025. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5026. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5027. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5028. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5029. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5030. .Select((tcl, dc, cc) => new ClientInfo
  5031. {
  5032. LastName = dc.LastName,
  5033. FirstName = dc.FirstName,
  5034. Sex = dc.Sex,
  5035. Birthday = dc.BirthDay,
  5036. Company = cc.CompanyFullName,
  5037. Job = dc.Job
  5038. })
  5039. .ToList();
  5040. foreach (var item in DeleClientList)
  5041. {
  5042. EncryptionProcessor.DecryptProperties(item);
  5043. }
  5044. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5045. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5046. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5047. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5048. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5049. if (dto.ExportType == 1) //明细表
  5050. {
  5051. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5052. {
  5053. //获取模板
  5054. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5055. //载入模板
  5056. Document doc = new Document(tempPath);
  5057. DocumentBuilder builder = new DocumentBuilder(doc);
  5058. //利用键值对存放数据
  5059. Dictionary<string, string> dic = new Dictionary<string, string>();
  5060. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5061. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5062. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5063. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5064. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5065. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5066. //境内费用(其他费用)
  5067. if (_EnterExitCosts.ChoiceOne == 1)
  5068. {
  5069. string row1_1 = "";
  5070. if (_EnterExitCosts.Visa > 0)
  5071. {
  5072. //insidePayTotal += _EnterExitCosts.Visa;
  5073. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5074. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5075. {
  5076. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5077. }
  5078. }
  5079. string row1_2 = "";
  5080. if (_EnterExitCosts.YiMiao > 0)
  5081. {
  5082. //insidePayTotal += _EnterExitCosts.YiMiao;
  5083. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5084. }
  5085. if (_EnterExitCosts.HeSuan > 0)
  5086. {
  5087. //insidePayTotal += _EnterExitCosts.HeSuan;
  5088. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5089. }
  5090. if (_EnterExitCosts.Service > 0)
  5091. {
  5092. //insidePayTotal += _EnterExitCosts.Service;
  5093. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5094. }
  5095. string row1_3 = "";
  5096. if (_EnterExitCosts.Safe > 0)
  5097. {
  5098. //insidePayTotal += _EnterExitCosts.Safe;
  5099. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5100. }
  5101. if (_EnterExitCosts.Ticket > 0)
  5102. {
  5103. //insidePayTotal += _EnterExitCosts.Ticket;
  5104. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5105. }
  5106. string row1 = "";
  5107. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5108. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5109. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5110. row1 += $"备注:{_EnterExitCosts.Remark}";
  5111. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5112. dic.Add("Row1Str", row1);
  5113. }
  5114. string airTotalStr = string.Empty,
  5115. airPriceStr = string.Empty;
  5116. //经济舱
  5117. if (_EnterExitCosts.SumJJC == 1)
  5118. {
  5119. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5120. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5121. }
  5122. //公务舱
  5123. if (_EnterExitCosts.SumGWC == 1)
  5124. {
  5125. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5126. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5127. }
  5128. //头等舱
  5129. if (_EnterExitCosts.SumTDC == 1)
  5130. {
  5131. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5132. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5133. }
  5134. //汇率描述
  5135. string rateStr = "";
  5136. if (peiceItemCurrencyInfos.Any())
  5137. {
  5138. rateStr = "\r\n汇率描述:";
  5139. foreach (var item in peiceItemCurrencyInfos)
  5140. {
  5141. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5142. }
  5143. }
  5144. string twoItemRemark = "备注:";
  5145. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5146. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5147. dic.Add("AirTotalStr", airTotalStr);
  5148. dic.Add("AirPriceStr", airPriceStr);
  5149. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5150. dic.Add("TwoItemRemark", twoItemRemark);
  5151. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5152. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5153. int table1Row = 0,
  5154. table2Row = 0,
  5155. table3Row = 0,
  5156. table4Row = 0,
  5157. table5Row = 0;
  5158. //住宿费
  5159. if (_EnterExitCosts.ChoiceThree == 1)
  5160. {
  5161. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5162. table1Row = dac1.Count;
  5163. #region 填充word表格内容
  5164. for (int i = 0; i < dac1.Count; i++)
  5165. {
  5166. Grp_DayAndCost dac = dac1[i];
  5167. if (dac == null) continue;
  5168. builder.MoveToCell(0, i, 0, 0);
  5169. builder.Write("第" + dac.Days.ToString() + "晚:");
  5170. builder.MoveToCell(0, i, 1, 0);
  5171. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5172. //builder.Write(dac.Place == null ? "" : dac.Place);
  5173. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5174. builder.MoveToCell(0, i, 2, 0);
  5175. builder.Write("费用标准:");
  5176. string curr = "";
  5177. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5178. if (currData != null)
  5179. {
  5180. curr = currData.Name;
  5181. }
  5182. builder.MoveToCell(0, i, 3, 0);
  5183. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5184. builder.MoveToCell(0, i, 4, 0);
  5185. builder.Write("费用小计:");
  5186. builder.MoveToCell(0, i, 5, 0);
  5187. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5188. }
  5189. #endregion
  5190. }
  5191. else dic.Add("SubZS", "0.00");
  5192. //删除多余行
  5193. while (table1.Rows.Count > table1Row)
  5194. {
  5195. table1.Rows.RemoveAt(table1Row);
  5196. }
  5197. //伙食费
  5198. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5199. if (_EnterExitCosts.ChoiceFour == 1)
  5200. {
  5201. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5202. table2Row = dac2.Count;
  5203. #region 填充word表格内容
  5204. for (int i = 0; i < dac2.Count; i++)
  5205. {
  5206. Grp_DayAndCost dac = dac2[i];
  5207. if (dac == null) continue;
  5208. builder.MoveToCell(1, i, 0, 0);
  5209. builder.Write("第" + dac.Days.ToString() + "天:");
  5210. builder.MoveToCell(1, i, 1, 0);
  5211. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5212. builder.MoveToCell(1, i, 2, 0);
  5213. builder.Write("费用标准:");
  5214. string curr = "";
  5215. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5216. if (currData != null)
  5217. {
  5218. curr = currData.Name;
  5219. }
  5220. builder.MoveToCell(1, i, 3, 0);
  5221. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5222. builder.MoveToCell(1, i, 4, 0);
  5223. builder.Write("费用小计:");
  5224. builder.MoveToCell(1, i, 5, 0);
  5225. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5226. }
  5227. #endregion
  5228. }
  5229. else dic.Add("SubHS", "0.00");
  5230. //删除多余行
  5231. while (table2.Rows.Count > table2Row)
  5232. {
  5233. table2.Rows.RemoveAt(table2Row);
  5234. }
  5235. //公杂费
  5236. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5237. if (_EnterExitCosts.ChoiceFive == 1)
  5238. {
  5239. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5240. table3Row = dac3.Count;
  5241. #region 填充word表格内容
  5242. for (int i = 0; i < dac3.Count; i++)
  5243. {
  5244. Grp_DayAndCost dac = dac3[i];
  5245. if (dac == null) continue;
  5246. builder.MoveToCell(2, i, 0, 0);
  5247. builder.Write("第" + dac.Days.ToString() + "天:");
  5248. builder.MoveToCell(2, i, 1, 0);
  5249. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5250. builder.MoveToCell(2, i, 2, 0);
  5251. builder.Write("费用标准:");
  5252. string curr = "";
  5253. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5254. if (currData != null)
  5255. {
  5256. curr = currData.Name;
  5257. }
  5258. builder.MoveToCell(2, i, 3, 0);
  5259. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5260. builder.MoveToCell(2, i, 4, 0);
  5261. builder.Write("费用小计:");
  5262. builder.MoveToCell(2, i, 5, 0);
  5263. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5264. }
  5265. //删除多余行
  5266. while (table3.Rows.Count > table3Row)
  5267. {
  5268. table3.Rows.RemoveAt(table3Row);
  5269. }
  5270. #endregion
  5271. }
  5272. else dic.Add("SubGZF", "0.00");
  5273. //删除多余行
  5274. while (table3.Rows.Count > table3Row)
  5275. {
  5276. table3.Rows.RemoveAt(table3Row);
  5277. }
  5278. //培训费
  5279. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5280. if (_EnterExitCosts.ChoiceSix == 1)
  5281. {
  5282. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5283. dic.Add("SubPX", pxStr);
  5284. table4Row = dac4.Count;
  5285. #region 填充word表格内容
  5286. for (int i = 0; i < dac4.Count; i++)
  5287. {
  5288. Grp_DayAndCost dac = dac4[i];
  5289. if (dac == null) continue;
  5290. builder.MoveToCell(3, i, 0, 0);
  5291. builder.Write("第" + dac.Days.ToString() + "天:");
  5292. builder.MoveToCell(3, i, 1, 0);
  5293. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5294. builder.MoveToCell(3, i, 2, 0);
  5295. builder.Write("费用标准:");
  5296. string curr = "";
  5297. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5298. if (currData != null)
  5299. {
  5300. curr = currData.Name;
  5301. }
  5302. builder.MoveToCell(3, i, 3, 0);
  5303. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5304. builder.MoveToCell(3, i, 4, 0);
  5305. builder.Write("费用小计:");
  5306. builder.MoveToCell(3, i, 5, 0);
  5307. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5308. }
  5309. #endregion
  5310. }
  5311. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5312. //删除多余行
  5313. while (table4.Rows.Count > table4Row)
  5314. {
  5315. table4.Rows.RemoveAt(table4Row);
  5316. }
  5317. //其他费用
  5318. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5319. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5320. {
  5321. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5322. dic.Add("titleQi", qtStr);
  5323. table5Row = dac5.Count;
  5324. #region 填充word表格内容
  5325. for (int i = 0; i < dac5.Count; i++)
  5326. {
  5327. var dac = dac5[i];
  5328. if (dac == null) continue;
  5329. builder.MoveToCell(4, i, 0, 0);
  5330. builder.Write("第" + dac.Index.ToString() + "项:");
  5331. builder.MoveToCell(4, i, 1, 0);
  5332. builder.Write(dac.itemName);
  5333. builder.MoveToCell(4, i, 2, 0);
  5334. builder.Write("费用标准:");
  5335. builder.MoveToCell(4, i, 3, 0);
  5336. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5337. builder.MoveToCell(4, i, 4, 0);
  5338. builder.Write("费用小计:");
  5339. builder.MoveToCell(4, i, 5, 0);
  5340. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5341. builder.MoveToCell(4, i, 6, 0);
  5342. builder.Write("备注:");
  5343. builder.MoveToCell(4, i, 7, 0);
  5344. builder.Write(dac.Remark);
  5345. }
  5346. #endregion
  5347. }
  5348. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5349. //删除多余行
  5350. while (table5.Rows.Count > table5Row)
  5351. {
  5352. table5.Rows.RemoveAt(table5Row);
  5353. }
  5354. //加上其他费用
  5355. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5356. decimal subJJC = 0.00M,
  5357. subGWC = 0.00M,
  5358. subTDC = 0.00M;
  5359. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5360. string totalLabel = string.Format("全部费用总计:");
  5361. //经济舱
  5362. if (_EnterExitCosts.SumJJC == 1)
  5363. {
  5364. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5365. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5366. }
  5367. //公务舱
  5368. if (_EnterExitCosts.SumGWC == 1) {
  5369. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5370. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5371. }
  5372. //头等舱
  5373. if (_EnterExitCosts.SumTDC == 1)
  5374. {
  5375. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5376. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5377. }
  5378. //TotalLabel
  5379. dic.Add("TotalLabel", totalLabel);
  5380. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5381. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5382. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5383. #region 填充word模板书签内容
  5384. foreach (var key in dic.Keys)
  5385. {
  5386. Bookmark bookmark = doc.Range.Bookmarks[key];
  5387. if (bookmark != null)
  5388. {
  5389. builder.MoveToBookmark(key);
  5390. builder.Write(dic[key]);
  5391. }
  5392. }
  5393. #endregion
  5394. #region 设置页眉
  5395. string userLabel = string.Empty;
  5396. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5397. if (currUserInfo != null)
  5398. {
  5399. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5400. if (userInfo != null)
  5401. {
  5402. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5403. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5404. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5405. }
  5406. }
  5407. //设置页脚
  5408. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5409. #endregion
  5410. //文件名
  5411. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5412. AsposeHelper.removewatermark_v2180();
  5413. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5414. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5415. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5416. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5417. }
  5418. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5419. {
  5420. //获取模板
  5421. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5422. //载入模板
  5423. Document doc = new Document(tempPath);
  5424. DocumentBuilder builder = new DocumentBuilder(doc);
  5425. Dictionary<string, string> dic = new Dictionary<string, string>();
  5426. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5427. {
  5428. List<string> list = new List<string>();
  5429. try
  5430. {
  5431. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5432. foreach (var item in spilitArr)
  5433. {
  5434. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5435. var depCode = spDotandEmpty[2].Substring(0, 3);
  5436. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5437. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5438. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5439. list.Add(depName);
  5440. list.Add(arrName);
  5441. }
  5442. list = list.Distinct().ToList();
  5443. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5444. }
  5445. catch (Exception)
  5446. {
  5447. dic.Add("ReturnCode", "行程录入不正确!");
  5448. }
  5449. }
  5450. else
  5451. {
  5452. dic.Add("ReturnCode", "未录入行程!");
  5453. }
  5454. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5455. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5456. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5457. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5458. {
  5459. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5460. dic.Add("Day", sp.Days.ToString());
  5461. }
  5462. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5463. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5464. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5465. //dic.Add("Names", Names);
  5466. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5467. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5468. decimal dac1totalPrice = 0.00M;
  5469. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5470. foreach (var dac in dac1)
  5471. {
  5472. if (dac.SubTotal == 0.00M)
  5473. {
  5474. continue;
  5475. }
  5476. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5477. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5478. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5479. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5480. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5481. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5482. builder.Write(currency);//币种
  5483. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5484. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5485. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5486. builder.Write("");//人数
  5487. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5488. builder.Write("");//天数
  5489. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5490. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5491. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5492. decimal rate = 0.00M;
  5493. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5494. builder.Write(rate.ToString("#0.0000"));//汇率
  5495. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5496. decimal rbmPrice = dac.SubTotal;
  5497. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5498. accommodationStartIndex++;
  5499. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5500. }
  5501. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5502. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5503. {
  5504. table1.Rows.RemoveAt(i - 1);
  5505. foodandotherStartIndex--;
  5506. }
  5507. if (dac2.Count == dac3.Count)//国家 币种 金额
  5508. {
  5509. for (int i = 0; i < dac2.Count; i++)
  5510. {
  5511. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5512. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5513. }
  5514. }
  5515. decimal dac2totalPrice = 0.00M;
  5516. foreach (var dac in dac2)
  5517. {
  5518. if (dac.SubTotal == 0)
  5519. {
  5520. continue;
  5521. }
  5522. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5523. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5524. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5525. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5526. builder.Write(currency);//币种
  5527. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5528. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5529. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5530. builder.Write("");//人数
  5531. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5532. builder.Write("");//天数
  5533. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5534. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5535. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5536. decimal rate = 0.00M;
  5537. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5538. builder.Write(rate.ToString("#0.0000"));//汇率
  5539. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5540. decimal rbmPrice = dac.SubTotal;
  5541. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5542. foodandotherStartIndex++;
  5543. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5544. }
  5545. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5546. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5547. {
  5548. table1.Rows.RemoveAt(i - 1);
  5549. }
  5550. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5551. string otherFeeStr = "";
  5552. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5553. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5554. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5555. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5556. foreach (var otherInfo in dac5)
  5557. {
  5558. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5559. }
  5560. #endregion
  5561. if (otherFeeStr.Length > 0)
  5562. {
  5563. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5564. otherFeeStr = $"({otherFeeStr})";
  5565. dic.Add("OtherFeeStr", otherFeeStr);
  5566. }
  5567. //总计
  5568. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5569. //国际旅费
  5570. string outsideAir = string.Empty;
  5571. string allPriceAir = string.Empty;
  5572. if (_EnterExitCosts.SumJJC == 1)
  5573. {
  5574. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5575. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5576. }
  5577. if (_EnterExitCosts.SumGWC == 1)
  5578. {
  5579. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5580. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5581. }
  5582. if (_EnterExitCosts.SumTDC == 1)
  5583. {
  5584. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5585. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5586. }
  5587. dic.Add("InTravelPrice", $"({outsideAir})");
  5588. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5589. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5590. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5591. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5592. foreach (var key in dic.Keys)
  5593. {
  5594. builder.MoveToBookmark(key);
  5595. builder.Write(dic[key]);
  5596. }
  5597. //模板文件名
  5598. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5599. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5600. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5601. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5602. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5603. }
  5604. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5605. {
  5606. //获取模板
  5607. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5608. //载入模板
  5609. WorkbookDesigner designer = new WorkbookDesigner();
  5610. designer.Workbook = new Workbook(tempPath);
  5611. Dictionary<string, string> dic = new Dictionary<string, string>();
  5612. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5613. {
  5614. List<string> list = new List<string>();
  5615. try
  5616. {
  5617. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5618. foreach (var item in spilitArr)
  5619. {
  5620. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5621. var depCode = spDotandEmpty[2].Substring(0, 3);
  5622. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5623. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5624. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5625. list.Add(depName);
  5626. list.Add(arrName);
  5627. }
  5628. list = list.Distinct().ToList();
  5629. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5630. }
  5631. catch (Exception)
  5632. {
  5633. dic.Add("ReturnCode", "行程录入不正确!");
  5634. }
  5635. }
  5636. else
  5637. {
  5638. dic.Add("ReturnCode", "未录入行程!");
  5639. }
  5640. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5641. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5642. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5643. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5644. {
  5645. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5646. dic.Add("Day", sp.Days.ToString());
  5647. }
  5648. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5649. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5650. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5651. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5652. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5653. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5654. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5655. designer.SetDataSource("Name", Names);
  5656. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5657. designer.SetDataSource("Day", dic["Day"] + "天");
  5658. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5659. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5660. int startIndex = 10;
  5661. const int startIndexcopy = 10;
  5662. if (dac2.Count == dac3.Count)//国家 币种 金额
  5663. {
  5664. for (int i = 0; i < dac2.Count; i++)
  5665. {
  5666. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5667. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5668. }
  5669. }
  5670. DataTable dtdac1 = new DataTable();
  5671. List<string> place = new List<string>();
  5672. dtdac1.Columns.AddRange(new DataColumn[] {
  5673. new DataColumn(){ ColumnName = "city"},
  5674. new DataColumn(){ ColumnName = "curr"},
  5675. new DataColumn(){ ColumnName = "criterion"},
  5676. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5677. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5678. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5679. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5680. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5681. });
  5682. DataTable dtdac2 = new DataTable();
  5683. dtdac2.Columns.AddRange(new DataColumn[] {
  5684. new DataColumn(){ ColumnName = "city"},
  5685. new DataColumn(){ ColumnName = "curr"},
  5686. new DataColumn(){ ColumnName = "criterion"},
  5687. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5688. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5689. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5690. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5691. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5692. });
  5693. dtdac1.TableName = "tb1";
  5694. dtdac2.TableName = "tb2";
  5695. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5696. foreach (var item in dac1)
  5697. {
  5698. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5699. if (place.Contains(item.Place))
  5700. {
  5701. continue;
  5702. }
  5703. DataRow row = dtdac1.NewRow();
  5704. row["city"] = item.Place;
  5705. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5706. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5707. row["curr"] = currency;
  5708. row["rate"] = rate.ToString("#0.0000");
  5709. row["criterion"] = item.Cost.ToString("#0.00");
  5710. row["number"] = 1;
  5711. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5712. //row["costRMB"] = rbmPrice;
  5713. dtdac1.Rows.Add(row);
  5714. place.Add(item.Place);
  5715. }
  5716. place = new List<string>();
  5717. foreach (var item in dac2)
  5718. {
  5719. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5720. if (place.Contains(item.Place))
  5721. {
  5722. continue;
  5723. }
  5724. DataRow row = dtdac2.NewRow();
  5725. row["city"] = item.Place;
  5726. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5727. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5728. row["curr"] = currency;
  5729. row["rate"] = rate.ToString("#0.0000");
  5730. row["criterion"] = item.Cost.ToString("#0.00");
  5731. row["number"] = 1;
  5732. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5733. //row["cost"] = item.SubTotal;
  5734. //row["costRMB"] = rbmPrice;
  5735. dtdac2.Rows.Add(row);
  5736. place.Add(item.Place);
  5737. //dac2totalPrice += rbmPrice;
  5738. }
  5739. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5740. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5741. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5742. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5743. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5744. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5745. string cell4Str1 = string.Empty;
  5746. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5747. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5748. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5749. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5750. string cellStr = $" 5.其他费用(";
  5751. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5752. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5753. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5754. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5755. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5756. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5757. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5758. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5759. foreach (var otherInfo in dac5)
  5760. {
  5761. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5762. }
  5763. #endregion
  5764. if (cellStr.Length > 8)
  5765. {
  5766. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5767. }
  5768. cellStr += ")";
  5769. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5770. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5771. decimal pxFee = dac4.Sum(it => it.Cost);
  5772. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5773. string celllastStr1 = "";
  5774. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5775. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5776. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5777. celllastStr1 += $",国际旅费 元";
  5778. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5779. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5780. designer.SetDataSource("cell4Str", cell4Str);
  5781. designer.SetDataSource("cellStr", cellStr);
  5782. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5783. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5784. designer.SetDataSource("celllastStr", celllastStr);
  5785. Workbook wb = designer.Workbook;
  5786. var sheet = wb.Worksheets[0];
  5787. //绑定datatable数据集
  5788. designer.SetDataSource(dtdac1);
  5789. designer.SetDataSource(dtdac2);
  5790. designer.Process();
  5791. var rowStart = dtdac1.Rows.Count;
  5792. while (rowStart > 0)
  5793. {
  5794. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5795. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5796. startIndex++;
  5797. rowStart--;
  5798. }
  5799. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5800. startIndex += 1; //总计行
  5801. rowStart = dtdac2.Rows.Count;
  5802. while (rowStart > 0)
  5803. {
  5804. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5805. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5806. startIndex++;
  5807. rowStart--;
  5808. }
  5809. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5810. wb.CalculateFormula(true);
  5811. //模板文件名
  5812. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5813. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5814. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5815. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5816. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5817. }
  5818. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5819. {
  5820. //获取模板
  5821. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5822. //载入模板
  5823. Document doc = new Document(tempPath);
  5824. DocumentBuilder builder = new DocumentBuilder(doc);
  5825. Dictionary<string, string> dic = new Dictionary<string, string>();
  5826. dic.Add("GroupName", _DelegationInfo.TeamName);
  5827. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5828. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5829. string missionLeaderJob = "";//负责人job
  5830. //int groupNumber = 0; //团人数
  5831. if (DeleClientList.Count > 0)
  5832. {
  5833. missionLeader = DeleClientList[0]?.Name ?? "";
  5834. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5835. }
  5836. dic.Add("MissionLeader", missionLeader); //团负责人
  5837. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5838. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5839. #region MyRegion
  5840. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5841. //{
  5842. // List<string> list = new List<string>();
  5843. // try
  5844. // {
  5845. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5846. // foreach (var item in spilitArr)
  5847. // {
  5848. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5849. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5850. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5851. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5852. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5853. // list.Add(depName);
  5854. // list.Add(arrName);
  5855. // }
  5856. // list = list.Distinct().ToList();
  5857. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5858. // }
  5859. // catch (Exception)
  5860. // {
  5861. // dic.Add("ReturnCode", "行程录入不正确!");
  5862. // }
  5863. //}
  5864. //else
  5865. //{
  5866. // dic.Add("ReturnCode", "未录入行程!");
  5867. //}
  5868. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5869. dic.Add("ReturnCode", string.Join("、", countrys));
  5870. #endregion
  5871. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5872. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5873. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5874. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5875. //{
  5876. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5877. // dic.Add("Day", sp.Days.ToString());
  5878. //}
  5879. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5880. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5881. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5882. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5883. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5884. //培训人员名单
  5885. int cultivateRowIndex = 7;
  5886. foreach (var item in DeleClientList)
  5887. {
  5888. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5889. builder.Write(item.Name);
  5890. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5891. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5892. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5893. string birthDay = "";
  5894. if (item.Birthday != null)
  5895. {
  5896. DateTime dt = Convert.ToDateTime(item.Birthday);
  5897. birthDay = $"{dt.Year}.{dt.Month}";
  5898. }
  5899. builder.Write(birthDay);
  5900. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5901. builder.Write(item.Company);
  5902. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5903. builder.Write(item.Job);
  5904. cultivateRowIndex++;
  5905. }
  5906. //删除多余行
  5907. //cultivateRowIndex -= 2;
  5908. int delRows = 10 + 7 - cultivateRowIndex;
  5909. if (delRows > 0)
  5910. {
  5911. for (int i = 0; i < delRows; i++)
  5912. {
  5913. table1.Rows.RemoveAt(cultivateRowIndex);
  5914. //cultivateRowIndex++;
  5915. }
  5916. }
  5917. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5918. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5919. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5920. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5921. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5922. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5923. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5924. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5925. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5926. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5927. //其他费用
  5928. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5929. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5930. //其他费用合计
  5931. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5932. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5933. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5934. //公务舱合计
  5935. //国际旅费
  5936. //string outsideJJ = "";
  5937. //string allPriceJJ = "";
  5938. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5939. {
  5940. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5941. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5942. }
  5943. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5944. {
  5945. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5946. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5947. }
  5948. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5949. {
  5950. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5951. dic.Add("AirFeeTotal", airFeeTotalStr);
  5952. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5953. dic.Add("FeeTotal", feeTotalStr);
  5954. }
  5955. foreach (var key in dic.Keys)
  5956. {
  5957. builder.MoveToBookmark(key);
  5958. builder.Write(dic[key]);
  5959. }
  5960. //模板文件名
  5961. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5962. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5963. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5964. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5965. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5966. }
  5967. }
  5968. else if (dto.ExportType == 2) //表格
  5969. {
  5970. //利用键值对存放数据
  5971. Dictionary<string, string> dic = new Dictionary<string, string>();
  5972. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5973. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5974. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5975. dic.Add("Day", sp.Days.ToString());
  5976. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5977. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5978. {
  5979. //获取模板
  5980. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5981. //载入模板
  5982. Document doc = new Document(tempPath);
  5983. DocumentBuilder builder = new DocumentBuilder(doc);
  5984. dic.Add("TeamName", _DelegationInfo.TeamName);
  5985. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5986. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5987. string missionLeaderName = "",
  5988. missionLeaderJob = "";
  5989. if (DeleClientList.Count > 0)
  5990. {
  5991. missionLeaderName = DeleClientList[0].Name;
  5992. missionLeaderJob = DeleClientList[0].Job;
  5993. }
  5994. dic.Add("MissionLeaderName", missionLeaderName);
  5995. dic.Add("MissionLeaderJob", missionLeaderJob);
  5996. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5997. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5998. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5999. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6000. int rowCount = 10;//总人数行
  6001. int startRowIndex = 7; //起始行
  6002. for (int i = 0; i < DeleClientList.Count; i++)
  6003. {
  6004. builder.MoveToCell(0, startRowIndex, 0, 0);
  6005. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6006. builder.MoveToCell(0, startRowIndex, 1, 0);
  6007. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6008. builder.Write(sex);//性别
  6009. builder.MoveToCell(0, startRowIndex, 2, 0);
  6010. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6011. builder.MoveToCell(0, startRowIndex, 3, 0);
  6012. builder.Write(DeleClientList[i].Company);//工作单位
  6013. builder.MoveToCell(0, startRowIndex, 4, 0);
  6014. builder.Write(DeleClientList[i].Job);//职务及级别
  6015. builder.MoveToCell(0, startRowIndex, 5, 0);
  6016. builder.Write("");//人员属性
  6017. builder.MoveToCell(0, startRowIndex, 6, 0);
  6018. builder.Write("");//上次出国时间
  6019. startRowIndex++;
  6020. }
  6021. int nullRow = rowCount - DeleClientList.Count;//空行
  6022. for (int i = 0; i < nullRow; i++)
  6023. {
  6024. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6025. }
  6026. foreach (var key in dic.Keys)
  6027. {
  6028. builder.MoveToBookmark(key);
  6029. builder.Write(dic[key]);
  6030. }
  6031. //模板文件名
  6032. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6033. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6034. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6035. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6036. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6037. }
  6038. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6039. {
  6040. //获取模板
  6041. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6042. //载入模板
  6043. Document doc = new Document(tempPath);
  6044. DocumentBuilder builder = new DocumentBuilder(doc);
  6045. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6046. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6047. dic.Add("Names", Names);
  6048. int accommodationRows = 12;
  6049. //int foodandotherRows = 12;
  6050. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6051. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6052. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6053. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6054. int accommodationStartIndex = 6;
  6055. decimal dac1totalPrice = 0.00M;
  6056. foreach (var dac in dac1)
  6057. {
  6058. if (dac.SubTotal == 0)
  6059. {
  6060. continue;
  6061. }
  6062. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6063. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6064. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6065. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6066. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6067. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6068. builder.Write(currency);//币种
  6069. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6070. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6071. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6072. builder.Write("");//人数
  6073. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6074. builder.Write("");//天数
  6075. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6076. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6077. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6078. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6079. builder.Write(rate.ToString("#0.0000"));//汇率
  6080. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6081. decimal rbmPrice = rate * dac.SubTotal;
  6082. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6083. accommodationStartIndex++;
  6084. dac1totalPrice += rbmPrice;
  6085. }
  6086. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6087. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6088. builder.Write("小计");
  6089. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6090. builder.Write(dac1totalPrice.ToString("#0.00"));
  6091. accommodationStartIndex++;
  6092. int nullRow = accommodationRows - dac1.Count;
  6093. //删除空行
  6094. //if (nullRow > 0)
  6095. //{
  6096. // int rowIndex = accommodationStartIndex;
  6097. // for (int i = 0; i < nullRow; i++)
  6098. // {
  6099. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6100. // row.Remove();
  6101. // rowIndex++;
  6102. // }
  6103. //}
  6104. if (dac2.Count == dac3.Count)//国家 币种 金额
  6105. {
  6106. for (int i = 0; i < dac2.Count; i++)
  6107. {
  6108. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6109. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6110. }
  6111. }
  6112. int foodandotherStartIndex = 19;//
  6113. decimal dac2totalPrice = 0.00M;
  6114. foreach (var dac in dac2)
  6115. {
  6116. if (dac.SubTotal == 0)
  6117. {
  6118. continue;
  6119. }
  6120. //foodandotherStartIndex = 12;
  6121. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6122. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6123. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6124. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6125. builder.Write(currency);//币种
  6126. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6127. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6128. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6129. builder.Write("");//人数
  6130. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6131. builder.Write("");//天数
  6132. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6133. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6134. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6135. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6136. builder.Write(rate.ToString("#0.0000"));//汇率
  6137. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6138. decimal rbmPrice = rate * dac.SubTotal;
  6139. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6140. foodandotherStartIndex++;
  6141. dac2totalPrice += rbmPrice;
  6142. }
  6143. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6144. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6145. //删除空行
  6146. //if (dac2.Count < foodandotherRows)
  6147. //{
  6148. // while (table2.Rows.Count > dac2.Count)
  6149. // {
  6150. // table2.Rows.RemoveAt(dac2.Count);
  6151. // }
  6152. //}
  6153. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6154. string otherFeeStr = "";
  6155. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6156. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6157. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6158. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6159. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6160. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6161. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6162. foreach (var otherInfo in dac5)
  6163. {
  6164. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6165. }
  6166. #endregion
  6167. if (otherFeeStr.Length > 0)
  6168. {
  6169. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6170. otherFeeStr = $"({otherFeeStr})";
  6171. dic.Add("OtherFeeStr", otherFeeStr);
  6172. }
  6173. foreach (var key in dic.Keys)
  6174. {
  6175. builder.MoveToBookmark(key);
  6176. builder.Write(dic[key]);
  6177. }
  6178. //模板文件名
  6179. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6180. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6181. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6182. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6183. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6184. }
  6185. }
  6186. else if (dto.ExportType == 3)
  6187. {
  6188. if (dto.SubTypeId == 1) //团组成员名单
  6189. {
  6190. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6191. //获取模板
  6192. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6193. //载入模板
  6194. Document doc = new Document(tempPath);
  6195. DocumentBuilder builder = new DocumentBuilder(doc);
  6196. //获取word里所有表格
  6197. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6198. //获取所填表格的序数
  6199. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6200. var rowStart = tableOne.Rows[0]; //获取第1行
  6201. //循环赋值
  6202. for (int i = 0; i < DeleClientList.Count; i++)
  6203. {
  6204. builder.MoveToCell(0, i + 1, 0, 0);
  6205. builder.Write(DeleClientList[i].Name);
  6206. builder.MoveToCell(0, i + 1, 1, 0);
  6207. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6208. builder.Write(sex);
  6209. builder.MoveToCell(0, i + 1, 2, 0);
  6210. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6211. builder.MoveToCell(0, i + 1, 3, 0);
  6212. builder.Write(DeleClientList[i].Company);
  6213. builder.MoveToCell(0, i + 1, 4, 0);
  6214. builder.Write(DeleClientList[i].Job);
  6215. }
  6216. //删除多余行
  6217. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6218. {
  6219. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6220. }
  6221. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6222. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6223. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6224. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6225. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6226. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6227. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6228. }
  6229. }
  6230. return Ok(JsonView(400, "操作失败!", ""));
  6231. }
  6232. catch (Exception ex)
  6233. {
  6234. return Ok(JsonView(400, ex.Message, ""));
  6235. }
  6236. }
  6237. /// <summary>
  6238. /// 获取三公费用标准city
  6239. /// </summary>
  6240. /// <param name="placeData"></param>
  6241. /// <param name="nationalTravelFeeId"></param>
  6242. /// <returns></returns>
  6243. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6244. {
  6245. string _city = string.Empty;
  6246. if (placeData.Count < 1) return _city;
  6247. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6248. if (data == null) return _city;
  6249. string country = data.Country;
  6250. string city = data.City;
  6251. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6252. else _city = city;
  6253. return _city;
  6254. }
  6255. /// <summary>
  6256. /// 团组模块 - 出入境费用 - 明细表导出
  6257. /// </summary>
  6258. /// <returns></returns>
  6259. [HttpPost]
  6260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6261. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6262. {
  6263. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6264. if (data.Code != 0)
  6265. {
  6266. return Ok(JsonView(false, data.Msg));
  6267. }
  6268. return Ok(JsonView(true, data.Msg, data.Data));
  6269. }
  6270. /// <summary>
  6271. /// 团组模块 - 出入境费用 - 一键清空
  6272. /// </summary>
  6273. /// <returns></returns>
  6274. [HttpPost]
  6275. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6277. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6278. {
  6279. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6280. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6281. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6282. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6283. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6284. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6285. .SetColumns(x => new Grp_DayOtherPrice
  6286. {
  6287. IsDel = 1,
  6288. DeleteUserId = dto.UserId,
  6289. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6290. })
  6291. .ExecuteCommandAsync();
  6292. if (_view.Code == 0)
  6293. {
  6294. return Ok(JsonView(true, "操作成功"));
  6295. }
  6296. return Ok(JsonView(false, "操作失败"));
  6297. }
  6298. /// <summary>
  6299. /// 团组模块 - 出入境费用 - 子项删除
  6300. /// </summary>
  6301. /// <returns></returns>
  6302. [HttpPost]
  6303. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6305. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6306. {
  6307. try
  6308. {
  6309. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6310. if (data.Code != 0)
  6311. {
  6312. return Ok(JsonView(false, data.Msg));
  6313. }
  6314. return Ok(JsonView(true, "操作成功!", data.Data));
  6315. }
  6316. catch (Exception ex)
  6317. {
  6318. return Ok(JsonView(false, ex.Message));
  6319. }
  6320. }
  6321. /// <summary>
  6322. /// 删除三公其他费用
  6323. /// </summary>
  6324. /// <param name="dto"></param>
  6325. /// <returns></returns>
  6326. [HttpPost]
  6327. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6328. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6329. {
  6330. var jw = JsonView(false, "删除失败!");
  6331. var data = new Grp_DayOtherPrice()
  6332. {
  6333. Id = dto.Id,
  6334. IsDel = 1,
  6335. DeleteUserId = dto.DeleteUserId,
  6336. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6337. };
  6338. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6339. if (del > 0)
  6340. {
  6341. jw.Code = 200;
  6342. jw.Msg = "删除成功!";
  6343. }
  6344. return Ok(jw);
  6345. }
  6346. /// <summary>
  6347. /// 团组模块 - 出入境国家费用标准 List
  6348. /// </summary>
  6349. /// <returns></returns>
  6350. [HttpPost]
  6351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6352. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6353. {
  6354. try
  6355. {
  6356. Stopwatch sw = new Stopwatch();
  6357. sw.Start();
  6358. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6359. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6360. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6361. Where gntf.Isdel = 0");
  6362. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6363. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6364. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6365. //foreach (var item in nationalTravel)
  6366. //{
  6367. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6368. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6369. // if (otherData != null)
  6370. // {
  6371. // cityData.Remove(otherData);
  6372. // cityData.Add(otherData);
  6373. // }
  6374. // nationalTravelFeeData1.Add(new
  6375. // {
  6376. // Country = item.Country,
  6377. // CityData = cityData
  6378. // });
  6379. //}
  6380. sw.Stop();
  6381. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6382. }
  6383. catch (Exception ex)
  6384. {
  6385. return Ok(JsonView(false, ex.Message));
  6386. throw;
  6387. }
  6388. }
  6389. /// <summary>
  6390. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6391. /// </summary>
  6392. /// <returns></returns>
  6393. [HttpPost]
  6394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6395. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6396. {
  6397. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6398. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6399. List<string> countryData = new List<string>();
  6400. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6401. countryData = countryData.Distinct().ToList();
  6402. List<dynamic> dataSource = new List<dynamic>();
  6403. foreach (var item in countryData)
  6404. {
  6405. var cityData1 = new List<string>();
  6406. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6407. var countryData2 = new
  6408. {
  6409. CountryName = item,
  6410. CityData = cityData1
  6411. };
  6412. dataSource.Add(countryData2);
  6413. }
  6414. return Ok(JsonView(true, "查询成功!", dataSource));
  6415. }
  6416. /// <summary>
  6417. /// 团组模块 - 出入境国家费用标准 Page List
  6418. /// </summary>
  6419. /// <returns></returns>
  6420. [HttpPost]
  6421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6422. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6423. {
  6424. int portId = dto.PortType;
  6425. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6426. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6427. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6428. string whereSql = string.Empty;
  6429. if (!string.IsNullOrEmpty(dto.Country))
  6430. {
  6431. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6432. }
  6433. if (!string.IsNullOrEmpty(dto.City))
  6434. {
  6435. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6436. }
  6437. string pageSql = string.Format(@"Select * From (
  6438. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6439. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6440. From Grp_NationalTravelFee gntf
  6441. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6442. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6443. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6444. RefAsync<int> total = 0;
  6445. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6446. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6447. }
  6448. /// <summary>
  6449. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6450. /// </summary>
  6451. /// <returns></returns>
  6452. [HttpPost]
  6453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6454. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6455. {
  6456. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6457. int portId = dto.PortType;
  6458. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6459. string whereSql = string.Empty;
  6460. if (!string.IsNullOrEmpty(dto.Country))
  6461. {
  6462. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6463. }
  6464. if (!string.IsNullOrEmpty(dto.City))
  6465. {
  6466. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6467. }
  6468. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6469. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6470. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6471. From Grp_NationalTravelFee gntf
  6472. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6473. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6474. Where gntf.Isdel = 0 {0} ", whereSql);
  6475. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6476. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6477. }
  6478. /// <summary>
  6479. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6480. /// </summary>
  6481. /// <returns></returns>
  6482. [HttpPost]
  6483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6484. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6485. {
  6486. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6487. if (data.Code != 0)
  6488. {
  6489. return Ok(JsonView(false, data.Msg));
  6490. }
  6491. return Ok(JsonView(true, "操作成功!", data.Data));
  6492. }
  6493. /// <summary>
  6494. /// 团组模块 - 出入境国家费用标准 - Del
  6495. /// </summary>
  6496. /// <returns></returns>
  6497. [HttpPost]
  6498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6499. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6500. {
  6501. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6502. {
  6503. Id = dto.Id,
  6504. DeleteUserId = dto.DeleteUserId,
  6505. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6506. IsDel = 1
  6507. };
  6508. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6509. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6510. .WhereColumns(it => new { it.Id })
  6511. .ExecuteCommandAsync();
  6512. if (delStatus <= 0)
  6513. {
  6514. return Ok(JsonView(false, "删除失败!"));
  6515. }
  6516. return Ok(JsonView(true, "操作成功!"));
  6517. }
  6518. /// <summary>
  6519. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6520. /// 注:Get 请求Headers 加 Token
  6521. /// </summary>
  6522. /// <param name="groupId"></param>
  6523. /// <returns></returns>
  6524. [HttpGet("{groupId}")]
  6525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6526. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6527. {
  6528. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6529. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6530. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6531. data.ForEach(x =>
  6532. {
  6533. x.CreateUserId = _currUserInfo.UserId;
  6534. });
  6535. if (data.Any())
  6536. {
  6537. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6538. if (add > 0)
  6539. {
  6540. return Ok(JsonView(true, "操作成功!"));
  6541. }
  6542. }
  6543. return Ok(JsonView(false, "未操作!"));
  6544. }
  6545. #endregion
  6546. #region 团组经理模块 出入境费用-草稿
  6547. /// <summary>
  6548. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6549. /// </summary>
  6550. /// <returns></returns>
  6551. [HttpPost]
  6552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6553. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6554. {
  6555. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6556. .Where(x => x.IsDel == 0)
  6557. .OrderByDescending(x => x.CreateTime)
  6558. .Select(x => new { x.Id, x.DraftName })
  6559. .ToListAsync();
  6560. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6561. //SetDataInfoView
  6562. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6563. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6564. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6565. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6566. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6567. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6568. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6569. //默认币种显示
  6570. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6571. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6572. return Ok(JsonView(true, "查询成功!", new
  6573. {
  6574. DraftNameDatas = draftNameDatas,
  6575. CurrencyData = _CurrencyData,
  6576. WordTypeData = _WordTypeData,
  6577. ExcelTypeData = _ExcelTypeData,
  6578. CurrencyInit = _currencyInfos,
  6579. ViewPermissionData = viewPermissionData
  6580. }));
  6581. }
  6582. /// <summary>
  6583. /// 团组模块 - 出入境费用-草稿
  6584. /// 实时汇率 tips
  6585. /// 机票费用 tips
  6586. /// </summary>
  6587. /// <returns></returns>
  6588. [HttpPost]
  6589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6590. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6591. {
  6592. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6593. return Ok(JsonView(true, "查询成功!", new
  6594. {
  6595. //GroupNameData = groupNameData.Data,
  6596. //visaData = visaData.Data,
  6597. //airData = airData.Data,
  6598. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6599. }));
  6600. }
  6601. /// <summary>
  6602. /// 团组模块 - 出入境费用-草稿
  6603. /// 签证费用 tips
  6604. /// </summary>
  6605. /// <returns></returns>
  6606. [HttpPost]
  6607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6608. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6609. {
  6610. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6611. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6612. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6613. .Select(x => x.NationalTravelFeeId)
  6614. .Distinct()
  6615. .ToListAsync();
  6616. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6617. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6618. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6619. .Select(x => x.Country)
  6620. .Distinct()
  6621. .ToArrayAsync();
  6622. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6623. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6624. return Ok(JsonView(true, "查询成功!", new
  6625. {
  6626. totalAmt = totalAmt,
  6627. remark = remark
  6628. }));
  6629. }
  6630. /// <summary>
  6631. /// 团组模块 - 出入境费用-草稿 - Info
  6632. /// </summary>
  6633. /// <returns></returns>
  6634. [HttpPost]
  6635. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6637. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6638. {
  6639. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6640. }
  6641. /// <summary>
  6642. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6643. /// </summary>
  6644. /// <returns></returns>
  6645. [HttpPost]
  6646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6647. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6648. {
  6649. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6650. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6651. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6652. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6653. foreach (var userId in dto.UserIds)
  6654. {
  6655. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6656. }
  6657. if (permissions.Any())
  6658. {
  6659. _sqlSugar.BeginTran();
  6660. try
  6661. {
  6662. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6663. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6664. if (result < 1)
  6665. {
  6666. _sqlSugar.RollbackTran();
  6667. return Ok(JsonView(false));
  6668. }
  6669. }
  6670. catch (Exception ex)
  6671. {
  6672. _sqlSugar.RollbackTran();
  6673. return Ok(JsonView(false, ex.Message));
  6674. }
  6675. _sqlSugar.CommitTran();
  6676. return Ok(JsonView(true));
  6677. }
  6678. return Ok(JsonView(false));
  6679. }
  6680. /// <summary>
  6681. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6682. /// </summary>
  6683. /// <returns></returns>
  6684. [HttpPost]
  6685. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6687. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6688. {
  6689. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6690. if (data.Code != 0)
  6691. {
  6692. return Ok(JsonView(false, data.Msg));
  6693. }
  6694. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6695. //汇率信息记录
  6696. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6697. return Ok(JsonView(true, data.Msg, data.Data));
  6698. }
  6699. /// <summary>
  6700. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6701. /// </summary>
  6702. /// <param name="dto"></param>
  6703. /// <returns></returns>
  6704. [HttpPost]
  6705. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6707. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6708. {
  6709. try
  6710. {
  6711. var id = dto.Id;
  6712. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6713. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6714. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6715. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6716. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6717. 3 团组成员名单 1 团组成员名单", ""));
  6718. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6719. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6720. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6721. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6722. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6723. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6724. //数据源
  6725. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6726. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6727. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6728. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6729. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6730. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6731. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6732. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6733. .Select((x, a, b) => new
  6734. {
  6735. x.Index,
  6736. itemName = a.Name,
  6737. CurrencyStr = b.Name,
  6738. x.Cost,
  6739. x.SubTotal,
  6740. x.Remark
  6741. })
  6742. .OrderBy((x) => x.Index)
  6743. .ToList(); //其他款项费用
  6744. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6745. var peiceItemCurrencys = new List<string>();
  6746. if (_DayAndCosts.Any())
  6747. {
  6748. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6749. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6750. }
  6751. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6752. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6753. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6754. {
  6755. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6756. }
  6757. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6758. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6759. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6760. if (dto.ExportType == 1) //明细表
  6761. {
  6762. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6763. {
  6764. //获取模板
  6765. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6766. //载入模板
  6767. Document doc = new Document(tempPath);
  6768. DocumentBuilder builder = new DocumentBuilder(doc);
  6769. //利用键值对存放数据
  6770. Dictionary<string, string> dic = new Dictionary<string, string>();
  6771. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6772. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6773. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6774. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6775. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6776. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6777. //境内费用(其他费用)
  6778. if (_EnterExitCosts.ChoiceOne == 1)
  6779. {
  6780. string row1_1 = "";
  6781. if (_EnterExitCosts.Visa > 0)
  6782. {
  6783. //insidePayTotal += _EnterExitCosts.Visa;
  6784. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6785. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6786. {
  6787. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6788. }
  6789. }
  6790. string row1_2 = "";
  6791. if (_EnterExitCosts.YiMiao > 0)
  6792. {
  6793. //insidePayTotal += _EnterExitCosts.YiMiao;
  6794. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6795. }
  6796. if (_EnterExitCosts.HeSuan > 0)
  6797. {
  6798. //insidePayTotal += _EnterExitCosts.HeSuan;
  6799. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6800. }
  6801. if (_EnterExitCosts.Service > 0)
  6802. {
  6803. //insidePayTotal += _EnterExitCosts.Service;
  6804. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6805. }
  6806. string row1_3 = "";
  6807. if (_EnterExitCosts.Safe > 0)
  6808. {
  6809. //insidePayTotal += _EnterExitCosts.Safe;
  6810. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6811. }
  6812. if (_EnterExitCosts.Ticket > 0)
  6813. {
  6814. //insidePayTotal += _EnterExitCosts.Ticket;
  6815. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6816. }
  6817. string row1 = "";
  6818. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6819. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6820. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6821. row1 += $"备注:{_EnterExitCosts.Remark}";
  6822. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6823. dic.Add("Row1Str", row1);
  6824. }
  6825. string airTotalStr = string.Empty,
  6826. airPriceStr = string.Empty;
  6827. //经济舱
  6828. if (_EnterExitCosts.SumJJC == 1)
  6829. {
  6830. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6831. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6832. }
  6833. //公务舱
  6834. if (_EnterExitCosts.SumGWC == 1)
  6835. {
  6836. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6837. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6838. }
  6839. //头等舱
  6840. if (_EnterExitCosts.SumTDC == 1)
  6841. {
  6842. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6843. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6844. }
  6845. //汇率描述
  6846. string rateStr = "";
  6847. if (peiceItemCurrencyInfos.Any())
  6848. {
  6849. rateStr = "\r\n汇率描述:";
  6850. foreach (var item in peiceItemCurrencyInfos)
  6851. {
  6852. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6853. }
  6854. }
  6855. string twoItemRemark = "备注:";
  6856. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6857. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6858. dic.Add("AirTotalStr", airTotalStr);
  6859. dic.Add("AirPriceStr", airPriceStr);
  6860. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6861. dic.Add("TwoItemRemark", twoItemRemark);
  6862. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6863. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6864. int table1Row = 0,
  6865. table2Row = 0,
  6866. table3Row = 0,
  6867. table4Row = 0,
  6868. table5Row = 0;
  6869. //住宿费
  6870. if (_EnterExitCosts.ChoiceThree == 1)
  6871. {
  6872. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6873. table1Row = dac1.Count;
  6874. #region 填充word表格内容
  6875. for (int i = 0; i < dac1.Count; i++)
  6876. {
  6877. var dac = dac1[i];
  6878. if (dac == null) continue;
  6879. builder.MoveToCell(0, i, 0, 0);
  6880. builder.Write("第" + dac.Days.ToString() + "晚:");
  6881. builder.MoveToCell(0, i, 1, 0);
  6882. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6883. //builder.Write(dac.Place == null ? "" : dac.Place);
  6884. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6885. builder.MoveToCell(0, i, 2, 0);
  6886. builder.Write("费用标准:");
  6887. string curr = "";
  6888. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6889. if (currData != null)
  6890. {
  6891. curr = currData.Name;
  6892. }
  6893. builder.MoveToCell(0, i, 3, 0);
  6894. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6895. builder.MoveToCell(0, i, 4, 0);
  6896. builder.Write("费用小计:");
  6897. builder.MoveToCell(0, i, 5, 0);
  6898. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6899. }
  6900. #endregion
  6901. }
  6902. else dic.Add("SubZS", "0.00");
  6903. //删除多余行
  6904. while (table1.Rows.Count > table1Row)
  6905. {
  6906. table1.Rows.RemoveAt(table1Row);
  6907. }
  6908. //伙食费
  6909. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6910. if (_EnterExitCosts.ChoiceFour == 1)
  6911. {
  6912. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6913. table2Row = dac2.Count;
  6914. #region 填充word表格内容
  6915. for (int i = 0; i < dac2.Count; i++)
  6916. {
  6917. var dac = dac2[i];
  6918. if (dac == null) continue;
  6919. builder.MoveToCell(1, i, 0, 0);
  6920. builder.Write("第" + dac.Days.ToString() + "天:");
  6921. builder.MoveToCell(1, i, 1, 0);
  6922. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6923. builder.MoveToCell(1, i, 2, 0);
  6924. builder.Write("费用标准:");
  6925. string curr = "";
  6926. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6927. if (currData != null)
  6928. {
  6929. curr = currData.Name;
  6930. }
  6931. builder.MoveToCell(1, i, 3, 0);
  6932. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6933. builder.MoveToCell(1, i, 4, 0);
  6934. builder.Write("费用小计:");
  6935. builder.MoveToCell(1, i, 5, 0);
  6936. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6937. }
  6938. #endregion
  6939. }
  6940. else dic.Add("SubHS", "0.00");
  6941. //删除多余行
  6942. while (table2.Rows.Count > table2Row)
  6943. {
  6944. table2.Rows.RemoveAt(table2Row);
  6945. }
  6946. //公杂费
  6947. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6948. if (_EnterExitCosts.ChoiceFive == 1)
  6949. {
  6950. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6951. table3Row = dac3.Count;
  6952. #region 填充word表格内容
  6953. for (int i = 0; i < dac3.Count; i++)
  6954. {
  6955. var dac = dac3[i];
  6956. if (dac == null) continue;
  6957. builder.MoveToCell(2, i, 0, 0);
  6958. builder.Write("第" + dac.Days.ToString() + "天:");
  6959. builder.MoveToCell(2, i, 1, 0);
  6960. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6961. builder.MoveToCell(2, i, 2, 0);
  6962. builder.Write("费用标准:");
  6963. string curr = "";
  6964. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6965. if (currData != null)
  6966. {
  6967. curr = currData.Name;
  6968. }
  6969. builder.MoveToCell(2, i, 3, 0);
  6970. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6971. builder.MoveToCell(2, i, 4, 0);
  6972. builder.Write("费用小计:");
  6973. builder.MoveToCell(2, i, 5, 0);
  6974. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6975. }
  6976. //删除多余行
  6977. while (table3.Rows.Count > table3Row)
  6978. {
  6979. table3.Rows.RemoveAt(table3Row);
  6980. }
  6981. #endregion
  6982. }
  6983. else dic.Add("SubGZF", "0.00");
  6984. //删除多余行
  6985. while (table3.Rows.Count > table3Row)
  6986. {
  6987. table3.Rows.RemoveAt(table3Row);
  6988. }
  6989. //培训费
  6990. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6991. if (_EnterExitCosts.ChoiceSix == 1)
  6992. {
  6993. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6994. dic.Add("SubPX", pxStr);
  6995. table4Row = dac4.Count;
  6996. #region 填充word表格内容
  6997. for (int i = 0; i < dac4.Count; i++)
  6998. {
  6999. var dac = dac4[i];
  7000. if (dac == null) continue;
  7001. builder.MoveToCell(3, i, 0, 0);
  7002. builder.Write("第" + dac.Days.ToString() + "天:");
  7003. builder.MoveToCell(3, i, 1, 0);
  7004. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7005. builder.MoveToCell(3, i, 2, 0);
  7006. builder.Write("费用标准:");
  7007. string curr = "";
  7008. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7009. if (currData != null)
  7010. {
  7011. curr = currData.Name;
  7012. }
  7013. builder.MoveToCell(3, i, 3, 0);
  7014. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7015. builder.MoveToCell(3, i, 4, 0);
  7016. builder.Write("费用小计:");
  7017. builder.MoveToCell(3, i, 5, 0);
  7018. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7019. }
  7020. #endregion
  7021. }
  7022. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7023. //删除多余行
  7024. while (table4.Rows.Count > table4Row)
  7025. {
  7026. table4.Rows.RemoveAt(table4Row);
  7027. }
  7028. //其他费用
  7029. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7030. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7031. {
  7032. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7033. dic.Add("titleQi", qtStr);
  7034. table5Row = dac5.Count;
  7035. #region 填充word表格内容
  7036. for (int i = 0; i < dac5.Count; i++)
  7037. {
  7038. var dac = dac5[i];
  7039. if (dac == null) continue;
  7040. builder.MoveToCell(4, i, 0, 0);
  7041. builder.Write("第" + dac.Index.ToString() + "项:");
  7042. builder.MoveToCell(4, i, 1, 0);
  7043. builder.Write(dac.itemName);
  7044. builder.MoveToCell(4, i, 2, 0);
  7045. builder.Write("费用标准:");
  7046. builder.MoveToCell(4, i, 3, 0);
  7047. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7048. builder.MoveToCell(4, i, 4, 0);
  7049. builder.Write("费用小计:");
  7050. builder.MoveToCell(4, i, 5, 0);
  7051. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7052. builder.MoveToCell(4, i, 6, 0);
  7053. builder.Write("备注:");
  7054. builder.MoveToCell(4, i, 7, 0);
  7055. builder.Write(dac.Remark);
  7056. }
  7057. #endregion
  7058. }
  7059. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7060. //删除多余行
  7061. while (table5.Rows.Count > table5Row)
  7062. {
  7063. table5.Rows.RemoveAt(table5Row);
  7064. }
  7065. //加上其他费用
  7066. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7067. decimal subJJC = 0.00M,
  7068. subGWC = 0.00M,
  7069. subTDC = 0.00M;
  7070. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7071. string totalLabel = string.Format("全部费用总计:");
  7072. //经济舱
  7073. if (_EnterExitCosts.SumJJC == 1)
  7074. {
  7075. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7076. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7077. }
  7078. //公务舱
  7079. if (_EnterExitCosts.SumGWC == 1)
  7080. {
  7081. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7082. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7083. }
  7084. //头等舱
  7085. if (_EnterExitCosts.SumTDC == 1)
  7086. {
  7087. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7088. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7089. }
  7090. //TotalLabel
  7091. dic.Add("TotalLabel", totalLabel);
  7092. #region 填充word模板书签内容
  7093. foreach (var key in dic.Keys)
  7094. {
  7095. Bookmark bookmark = doc.Range.Bookmarks[key];
  7096. if (bookmark != null)
  7097. {
  7098. builder.MoveToBookmark(key);
  7099. builder.Write(dic[key]);
  7100. }
  7101. }
  7102. #endregion
  7103. //文件名
  7104. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7105. strFileName = CommonFun.ValidFileName(strFileName);
  7106. AsposeHelper.removewatermark_v2180();
  7107. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7108. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7109. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7110. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7111. }
  7112. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7113. {
  7114. //获取模板
  7115. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7116. //载入模板
  7117. Document doc = new Document(tempPath);
  7118. DocumentBuilder builder = new DocumentBuilder(doc);
  7119. Dictionary<string, string> dic = new Dictionary<string, string>();
  7120. string returnCodeLabel = string.Empty;
  7121. if (nationalTravelFeeData.Any())
  7122. {
  7123. List<string> list = new List<string>();
  7124. foreach (var item in nationalTravelFeeData)
  7125. {
  7126. list.Add($"{item.Country}({item.City})");
  7127. }
  7128. list = list.Distinct().ToList();
  7129. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7130. }
  7131. var countryLabel = string.Empty;
  7132. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7133. if (countryData.Any())
  7134. {
  7135. countryLabel = string.Join("、", countryData);
  7136. }
  7137. dic.Add("ReturnCodeAir", returnCodeLabel);
  7138. dic.Add("VisitStartDate", "-");
  7139. dic.Add("VisitEndDate", "-");
  7140. dic.Add("Day", "-");
  7141. dic.Add("VisitCountry", countryLabel);
  7142. dic.Add("ClientUnit", "-");
  7143. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7144. //dic.Add("Names", Names);
  7145. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7146. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7147. decimal dac1totalPrice = 0.00M;
  7148. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7149. foreach (var dac in dac1)
  7150. {
  7151. if (dac.SubTotal == 0.00M)
  7152. {
  7153. continue;
  7154. }
  7155. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7156. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7157. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7158. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7159. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7160. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7161. builder.Write(currency);//币种
  7162. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7163. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7164. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7165. builder.Write("");//人数
  7166. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7167. builder.Write("");//天数
  7168. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7169. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7170. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7171. decimal rate = 0.00M;
  7172. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7173. builder.Write(rate.ToString("#0.0000"));//汇率
  7174. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7175. decimal rbmPrice = dac.SubTotal;
  7176. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7177. accommodationStartIndex++;
  7178. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7179. }
  7180. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7181. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7182. {
  7183. table1.Rows.RemoveAt(i - 1);
  7184. foodandotherStartIndex--;
  7185. }
  7186. if (dac2.Count == dac3.Count)//国家 币种 金额
  7187. {
  7188. for (int i = 0; i < dac2.Count; i++)
  7189. {
  7190. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7191. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7192. }
  7193. }
  7194. decimal dac2totalPrice = 0.00M;
  7195. foreach (var dac in dac2)
  7196. {
  7197. if (dac.SubTotal == 0)
  7198. {
  7199. continue;
  7200. }
  7201. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7202. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7203. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7204. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7205. builder.Write(currency);//币种
  7206. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7207. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7208. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7209. builder.Write("");//人数
  7210. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7211. builder.Write("");//天数
  7212. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7213. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7214. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7215. decimal rate = 0.00M;
  7216. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7217. builder.Write(rate.ToString("#0.0000"));//汇率
  7218. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7219. decimal rbmPrice = dac.SubTotal;
  7220. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7221. foodandotherStartIndex++;
  7222. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7223. }
  7224. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7225. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7226. {
  7227. table1.Rows.RemoveAt(i - 1);
  7228. }
  7229. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7230. string otherFeeStr = "";
  7231. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7232. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7233. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7234. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7235. foreach (var otherInfo in dac5)
  7236. {
  7237. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7238. }
  7239. #endregion
  7240. if (otherFeeStr.Length > 0)
  7241. {
  7242. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7243. otherFeeStr = $"({otherFeeStr})";
  7244. dic.Add("OtherFeeStr", otherFeeStr);
  7245. }
  7246. //总计
  7247. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7248. //国际旅费
  7249. string outsideAir = string.Empty;
  7250. string allPriceAir = string.Empty;
  7251. if (_EnterExitCosts.SumJJC == 1)
  7252. {
  7253. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7254. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7255. }
  7256. if (_EnterExitCosts.SumGWC == 1)
  7257. {
  7258. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7259. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7260. }
  7261. if (_EnterExitCosts.SumTDC == 1)
  7262. {
  7263. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7264. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7265. }
  7266. dic.Add("InTravelPrice", $"({outsideAir})");
  7267. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7268. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7269. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7270. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7271. foreach (var key in dic.Keys)
  7272. {
  7273. builder.MoveToBookmark(key);
  7274. builder.Write(dic[key]);
  7275. }
  7276. //模板文件名
  7277. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7278. strFileName = CommonFun.ValidFileName(strFileName);
  7279. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7280. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7281. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7282. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7283. }
  7284. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7285. {
  7286. //获取模板
  7287. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7288. //载入模板
  7289. WorkbookDesigner designer = new WorkbookDesigner();
  7290. designer.Workbook = new Workbook(tempPath);
  7291. Dictionary<string, string> dic = new Dictionary<string, string>();
  7292. string returnCodeLabel = string.Empty;
  7293. if (nationalTravelFeeData.Any())
  7294. {
  7295. List<string> list = new List<string>();
  7296. foreach (var item in nationalTravelFeeData)
  7297. {
  7298. list.Add($"{item.Country}({item.City})");
  7299. }
  7300. list = list.Distinct().ToList();
  7301. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7302. }
  7303. var countryLabel = string.Empty;
  7304. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7305. if (countryData.Any())
  7306. {
  7307. countryLabel = string.Join("、", countryData);
  7308. }
  7309. dic.Add("ReturnCodeAir", returnCodeLabel);
  7310. dic.Add("VisitStartDate", "-");
  7311. dic.Add("VisitEndDate", "-");
  7312. dic.Add("Day", "0");
  7313. dic.Add("VisitCountry", countryLabel);
  7314. dic.Add("ClientUnit", "-");
  7315. designer.SetDataSource("ClientUnit", "-");
  7316. designer.SetDataSource("VisitCountry", countryLabel);
  7317. designer.SetDataSource("Group", "-");
  7318. designer.SetDataSource("ClientUnitTitle", "-");
  7319. designer.SetDataSource("Name", "-");
  7320. designer.SetDataSource("VisitStartDate", "-");
  7321. designer.SetDataSource("Day", "0");
  7322. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7323. designer.SetDataSource("ReturnCodeAir", "-");
  7324. int startIndex = 10;
  7325. const int startIndexcopy = 10;
  7326. if (dac2.Count == dac3.Count)//国家 币种 金额
  7327. {
  7328. for (int i = 0; i < dac2.Count; i++)
  7329. {
  7330. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7331. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7332. }
  7333. }
  7334. DataTable dtdac1 = new DataTable();
  7335. List<string> place = new List<string>();
  7336. dtdac1.Columns.AddRange(new DataColumn[] {
  7337. new DataColumn(){ ColumnName = "city"},
  7338. new DataColumn(){ ColumnName = "curr"},
  7339. new DataColumn(){ ColumnName = "criterion"},
  7340. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7341. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7342. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7343. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7344. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7345. });
  7346. DataTable dtdac2 = new DataTable();
  7347. dtdac2.Columns.AddRange(new DataColumn[] {
  7348. new DataColumn(){ ColumnName = "city"},
  7349. new DataColumn(){ ColumnName = "curr"},
  7350. new DataColumn(){ ColumnName = "criterion"},
  7351. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7352. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7353. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7354. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7355. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7356. });
  7357. dtdac1.TableName = "tb1";
  7358. dtdac2.TableName = "tb2";
  7359. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7360. foreach (var item in dac1)
  7361. {
  7362. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7363. if (place.Contains(item.Place))
  7364. {
  7365. continue;
  7366. }
  7367. DataRow row = dtdac1.NewRow();
  7368. row["city"] = item.Place;
  7369. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7370. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7371. row["curr"] = currency;
  7372. row["rate"] = rate.ToString("#0.0000");
  7373. row["criterion"] = item.Cost.ToString("#0.00");
  7374. row["number"] = 1;
  7375. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7376. //row["costRMB"] = rbmPrice;
  7377. dtdac1.Rows.Add(row);
  7378. place.Add(item.Place);
  7379. }
  7380. place = new List<string>();
  7381. foreach (var item in dac2)
  7382. {
  7383. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7384. if (place.Contains(item.Place))
  7385. {
  7386. continue;
  7387. }
  7388. DataRow row = dtdac2.NewRow();
  7389. row["city"] = item.Place;
  7390. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7391. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7392. row["curr"] = currency;
  7393. row["rate"] = rate.ToString("#0.0000");
  7394. row["criterion"] = item.Cost.ToString("#0.00");
  7395. row["number"] = 1;
  7396. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7397. //row["cost"] = item.SubTotal;
  7398. //row["costRMB"] = rbmPrice;
  7399. dtdac2.Rows.Add(row);
  7400. place.Add(item.Place);
  7401. //dac2totalPrice += rbmPrice;
  7402. }
  7403. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7404. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7405. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7406. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7407. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7408. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7409. string cell4Str1 = string.Empty;
  7410. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7411. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7412. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7413. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7414. string cellStr = $" 5.其他费用(";
  7415. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7416. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7417. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7418. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7419. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7420. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7421. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7422. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7423. foreach (var otherInfo in dac5)
  7424. {
  7425. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7426. }
  7427. #endregion
  7428. if (cellStr.Length > 8)
  7429. {
  7430. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7431. }
  7432. cellStr += ")";
  7433. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7434. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7435. decimal pxFee = dac4.Sum(it => it.Cost);
  7436. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7437. string celllastStr1 = "";
  7438. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7439. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7440. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7441. celllastStr1 += $",国际旅费 元";
  7442. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7443. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7444. designer.SetDataSource("cell4Str", cell4Str);
  7445. designer.SetDataSource("cellStr", cellStr);
  7446. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7447. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7448. designer.SetDataSource("celllastStr", celllastStr);
  7449. Workbook wb = designer.Workbook;
  7450. var sheet = wb.Worksheets[0];
  7451. //绑定datatable数据集
  7452. designer.SetDataSource(dtdac1);
  7453. designer.SetDataSource(dtdac2);
  7454. designer.Process();
  7455. var rowStart = dtdac1.Rows.Count;
  7456. while (rowStart > 0)
  7457. {
  7458. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7459. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7460. startIndex++;
  7461. rowStart--;
  7462. }
  7463. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7464. startIndex += 1; //总计行
  7465. rowStart = dtdac2.Rows.Count;
  7466. while (rowStart > 0)
  7467. {
  7468. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7469. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7470. startIndex++;
  7471. rowStart--;
  7472. }
  7473. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7474. wb.CalculateFormula(true);
  7475. //模板文件名
  7476. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7477. designer.Workbook.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. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7483. {
  7484. //获取模板
  7485. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7486. //载入模板
  7487. Document doc = new Document(tempPath);
  7488. DocumentBuilder builder = new DocumentBuilder(doc);
  7489. Dictionary<string, string> dic = new Dictionary<string, string>();
  7490. dic.Add("GroupName", "-");
  7491. dic.Add("ClientUnit", "-");
  7492. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7493. //string missionLeaderJob = "";//负责人job
  7494. //int groupNumber = 0; //团人数
  7495. dic.Add("MissionLeader", "-"); //团负责人
  7496. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7497. dic.Add("GroupNumber", "0"); //团人数
  7498. dic.Add("Day", "0");
  7499. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7500. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7501. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7502. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7503. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7504. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7505. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7506. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7507. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7508. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7509. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7510. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7511. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7512. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7513. //其他费用
  7514. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7515. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7516. //其他费用合计
  7517. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7518. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7519. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7520. //公务舱合计
  7521. //国际旅费
  7522. //string outsideJJ = "";
  7523. //string allPriceJJ = "";
  7524. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7525. {
  7526. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7527. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7528. }
  7529. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7530. {
  7531. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7532. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7533. }
  7534. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7535. {
  7536. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7537. dic.Add("AirFeeTotal", airFeeTotalStr);
  7538. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7539. dic.Add("FeeTotal", feeTotalStr);
  7540. }
  7541. foreach (var key in dic.Keys)
  7542. {
  7543. builder.MoveToBookmark(key);
  7544. builder.Write(dic[key]);
  7545. }
  7546. //模板文件名
  7547. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7548. strFileName = CommonFun.ValidFileName(strFileName);
  7549. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7550. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7551. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7552. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7553. }
  7554. }
  7555. else if (dto.ExportType == 2) //表格
  7556. {
  7557. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7558. }
  7559. else if (dto.ExportType == 3)
  7560. {
  7561. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7562. }
  7563. return Ok(JsonView(400, "只可导出明细表!", ""));
  7564. }
  7565. catch (Exception ex)
  7566. {
  7567. return Ok(JsonView(400, ex.Message, ""));
  7568. }
  7569. }
  7570. /// <summary>
  7571. /// 获取三公费用标准city
  7572. /// </summary>
  7573. /// <param name="placeData"></param>
  7574. /// <param name="nationalTravelFeeId"></param>
  7575. /// <returns></returns>
  7576. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7577. {
  7578. string _city = string.Empty;
  7579. if (!placeData.Any()) return _city;
  7580. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7581. if (data == null) return _city;
  7582. string country = data.Country;
  7583. string city = data.City;
  7584. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7585. else _city = city;
  7586. return _city;
  7587. }
  7588. /// <summary>
  7589. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7590. /// </summary>
  7591. /// <returns></returns>
  7592. [HttpPost]
  7593. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7595. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7596. {
  7597. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7598. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7599. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7600. if (_view.Code == 0)
  7601. {
  7602. return Ok(JsonView(true, "操作成功"));
  7603. }
  7604. return Ok(JsonView(false, "操作失败"));
  7605. }
  7606. /// <summary>
  7607. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7608. /// </summary>
  7609. /// <returns></returns>
  7610. [HttpPost]
  7611. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7613. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7614. {
  7615. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7616. if (data.Code != 0)
  7617. {
  7618. return Ok(JsonView(false, data.Msg));
  7619. }
  7620. return Ok(JsonView(true, "操作成功!", data.Data));
  7621. }
  7622. /// <summary>
  7623. /// 三公其他费用草稿 删除
  7624. /// </summary>
  7625. /// <param name="dto"></param>
  7626. /// <returns></returns>
  7627. [HttpPost]
  7628. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7629. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7630. {
  7631. var jw = JsonView(false, "删除失败!");
  7632. var data = new Grp_DayOtherPriceDraft()
  7633. {
  7634. Id = dto.Id,
  7635. IsDel = 1,
  7636. DeleteUserId = dto.DeleteUserId,
  7637. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7638. };
  7639. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7640. if (del > 0)
  7641. {
  7642. jw.Code = 200;
  7643. jw.Msg = "删除成功!";
  7644. }
  7645. return Ok(jw);
  7646. }
  7647. /// <summary>
  7648. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7649. /// </summary>
  7650. /// <returns></returns>
  7651. [HttpPost]
  7652. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7653. {
  7654. var jw = JsonView(false);
  7655. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7656. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7657. jw.Code = StatusCodes.Status200OK;
  7658. jw.Msg = "操作成功!";
  7659. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7660. return Ok(jw);
  7661. }
  7662. /// <summary>
  7663. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7664. /// </summary>
  7665. /// <param name="dto"></param>
  7666. /// <returns></returns>
  7667. [HttpPost]
  7668. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7669. {
  7670. int userId = dto.UserId,
  7671. portId = dto.PortType,
  7672. groupId = dto.GroupId,
  7673. draftId = dto.DraftId;
  7674. _portTypeData.Add(1);
  7675. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7676. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7677. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7678. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7679. _sqlSugar.BeginTran();
  7680. try
  7681. {
  7682. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7683. if (draftDatas == null)
  7684. {
  7685. _sqlSugar.RollbackTran();
  7686. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7687. }
  7688. //验证可覆盖已有数据 两边创建人需为同一人;
  7689. int draftCreateUserId = draftDatas.CreateUserId,
  7690. formalCreateUserId = 0;
  7691. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7692. if (formalData != null)
  7693. {
  7694. formalCreateUserId = formalData.CreateUserId;
  7695. if (draftCreateUserId != formalCreateUserId)
  7696. {
  7697. _sqlSugar.RollbackTran();
  7698. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7699. }
  7700. }
  7701. //默认添加查看、编辑权限(创建人、自己)
  7702. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7703. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7704. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7705. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7706. newExterData.DiId = groupId;
  7707. newExterData.CreateUserId = userId;
  7708. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7709. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7710. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7711. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7712. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7713. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7714. //数据如果存在执行删除
  7715. if (enterExitCostInfo != null)
  7716. {
  7717. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7718. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7719. .Where(x => x.Id == enterExitCostInfo.Id)
  7720. .ExecuteCommand();
  7721. _sqlSugar.Updateable<Grp_DayAndCost>()
  7722. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7723. .Where(x => x.DiId == groupId)
  7724. .ExecuteCommand();
  7725. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7726. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7727. .Where(x => x.Diid == groupId)
  7728. .ExecuteCommand();
  7729. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7730. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7731. .Where(x => x.GroupId == groupId)
  7732. .ExecuteCommand();
  7733. }
  7734. //执行insert
  7735. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7736. if (insertId < 1)
  7737. {
  7738. _sqlSugar.RollbackTran();
  7739. return Ok(JsonView(false, "草稿数据导入失败!"));
  7740. }
  7741. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7742. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7743. #region 默认添加权限
  7744. #endregion
  7745. _sqlSugar.CommitTran();
  7746. //执行操作之后
  7747. //生成默认文件pdf并且通知人员
  7748. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7749. {
  7750. DiId = groupId,
  7751. ExportType = 1,
  7752. SubTypeId = 1005
  7753. }, "pdf");
  7754. //发送通知
  7755. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7756. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7757. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7758. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7759. //汇率信息记录
  7760. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7761. return Ok(JsonView(true));
  7762. }
  7763. catch (Exception ex)
  7764. {
  7765. _sqlSugar.RollbackTran();
  7766. return Ok(JsonView(false, ex.Message));
  7767. }
  7768. }
  7769. #endregion
  7770. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7771. /// <summary>
  7772. /// 获取币种基础数据(含逻辑处理)
  7773. /// </summary>
  7774. /// <returns></returns>
  7775. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7776. {
  7777. return await GeneralMethod.EnterExitCostInitRate();
  7778. }
  7779. /// <summary>
  7780. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7781. /// </summary>
  7782. /// <returns></returns>
  7783. [HttpPost]
  7784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7785. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7786. {
  7787. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7788. //SetDataInfoView
  7789. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7790. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7791. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7792. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7793. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7794. //默认币种显示
  7795. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7796. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7797. return Ok(JsonView(true, "查询成功!", new
  7798. {
  7799. WordTypeData = _WordTypeData,
  7800. ExcelTypeData = _ExcelTypeData,
  7801. CurrencyInit = _currencyInfos,
  7802. viewPermissionData = viewPermissionData
  7803. }));
  7804. }
  7805. /// <summary>
  7806. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7807. /// </summary>
  7808. /// <returns></returns>
  7809. [HttpPost]
  7810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7811. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7812. {
  7813. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7814. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7815. RefAsync<int> total = 0;
  7816. int diId = 0;
  7817. var status = int.TryParse(dto.GroupName, out diId);
  7818. string sql = string.Format(@"SELECT
  7819. Id,
  7820. TeamName GroupName,
  7821. CASE WHEN EXISTS (
  7822. SELECT
  7823. 1
  7824. FROM
  7825. Grp_EnterExitCost
  7826. WHERE
  7827. IsDel = 0
  7828. AND DiId = di.Id
  7829. ) THEN 1 ELSE 0 END AS [IsNull],
  7830. CASE WHEN EXISTS(
  7831. SELECT
  7832. TOP 1 *
  7833. FROM
  7834. Grp_EnterExitCost
  7835. WHERE
  7836. IsDel = 0
  7837. AND DiId = di.Id
  7838. AND CreateUserId = {0}
  7839. ORDER BY
  7840. CreateTime DESC
  7841. ) THEN 1 ELSE 0 END AS [IsEdit],
  7842. CASE WHEN EXISTS(
  7843. SELECT
  7844. TOP 1 *
  7845. FROM
  7846. Grp_EnterExitCost
  7847. WHERE
  7848. IsDel = 0
  7849. AND DiId = di.Id
  7850. AND CreateUserId = {0}
  7851. ORDER BY
  7852. CreateTime DESC
  7853. ) THEN 1 WHEN EXISTS(
  7854. SELECT
  7855. TOP 1 *
  7856. FROM
  7857. Grp_EnterExitCostPermission
  7858. WHERE
  7859. IsDel = 0
  7860. AND GroupId = di.Id
  7861. AND Permission = 1
  7862. AND UserId = {0}
  7863. ORDER BY
  7864. CreateTime DESC
  7865. ) THEN 1 ELSE 0 END AS [IsView]
  7866. FROM
  7867. Grp_DelegationInfo di
  7868. WHERE
  7869. di.Isdel = 0
  7870. ORDER BY di.VisitStartDate DESC", dto.CurrUserId);
  7871. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7872. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7873. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7874. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7875. .OrderByDescending(x => x.Id)
  7876. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7877. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  7878. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  7879. {
  7880. foreach (var item in data)
  7881. {
  7882. item.IsView = true;
  7883. }
  7884. }
  7885. return Ok(JsonView(true, "查询成功!", data, total));
  7886. }
  7887. /// <summary>
  7888. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7889. /// </summary>
  7890. /// <returns></returns>
  7891. [HttpPost]
  7892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7893. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7894. {
  7895. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7896. RefAsync<int> total = 0;
  7897. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7898. .Where(x => x.IsDel == 0 && x.STid == 66)
  7899. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7900. .Select(x => new
  7901. {
  7902. id = x.Id,
  7903. name = x.Name,
  7904. remark = x.Remark,
  7905. })
  7906. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7907. return Ok(JsonView(true, "查询成功!", data, total));
  7908. }
  7909. /// <summary>
  7910. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7911. /// </summary>
  7912. /// <returns></returns>
  7913. [HttpPost]
  7914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7915. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7916. {
  7917. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7918. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7919. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7920. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7921. var groupOtherRateData = groupRateData.TeamRates;
  7922. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7923. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7924. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7925. groupOtherRateData = groupOtherRateData
  7926. .Select(x => new TeamRateDescAddCurrencyIdView
  7927. {
  7928. CurrencyId = x.CurrencyId,
  7929. CurrencyName = x.CurrencyName,
  7930. CurrencyCode = x.CurrencyCode,
  7931. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7932. }).ToList();
  7933. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7934. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7935. }
  7936. /// <summary>
  7937. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7938. /// </summary>
  7939. /// <returns></returns>
  7940. [HttpPost]
  7941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7942. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7943. {
  7944. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7945. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7946. var tipsData = new List<int>() { 1, 2, 3 };
  7947. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7948. if (dto.TipsType == 1)
  7949. {
  7950. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  7951. }
  7952. else if (dto.TipsType == 2)
  7953. {
  7954. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  7955. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7956. }
  7957. else if (dto.TipsType == 3)
  7958. {
  7959. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7960. return Ok(JsonView(true, "查询成功!", airData.Data));
  7961. }
  7962. return Ok(JsonView(false));
  7963. }
  7964. /// <summary>
  7965. /// 团组模块 - 出入境国家费用标准-移动端 List
  7966. /// </summary>
  7967. /// <returns></returns>
  7968. [HttpPost]
  7969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7970. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7971. {
  7972. Stopwatch sw = new Stopwatch();
  7973. sw.Start();
  7974. RefAsync<int> total = 0;
  7975. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7976. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7977. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7978. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7979. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7980. .Select((ntf, sd, u) => new
  7981. {
  7982. Id = ntf.Id,
  7983. Area = $"{ntf.Country}-{ntf.City}",
  7984. Currency = ntf.Currency,
  7985. CurrencyCode = sd.Name,
  7986. CurrencyName = sd.Remark,
  7987. RoomCost = ntf.RoomCost,
  7988. FoodCost = ntf.FoodCost,
  7989. PublicCost = ntf.PublicCost,
  7990. LastUpdateUserId = ntf.LastUpdateUserId,
  7991. LastUpdateUserName = u.CnName,
  7992. LastUpdateTime = ntf.LastUpdateTime,
  7993. })
  7994. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7995. sw.Stop();
  7996. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  7997. }
  7998. /// <summary>
  7999. /// 团组模块 - 出入境费用-移动端 - Info
  8000. /// </summary>
  8001. /// <returns></returns>
  8002. [HttpPost]
  8003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8004. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8005. {
  8006. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8007. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8008. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8009. return Ok(data);
  8010. }
  8011. /// <summary>
  8012. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8013. /// </summary>
  8014. /// <returns></returns>
  8015. [HttpPost]
  8016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8017. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8018. {
  8019. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8020. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8021. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8022. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8023. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8024. mobileInfo.DiId = dto.DiId;
  8025. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8026. if (eecInfo == null) return Ok(mobileInfo);
  8027. //验证查看权限
  8028. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8029. //if (!isView) return Ok(JsonView(false, msg));
  8030. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8031. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8032. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8033. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8034. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8035. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8036. {
  8037. SubId = dac.Id,
  8038. DiId = dac.DiId,
  8039. Type = dac.Type,
  8040. Days = dac.Days,
  8041. NationalTravelFeeId = dac.NationalTravelFeeId,
  8042. Arae = $"{ntf.Country}-{ntf.City}",
  8043. Cost = dac.Cost,
  8044. Currency = dac.Currency,
  8045. CurrencyName = sd.Name,
  8046. SubTotal = dac.SubTotal,
  8047. })
  8048. .ToList();
  8049. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8050. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8051. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8052. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8053. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8054. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8055. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8056. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8057. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8058. //其他款项
  8059. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8060. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8061. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8062. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8063. .OrderBy((dop, sd1, sd2) => dop.Index)
  8064. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8065. {
  8066. SubId = dop.Id,
  8067. DiId = dop.Diid,
  8068. Index = dop.Index,
  8069. SetDataId = dop.SetDataId,
  8070. SetDataName = sd1.Name,
  8071. Cost = dop.Cost,
  8072. Currency = dop.Currency,
  8073. CurrencyName = sd2.Remark,
  8074. SubTotal = dop.SubTotal,
  8075. Remark = dop.Remark,
  8076. })
  8077. .ToArray();
  8078. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8079. return Ok(mobileInfo);
  8080. }
  8081. /// <summary>
  8082. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8083. /// </summary>
  8084. /// <returns></returns>
  8085. [HttpPost]
  8086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8087. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8088. {
  8089. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8090. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8091. //验证查看权限
  8092. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8093. if (!isView) return Ok(JsonView(false, msg));
  8094. var userIds = Array.Empty<int>();
  8095. userIds = await _sqlSugar
  8096. .Queryable<Grp_EnterExitCostPermission>()
  8097. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8098. .Select(x => x.UserId)
  8099. .ToArrayAsync();
  8100. return Ok(userIds);
  8101. }
  8102. /// <summary>
  8103. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8104. /// </summary>
  8105. /// <returns></returns>
  8106. [HttpPost]
  8107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8108. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8109. {
  8110. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8111. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8112. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8113. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8114. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8115. //验证查看权限
  8116. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8117. //if (!isView) return Ok(JsonView(false, msg));
  8118. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8119. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8120. var subType = dto.SubType;
  8121. if (subType == 1) //1:境内费用
  8122. {
  8123. var oneData = new ChoiceOneMobileSubInfoView()
  8124. {
  8125. Id = eecInfo.Id,
  8126. ChoiceOne = eecInfo.ChoiceOne,
  8127. ChoiceOneTotalCost = eecInfo.InsidePay,
  8128. Visa = eecInfo.Visa,
  8129. VisaRemark = eecInfo.VisaRemark,
  8130. YiMiao = eecInfo.YiMiao,
  8131. HeSuan = eecInfo.HeSuan,
  8132. Service = eecInfo.Service,
  8133. Ticket = eecInfo.Ticket,
  8134. Safe = eecInfo.Safe,
  8135. FirstItemRemark = eecInfo.FirstItemRemark
  8136. };
  8137. return Ok(JsonView(oneData));
  8138. }
  8139. else if (subType == 2) //2:国际旅费
  8140. {
  8141. var twoData = new ChoiceTwoMobileSubInfoView()
  8142. {
  8143. Id = eecInfo.Id,
  8144. ChoiceTwoJJ = eecInfo.SumJJC,
  8145. OutsideJJPay = eecInfo.OutsideJJPay,
  8146. ChoiceTwoGW = eecInfo.SumGWC,
  8147. OutsideGWPay = eecInfo.OutsideGWPay,
  8148. ChoiceTwoTD = eecInfo.SumTDC,
  8149. OutsideTDPay = eecInfo.OutsideTDPay,
  8150. AirJJ = eecInfo.AirJJ,
  8151. AirGW = eecInfo.AirGW,
  8152. AirTD = eecInfo.AirTD,
  8153. CityTranffic = eecInfo.CityTranffic,
  8154. TwoItemRemark = eecInfo.TwoItemRemark
  8155. };
  8156. return Ok(JsonView(twoData));
  8157. }
  8158. else if (subType == 3) //3:住宿费
  8159. {
  8160. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8161. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8162. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8163. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8164. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8165. {
  8166. SubId = dac.Id,
  8167. DiId = dac.DiId,
  8168. Type = dac.Type,
  8169. Days = dac.Days,
  8170. NationalTravelFeeId = dac.NationalTravelFeeId,
  8171. Arae = $"{ntf.Country}-{ntf.City}",
  8172. Cost = dac.Cost,
  8173. Currency = dac.Currency,
  8174. CurrencyName = sd.Name,
  8175. SubTotal = dac.SubTotal,
  8176. })
  8177. .ToArray();
  8178. var data = new ChoiceMobileSubInfo3To6View()
  8179. {
  8180. ParentId = eecInfo.Id,
  8181. Choice = eecInfo.ChoiceThree,
  8182. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8183. Details = dayAndCostDatas
  8184. };
  8185. return Ok(JsonView(data));
  8186. }
  8187. else if (subType == 4) //4:伙食费
  8188. {
  8189. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8190. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8191. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8192. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8193. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8194. {
  8195. SubId = dac.Id,
  8196. DiId = dac.DiId,
  8197. Type = dac.Type,
  8198. Days = dac.Days,
  8199. NationalTravelFeeId = dac.NationalTravelFeeId,
  8200. Arae = $"{ntf.Country}-{ntf.City}",
  8201. Cost = dac.Cost,
  8202. Currency = dac.Currency,
  8203. CurrencyName = sd.Name,
  8204. SubTotal = dac.SubTotal,
  8205. })
  8206. .ToArray();
  8207. var data = new ChoiceMobileSubInfo3To6View()
  8208. {
  8209. ParentId = eecInfo.Id,
  8210. Choice = eecInfo.ChoiceFour,
  8211. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8212. Details = dayAndCostDatas
  8213. };
  8214. return Ok(JsonView(data));
  8215. }
  8216. else if (subType == 5) //5:公杂费
  8217. {
  8218. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8219. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8220. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8221. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8222. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8223. {
  8224. SubId = dac.Id,
  8225. DiId = dac.DiId,
  8226. Type = dac.Type,
  8227. Days = dac.Days,
  8228. NationalTravelFeeId = dac.NationalTravelFeeId,
  8229. Arae = $"{ntf.Country}-{ntf.City}",
  8230. Cost = dac.Cost,
  8231. Currency = dac.Currency,
  8232. CurrencyName = sd.Name,
  8233. SubTotal = dac.SubTotal,
  8234. })
  8235. .ToArray();
  8236. var data = new ChoiceMobileSubInfo3To6View()
  8237. {
  8238. ParentId = eecInfo.Id,
  8239. Choice = eecInfo.ChoiceFive,
  8240. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8241. Details = dayAndCostDatas
  8242. };
  8243. return Ok(JsonView(data));
  8244. }
  8245. else if (subType == 6) //6:培训费
  8246. {
  8247. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8248. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8249. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8250. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8251. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8252. {
  8253. SubId = dac.Id,
  8254. DiId = dac.DiId,
  8255. Type = dac.Type,
  8256. Days = dac.Days,
  8257. NationalTravelFeeId = dac.NationalTravelFeeId,
  8258. Arae = $"{ntf.Country}-{ntf.City}",
  8259. Cost = dac.Cost,
  8260. Currency = dac.Currency,
  8261. CurrencyName = sd.Name,
  8262. SubTotal = dac.SubTotal,
  8263. })
  8264. .ToArray();
  8265. var data = new ChoiceMobileSubInfo3To6View()
  8266. {
  8267. ParentId = eecInfo.Id,
  8268. Choice = eecInfo.ChoiceSix,
  8269. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8270. Details = dayAndCostDatas
  8271. };
  8272. return Ok(JsonView(data));
  8273. }
  8274. else if (subType == 7) //7:其他
  8275. {
  8276. //其他款项
  8277. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8278. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8279. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8280. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8281. .OrderBy((dop, sd1, sd2) => dop.Index)
  8282. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8283. {
  8284. SubId = dop.Id,
  8285. DiId = dop.Diid,
  8286. Index = dop.Index,
  8287. SetDataId = dop.SetDataId,
  8288. SetDataName = sd1.Name,
  8289. Cost = dop.Cost,
  8290. Currency = dop.Currency,
  8291. CurrencyName = sd2.Name,
  8292. SubTotal = dop.SubTotal,
  8293. Remark = dop.Remark,
  8294. })
  8295. .ToArray();
  8296. var data = new ChoiceSevenMobileSubInfoView()
  8297. {
  8298. ParentId = eecInfo.Id,
  8299. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8300. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8301. Details = otherData
  8302. };
  8303. return Ok(JsonView(data));
  8304. }
  8305. return Ok(JsonView(false));
  8306. }
  8307. #region op
  8308. /// <summary>
  8309. /// 移动端更新费用消息通知
  8310. /// </summary>
  8311. /// <param name="diid"></param>
  8312. /// <param name="id"></param>
  8313. /// <param name="currUserId"></param>
  8314. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8315. {
  8316. try
  8317. {
  8318. ////生成默认文件pdf并且通知人员
  8319. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8320. //{
  8321. // DiId = diid,
  8322. // ExportType = 1,
  8323. // SubTypeId = 1005
  8324. //}, "pdf");
  8325. ////发送通知
  8326. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8327. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8328. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8329. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8330. ////汇率信息记录
  8331. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8332. }
  8333. catch (Exception ex)
  8334. {
  8335. //记录日志
  8336. throw;
  8337. }
  8338. }
  8339. /// <summary>
  8340. /// 验证出入境费用数据是否存在
  8341. /// 不存在添加
  8342. /// </summary>
  8343. /// <param name="diId"></param>
  8344. /// <param name="currUserId"></param>
  8345. /// <returns></returns>
  8346. /// <exception cref="CustomException"></exception>
  8347. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8348. {
  8349. var parentId = 0;
  8350. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8351. if (info != null)
  8352. {
  8353. parentId = info.Id;
  8354. }
  8355. else
  8356. {
  8357. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8358. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8359. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8360. parentId = addId;
  8361. }
  8362. return parentId;
  8363. }
  8364. /// <summary>
  8365. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8366. /// </summary>
  8367. /// <returns></returns>
  8368. [HttpPost]
  8369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8370. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8371. {
  8372. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8373. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8374. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8375. //验证编辑权限
  8376. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8377. //if (!isEdit) return Ok(JsonView(false, msg));
  8378. var permissions = new List<Grp_EnterExitCostPermission>();
  8379. foreach (var userId in dto.UserIds)
  8380. {
  8381. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8382. }
  8383. if (permissions.Any())
  8384. {
  8385. _sqlSugar.BeginTran();
  8386. try
  8387. {
  8388. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8389. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8390. if (result < 1)
  8391. {
  8392. _sqlSugar.RollbackTran();
  8393. return Ok(JsonView(false));
  8394. }
  8395. }
  8396. catch (Exception ex)
  8397. {
  8398. _sqlSugar.RollbackTran();
  8399. return Ok(JsonView(false, ex.Message));
  8400. }
  8401. _sqlSugar.CommitTran();
  8402. return Ok(JsonView(true));
  8403. }
  8404. return Ok(JsonView(false));
  8405. }
  8406. /// <summary>
  8407. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8408. /// </summary>
  8409. /// <returns></returns>
  8410. [HttpPost]
  8411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8412. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8413. {
  8414. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8415. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8416. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8417. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8418. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8419. int id = dto.Id;
  8420. if (id <= 0) //add
  8421. {
  8422. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8423. if (add < 1) return Ok(JsonView(false));
  8424. id = add;
  8425. }
  8426. else //update
  8427. {
  8428. ////验证编辑权限
  8429. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8430. //if (!isEdit) return Ok(JsonView(false, msg));
  8431. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8432. if (upd < 1) return Ok(JsonView(false));
  8433. }
  8434. #region 汇率变更时更改币种相关费用
  8435. var opDayCosts = new List<Grp_DayAndCost>();
  8436. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8437. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8438. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8439. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8440. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8441. .Select((dac, sd) => new
  8442. {
  8443. dac.Id,
  8444. dac.DiId,
  8445. CurrencyCode = sd.Name,
  8446. dac.Cost
  8447. })
  8448. .ToList();
  8449. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8450. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8451. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8452. .Select((dop, sd) => new
  8453. {
  8454. dop.Id,
  8455. dop.Diid,
  8456. CurrencyCode = sd.Name,
  8457. dop.Cost
  8458. })
  8459. .ToList();
  8460. if (dayCosts.Count > 0)
  8461. {
  8462. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8463. foreach (var dc in new_dayCosts)
  8464. {
  8465. var thisCurrency = dc.Key.ToUpper();
  8466. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8467. if (thisRate == 0.00M) continue;
  8468. foreach (var dcSub in dc)
  8469. {
  8470. opDayCosts.Add(new Grp_DayAndCost()
  8471. {
  8472. Id = dcSub.Id,
  8473. DiId = dcSub.DiId,
  8474. Cost = dcSub.Cost,
  8475. SubTotal = dcSub.Cost * thisRate,
  8476. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8477. });
  8478. }
  8479. }
  8480. if (opDayCosts.Count > 0)
  8481. {
  8482. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8483. }
  8484. }
  8485. if (dayOtherCosts.Count > 0)
  8486. {
  8487. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8488. foreach (var dc in new_dayOtherCosts)
  8489. {
  8490. var thisCurrency = dc.Key.ToUpper();
  8491. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8492. if (thisRate == 0.00M) continue;
  8493. foreach (var dcSub in dc)
  8494. {
  8495. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8496. {
  8497. Id = dcSub.Id,
  8498. Diid = dcSub.Diid,
  8499. Cost = dcSub.Cost,
  8500. SubTotal = dcSub.Cost * thisRate,
  8501. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8502. });
  8503. }
  8504. }
  8505. if (opDayOtherCosts.Count > 0)
  8506. {
  8507. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8508. }
  8509. }
  8510. #endregion
  8511. //消息通知
  8512. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8513. //汇率信息记录
  8514. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8515. return Ok(JsonView(new { parentId = id }));
  8516. }
  8517. /// <summary>
  8518. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8519. /// </summary>
  8520. /// <returns></returns>
  8521. [HttpPost]
  8522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8523. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8524. {
  8525. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8526. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8527. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8528. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8529. int id = dto.Id;
  8530. if (id <= 0) //add
  8531. {
  8532. checkboxInfo.CreateUserId = dto.CurrUserId;
  8533. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8534. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8535. if (add < 1) return Ok(JsonView(false));
  8536. }
  8537. else //update
  8538. {
  8539. ////验证编辑权限
  8540. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8541. //if (!isEdit) return Ok(JsonView(false, msg));
  8542. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8543. .UpdateColumns(x => new
  8544. {
  8545. x.ChoiceOne,
  8546. x.ChoiceTwo,
  8547. x.SumJJC,
  8548. x.SumGWC,
  8549. x.SumTDC,
  8550. x.ChoiceThree,
  8551. x.ChoiceFour,
  8552. x.ChoiceFive,
  8553. x.ChoiceSix,
  8554. x.OtherExpenses_Checked
  8555. })
  8556. .Where(x => x.Id == id)
  8557. .ExecuteCommandAsync();
  8558. if (upd < 1) return Ok(JsonView(false));
  8559. }
  8560. return Ok(JsonView(new { parentId = id }));
  8561. }
  8562. /// <summary>
  8563. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8564. /// </summary>
  8565. /// <returns></returns>
  8566. [HttpPost]
  8567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8568. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8569. {
  8570. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8571. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8572. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8573. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8574. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8575. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8576. var checkboxInfo = new Grp_EnterExitCost()
  8577. {
  8578. Id = id,
  8579. DiId = diId,
  8580. CreateUserId = currUserId
  8581. };
  8582. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8583. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8584. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8585. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8586. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8587. if (id <= 0) //add
  8588. {
  8589. checkboxInfo.CreateUserId = dto.CurrUserId;
  8590. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8591. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8592. if (add < 1) return Ok(JsonView(false));
  8593. }
  8594. else //update
  8595. {
  8596. ////验证编辑权限
  8597. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8598. //if (!isEdit) return Ok(JsonView(false, msg));
  8599. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8600. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8601. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8602. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8603. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8604. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8605. .Where(x => x.Id == id)
  8606. .ExecuteCommandAsync();
  8607. if (upd < 1) return Ok(JsonView(false));
  8608. }
  8609. return Ok(JsonView(new { parentId = id }));
  8610. }
  8611. /// <summary>
  8612. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8613. /// </summary>
  8614. /// <returns></returns>
  8615. [HttpPost]
  8616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8617. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8618. {
  8619. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8620. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8621. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8622. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8623. info.FirstItemRemark = dto.FirstItemRemark;
  8624. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8625. int id = dto.Id;
  8626. if (id <= 0) //add
  8627. {
  8628. info.CreateUserId = dto.CurrUserId;
  8629. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8630. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8631. if (add < 1) return Ok(JsonView(false));
  8632. id = add;
  8633. }
  8634. else //update
  8635. {
  8636. ////验证编辑权限
  8637. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8638. //if (!isEdit) return Ok(JsonView(false, msg));
  8639. var upd = await _sqlSugar.Updateable(info)
  8640. .UpdateColumns(x => new
  8641. {
  8642. x.ChoiceOne,
  8643. x.InsidePay,
  8644. x.VisaRemark,
  8645. x.Visa,
  8646. x.Service,
  8647. x.Safe,
  8648. x.Ticket,
  8649. x.HeSuan,
  8650. x.YiMiao,
  8651. x.FirstItemRemark
  8652. })
  8653. .Where(x => x.Id == id)
  8654. .ExecuteCommandAsync();
  8655. if (upd < 1) return Ok(JsonView(false));
  8656. }
  8657. //消息通知
  8658. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8659. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8660. }
  8661. /// <summary>
  8662. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8663. /// </summary>
  8664. /// <returns></returns>
  8665. [HttpPost]
  8666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8667. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8668. {
  8669. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8670. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8671. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8672. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8673. info.OutsideJJPay = dto.OutsideJJPay;
  8674. info.OutsideGWPay = dto.OutsideGWPay;
  8675. info.OutsideTDPay = dto.OutsideTDPay;
  8676. info.AirJJ = dto.AirJJ;
  8677. info.AirGW = dto.AirGW;
  8678. info.AirTD = dto.AirTD;
  8679. info.CityTranffic = dto.CityTranffic;
  8680. info.TwoItemRemark = dto.TwoItemRemark;
  8681. info.SumJJC = dto.ChoiceTwoJJ;
  8682. info.SumGWC = dto.ChoiceTwoGW;
  8683. info.SumTDC = dto.ChoiceTwoTD;
  8684. int id = dto.Id;
  8685. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8686. if (id <= 0) //add
  8687. {
  8688. info.CreateUserId = dto.CurrUserId;
  8689. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8690. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8691. if (addId <= 0) return Ok(JsonView(false));
  8692. id = addId;
  8693. }
  8694. else //update
  8695. {
  8696. ////验证编辑权限
  8697. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8698. //if (!isEdit) return Ok(JsonView(false, msg));
  8699. var upd = await _sqlSugar.Updateable(info)
  8700. .UpdateColumns(x => new
  8701. {
  8702. x.SumJJC,
  8703. x.OutsideJJPay,
  8704. x.SumGWC,
  8705. x.OutsideGWPay,
  8706. x.SumTDC,
  8707. x.OutsideTDPay,
  8708. x.AirJJ,
  8709. x.AirGW,
  8710. x.AirTD,
  8711. x.CityTranffic,
  8712. x.TwoItemRemark
  8713. })
  8714. .Where(x => x.Id == id)
  8715. .ExecuteCommandAsync();
  8716. if (upd < 1) return Ok(JsonView(false));
  8717. }
  8718. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8719. gwcItemTotal = info.AirGW + info.CityTranffic;
  8720. tdcItemTotal = info.AirTD + info.CityTranffic;
  8721. //消息通知
  8722. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8723. return Ok(JsonView(new
  8724. {
  8725. parentId = id,
  8726. choiceTwoJJ = dto.ChoiceTwoJJ,
  8727. jjcItemTotal = jjcItemTotal,
  8728. choiceTwoGW = dto.ChoiceTwoGW,
  8729. gwcItemTotal = gwcItemTotal,
  8730. choiceTwoTD = dto.ChoiceTwoTD,
  8731. tdcItemTotal = tdcItemTotal
  8732. }));
  8733. }
  8734. /// <summary>
  8735. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8736. /// </summary>
  8737. /// <returns></returns>
  8738. [HttpPost]
  8739. [ApiExplorerSettings(IgnoreApi = true)]
  8740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8741. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8742. {
  8743. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8744. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8745. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8746. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8747. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8748. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8749. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8750. var infos = infos1.Select(x => new Grp_DayAndCost
  8751. {
  8752. Id = x.Id,
  8753. DiId = dto.DiId,
  8754. Type = dto.FeeType,
  8755. Days = x.Days,
  8756. NationalTravelFeeId = x.NationalTravelFeeId,
  8757. Cost = x.Cost,
  8758. Currency = x.Currency,
  8759. SubTotal = x.SubTotal,
  8760. CreateUserId = dto.CurrUserId
  8761. })
  8762. .ToList();
  8763. var adds = infos.Where(x => x.Id <= 0).ToList();
  8764. var upds = infos.Where(x => x.Id > 0).ToList();
  8765. if (adds.Count > 0)
  8766. {
  8767. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8768. if (add < 1) return Ok(JsonView(false));
  8769. }
  8770. if (upds.Count > 0)
  8771. {
  8772. var upd = await _sqlSugar.Updateable(adds)
  8773. .UpdateColumns(x => new
  8774. {
  8775. x.Days,
  8776. x.NationalTravelFeeId,
  8777. x.Cost,
  8778. x.Currency,
  8779. x.SubTotal
  8780. })
  8781. .WhereColumns(x => new { x.Id })
  8782. .ExecuteCommandAsync();
  8783. if (upd < 1) return Ok(JsonView(false));
  8784. }
  8785. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8786. //消息通知
  8787. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8788. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8789. return Ok(JsonView(new { itemTotal = itemTotal }));
  8790. }
  8791. /// <summary>
  8792. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8793. /// </summary>
  8794. /// <returns></returns>
  8795. [HttpPost]
  8796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8797. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8798. {
  8799. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8800. int subId = dto.SubId, feeType = dto.FeeType;
  8801. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8802. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8803. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8804. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8805. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8806. subInfo.Id = subId;
  8807. subInfo.DiId = dto.DiId;
  8808. if (feeType == 3) subInfo.Type = 1;
  8809. else if (feeType == 4) subInfo.Type = 2;
  8810. else if (feeType == 5) subInfo.Type = 3;
  8811. else if (feeType == 6) subInfo.Type = 4;
  8812. subInfo.CreateUserId = dto.CurrUserId;
  8813. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8814. if (parentId < 1) return Ok(JsonView(false));
  8815. //子表op
  8816. if (subId < 1)
  8817. {
  8818. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8819. if (subAdd < 1) return Ok(JsonView(false));
  8820. }
  8821. else
  8822. {
  8823. ////验证编辑权限
  8824. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8825. //if (!isEdit) return Ok(JsonView(false, msg));
  8826. var subUpd = await _sqlSugar.Updateable(subInfo)
  8827. .UpdateColumns(x => new
  8828. {
  8829. x.Days,
  8830. x.NationalTravelFeeId,
  8831. x.Cost,
  8832. x.Currency,
  8833. x.SubTotal
  8834. })
  8835. .WhereColumns(x => new { x.Id })
  8836. .ExecuteCommandAsync();
  8837. if (subUpd < 1) return Ok(JsonView(false));
  8838. }
  8839. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8840. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8841. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8842. }
  8843. /// <summary>
  8844. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8845. /// </summary>
  8846. /// <returns></returns>
  8847. [HttpPost]
  8848. [ApiExplorerSettings(IgnoreApi = true)]
  8849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8850. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8851. {
  8852. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8853. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8854. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8855. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8856. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8857. {
  8858. Id = x.Id,
  8859. Diid = dto.DiId,
  8860. SetDataId = x.SetDataId,
  8861. Index = x.Index,
  8862. Cost = x.Cost,
  8863. Currency = x.Currency,
  8864. SubTotal = x.SubTotal,
  8865. CreateUserId = dto.CurrUserId,
  8866. Remark = x.Remark
  8867. }).ToList();
  8868. var adds = infos.Where(x => x.Id <= 0).ToList();
  8869. var upds = infos.Where(x => x.Id > 0).ToList();
  8870. if (adds.Count > 0)
  8871. {
  8872. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8873. if (add < 1) return Ok(JsonView(false));
  8874. }
  8875. if (upds.Count > 0)
  8876. {
  8877. var upd = await _sqlSugar.Updateable(adds)
  8878. .UpdateColumns(x => new
  8879. {
  8880. x.Index,
  8881. x.SetDataId,
  8882. x.Cost,
  8883. x.Currency,
  8884. x.SubTotal,
  8885. x.Remark
  8886. })
  8887. .WhereColumns(x => new { x.Id })
  8888. .ExecuteCommandAsync();
  8889. if (upd < 1) return Ok(JsonView(false));
  8890. }
  8891. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8892. //消息通知
  8893. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8894. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8895. return Ok(JsonView(new { itemTotal = itemTotal }));
  8896. }
  8897. /// <summary>
  8898. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8899. /// </summary>
  8900. /// <returns></returns>
  8901. [HttpPost]
  8902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8903. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8904. {
  8905. int subId = dto.SubId;
  8906. int diId = dto.Diid;
  8907. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8908. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8909. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8910. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8911. subInfo.Id = subId;
  8912. subInfo.Diid = dto.Diid;
  8913. subInfo.CreateUserId = dto.CurrUserId;
  8914. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8915. if (parentId < 1) return Ok(JsonView(false));
  8916. #region 子表op
  8917. if (subId < 1)//add
  8918. {
  8919. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8920. if (subAdd < 1) return Ok(JsonView(false));
  8921. }
  8922. else //upd
  8923. {
  8924. ////验证编辑权限
  8925. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8926. //if (!isEdit) return Ok(JsonView(false, msg));
  8927. var subUpd = await _sqlSugar.Updateable(subInfo)
  8928. .UpdateColumns(x => new
  8929. {
  8930. x.Index,
  8931. x.SetDataId,
  8932. x.Cost,
  8933. x.Currency,
  8934. x.SubTotal,
  8935. x.Remark
  8936. })
  8937. .WhereColumns(x => new { x.Id })
  8938. .ExecuteCommandAsync();
  8939. if (subUpd < 1) return Ok(JsonView(false));
  8940. }
  8941. #endregion
  8942. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8943. //消息通知
  8944. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8945. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8946. }
  8947. /// <summary>
  8948. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8949. /// </summary>
  8950. /// <returns></returns>
  8951. [HttpPost]
  8952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8953. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8954. {
  8955. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8956. if (data.Code != 0)
  8957. {
  8958. return Ok(JsonView(false, data.Msg));
  8959. }
  8960. return Ok(JsonView(true, "操作成功!", data.Data));
  8961. }
  8962. /// <summary>
  8963. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8964. /// </summary>
  8965. /// <param name="dto"></param>
  8966. /// <returns></returns>
  8967. [HttpPost]
  8968. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8969. {
  8970. var data = new Grp_DayOtherPrice()
  8971. {
  8972. Id = dto.Id,
  8973. IsDel = 1,
  8974. DeleteUserId = dto.DeleteUserId,
  8975. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8976. };
  8977. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8978. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  8979. return Ok(JsonView(false, "删除失败!"));
  8980. }
  8981. #endregion
  8982. #endregion
  8983. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  8984. /// <summary>
  8985. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  8986. /// </summary>
  8987. /// <returns></returns>
  8988. [HttpPost]
  8989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8990. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  8991. {
  8992. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8993. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8994. RefAsync<int> total = 0;
  8995. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8996. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  8997. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  8998. .Select(x => new
  8999. {
  9000. Id = x.Id,
  9001. DraftName = x.DraftName,
  9002. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9003. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9004. .Any()
  9005. })
  9006. .OrderByDescending(x => x.Id)
  9007. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9008. return Ok(JsonView(true, "查询成功!", data, total));
  9009. }
  9010. /// <summary>
  9011. /// 出入境费用-草稿 移动端
  9012. /// 获取币种基础数据(含逻辑处理)
  9013. /// </summary>
  9014. /// <returns></returns>
  9015. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9016. {
  9017. return await GeneralMethod.EnterExitCostInitRate();
  9018. }
  9019. /// <summary>
  9020. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9021. /// </summary>
  9022. /// <returns></returns>
  9023. [HttpPost]
  9024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9025. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9026. {
  9027. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9028. //SetDataInfoView
  9029. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9030. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9031. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9032. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9033. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9034. //默认币种显示
  9035. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9036. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9037. return Ok(JsonView(true, "查询成功!", new
  9038. {
  9039. WordTypeData = _WordTypeData,
  9040. ExcelTypeData = _ExcelTypeData,
  9041. CurrencyInit = _currencyInfos,
  9042. viewPermissionData = viewPermissionData
  9043. }));
  9044. }
  9045. /// <summary>
  9046. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9047. /// </summary>
  9048. /// <returns></returns>
  9049. [HttpPost]
  9050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9051. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9052. {
  9053. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9054. RefAsync<int> total = 0;
  9055. int diId = 0;
  9056. var status = int.TryParse(dto.GroupName, out diId);
  9057. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9058. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9059. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9060. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9061. .Select(x => new
  9062. {
  9063. Id = x.Id,
  9064. GroupName = x.TeamName
  9065. })
  9066. .OrderByDescending(x => x.Id)
  9067. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9068. return Ok(JsonView(true, "查询成功!", data, total));
  9069. }
  9070. /// <summary>
  9071. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9072. /// </summary>
  9073. /// <returns></returns>
  9074. [HttpPost]
  9075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9076. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9077. {
  9078. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9079. RefAsync<int> total = 0;
  9080. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9081. .Where(x => x.IsDel == 0 && x.STid == 66)
  9082. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9083. .Select(x => new
  9084. {
  9085. id = x.Id,
  9086. name = x.Name,
  9087. remark = x.Remark,
  9088. })
  9089. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9090. return Ok(JsonView(true, "查询成功!", data, total));
  9091. }
  9092. /// <summary>
  9093. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9094. /// </summary>
  9095. /// <returns></returns>
  9096. [HttpPost]
  9097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9098. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9099. {
  9100. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9101. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9102. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9103. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9104. var groupOtherRateData = groupRateData.TeamRates;
  9105. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9106. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9107. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9108. groupOtherRateData = groupOtherRateData
  9109. .Select(x => new TeamRateDescAddCurrencyIdView
  9110. {
  9111. CurrencyId = x.CurrencyId,
  9112. CurrencyName = x.CurrencyName,
  9113. CurrencyCode = x.CurrencyCode,
  9114. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9115. }).ToList();
  9116. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9117. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9118. }
  9119. /// <summary>
  9120. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9121. /// </summary>
  9122. /// <returns></returns>
  9123. [HttpPost]
  9124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9125. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9126. {
  9127. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9128. var tipsData = new List<int>() { 1, 2, 3 };
  9129. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9130. if (dto.TipsType == 1)
  9131. {
  9132. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9133. }
  9134. else if (dto.TipsType == 2)
  9135. {
  9136. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9137. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9138. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9139. .Select(x => x.NationalTravelFeeId)
  9140. .Distinct()
  9141. .ToListAsync();
  9142. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9143. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9144. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9145. .Select(x => x.Country)
  9146. .Distinct()
  9147. .ToArrayAsync();
  9148. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9149. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9150. return Ok(JsonView(true, "查询成功!", new
  9151. {
  9152. totalAmt = totalAmt,
  9153. remark = remark
  9154. }));
  9155. }
  9156. else if (dto.TipsType == 3)
  9157. {
  9158. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9159. }
  9160. return Ok(JsonView(false));
  9161. }
  9162. /// <summary>
  9163. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9164. /// </summary>
  9165. /// <returns></returns>
  9166. [HttpPost]
  9167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9168. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9169. {
  9170. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9171. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9172. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9173. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9174. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9175. var info = new Grp_EnterExitCostDraft() {
  9176. DraftName = dto.DraftName,
  9177. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9178. CreateUserId = dto.CurrUserId
  9179. };
  9180. _sqlSugar.BeginTran();
  9181. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9182. if (draftId < 1) {
  9183. _sqlSugar.RollbackTran();
  9184. return Ok(JsonView(false, "草稿创建失败!"));
  9185. }
  9186. //添加默认权限
  9187. await _enterExitCostDraftRep.InitPerm(draftId,dto.CurrUserId);
  9188. _sqlSugar.CommitTran();
  9189. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9190. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9191. mobileInfo.Id = draftId;
  9192. mobileInfo.DraftName = dto.DraftName;
  9193. mobileInfo.Currencys = rateInfos;
  9194. mobileInfo.IsAssignPerm = assignPerm;
  9195. return Ok(JsonView(mobileInfo));
  9196. }
  9197. /// <summary>
  9198. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9199. /// </summary>
  9200. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9201. /// <summary>
  9202. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9203. /// </summary>
  9204. /// <returns></returns>
  9205. [HttpPost]
  9206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9207. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9208. {
  9209. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9210. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9211. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9212. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9213. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9214. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9215. //验证查看编辑权限
  9216. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9217. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9218. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9219. mobileInfo.IsAssignPerm = assignPerm;
  9220. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9221. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9222. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9223. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9224. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9225. {
  9226. ParentId = dac.ParentId,
  9227. SubId = dac.Id,
  9228. Type = dac.Type,
  9229. Days = dac.Days,
  9230. NationalTravelFeeId = dac.NationalTravelFeeId,
  9231. Arae = $"{ntf.Country}-{ntf.City}",
  9232. Cost = dac.Cost,
  9233. Currency = dac.Currency,
  9234. CurrencyName = sd.Name,
  9235. SubTotal = dac.SubTotal,
  9236. })
  9237. .ToList();
  9238. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9239. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9240. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9241. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9242. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9243. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9244. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9245. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9246. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9247. //其他款项
  9248. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9249. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9250. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9251. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9252. .OrderBy((dop, sd1, sd2) => dop.Index)
  9253. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9254. {
  9255. ParentId = dop.ParentId,
  9256. SubId = dop.Id,
  9257. Index = dop.Index,
  9258. SetDataId = dop.SetDataId,
  9259. SetDataName = sd1.Name,
  9260. Cost = dop.Cost,
  9261. Currency = dop.Currency,
  9262. CurrencyName = sd2.Remark,
  9263. SubTotal = dop.SubTotal,
  9264. Remark = dop.Remark,
  9265. })
  9266. .ToArray();
  9267. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9268. return Ok(mobileInfo);
  9269. }
  9270. /// <summary>
  9271. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9272. /// </summary>
  9273. /// <returns></returns>
  9274. [HttpPost]
  9275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9276. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9277. {
  9278. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9279. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9280. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9281. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9282. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9283. //验证查看编辑权限
  9284. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9285. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9286. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9287. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9288. var subType = dto.SubType;
  9289. if (subType == 1) //1:境内费用
  9290. {
  9291. var oneData = new ChoiceOneMobileSubInfoView()
  9292. {
  9293. Id = eecInfo.Id,
  9294. ChoiceOne = eecInfo.ChoiceOne,
  9295. ChoiceOneTotalCost = eecInfo.InsidePay,
  9296. Visa = eecInfo.Visa,
  9297. VisaRemark = eecInfo.VisaRemark,
  9298. YiMiao = eecInfo.YiMiao,
  9299. HeSuan = eecInfo.HeSuan,
  9300. Service = eecInfo.Service,
  9301. Ticket = eecInfo.Ticket,
  9302. Safe = eecInfo.Safe,
  9303. FirstItemRemark = eecInfo.FirstItemRemark
  9304. };
  9305. return Ok(JsonView(oneData));
  9306. }
  9307. else if (subType == 2) //2:国际旅费
  9308. {
  9309. var twoData = new ChoiceTwoMobileSubInfoView()
  9310. {
  9311. Id = eecInfo.Id,
  9312. ChoiceTwoJJ = eecInfo.SumJJC,
  9313. OutsideJJPay = eecInfo.OutsideJJPay,
  9314. ChoiceTwoGW = eecInfo.SumGWC,
  9315. OutsideGWPay = eecInfo.OutsideGWPay,
  9316. ChoiceTwoTD = eecInfo.SumTDC,
  9317. OutsideTDPay = eecInfo.OutsideTDPay,
  9318. AirJJ = eecInfo.AirJJ,
  9319. AirGW = eecInfo.AirGW,
  9320. AirTD = eecInfo.AirTD,
  9321. CityTranffic = eecInfo.CityTranffic,
  9322. TwoItemRemark = eecInfo.TwoItemRemark
  9323. };
  9324. return Ok(JsonView(twoData));
  9325. }
  9326. else if (subType == 3) //3:住宿费
  9327. {
  9328. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9329. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9330. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9331. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9332. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9333. {
  9334. ParentId = dac.ParentId,
  9335. SubId = dac.Id,
  9336. Type = dac.Type,
  9337. Days = dac.Days,
  9338. NationalTravelFeeId = dac.NationalTravelFeeId,
  9339. Arae = $"{ntf.Country}-{ntf.City}",
  9340. Cost = dac.Cost,
  9341. Currency = dac.Currency,
  9342. CurrencyName = sd.Name,
  9343. SubTotal = dac.SubTotal,
  9344. })
  9345. .ToArray();
  9346. var data = new ChoiceDraftMobileSubInfo3To6View()
  9347. {
  9348. ParentId = eecInfo.Id,
  9349. Choice = eecInfo.ChoiceThree,
  9350. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9351. Details = dayAndCostDatas
  9352. };
  9353. return Ok(JsonView(data));
  9354. }
  9355. else if (subType == 4) //4:伙食费
  9356. {
  9357. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9358. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9359. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9360. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9361. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9362. {
  9363. ParentId = dac.ParentId,
  9364. SubId = dac.Id,
  9365. Type = dac.Type,
  9366. Days = dac.Days,
  9367. NationalTravelFeeId = dac.NationalTravelFeeId,
  9368. Arae = $"{ntf.Country}-{ntf.City}",
  9369. Cost = dac.Cost,
  9370. Currency = dac.Currency,
  9371. CurrencyName = sd.Name,
  9372. SubTotal = dac.SubTotal,
  9373. })
  9374. .ToArray();
  9375. var data = new ChoiceDraftMobileSubInfo3To6View()
  9376. {
  9377. ParentId = eecInfo.Id,
  9378. Choice = eecInfo.ChoiceFour,
  9379. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9380. Details = dayAndCostDatas
  9381. };
  9382. return Ok(JsonView(data));
  9383. }
  9384. else if (subType == 5) //5:公杂费
  9385. {
  9386. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9387. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9388. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9389. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9390. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9391. {
  9392. ParentId = dac.ParentId,
  9393. SubId = dac.Id,
  9394. Type = dac.Type,
  9395. Days = dac.Days,
  9396. NationalTravelFeeId = dac.NationalTravelFeeId,
  9397. Arae = $"{ntf.Country}-{ntf.City}",
  9398. Cost = dac.Cost,
  9399. Currency = dac.Currency,
  9400. CurrencyName = sd.Name,
  9401. SubTotal = dac.SubTotal,
  9402. })
  9403. .ToArray();
  9404. var data = new ChoiceDraftMobileSubInfo3To6View()
  9405. {
  9406. ParentId = eecInfo.Id,
  9407. Choice = eecInfo.ChoiceFive,
  9408. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9409. Details = dayAndCostDatas
  9410. };
  9411. return Ok(JsonView(data));
  9412. }
  9413. else if (subType == 6) //6:培训费
  9414. {
  9415. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9416. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9417. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9418. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9419. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9420. {
  9421. ParentId = dac.ParentId,
  9422. SubId = dac.Id,
  9423. Type = dac.Type,
  9424. Days = dac.Days,
  9425. NationalTravelFeeId = dac.NationalTravelFeeId,
  9426. Arae = $"{ntf.Country}-{ntf.City}",
  9427. Cost = dac.Cost,
  9428. Currency = dac.Currency,
  9429. CurrencyName = sd.Name,
  9430. SubTotal = dac.SubTotal,
  9431. })
  9432. .ToArray();
  9433. var data = new ChoiceDraftMobileSubInfo3To6View()
  9434. {
  9435. ParentId = eecInfo.Id,
  9436. Choice = eecInfo.ChoiceSix,
  9437. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9438. Details = dayAndCostDatas
  9439. };
  9440. return Ok(JsonView(data));
  9441. }
  9442. else if (subType == 7) //7:其他
  9443. {
  9444. //其他款项
  9445. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9446. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9447. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9448. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9449. .OrderBy((dop, sd1, sd2) => dop.Index)
  9450. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9451. {
  9452. ParentId = dop.ParentId,
  9453. SubId = dop.Id,
  9454. Index = dop.Index,
  9455. SetDataId = dop.SetDataId,
  9456. SetDataName = sd1.Name,
  9457. Cost = dop.Cost,
  9458. Currency = dop.Currency,
  9459. CurrencyName = sd2.Name,
  9460. SubTotal = dop.SubTotal,
  9461. Remark = dop.Remark,
  9462. })
  9463. .ToArray();
  9464. var data = new ChoiceSevenDraftMobileSubInfoView()
  9465. {
  9466. ParentId = eecInfo.Id,
  9467. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9468. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9469. Details = otherData
  9470. };
  9471. return Ok(JsonView(data));
  9472. }
  9473. return Ok(JsonView(false));
  9474. }
  9475. #region op
  9476. /// <summary>
  9477. /// 移动端更新费用消息通知
  9478. /// </summary>
  9479. /// <param name="draftId"></param>
  9480. /// <param name="id"></param>
  9481. /// <param name="currUserId"></param>
  9482. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9483. {
  9484. try
  9485. {
  9486. ////生成默认文件pdf并且通知人员
  9487. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9488. //{
  9489. // DiId = draftId,
  9490. // ExportType = 1,
  9491. // SubTypeId = 1005
  9492. //}, "pdf");
  9493. ////发送通知
  9494. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9495. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9496. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9497. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9498. ////汇率信息记录
  9499. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9500. }
  9501. catch (Exception ex)
  9502. {
  9503. //记录日志
  9504. throw;
  9505. }
  9506. }
  9507. /// <summary>
  9508. /// 验证出入境费用数据是否存在
  9509. /// 不存在添加
  9510. /// </summary>
  9511. /// <param name="draftId"></param>
  9512. /// <param name="currUserId"></param>
  9513. /// <returns></returns>
  9514. /// <exception cref="CustomException"></exception>
  9515. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9516. {
  9517. var parentId = 0;
  9518. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9519. if (info != null) parentId = info.Id;
  9520. else
  9521. {
  9522. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9523. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9524. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9525. parentId = addId;
  9526. }
  9527. return parentId;
  9528. }
  9529. /// <summary>
  9530. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9531. /// </summary>
  9532. /// <returns></returns>
  9533. [HttpPost]
  9534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9535. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9536. {
  9537. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9538. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9539. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9540. //验证查看编辑权限
  9541. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9542. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9543. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9544. foreach (var userId in dto.UserIds)
  9545. {
  9546. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9547. }
  9548. if (permissions.Any())
  9549. {
  9550. _sqlSugar.BeginTran();
  9551. try
  9552. {
  9553. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9554. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9555. if (result < 1)
  9556. {
  9557. _sqlSugar.RollbackTran();
  9558. return Ok(JsonView(false));
  9559. }
  9560. }
  9561. catch (Exception ex)
  9562. {
  9563. _sqlSugar.RollbackTran();
  9564. return Ok(JsonView(false, ex.Message));
  9565. }
  9566. _sqlSugar.CommitTran();
  9567. return Ok(JsonView(true));
  9568. }
  9569. return Ok(JsonView(false));
  9570. }
  9571. /// <summary>
  9572. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9573. /// </summary>
  9574. /// <returns></returns>
  9575. [HttpPost]
  9576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9577. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9578. {
  9579. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9580. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9581. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9582. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9583. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9584. int id = dto.DraftId;
  9585. if (id <= 0) //add
  9586. {
  9587. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9588. if (add < 1) return Ok(JsonView(false));
  9589. id = add;
  9590. }
  9591. else //update
  9592. {
  9593. //验证查看编辑权限
  9594. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9595. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9596. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9597. if (upd < 1) return Ok(JsonView(false));
  9598. }
  9599. #region 汇率变更时更改币种相关费用
  9600. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9601. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9602. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9603. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9604. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9605. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9606. .Select((dac, sd) => new
  9607. {
  9608. dac.Id,
  9609. dac.ParentId,
  9610. CurrencyCode = sd.Name,
  9611. dac.Cost
  9612. })
  9613. .ToList();
  9614. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9615. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9616. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9617. .Select((dop, sd) => new
  9618. {
  9619. dop.Id,
  9620. dop.ParentId,
  9621. CurrencyCode = sd.Name,
  9622. dop.Cost
  9623. })
  9624. .ToList();
  9625. if (dayCosts.Count > 0)
  9626. {
  9627. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9628. foreach (var dc in new_dayCosts)
  9629. {
  9630. var thisCurrency = dc.Key.ToUpper();
  9631. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9632. if (thisRate == 0.00M) continue;
  9633. foreach (var dcSub in dc)
  9634. {
  9635. opDayCosts.Add(new Grp_DayAndCostDraft()
  9636. {
  9637. Id = dcSub.Id,
  9638. ParentId = dcSub.ParentId,
  9639. Cost = dcSub.Cost,
  9640. SubTotal = dcSub.Cost * thisRate,
  9641. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9642. });
  9643. }
  9644. }
  9645. if (opDayCosts.Count > 0)
  9646. {
  9647. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9648. }
  9649. }
  9650. if (dayOtherCosts.Count > 0)
  9651. {
  9652. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9653. foreach (var dc in new_dayOtherCosts)
  9654. {
  9655. var thisCurrency = dc.Key.ToUpper();
  9656. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9657. if (thisRate == 0.00M) continue;
  9658. foreach (var dcSub in dc)
  9659. {
  9660. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9661. {
  9662. Id = dcSub.Id,
  9663. ParentId = dcSub.ParentId,
  9664. Cost = dcSub.Cost,
  9665. SubTotal = dcSub.Cost * thisRate,
  9666. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9667. });
  9668. }
  9669. }
  9670. if (opDayOtherCosts.Count > 0)
  9671. {
  9672. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9673. }
  9674. }
  9675. #endregion
  9676. ////消息通知
  9677. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9678. ////汇率信息记录
  9679. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9680. return Ok(JsonView(new { parentId = id }));
  9681. }
  9682. /// <summary>
  9683. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9684. /// </summary>
  9685. /// <returns></returns>
  9686. [HttpPost]
  9687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9688. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9689. {
  9690. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9691. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9692. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9693. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9694. int id = dto.DraftId;
  9695. if (id <= 0) //add
  9696. {
  9697. checkboxInfo.CreateUserId = dto.CurrUserId;
  9698. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9699. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9700. if (add < 1) return Ok(JsonView(false));
  9701. }
  9702. else //update
  9703. {
  9704. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9705. .UpdateColumns(x => new
  9706. {
  9707. x.ChoiceOne,
  9708. x.ChoiceTwo,
  9709. x.SumJJC,
  9710. x.SumGWC,
  9711. x.SumTDC,
  9712. x.ChoiceThree,
  9713. x.ChoiceFour,
  9714. x.ChoiceFive,
  9715. x.ChoiceSix,
  9716. x.OtherExpenses_Checked
  9717. })
  9718. .Where(x => x.Id == id)
  9719. .ExecuteCommandAsync();
  9720. if (upd < 1) return Ok(JsonView(false));
  9721. }
  9722. return Ok(JsonView(new { parentId = id }));
  9723. }
  9724. /// <summary>
  9725. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9726. /// </summary>
  9727. /// <returns></returns>
  9728. [HttpPost]
  9729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9730. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9731. {
  9732. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9733. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9734. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9735. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9736. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9737. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9738. var checkboxInfo = new Grp_EnterExitCostDraft()
  9739. {
  9740. Id = draftId,
  9741. CreateUserId = currUserId
  9742. };
  9743. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9744. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9745. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9746. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9747. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9748. if (draftId <= 0) //add
  9749. {
  9750. checkboxInfo.CreateUserId = dto.CurrUserId;
  9751. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9752. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9753. if (add < 1) return Ok(JsonView(false));
  9754. }
  9755. else //update
  9756. {
  9757. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9758. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9759. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9760. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9761. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9762. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9763. .Where(x => x.Id == draftId)
  9764. .ExecuteCommandAsync();
  9765. if (upd < 1) return Ok(JsonView(false));
  9766. }
  9767. return Ok(JsonView(new { parentId = draftId }));
  9768. }
  9769. /// <summary>
  9770. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9771. /// </summary>
  9772. /// <returns></returns>
  9773. [HttpPost]
  9774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9775. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9776. {
  9777. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9778. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9779. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9780. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9781. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9782. info.FirstItemRemark = dto.FirstItemRemark;
  9783. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9784. if (id <= 0) //add
  9785. {
  9786. info.CreateUserId = dto.CurrUserId;
  9787. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9788. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9789. if (add < 1) return Ok(JsonView(false));
  9790. id = add;
  9791. }
  9792. else //update
  9793. {
  9794. var upd = await _sqlSugar.Updateable(info)
  9795. .UpdateColumns(x => new
  9796. {
  9797. x.ChoiceOne,
  9798. x.InsidePay,
  9799. x.VisaRemark,
  9800. x.Visa,
  9801. x.Service,
  9802. x.Safe,
  9803. x.Ticket,
  9804. x.HeSuan,
  9805. x.YiMiao,
  9806. x.FirstItemRemark
  9807. })
  9808. .Where(x => x.Id == id)
  9809. .ExecuteCommandAsync();
  9810. if (upd < 1) return Ok(JsonView(false));
  9811. }
  9812. ////消息通知
  9813. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9814. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9815. }
  9816. /// <summary>
  9817. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9818. /// </summary>
  9819. /// <returns></returns>
  9820. [HttpPost]
  9821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9822. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9823. {
  9824. int id = dto.DraftId;
  9825. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9826. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9827. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9828. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9829. info.OutsideJJPay = dto.OutsideJJPay;
  9830. info.OutsideGWPay = dto.OutsideGWPay;
  9831. info.OutsideTDPay = dto.OutsideTDPay;
  9832. info.AirJJ = dto.AirJJ;
  9833. info.AirGW = dto.AirGW;
  9834. info.AirTD = dto.AirTD;
  9835. info.CityTranffic = dto.CityTranffic;
  9836. info.TwoItemRemark = dto.TwoItemRemark;
  9837. info.SumJJC = dto.ChoiceTwoJJ;
  9838. info.SumGWC = dto.ChoiceTwoGW;
  9839. info.SumTDC = dto.ChoiceTwoTD;
  9840. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9841. if (id <= 0) //add
  9842. {
  9843. info.CreateUserId = dto.CurrUserId;
  9844. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9845. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9846. if (addId <= 0) return Ok(JsonView(false));
  9847. id = addId;
  9848. }
  9849. else //update
  9850. {
  9851. var upd = await _sqlSugar.Updateable(info)
  9852. .UpdateColumns(x => new
  9853. {
  9854. x.SumJJC,
  9855. x.OutsideJJPay,
  9856. x.SumGWC,
  9857. x.OutsideGWPay,
  9858. x.SumTDC,
  9859. x.OutsideTDPay,
  9860. x.AirJJ,
  9861. x.AirGW,
  9862. x.AirTD,
  9863. x.CityTranffic,
  9864. x.TwoItemRemark
  9865. })
  9866. .Where(x => x.Id == id)
  9867. .ExecuteCommandAsync();
  9868. if (upd < 1) return Ok(JsonView(false));
  9869. }
  9870. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9871. gwcItemTotal = info.AirGW + info.CityTranffic;
  9872. tdcItemTotal = info.AirTD + info.CityTranffic;
  9873. ////消息通知
  9874. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9875. return Ok(JsonView(new
  9876. {
  9877. parentId = id,
  9878. choiceTwoJJ = dto.ChoiceTwoJJ,
  9879. jjcItemTotal = jjcItemTotal,
  9880. choiceTwoGW = dto.ChoiceTwoGW,
  9881. gwcItemTotal = gwcItemTotal,
  9882. choiceTwoTD = dto.ChoiceTwoTD,
  9883. tdcItemTotal = tdcItemTotal
  9884. }));
  9885. }
  9886. /// <summary>
  9887. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9888. /// </summary>
  9889. /// <returns></returns>
  9890. [HttpPost]
  9891. [ApiExplorerSettings(IgnoreApi = true)]
  9892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9893. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9894. {
  9895. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9896. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9897. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9898. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9899. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9900. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9901. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9902. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9903. {
  9904. Id = x.Id,
  9905. ParentId = dto.DraftId,
  9906. Type = dto.FeeType,
  9907. Days = x.Days,
  9908. NationalTravelFeeId = x.NationalTravelFeeId,
  9909. Cost = x.Cost,
  9910. Currency = x.Currency,
  9911. SubTotal = x.SubTotal,
  9912. CreateUserId = dto.CurrUserId
  9913. })
  9914. .ToList();
  9915. var adds = infos.Where(x => x.Id <= 0).ToList();
  9916. var upds = infos.Where(x => x.Id > 0).ToList();
  9917. if (adds.Count > 0)
  9918. {
  9919. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9920. if (add < 1) return Ok(JsonView(false));
  9921. }
  9922. if (upds.Count > 0)
  9923. {
  9924. var upd = await _sqlSugar.Updateable(adds)
  9925. .UpdateColumns(x => new
  9926. {
  9927. x.Days,
  9928. x.NationalTravelFeeId,
  9929. x.Cost,
  9930. x.Currency,
  9931. x.SubTotal
  9932. })
  9933. .WhereColumns(x => new { x.Id })
  9934. .ExecuteCommandAsync();
  9935. if (upd < 1) return Ok(JsonView(false));
  9936. }
  9937. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9938. ////消息通知
  9939. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9940. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9941. return Ok(JsonView(new { itemTotal = itemTotal }));
  9942. }
  9943. /// <summary>
  9944. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9945. /// </summary>
  9946. /// <returns></returns>
  9947. [HttpPost]
  9948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9949. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9950. {
  9951. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9952. int subId = dto.SubId, feeType = dto.FeeType;
  9953. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9954. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9955. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9956. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9957. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9958. subInfo.Id = subId;
  9959. subInfo.ParentId = dto.DraftId;
  9960. if (feeType == 3) subInfo.Type = 1;
  9961. else if (feeType == 4) subInfo.Type = 2;
  9962. else if (feeType == 5) subInfo.Type = 3;
  9963. else if (feeType == 6) subInfo.Type = 4;
  9964. subInfo.CreateUserId = dto.CurrUserId;
  9965. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9966. if (parentId < 1) return Ok(JsonView(false));
  9967. //子表op
  9968. if (subId < 1)
  9969. {
  9970. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9971. if (subAdd < 1) return Ok(JsonView(false));
  9972. }
  9973. else
  9974. {
  9975. var subUpd = await _sqlSugar.Updateable(subInfo)
  9976. .UpdateColumns(x => new
  9977. {
  9978. x.Days,
  9979. x.NationalTravelFeeId,
  9980. x.Cost,
  9981. x.Currency,
  9982. x.SubTotal
  9983. })
  9984. .WhereColumns(x => new { x.Id })
  9985. .ExecuteCommandAsync();
  9986. if (subUpd < 1) return Ok(JsonView(false));
  9987. }
  9988. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  9989. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9990. }
  9991. /// <summary>
  9992. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  9993. /// </summary>
  9994. /// <returns></returns>
  9995. [HttpPost]
  9996. [ApiExplorerSettings(IgnoreApi = true)]
  9997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9998. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  9999. {
  10000. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10001. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10002. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10003. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10004. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10005. {
  10006. Id = x.Id,
  10007. ParentId = dto.DraftId,
  10008. SetDataId = x.SetDataId,
  10009. Index = x.Index,
  10010. Cost = x.Cost,
  10011. Currency = x.Currency,
  10012. SubTotal = x.SubTotal,
  10013. CreateUserId = dto.CurrUserId,
  10014. Remark = x.Remark
  10015. }).ToList();
  10016. var adds = infos.Where(x => x.Id <= 0).ToList();
  10017. var upds = infos.Where(x => x.Id > 0).ToList();
  10018. if (adds.Count > 0)
  10019. {
  10020. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10021. if (add < 1) return Ok(JsonView(false));
  10022. }
  10023. if (upds.Count > 0)
  10024. {
  10025. var upd = await _sqlSugar.Updateable(adds)
  10026. .UpdateColumns(x => new
  10027. {
  10028. x.Index,
  10029. x.SetDataId,
  10030. x.Cost,
  10031. x.Currency,
  10032. x.SubTotal,
  10033. x.Remark
  10034. })
  10035. .WhereColumns(x => new { x.Id })
  10036. .ExecuteCommandAsync();
  10037. if (upd < 1) return Ok(JsonView(false));
  10038. }
  10039. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10040. //消息通知
  10041. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10042. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10043. return Ok(JsonView(new { itemTotal = itemTotal }));
  10044. }
  10045. /// <summary>
  10046. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10047. /// </summary>
  10048. /// <returns></returns>
  10049. [HttpPost]
  10050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10051. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10052. {
  10053. int subId = dto.SubId, id = dto.DraftId;
  10054. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10055. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10056. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10057. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10058. subInfo.Id = subId;
  10059. subInfo.ParentId = id;
  10060. subInfo.CreateUserId = dto.CurrUserId;
  10061. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10062. if (parentId < 1) return Ok(JsonView(false));
  10063. #region 子表op
  10064. if (subId < 1)//add
  10065. {
  10066. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10067. if (subAdd < 1) return Ok(JsonView(false));
  10068. }
  10069. else //upd
  10070. {
  10071. var subUpd = await _sqlSugar.Updateable(subInfo)
  10072. .UpdateColumns(x => new
  10073. {
  10074. x.Index,
  10075. x.SetDataId,
  10076. x.Cost,
  10077. x.Currency,
  10078. x.SubTotal,
  10079. x.Remark
  10080. })
  10081. .WhereColumns(x => new { x.Id })
  10082. .ExecuteCommandAsync();
  10083. if (subUpd < 1) return Ok(JsonView(false));
  10084. }
  10085. #endregion
  10086. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10087. ////消息通知
  10088. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10089. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10090. }
  10091. /// <summary>
  10092. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10093. /// </summary>
  10094. /// <returns></returns>
  10095. [HttpPost]
  10096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10097. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10098. {
  10099. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10100. if (data.Code != 0)
  10101. {
  10102. return Ok(JsonView(false, data.Msg));
  10103. }
  10104. return Ok(JsonView(true, "操作成功!", data.Data));
  10105. }
  10106. /// <summary>
  10107. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10108. /// </summary>
  10109. /// <param name="dto"></param>
  10110. /// <returns></returns>
  10111. [HttpPost]
  10112. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10113. {
  10114. var data = new Grp_DayOtherPriceDraft()
  10115. {
  10116. Id = dto.Id,
  10117. IsDel = 1,
  10118. DeleteUserId = dto.DeleteUserId,
  10119. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10120. };
  10121. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10122. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10123. return Ok(JsonView(false, "删除失败!"));
  10124. }
  10125. #endregion
  10126. #endregion
  10127. #region 团组经理模块 出入境费用报价表
  10128. /// <summary>
  10129. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10130. /// </summary>
  10131. /// <returns></returns>
  10132. [HttpPost]
  10133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10134. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10135. {
  10136. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10137. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10138. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10139. initRates.Insert(0, cnyInfo);
  10140. liveRates.Insert(0, cnyInfo);
  10141. return Ok(JsonView(true, "查询成功!", new
  10142. {
  10143. InitRates = initRates,
  10144. LiveRates = liveRates
  10145. }));
  10146. }
  10147. /// <summary>
  10148. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10149. /// </summary>
  10150. /// <returns></returns>
  10151. [HttpPost]
  10152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10153. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10154. {
  10155. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10156. }
  10157. /// <summary>
  10158. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10159. /// </summary>
  10160. /// <returns></returns>
  10161. [HttpPost]
  10162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10163. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10164. {
  10165. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10166. }
  10167. /// <summary>
  10168. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10169. /// </summary>
  10170. /// <returns></returns>
  10171. [HttpPost]
  10172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10173. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10174. {
  10175. int groupId = dto.DiId,
  10176. currUserId = dto.CurrUserId;
  10177. if (groupId < 1) return Ok(JsonView(false,"请传入有效的GroupId;"));
  10178. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10179. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10180. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10181. var infoView = info.Data as EnterExitCostInfoView;
  10182. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10183. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10184. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10185. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10186. var eecRates = infoView.Currencys;
  10187. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10188. int pplNum = 1;
  10189. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10190. var views = new List<QuoteSubItemInfo>();
  10191. #region 数据填充
  10192. var intTravelCosts = new List<QuoteSubItemInfo>();
  10193. #region 机票费用 1354
  10194. int intTravelIndex = 1;
  10195. if (infoView.SumJJC == 1)
  10196. {
  10197. intTravelCosts.Add(new QuoteSubItemInfo
  10198. {
  10199. ItemId = 1354,
  10200. Index = intTravelIndex,
  10201. FeeName = "经济舱",
  10202. UnitPrice = infoView.AirJJ,
  10203. Currency = "CNY",
  10204. Quantity = 1,
  10205. PplNum = 1,
  10206. TotalAmt = infoView.AirJJ,
  10207. Remark = "",
  10208. });
  10209. intTravelIndex++;
  10210. }
  10211. if (infoView.SumGWC == 1)
  10212. {
  10213. intTravelCosts.Add(new QuoteSubItemInfo
  10214. {
  10215. ItemId = 1354,
  10216. Index = intTravelIndex,
  10217. FeeName = "公务舱",
  10218. UnitPrice = infoView.AirGW,
  10219. Currency = "CNY",
  10220. Quantity = 1,
  10221. PplNum = 1,
  10222. TotalAmt = infoView.AirGW,
  10223. Remark = "",
  10224. });
  10225. intTravelIndex++;
  10226. }
  10227. if (infoView.SumTDC == 1)
  10228. {
  10229. intTravelCosts.Add(new QuoteSubItemInfo
  10230. {
  10231. ItemId = 1354,
  10232. Index = intTravelIndex,
  10233. FeeName = "头等舱",
  10234. UnitPrice = infoView.AirTD,
  10235. Currency = "CNY",
  10236. Quantity = 1,
  10237. PplNum = 1,
  10238. TotalAmt = infoView.AirTD,
  10239. Remark = "",
  10240. });
  10241. intTravelIndex++;
  10242. }
  10243. intTravelCosts.Add(new QuoteSubItemInfo
  10244. {
  10245. ItemId = 1354,
  10246. Index = intTravelIndex,
  10247. FeeName = "城市间交通费用",
  10248. UnitPrice = infoView.CityTranffic,
  10249. Currency = "CNY",
  10250. Quantity = 1,
  10251. PplNum = pplNum,
  10252. TotalAmt = infoView.CityTranffic * pplNum,
  10253. Remark = "",
  10254. });
  10255. views.AddRange(intTravelCosts);
  10256. #endregion
  10257. var accomCosts = new List<QuoteSubItemInfo>();
  10258. #region 住宿费 1355
  10259. if (infoView.QuarterageData.Any())
  10260. {
  10261. int accomIndex = 1;
  10262. int accomItemTypeId = 1355;
  10263. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10264. foreach (var item in groupData)
  10265. {
  10266. string feeName = string.Empty;
  10267. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10268. if (countryInfo != null)
  10269. {
  10270. feeName = countryInfo.Country;
  10271. var city = countryInfo.City;
  10272. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10273. {
  10274. feeName += $"-{city}";
  10275. }
  10276. }
  10277. var hotelInfo = item.FirstOrDefault();
  10278. if (hotelInfo == null) continue;
  10279. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10280. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10281. int quantity = item.ToList().Count;
  10282. accomCosts.Add(new QuoteSubItemInfo
  10283. {
  10284. ItemId = accomItemTypeId,
  10285. Index = accomIndex,
  10286. FeeName = feeName,
  10287. UnitPrice = hotelInfo.Cost,
  10288. Currency = thisCurrency,
  10289. Quantity = quantity,
  10290. PplNum = pplNum,
  10291. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10292. Remark = "",
  10293. });
  10294. accomIndex++;
  10295. }
  10296. views.AddRange(accomCosts);
  10297. }
  10298. #endregion
  10299. var mealCosts = new List<QuoteSubItemInfo>();
  10300. #region 餐饮费 1356
  10301. if (infoView.BoardWagesData.Any())
  10302. {
  10303. var mealIndex = 1;
  10304. int mealItemTypeId = 1356;
  10305. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10306. foreach (var item in groupData)
  10307. {
  10308. string feeName = string.Empty;
  10309. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10310. if (countryInfo != null)
  10311. {
  10312. feeName = countryInfo.Country;
  10313. var city = countryInfo.City;
  10314. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10315. {
  10316. feeName += $"-{city}";
  10317. }
  10318. }
  10319. var mealInfo = item.FirstOrDefault();
  10320. if (mealInfo == null) continue;
  10321. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10322. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10323. int quantity = item.ToList().Count;
  10324. mealCosts.Add(new QuoteSubItemInfo
  10325. {
  10326. ItemId = mealItemTypeId,
  10327. Index = mealIndex,
  10328. FeeName = feeName,
  10329. UnitPrice = mealInfo.Cost,
  10330. Currency = thisCurrency,
  10331. Quantity = quantity,
  10332. PplNum = pplNum,
  10333. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10334. Remark = "",
  10335. });
  10336. mealIndex++;
  10337. }
  10338. views.AddRange(mealCosts);
  10339. }
  10340. #endregion
  10341. var miscCosts = new List<QuoteSubItemInfo>();
  10342. #region 公杂费 1364
  10343. if (infoView.MiscellaneousFeeData.Any())
  10344. {
  10345. var miscIndex = 1;
  10346. int miscItemTypeId = 1364;
  10347. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10348. foreach (var item in groupData)
  10349. {
  10350. string feeName = string.Empty;
  10351. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10352. if (countryInfo != null)
  10353. {
  10354. feeName = countryInfo.Country;
  10355. var city = countryInfo.City;
  10356. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10357. {
  10358. feeName += $"-{city}";
  10359. }
  10360. }
  10361. var miscInfo = item.FirstOrDefault();
  10362. if (miscInfo == null) continue;
  10363. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10364. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10365. int quantity = item.ToList().Count;
  10366. mealCosts.Add(new QuoteSubItemInfo
  10367. {
  10368. ItemId = miscItemTypeId,
  10369. Index = miscIndex,
  10370. FeeName = feeName,
  10371. UnitPrice = miscInfo.Cost,
  10372. Currency = thisCurrency,
  10373. Quantity = quantity,
  10374. PplNum = pplNum,
  10375. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10376. Remark = "",
  10377. });
  10378. miscIndex++;
  10379. }
  10380. views.AddRange(mealCosts);
  10381. }
  10382. #endregion
  10383. #region 签证+保险 1362
  10384. int visaInsIndex = 1;
  10385. int visaInsItemTypeId = 1362;
  10386. if (infoView.Visa > 0)
  10387. {
  10388. views.Add(new QuoteSubItemInfo() {
  10389. ItemId = visaInsItemTypeId,
  10390. Index = visaInsIndex,
  10391. FeeName = $"签证",
  10392. UnitPrice = infoView.Visa,
  10393. Currency = $"CNY",
  10394. Quantity = 1,
  10395. PplNum = pplNum,
  10396. TotalAmt = infoView.Visa * pplNum,
  10397. Remark = "",
  10398. });
  10399. visaInsIndex++;
  10400. }
  10401. if (infoView.Safe > 0)
  10402. {
  10403. views.Add(new QuoteSubItemInfo()
  10404. {
  10405. ItemId = visaInsItemTypeId,
  10406. Index = visaInsIndex,
  10407. FeeName = $"保险",
  10408. UnitPrice = infoView.Safe,
  10409. Currency = $"CNY",
  10410. Quantity = 1,
  10411. PplNum = pplNum,
  10412. TotalAmt = infoView.Safe * pplNum,
  10413. Remark = "",
  10414. });
  10415. }
  10416. #endregion
  10417. #region 服务费 1363
  10418. int serviceFeeIndex = 1;
  10419. int serviceFeeItemTypeId = 1363;
  10420. if (infoView.Service > 0)
  10421. {
  10422. views.Add(new QuoteSubItemInfo()
  10423. {
  10424. ItemId = serviceFeeItemTypeId,
  10425. Index = serviceFeeIndex,
  10426. FeeName = $"服务费",
  10427. UnitPrice = infoView.Service,
  10428. Currency = $"CNY",
  10429. Quantity = 1,
  10430. PplNum = pplNum,
  10431. TotalAmt = infoView.Service * pplNum,
  10432. Remark = "",
  10433. });
  10434. }
  10435. #endregion
  10436. #endregion
  10437. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10438. result.Rates = eecRates.ToArray();
  10439. if (result.FeeItems.Any())
  10440. {
  10441. result.FeeItems.Select(x =>
  10442. {
  10443. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10444. if (feeInfos.Any()) x.Infos = feeInfos;
  10445. return x;
  10446. }
  10447. )
  10448. .OrderBy(x => x.Index)
  10449. .ToList();
  10450. }
  10451. return Ok(JsonView(result));
  10452. }
  10453. /// <summary>
  10454. /// 团组模块 - 出入境费用报价表 - Info
  10455. /// </summary>
  10456. /// <returns></returns>
  10457. [HttpPost]
  10458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10459. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10460. {
  10461. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10462. if (!info.Rates.Any())
  10463. {
  10464. var rates = await GeneralMethod.EnterExitCostInitRate();
  10465. info.Rates = rates.ToArray();
  10466. }
  10467. return Ok(JsonView(info));
  10468. }
  10469. /// <summary>
  10470. /// 团组模块 - 出入境费用报价表 - OP
  10471. /// </summary>
  10472. /// <returns></returns>
  10473. [HttpPost]
  10474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10475. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10476. {
  10477. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10478. }
  10479. /// <summary>
  10480. /// 团组模块 - 出入境费用报价表 - 删除 项
  10481. /// </summary>
  10482. /// <returns></returns>
  10483. [HttpPost]
  10484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10485. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10486. {
  10487. if (dto.Id < 1) return Ok(JsonView(false,MsgTips.Id));
  10488. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10489. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10490. }
  10491. /// <summary>
  10492. /// 团组模块 - 出入境费用报价表 - 导出
  10493. /// </summary>
  10494. /// <returns></returns>
  10495. [HttpPost]
  10496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10497. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10498. {
  10499. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10500. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10501. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id= dto.Id });
  10502. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10503. var rates = info.Rates;
  10504. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10505. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10506. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10507. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10508. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10509. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10510. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10511. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10512. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10513. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10514. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10515. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10516. //获取模板
  10517. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx");
  10518. var designer = new WorkbookDesigner();
  10519. designer.Workbook = new Workbook(tempPath);
  10520. designer.SetDataSource("QuoteName", info.Name);
  10521. designer.SetDataSource("CompanyTitle", "公司名称");
  10522. designer.SetDataSource("CompanyLabel", "");
  10523. #region 国际旅费
  10524. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10525. if (intTravelCosts.Infos.Any())
  10526. {
  10527. var cabClassFilter = new string[] {"经济舱","公务舱","头等舱" };
  10528. string label = string.Empty;
  10529. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10530. if (infos.Any())
  10531. {
  10532. label = $"{infos.Sum(x => x.PplNum)}人全程机票:{infos.Sum(x => x.TotalAmt).TruncDecimals(2)}元\r\n";
  10533. }
  10534. foreach (var item in intTravelCosts.Infos)
  10535. {
  10536. label += $"{item.FeeName}:{item.UnitPrice.TruncDecimals(2)}元/人*{item.PplNum}人\r\n";
  10537. }
  10538. label += $"\r\n以上小计:{intTravelCosts.TotalAmt.TruncDecimals(2)}元";
  10539. designer.SetDataSource("IntTravelLabel", label);
  10540. }
  10541. #endregion
  10542. #region 住宿费
  10543. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10544. if (accomCosts.Infos.Any())
  10545. {
  10546. string currencyName = string.Empty;
  10547. decimal rate = 1.0000M;
  10548. string label = "全程五星酒店,每人1间房\r\n";
  10549. foreach (var item in accomCosts.Infos)
  10550. {
  10551. string hotelName = string.Empty;
  10552. if (item.FeeName.Contains("-"))
  10553. {
  10554. var feeName = item.FeeName.Split('-');
  10555. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10556. }
  10557. else hotelName = $"\r\n{item.FeeName}:";
  10558. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10559. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10560. rate = rateInfo?.Rate ?? 1.0000M;
  10561. label += $"{hotelName}{item.UnitPrice.TruncDecimals(2)}{currencyName}/间/晚*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10562. }
  10563. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元({currencyName}汇率:{rate.TruncDecimals(4)})";
  10564. designer.SetDataSource("AccomLabel", label);
  10565. }
  10566. #endregion
  10567. designer.Process();
  10568. //文件名
  10569. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10570. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  10571. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  10572. return Ok(JsonView(true, "成功", url));
  10573. }
  10574. #endregion
  10575. #region 签证费用录入
  10576. /// <summary>
  10577. /// 根据diid查询签证费用列表
  10578. /// </summary>
  10579. /// <param name="dto"></param>
  10580. /// <returns></returns>
  10581. [HttpPost]
  10582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10583. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10584. {
  10585. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10586. if (groupData.Code != 0)
  10587. {
  10588. return Ok(JsonView(false, groupData.Msg));
  10589. }
  10590. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10591. }
  10592. /// <summary>
  10593. /// 根据签证费用Id查询单条数据及c表数据
  10594. /// </summary>
  10595. /// <param name="dto"></param>
  10596. /// <returns></returns>
  10597. [HttpPost]
  10598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10599. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10600. {
  10601. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10602. if (groupData.Code != 0)
  10603. {
  10604. return Ok(JsonView(false, groupData.Msg));
  10605. }
  10606. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10607. }
  10608. /// <summary>
  10609. /// 签证费用删除
  10610. /// </summary>
  10611. /// <param name="dto"></param>
  10612. /// <returns></returns>
  10613. [HttpPost]
  10614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10615. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10616. {
  10617. _sqlSugar.BeginTran();
  10618. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10619. if (!res)
  10620. {
  10621. _sqlSugar.RollbackTran();
  10622. return Ok(JsonView(false, "删除失败"));
  10623. }
  10624. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10625. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10626. .SetColumns(a => new Grp_CreditCardPayment()
  10627. {
  10628. IsDel = 1,
  10629. DeleteUserId = dto.DeleteUserId,
  10630. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10631. })
  10632. .ExecuteCommand();
  10633. if (resSub < 1)
  10634. {
  10635. _sqlSugar.RollbackTran();
  10636. return Ok(JsonView(false, "删除失败"));
  10637. }
  10638. _sqlSugar.CommitTran();
  10639. return Ok(JsonView(true, "删除成功!"));
  10640. }
  10641. /// <summary>
  10642. /// 签证费用录入下拉框初始化
  10643. /// </summary>
  10644. /// <returns></returns>
  10645. [HttpPost]
  10646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10647. public async Task<IActionResult> VisaPriceAddSelect()
  10648. {
  10649. //支付方式
  10650. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10651. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10652. //币种
  10653. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10654. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10655. //乘客类型
  10656. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10657. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10658. //卡类型
  10659. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10660. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10661. //代办费类型
  10662. var agencyFeeTypeData = new List<dynamic>() {
  10663. new { id = 0 , Text = "未选择" },
  10664. new { id = 1 , Text = "小公务" },
  10665. new { id = 2 , Text = "大公务" },
  10666. };
  10667. //签证费用标准国家Data
  10668. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10669. var data = new
  10670. {
  10671. Payment = _Payment,
  10672. CurrencyList = _CurrencyList,
  10673. PassengerType = _PassengerType,
  10674. BankCard = _BankCard,
  10675. AgencyFeeType = agencyFeeTypeData,
  10676. CountryFeeData = visaCountryFeeData
  10677. };
  10678. return Ok(JsonView(true, "查询成功!", data));
  10679. }
  10680. /// <summary>
  10681. /// 签证费用录入操作(Status:1.新增,2.修改)
  10682. /// </summary>
  10683. /// <param name="dto"></param>
  10684. /// <returns></returns>
  10685. [HttpPost]
  10686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10687. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10688. {
  10689. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10690. if (groupData.Code != 0)
  10691. {
  10692. return Ok(JsonView(false, groupData.Msg));
  10693. }
  10694. #region 应用推送
  10695. try
  10696. {
  10697. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10698. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10699. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10700. //2024-10-21 新增LZ UID
  10701. var userIds = new List<int>() { 21 };
  10702. string title = $"系统通知";
  10703. string content = "";
  10704. var diId = dto.DiId;
  10705. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10706. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10707. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10708. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10709. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10710. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10711. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10712. }
  10713. catch (Exception ex)
  10714. {
  10715. }
  10716. #endregion
  10717. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10718. }
  10719. #endregion
  10720. #region 签证提成录入
  10721. /// <summary>
  10722. /// 签证提成录入
  10723. /// 基础数据
  10724. /// </summary>
  10725. /// <returns></returns>
  10726. [HttpGet]
  10727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10728. public async Task<IActionResult> VisaCommissionInit()
  10729. {
  10730. return Ok(await _visaCommissionRep.Init());
  10731. }
  10732. /// <summary>
  10733. /// 签证提成录入
  10734. /// Item
  10735. /// </summary>
  10736. /// <param name="_dto"></param>
  10737. /// <returns></returns>
  10738. [HttpPost]
  10739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10740. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10741. {
  10742. var validator = new VisaCommissionItemDtoValidator();
  10743. var validatorRes = await validator.ValidateAsync(_dto);
  10744. if (!validatorRes.IsValid)
  10745. {
  10746. StringBuilder sb = new StringBuilder();
  10747. foreach (var item in validatorRes.Errors)
  10748. {
  10749. sb.AppendLine(item.ErrorMessage);
  10750. }
  10751. return Ok(JsonView(false, sb.ToString()));
  10752. }
  10753. return Ok(await _visaCommissionRep.Item(_dto));
  10754. }
  10755. /// <summary>
  10756. /// 签证提成录入
  10757. /// Save
  10758. /// </summary>
  10759. /// <param name="_dto"></param>
  10760. /// <returns></returns>
  10761. [HttpPost]
  10762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10763. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10764. {
  10765. //参数验证
  10766. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10767. foreach (var item in _dto.Items)
  10768. {
  10769. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10770. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10771. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10772. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10773. }
  10774. return Ok(await _visaCommissionRep.Save(_dto));
  10775. }
  10776. /// <summary>
  10777. /// 签证提成录入
  10778. /// Create
  10779. /// </summary>
  10780. /// <param name="_dto"></param>
  10781. /// <returns></returns>
  10782. [HttpPost]
  10783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10784. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10785. {
  10786. var validator = new VisaCommissionCreateDtoValidator();
  10787. var validatorRes = await validator.ValidateAsync(_dto);
  10788. if (!validatorRes.IsValid)
  10789. {
  10790. StringBuilder sb = new StringBuilder();
  10791. foreach (var item in validatorRes.Errors)
  10792. {
  10793. sb.AppendLine(item.ErrorMessage);
  10794. }
  10795. return Ok(JsonView(false, sb.ToString()));
  10796. }
  10797. return Ok(await _visaCommissionRep.Create(_dto));
  10798. }
  10799. /// <summary>
  10800. /// 签证提成录入
  10801. /// Put(编辑)
  10802. /// </summary>
  10803. /// <param name="id"></param>
  10804. /// <param name="_dto"></param>
  10805. /// <returns></returns>
  10806. [HttpPut]
  10807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10808. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10809. {
  10810. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10811. var validator = new VisaCommissionCreateDtoValidator();
  10812. var validatorRes = await validator.ValidateAsync(_dto);
  10813. if (!validatorRes.IsValid)
  10814. {
  10815. StringBuilder sb = new StringBuilder();
  10816. foreach (var item in validatorRes.Errors)
  10817. {
  10818. sb.AppendLine(item.ErrorMessage);
  10819. }
  10820. return Ok(JsonView(false, sb.ToString()));
  10821. }
  10822. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10823. }
  10824. /// <summary>
  10825. /// 签证提成录入
  10826. /// Del
  10827. /// </summary>
  10828. /// <param name="id"></param>
  10829. /// <param name="currUserId"></param>
  10830. /// <returns></returns>
  10831. [HttpPost]
  10832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10833. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10834. {
  10835. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10836. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10837. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10838. }
  10839. #endregion
  10840. #region op费用录入
  10841. /// <summary>
  10842. /// 根据diid查询op费用列表
  10843. /// </summary>
  10844. /// <param name="dto"></param>
  10845. /// <returns></returns>
  10846. [HttpPost]
  10847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10848. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10849. {
  10850. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10851. if (groupData.Code != 0)
  10852. {
  10853. return Ok(JsonView(false, groupData.Msg));
  10854. }
  10855. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10856. }
  10857. /// <summary>
  10858. /// 根据op费用Id查询单条数据及c表数据
  10859. /// </summary>
  10860. /// <param name="dto"></param>
  10861. /// <returns></returns>
  10862. [HttpPost]
  10863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10864. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10865. {
  10866. try
  10867. {
  10868. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10869. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10870. var data = new
  10871. {
  10872. CarTouristGuideGround = _groupData,
  10873. CreditCardPayment = _creditCardPayment
  10874. };
  10875. return Ok(JsonView(true, "查询成功!", data));
  10876. }
  10877. catch (Exception ex)
  10878. {
  10879. return Ok(JsonView(false, "程序错误!"));
  10880. }
  10881. }
  10882. /// <summary>
  10883. /// op费用删除
  10884. /// </summary>
  10885. /// <param name="dto"></param>
  10886. /// <returns></returns>
  10887. [HttpPost]
  10888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10889. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10890. {
  10891. try
  10892. {
  10893. _sqlSugar.BeginTran();
  10894. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10895. if (!res)
  10896. {
  10897. return Ok(JsonView(false, "删除失败"));
  10898. }
  10899. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10900. {
  10901. IsDel = 1,
  10902. DeleteUserId = dto.DeleteUserId,
  10903. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10904. }).ExecuteCommandAsync();
  10905. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10906. {
  10907. IsDel = 1,
  10908. DeleteUserId = dto.DeleteUserId,
  10909. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10910. }).ExecuteCommandAsync();
  10911. #region 删除超支相关数据
  10912. //删除导入的超支数据
  10913. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10914. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10915. {
  10916. IsDel = 1,
  10917. DeleteUserId = dto.DeleteUserId,
  10918. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10919. }).ExecuteCommand();
  10920. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10921. {
  10922. IsDel = 1,
  10923. DeleteUserId = dto.DeleteUserId,
  10924. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10925. }).ExecuteCommand();
  10926. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10927. {
  10928. IsDel = 1,
  10929. DeleteUserId = dto.DeleteUserId,
  10930. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10931. }).ExecuteCommand();
  10932. #endregion
  10933. _sqlSugar.CommitTran();
  10934. return Ok(JsonView(true, "删除成功!"));
  10935. }
  10936. catch (Exception ex)
  10937. {
  10938. _sqlSugar.RollbackTran();
  10939. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10940. }
  10941. }
  10942. /// <summary>
  10943. /// op费用录入操作(Status:1.新增,2.修改)
  10944. /// </summary>
  10945. /// <param name="dto"></param>
  10946. /// <returns></returns>
  10947. [HttpPost]
  10948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10949. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10950. {
  10951. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10952. if (groupData.Code != 0)
  10953. {
  10954. return Ok(JsonView(false, groupData.Msg));
  10955. }
  10956. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10957. }
  10958. /// <summary>
  10959. /// 填写费用详细页面初始化绑定
  10960. /// </summary>
  10961. /// <param name="dto"></param>
  10962. /// <returns></returns>
  10963. [HttpPost]
  10964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10965. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10966. {
  10967. try
  10968. {
  10969. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10970. if (groupData.Code != 0)
  10971. {
  10972. return Ok(JsonView(false, groupData.Msg));
  10973. }
  10974. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10975. }
  10976. catch (Exception ex)
  10977. {
  10978. return Ok(JsonView(false, ex.Message));
  10979. }
  10980. }
  10981. /// <summary>
  10982. /// 根据op费用Id查询详细数据
  10983. /// </summary>
  10984. /// <param name="dto"></param>
  10985. /// <returns></returns>
  10986. [HttpPost]
  10987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10988. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10989. {
  10990. try
  10991. {
  10992. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10993. if (groupData.Code != 0)
  10994. {
  10995. return Ok(JsonView(false, groupData.Msg));
  10996. }
  10997. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10998. }
  10999. catch (Exception ex)
  11000. {
  11001. return Ok(JsonView(false, ex.Message));
  11002. }
  11003. }
  11004. /// <summary>
  11005. /// OP费用录入填写详情
  11006. /// </summary>
  11007. /// <param name="dto"></param>
  11008. /// <returns></returns>
  11009. [HttpPost]
  11010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11011. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11012. {
  11013. try
  11014. {
  11015. #region 参数校验
  11016. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11017. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11018. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11019. #endregion
  11020. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11021. if (groupData.Code != 0)
  11022. {
  11023. return Ok(JsonView(false, groupData.Msg));
  11024. }
  11025. //自动审核
  11026. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11027. #region 应用推送
  11028. try
  11029. {
  11030. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11031. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11032. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11033. //2024-10-21 新增LZ UID
  11034. var userIds = new List<int>() { 21 };
  11035. string title = $"系统通知";
  11036. var diId = dto.DiId;
  11037. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11038. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11039. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11040. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11041. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11042. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11043. }
  11044. catch (Exception ex)
  11045. {
  11046. }
  11047. #endregion
  11048. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11049. }
  11050. catch (Exception ex)
  11051. {
  11052. return Ok(JsonView(false, ex.Message));
  11053. }
  11054. }
  11055. /// <summary>
  11056. /// 获取三公详细所有城市
  11057. /// </summary>
  11058. /// <returns></returns>
  11059. [HttpGet]
  11060. public IActionResult OpCarCityResult()
  11061. {
  11062. var jw = JsonView(false);
  11063. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11064. {
  11065. x.Id,
  11066. x.Country,
  11067. x.City,
  11068. }).ToList();
  11069. if (data.Count > 0)
  11070. {
  11071. jw = JsonView(true, "获取成功!", data);
  11072. }
  11073. else
  11074. {
  11075. jw.Msg = "城市数据为空!";
  11076. jw.Data = new string[0];
  11077. }
  11078. return Ok(jw);
  11079. }
  11080. /// <summary>
  11081. /// 导出地接费用明细
  11082. /// </summary>
  11083. /// <param name="dto"></param>
  11084. /// <returns></returns>
  11085. [HttpPost]
  11086. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11087. {
  11088. var jw = JsonView(false);
  11089. if (dto.Diid < 1)
  11090. {
  11091. jw.Msg = "请输入正确的diid!";
  11092. return Ok(jw);
  11093. }
  11094. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11095. if (group == null)
  11096. {
  11097. jw.Msg = "未找到团组信息!";
  11098. return Ok(jw);
  11099. }
  11100. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11101. if (localGuideArr.Count == 0)
  11102. {
  11103. jw.Msg = "该团组暂无地接信息!";
  11104. return Ok(jw);
  11105. }
  11106. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11107. var overspendSoure = new Dictionary<int, int>
  11108. {
  11109. { 91, 982 }, //车
  11110. { 92 , 1059} ,//导游
  11111. { 994 , 1073}, //翻译
  11112. { 988 , 1074 }, //早餐
  11113. { 93 , 1075 }, //午餐
  11114. { 989 , 1076 }, //晚餐
  11115. };
  11116. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11117. foreach (var groupArr in localGroup)
  11118. {
  11119. var keyValue = groupArr.Key;
  11120. if (int.TryParse(keyValue, out int cityid))
  11121. {
  11122. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11123. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11124. }
  11125. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11126. foreach (var item in groupArr)
  11127. {
  11128. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11129. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11130. new Grp_CarTouristGuideGroundReservationsContentExtend
  11131. {
  11132. Count = a.Count,
  11133. CreateTime = a.CreateTime,
  11134. CreateUserId = a.CreateUserId,
  11135. CTGGRId = a.CTGGRId,
  11136. Currency = a.Currency,
  11137. DatePrice = a.DatePrice,
  11138. DeleteTime = a.DeleteTime,
  11139. DeleteUserId = a.DeleteUserId,
  11140. DiId = a.DiId,
  11141. Id = a.Id,
  11142. IsDel = a.IsDel,
  11143. Price = a.Price,
  11144. PriceContent = a.PriceContent,
  11145. Remark = a.Remark,
  11146. SId = a.SId,
  11147. SidName = b.Name,
  11148. Units = a.Units,
  11149. }
  11150. ).ToList();
  11151. if (content.Count > 0)
  11152. {
  11153. contentArr.Add(content);
  11154. }
  11155. }
  11156. //open excel
  11157. //set excel
  11158. //save excel
  11159. try
  11160. {
  11161. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11162. IWorkbook workbook;
  11163. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11164. {
  11165. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11166. }
  11167. else
  11168. {
  11169. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11170. }
  11171. ISheet sheet = workbook.GetSheetAt(0);
  11172. var rowStartIndex = 2;
  11173. var clounmCount = 10;
  11174. var initStyleRow = sheet.GetRow(2);
  11175. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11176. //var overspendArrDetail =
  11177. var existsId = new List<CarCompare>();
  11178. var lastElem = arr.Last();
  11179. var thisSid = -1;
  11180. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11181. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11182. {
  11183. Name = "未知币种!",
  11184. Remark = "未知币种!",
  11185. };
  11186. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11187. Action cloneRowFn = () =>
  11188. {
  11189. rowStartIndex++;
  11190. var cloneRow = sheet.CreateRow(rowStartIndex);
  11191. // 复制样式
  11192. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11193. {
  11194. ICell sourceCell = initStyleRow.GetCell(i);
  11195. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11196. // 确保单元格存在样式
  11197. if (sourceCell.CellStyle != null)
  11198. {
  11199. targetCell.CellStyle = sourceCell.CellStyle;
  11200. }
  11201. }
  11202. };
  11203. var mergeRow = () =>
  11204. {
  11205. for (int i = 2; i < sheet.LastRowNum; i++)
  11206. {
  11207. var row = sheet.GetRow(i);
  11208. var cellFirst = row.GetCell(0);
  11209. var thisIndex = i + 1;
  11210. while (thisIndex < sheet.LastRowNum)
  11211. {
  11212. var nextRow = sheet.GetRow(thisIndex);
  11213. var nextCellFirst = nextRow.GetCell(0);
  11214. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11215. {
  11216. thisIndex++;
  11217. }
  11218. else
  11219. {
  11220. break;
  11221. }
  11222. }
  11223. thisIndex--;
  11224. if (thisIndex != i)
  11225. {
  11226. //合并row
  11227. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11228. i, // 起始行索引(0-based)
  11229. thisIndex, // 结束行索引(0-based)
  11230. 0, // 起始列索引(0-based)
  11231. 0 // 结束列索引(0-based)
  11232. );
  11233. sheet.AddMergedRegion(cellRangeAddress);
  11234. i = thisIndex;
  11235. }
  11236. }
  11237. };
  11238. var chaoshiNumber = 0;
  11239. var totalNumber = 0.00M;
  11240. string lastStr = "";
  11241. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11242. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11243. {
  11244. b.IsAuditGM,
  11245. x.Id,
  11246. x.Area,
  11247. b.PayPercentage,
  11248. b.PayMoney,
  11249. }).ToList();
  11250. string yesPayment = "", noPayment = "";
  11251. foreach (var item in queryCarArrByCityAndDiid)
  11252. {
  11253. if (item.IsAuditGM == 1)
  11254. {
  11255. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11256. }
  11257. else
  11258. {
  11259. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11260. }
  11261. }
  11262. lastStr = yesPayment + noPayment;
  11263. foreach (var item in arr)
  11264. {
  11265. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11266. {
  11267. if (thisSid != item.SId)
  11268. {
  11269. if (thisSid == -1)
  11270. {
  11271. thisSid = item.SId;
  11272. }
  11273. else
  11274. {
  11275. //合并小计行
  11276. //创建合并区域的实例
  11277. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11278. rowStartIndex, // 起始行索引(0-based)
  11279. rowStartIndex, // 结束行索引(0-based)
  11280. 0, // 起始列索引(0-based)
  11281. 3 // 结束列索引(0-based)
  11282. );
  11283. sheet.AddMergedRegion(cellRangeAddress);
  11284. var CellStyle = workbook.CreateCellStyle();
  11285. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11286. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11287. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11288. for (int i = 0; i <= clounmCount; i++)
  11289. {
  11290. if (i > 6)
  11291. {
  11292. var CellStyle1 = workbook.CreateCellStyle();
  11293. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11294. IFont Font = workbook.CreateFont(); // 创建字体
  11295. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11296. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11297. CellStyle1.SetFont(Font);
  11298. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11299. }
  11300. else
  11301. {
  11302. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11303. }
  11304. }
  11305. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11306. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11307. //超时合计
  11308. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11309. //超时数
  11310. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11311. //超时合计费用
  11312. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11313. thisSid = item.SId;
  11314. cloneRowFn();
  11315. chaoshiNumber = 0;
  11316. totalNumber = 0;
  11317. }
  11318. }
  11319. IRow row = sheet.GetRow(rowStartIndex);
  11320. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11321. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11322. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11323. if (isOpenOverspendSoure)
  11324. {
  11325. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11326. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11327. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11328. }
  11329. for (int i = 0; i <= clounmCount; i++)
  11330. {
  11331. var cell = row.GetCell(i);
  11332. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11333. if (cell == null)
  11334. {
  11335. cell = row.CreateCell(i);
  11336. }
  11337. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11338. fontRed.CloneStyleFrom(cell.CellStyle);
  11339. IFont Font = workbook.CreateFont(); // 创建字体
  11340. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11341. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11342. fontRed.SetFont(Font);
  11343. byte[] rgb = new byte[3] { 255, 242, 204 };
  11344. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11345. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11346. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11347. if (workbook is XSSFWorkbook)
  11348. {
  11349. BackgroundColor255_242_204.FillForegroundColor = 0;
  11350. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11351. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  11352. }
  11353. else
  11354. {
  11355. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11356. }
  11357. if (i == 1 || i > 6)
  11358. {
  11359. if (i > 6)
  11360. {
  11361. fontRed.FillForegroundColor = 0;
  11362. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11363. fontRed.FillPattern = FillPattern.SolidForeground;
  11364. }
  11365. cell.CellStyle = fontRed;
  11366. }
  11367. if (i > 2 && i < 7)
  11368. {
  11369. cell.CellStyle = BackgroundColor255_242_204;
  11370. }
  11371. cell.SetCellValue(setCellValue); //写入单元格
  11372. }
  11373. if (overspendSoure.ContainsKey(thisSid))
  11374. {
  11375. var overspendId = overspendSoure[thisSid];
  11376. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11377. }
  11378. cloneRowFn();
  11379. existsId.Add(new CarCompare
  11380. {
  11381. DataPrice = item.DatePrice.ObjToDate(),
  11382. Sid = item.SId
  11383. });
  11384. }
  11385. if (item.Equals(lastElem))
  11386. {
  11387. //合并小计行
  11388. //创建合并区域的实例
  11389. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11390. rowStartIndex, // 起始行索引(0-based)
  11391. rowStartIndex, // 结束行索引(0-based)
  11392. 0, // 起始列索引(0-based)
  11393. 3 // 结束列索引(0-based)
  11394. );
  11395. sheet.AddMergedRegion(cellRangeAddress);
  11396. var CellStyle = workbook.CreateCellStyle();
  11397. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11398. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11399. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11400. for (int i = 0; i <= clounmCount; i++)
  11401. {
  11402. if (i > 6)
  11403. {
  11404. var CellStyle1 = workbook.CreateCellStyle();
  11405. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11406. IFont Font = workbook.CreateFont(); // 创建字体
  11407. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11408. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11409. CellStyle1.SetFont(Font);
  11410. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11411. }
  11412. else
  11413. {
  11414. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11415. }
  11416. }
  11417. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11418. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11419. //超时合计
  11420. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11421. //超时数
  11422. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11423. //超时合计费用
  11424. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11425. cloneRowFn();
  11426. // 创建合并区域的实例
  11427. cellRangeAddress = new CellRangeAddress(
  11428. rowStartIndex, // 起始行索引(0-based)
  11429. rowStartIndex, // 结束行索引(0-based)
  11430. 0, // 起始列索引(0-based)
  11431. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11432. );
  11433. // 添加合并区域
  11434. sheet.AddMergedRegion(cellRangeAddress);
  11435. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11436. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11437. }
  11438. }
  11439. mergeRow();
  11440. // 保存修改后的Excel文件到新文件
  11441. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11442. // new FileStream(newFilePath, FileMode.CreateNew)
  11443. using (var stream = new MemoryStream())
  11444. {
  11445. workbook.Write(stream, true);
  11446. stream.Flush();
  11447. stream.Seek(0, SeekOrigin.Begin);
  11448. MemoryStream memoryStream = new MemoryStream();
  11449. stream.CopyTo(memoryStream);
  11450. memoryStream.Seek(0, SeekOrigin.Begin);
  11451. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11452. }
  11453. workbook.Close();
  11454. workbook.Dispose();
  11455. }
  11456. catch (Exception ex)
  11457. {
  11458. jw.Msg = "出现异常!" + ex.Message;
  11459. return Ok(jw);
  11460. }
  11461. }
  11462. if (Zips.Count > 0)
  11463. {
  11464. IOOperatorHelper io = new IOOperatorHelper();
  11465. var byts = io.ConvertZipStream(Zips);
  11466. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11467. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11468. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11469. }
  11470. else
  11471. {
  11472. jw.Msg = "暂无生成文件!";
  11473. }
  11474. return Ok(jw);
  11475. }
  11476. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11477. {
  11478. string outStr = string.Empty;
  11479. switch (i)
  11480. {
  11481. case 0:
  11482. outStr = arr[0].SidName;
  11483. break;
  11484. case 1:
  11485. outStr = arr[0].DataPriceStr;
  11486. break;
  11487. case 2:
  11488. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11489. break;
  11490. case 4:
  11491. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11492. break;
  11493. case 7:
  11494. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11495. {
  11496. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11497. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11498. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11499. }
  11500. break;
  11501. case 8:
  11502. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11503. {
  11504. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11505. }
  11506. break;
  11507. case 9:
  11508. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11509. {
  11510. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11511. }
  11512. break;
  11513. case 10:
  11514. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11515. {
  11516. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11517. }
  11518. break;
  11519. }
  11520. return outStr;
  11521. }
  11522. #region OP行程单
  11523. /// <summary>
  11524. /// OP行程单初始化
  11525. /// </summary>
  11526. /// <param name="dto"></param>
  11527. /// <returns></returns>
  11528. [HttpPost]
  11529. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11530. {
  11531. var jw = JsonView(false);
  11532. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  11533. var group = groupList.First();
  11534. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11535. if (group == null)
  11536. {
  11537. jw.Msg = "暂无团组!";
  11538. return Ok(jw);
  11539. }
  11540. group = groupList.Find(x => x.Id == diid);
  11541. if (group == null)
  11542. {
  11543. jw.Msg = "请输入正确的团组ID!";
  11544. return Ok(jw);
  11545. }
  11546. string city = string.Empty;
  11547. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11548. if (blackCode.Count > 0)
  11549. {
  11550. var black = blackCode.First();
  11551. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11552. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11553. if (blackSp.Length > 0)
  11554. {
  11555. try
  11556. {
  11557. var cityArrCode = new List<string>(20);
  11558. foreach (var item in blackSp)
  11559. {
  11560. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11561. var IndexSelect = itemSp[2];
  11562. var cityArrCodeLength = cityArrCode.Count - 1;
  11563. var startCity = IndexSelect.Substring(0, 3);
  11564. if (cityArrCodeLength > 0)
  11565. {
  11566. var arrEndCity = cityArrCode[cityArrCodeLength];
  11567. if (arrEndCity != startCity)
  11568. {
  11569. cityArrCode.Add(startCity.ToUpper());
  11570. }
  11571. }
  11572. else
  11573. {
  11574. cityArrCode.Add(startCity.ToUpper());
  11575. }
  11576. var endCity = IndexSelect.Substring(3, 3);
  11577. cityArrCode.Add(endCity.ToUpper());
  11578. }
  11579. var cityThree = string.Empty;
  11580. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11581. cityThree = cityThree.TrimEnd(',');
  11582. if (string.IsNullOrWhiteSpace(cityThree))
  11583. {
  11584. throw new
  11585. Exception("error");
  11586. }
  11587. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11588. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11589. foreach (var item in cityArrCode)
  11590. {
  11591. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11592. if (find != null)
  11593. {
  11594. city += find.City + "/";
  11595. }
  11596. else
  11597. {
  11598. city += item + "三字码未收入/";
  11599. }
  11600. }
  11601. city = city.TrimEnd('/');
  11602. }
  11603. catch (Exception e)
  11604. {
  11605. city = "黑屏代码格式不正确!";
  11606. }
  11607. }
  11608. }
  11609. else
  11610. {
  11611. city = "未录入黑屏代码";
  11612. }
  11613. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11614. {
  11615. Date = x.Date,
  11616. Days = x.Days,
  11617. Diffgroup = x.Diffgroup,
  11618. Diid = x.Diid,
  11619. Traffic_First = x.Traffic_First,
  11620. Traffic_Second = x.Traffic_Second,
  11621. Trip = x.Trip,
  11622. WeekDay = x.WeekDay,
  11623. Id = x.Id
  11624. }).ToList();
  11625. jw.Data = new
  11626. {
  11627. groupList = groupList.Select(x => new
  11628. {
  11629. x.Id,
  11630. x.TeamName,
  11631. x.TourCode
  11632. }).ToList(),
  11633. groupInfo = new
  11634. {
  11635. group.VisitDays,
  11636. group.TourCode,
  11637. group.VisitPNumber,
  11638. group.TeamName,
  11639. city
  11640. },
  11641. OpTravelList
  11642. };
  11643. jw.Code = 200;
  11644. jw.Msg = "操作成功!";
  11645. return Ok(jw);
  11646. }
  11647. /// <summary>
  11648. /// 删除团组行程单
  11649. /// </summary>
  11650. /// <returns></returns>
  11651. [HttpPost]
  11652. public IActionResult DelTravel(DelOpTravelDto dto)
  11653. {
  11654. var jw = JsonView(false);
  11655. if (dto.UserId <= 0 || dto.Diid <= 0)
  11656. {
  11657. jw.Msg = "请输入正确的参数!";
  11658. return Ok(jw);
  11659. }
  11660. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11661. .SetColumns(x => new Grp_TravelList
  11662. {
  11663. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11664. DeleteUserId = dto.UserId,
  11665. IsDel = 1,
  11666. }).ExecuteCommand();
  11667. jw = JsonView(true);
  11668. return Ok(jw);
  11669. }
  11670. /// <summary>
  11671. /// 行程单保存
  11672. /// </summary>
  11673. /// <returns></returns>
  11674. [HttpPost]
  11675. public IActionResult TravelSave(TravelSaveDto dto)
  11676. {
  11677. var jw = JsonView(false);
  11678. if (dto.Arr.Count > 0)
  11679. {
  11680. try
  11681. {
  11682. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11683. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11684. .ToList();
  11685. _sqlSugar.BeginTran();
  11686. foreach (var item in dto.Arr)
  11687. {
  11688. if (item.Id == 0)
  11689. {
  11690. throw new Exception("请传入正确的Id");
  11691. }
  11692. //比较上一次的差异
  11693. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11694. if (findTravel != null)
  11695. {
  11696. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11697. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11698. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11699. }
  11700. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11701. .SetColumns(x => new Grp_TravelList
  11702. {
  11703. Trip = item.Trip
  11704. }).ExecuteCommand();
  11705. }
  11706. _sqlSugar.CommitTran();
  11707. jw = JsonView(true);
  11708. }
  11709. catch (Exception ex)
  11710. {
  11711. _sqlSugar.RollbackTran();
  11712. jw.Msg = "程序异常!" + ex.Message;
  11713. }
  11714. }
  11715. else
  11716. {
  11717. jw.Msg = "请传入正确的参数!";
  11718. }
  11719. return Ok(jw);
  11720. }
  11721. private string CheckStr(string original, string changed)
  11722. {
  11723. // 创建diff_match_patch对象
  11724. var dmp = new diff_match_patch();
  11725. // 计算差异
  11726. List<Diff> diffs = dmp.diff_main(original, changed);
  11727. // 清理和合并差异
  11728. dmp.diff_cleanupSemantic(diffs);
  11729. // 使用StringBuilder构建最终的字符串
  11730. StringBuilder finalString = new StringBuilder();
  11731. // 输出差异结果,并构建变动后的字符串
  11732. foreach (Diff diff in diffs)
  11733. {
  11734. switch (diff.operation)
  11735. {
  11736. case Operation.EQUAL:
  11737. // 相等的部分,直接添加到最终字符串
  11738. finalString.Append(diff.text);
  11739. break;
  11740. case Operation.INSERT:
  11741. // 插入的部分,添加标记并添加到最终字符串
  11742. finalString.Append("[++]" + diff.text + "[++]");
  11743. break;
  11744. case Operation.DELETE:
  11745. // 删除的部分,不添加到最终字符串
  11746. //finalString.Append("[++]" + diff.text + "[++]");
  11747. break;
  11748. }
  11749. }
  11750. // 输出变动后的字符串
  11751. return finalString.ToString();
  11752. }
  11753. private class tagContent
  11754. {
  11755. public DateTime Date { get; set; }
  11756. public string StartTag { get; set; }
  11757. public string EndTag { get; set; }
  11758. public string Content { get; set; }
  11759. public static int tagLength { get { return 3; } }
  11760. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11761. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11762. public bool IsFinally { get; set; }
  11763. }
  11764. private List<string> ExtractContentBetweenTags(string input, string tag)
  11765. {
  11766. List<string> results = new List<string>();
  11767. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11768. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11769. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11770. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11771. string[] strValueArr = new string[1];
  11772. foreach (System.Text.RegularExpressions.Match match in matches)
  11773. {
  11774. var strValue = match.Groups[1].Value;
  11775. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11776. }
  11777. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11778. return results;
  11779. }
  11780. /// <summary>
  11781. /// 导出行程单
  11782. /// </summary>
  11783. /// <param name="dto"></param>
  11784. /// <returns></returns>
  11785. [HttpPost]
  11786. public IActionResult ExportTravel(ExportTravelDto dto)
  11787. {
  11788. var jw = JsonView(false);
  11789. jw.Data = "";
  11790. int diid = 0;
  11791. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11792. if (Find == null)
  11793. {
  11794. jw.Msg = "请选择正确的团组!";
  11795. return Ok(jw);
  11796. }
  11797. else
  11798. {
  11799. diid = Find.Id;
  11800. }
  11801. //数据源
  11802. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11803. DataTable dtBlack = null;
  11804. try
  11805. {
  11806. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11807. }
  11808. catch (Exception)
  11809. {
  11810. jw.Msg = "机票黑屏代码有误!";
  11811. return Ok(jw);
  11812. }
  11813. string CityStr = string.Empty;
  11814. if (dtBlack.Rows.Count == 0)
  11815. {
  11816. jw.Msg = "机票黑屏代码有误!";
  11817. return Ok(jw);
  11818. }
  11819. else
  11820. {
  11821. foreach (DataRow row in dtBlack.Rows)
  11822. {
  11823. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11824. {
  11825. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11826. return Ok(jw);
  11827. }
  11828. }
  11829. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11830. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11831. }
  11832. // 指定的文字
  11833. var targetTextDic = new Dictionary<string, List<string>>();
  11834. //创建数据源Table
  11835. DataTable dtSource = new DataTable();
  11836. dtSource.Columns.Add("Days", typeof(string));
  11837. dtSource.Columns.Add("Date", typeof(string));
  11838. dtSource.Columns.Add("Week", typeof(string));
  11839. dtSource.Columns.Add("Traffic", typeof(string));
  11840. dtSource.Columns.Add("Trip", typeof(string));
  11841. //获取数据,放到datatable
  11842. foreach (var item in _travelList)
  11843. {
  11844. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11845. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11846. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11847. .Replace("[++]", string.Empty);
  11848. DataRow dr = dtSource.NewRow();
  11849. dr["Days"] = item.Days;
  11850. dr["Date"] = item.Date;
  11851. dr["Week"] = item.WeekDay;
  11852. dr["Traffic"] = item.Traffic_First
  11853. + "\r\n"
  11854. + item.Traffic_Second;
  11855. dr["Trip"] = item.Trip;
  11856. dtSource.Rows.Add(dr);
  11857. }
  11858. Dictionary<string, string> dic = new Dictionary<string, string>();
  11859. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11860. dic.Add("City", CityStr);
  11861. dic.Add("Days", Find.VisitDays.ToString());
  11862. dic.Add("DeleCode", Find.TourCode);
  11863. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11864. //模板路径
  11865. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11866. //载入模板
  11867. Document doc = null;
  11868. DocumentBuilder builder = null;
  11869. try
  11870. {
  11871. //载入模板
  11872. doc = new Document(tempPath);
  11873. builder = new DocumentBuilder(doc);
  11874. }
  11875. catch (Exception)
  11876. {
  11877. jw.Msg = "模板位置不存在!";
  11878. return Ok(jw);
  11879. }
  11880. foreach (var key in dic.Keys)
  11881. {
  11882. Bookmark bookmark = doc.Range.Bookmarks[key];
  11883. if (bookmark != null)
  11884. {
  11885. builder.MoveToBookmark(key);
  11886. builder.Write(dic[key]);
  11887. }
  11888. }
  11889. //获取word里所有表格
  11890. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11891. //获取所填表格的序数
  11892. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11893. try
  11894. {
  11895. //循环赋值
  11896. for (int i = 0; i < dtSource.Rows.Count; i++)
  11897. {
  11898. builder.MoveToCell(0, i + 1, 0, 0);
  11899. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11900. builder.MoveToCell(0, i + 1, 1, 0);
  11901. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11902. builder.MoveToCell(0, i + 1, 2, 0);
  11903. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11904. var trip = dtSource.Rows[i]["Trip"].ToString();
  11905. builder.MoveToCell(0, i + 1, 3, 0);
  11906. builder.Write(trip);
  11907. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11908. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11909. // 获取特定索引的段落
  11910. Paragraph paragraph = (Paragraph)paragraphs[0];
  11911. Run run = paragraph.Runs[0];
  11912. Aspose.Words.Font font = run.Font;
  11913. font.Name = "黑体";
  11914. //设置双休红色
  11915. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11916. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11917. paragraph = (Paragraph)paragraphs[1];
  11918. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11919. {
  11920. run = paragraph.Runs[0];
  11921. font = run.Font;
  11922. font.Color = Color.Red;
  11923. }
  11924. }
  11925. }
  11926. catch (Exception ex)
  11927. {
  11928. }
  11929. //删除多余行
  11930. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11931. {
  11932. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11933. }
  11934. var targetTextList = new List<string>();
  11935. // 遍历文档中的表格
  11936. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11937. {
  11938. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11939. {
  11940. var cellIndex = 0;
  11941. foreach (Cell cell in row.Cells)
  11942. {
  11943. if (cellIndex == 1 && row.Cells.Count == 4)
  11944. {
  11945. foreach (var target in targetTextDic.Keys)
  11946. {
  11947. if (cell.GetText().Contains(target))
  11948. {
  11949. targetTextList = targetTextDic[target];
  11950. break;
  11951. }
  11952. }
  11953. }
  11954. // 遍历单元格中的所有段落
  11955. foreach (Paragraph paragraph in cell.Paragraphs)
  11956. {
  11957. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11958. List<Run> runs = new List<Run>();
  11959. foreach (Run run in paragraph.Runs)
  11960. {
  11961. runs.Add(run);
  11962. }
  11963. foreach (Run run in runs)
  11964. {
  11965. foreach (var targetText in targetTextList)
  11966. {
  11967. // 检查文字是否包含指定文字
  11968. if (run.Text.Contains(targetText))
  11969. {
  11970. // 将包含的部分设置为红色
  11971. HighlightText(run, targetText, Color.Red);
  11972. }
  11973. }
  11974. }
  11975. }
  11976. cellIndex++;
  11977. }
  11978. }
  11979. }
  11980. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11981. if (!Directory.Exists(savePath))
  11982. {
  11983. try
  11984. {
  11985. Directory.CreateDirectory(savePath);
  11986. }
  11987. catch
  11988. {
  11989. }
  11990. }
  11991. string path = savePath + Find.TeamName + "出访日程";
  11992. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11993. try
  11994. {
  11995. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11996. string postfix = ".docx";
  11997. if (dto.IsPDF == 1)
  11998. {
  11999. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12000. postfix = ".pdf";
  12001. }
  12002. doc.Save(path + postfix, saveFormat);
  12003. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12004. }
  12005. catch (Exception)
  12006. {
  12007. jw = JsonView(false);
  12008. }
  12009. return Ok(jw);
  12010. }
  12011. /// <summary>
  12012. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12013. /// </summary>
  12014. /// <param name="num"></param>
  12015. /// <returns></returns>
  12016. string GetNum(string num)
  12017. {
  12018. string str = "";
  12019. switch (num)
  12020. {
  12021. case "1":
  12022. str = "一";
  12023. break;
  12024. case "2":
  12025. str = "二";
  12026. break;
  12027. case "3":
  12028. str = "三";
  12029. break;
  12030. case "4":
  12031. str = "四";
  12032. break;
  12033. case "5":
  12034. str = "五";
  12035. break;
  12036. case "6":
  12037. str = "六";
  12038. break;
  12039. case "7":
  12040. str = "七";
  12041. break;
  12042. case "8":
  12043. str = "八";
  12044. break;
  12045. case "9":
  12046. str = "九";
  12047. break;
  12048. case "10":
  12049. str = "十";
  12050. break;
  12051. case "11":
  12052. str = "十一";
  12053. break;
  12054. case "12":
  12055. str = "十二";
  12056. break;
  12057. case "一":
  12058. str = "1";
  12059. break;
  12060. case "二":
  12061. str = "2";
  12062. break;
  12063. case "三":
  12064. str = "3";
  12065. break;
  12066. case "四":
  12067. str = "4";
  12068. break;
  12069. case "五":
  12070. str = "5";
  12071. break;
  12072. case "六":
  12073. str = "6";
  12074. break;
  12075. case "七":
  12076. str = "7";
  12077. break;
  12078. case "八":
  12079. str = "8";
  12080. break;
  12081. case "九":
  12082. str = "9";
  12083. break;
  12084. case "十":
  12085. str = "10";
  12086. break;
  12087. case "十一":
  12088. str = "11";
  12089. break;
  12090. case "十二":
  12091. str = "12";
  12092. break;
  12093. }
  12094. return str;
  12095. }
  12096. // 高亮包含指定文字的部分
  12097. void HighlightText(Run run, string targetText, Color color)
  12098. {
  12099. string text = run.Text;
  12100. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12101. if (startIndex >= 0)
  12102. {
  12103. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12104. // 前部分
  12105. if (startIndex > 0)
  12106. {
  12107. Run beforeRun = (Run)run.Clone(true);
  12108. beforeRun.Text = text.Substring(0, startIndex);
  12109. parentParagraph.InsertBefore(beforeRun, run);
  12110. }
  12111. // 匹配部分
  12112. Run matchRun = (Run)run.Clone(true);
  12113. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12114. matchRun.Font.Color = color;
  12115. parentParagraph.InsertBefore(matchRun, run);
  12116. // 后部分
  12117. if (startIndex + targetText.Length < text.Length)
  12118. {
  12119. Run afterRun = (Run)run.Clone(true);
  12120. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12121. parentParagraph.InsertBefore(afterRun, run);
  12122. }
  12123. // 删除原始Run
  12124. run.Remove();
  12125. }
  12126. }
  12127. #endregion
  12128. #endregion
  12129. #region 团组成本
  12130. /// <summary>
  12131. /// 团组成本数据初始化
  12132. /// </summary>
  12133. /// <param name="dto"></param>
  12134. /// <returns></returns>
  12135. [HttpPost]
  12136. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12137. {
  12138. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12139. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12140. WHEN COUNT(*) >= 0 THEN 'True'
  12141. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12142. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12143. ").ToList(); //团组列表
  12144. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12145. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12146. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12147. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12148. if (groupinfoValue != null)
  12149. {
  12150. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12151. var spArr = new string[1] { countryArr };
  12152. if (countryArr.Contains("|"))
  12153. {
  12154. spArr = countryArr.Split("|");
  12155. }
  12156. else if (countryArr.Contains("、"))
  12157. {
  12158. spArr = countryArr.Split("、");
  12159. }
  12160. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12161. {
  12162. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12163. if (dbQueryCountry != null)
  12164. {
  12165. visaCountryInfoArr.Add(dbQueryCountry);
  12166. }
  12167. }
  12168. }
  12169. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12170. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12171. var create = _GroupCostRepository.
  12172. CreateGroupCostByBlackCode(dto.Diid);
  12173. if (groupCost.Count == 0 && create.Code == 0)
  12174. {
  12175. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12176. }
  12177. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12178. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12179. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12180. groupCostMap = groupCostMap.Select(x =>
  12181. {
  12182. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12183. {
  12184. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12185. }
  12186. return x;
  12187. }).ToList();
  12188. //GroupCostParameter.Add(new
  12189. // Grp_GroupCostParameter());
  12190. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12191. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12192. return Ok(JsonView(new
  12193. {
  12194. groupList,
  12195. groupInfo,
  12196. groupChecks,
  12197. groupCost = groupCostMap,
  12198. hotelNumber,
  12199. GroupCostParameter = GroupCostParameterMap,
  12200. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12201. {
  12202. x.VisaCountry,
  12203. x.VisaPrice,
  12204. x.Id,
  12205. }).ToList(),
  12206. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12207. blackCodeIsTrue = create.Code == 0 ? true : false,
  12208. hotelIsTrue = hotelIsTrue,
  12209. }));
  12210. }
  12211. /// <summary>
  12212. /// 团组成本信息保存
  12213. /// </summary>
  12214. /// <param name="dto"></param>
  12215. /// <returns></returns>
  12216. [HttpPost]
  12217. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12218. {
  12219. if (dto.Diid <= 0 || dto.Userid <= 0)
  12220. {
  12221. return Ok(JsonView(false));
  12222. }
  12223. JsonView jw = null;
  12224. bool isTrue = false;
  12225. #region 复制团组成本
  12226. //if (dto.Diid == 2581)
  12227. //{
  12228. // dto.Diid = 2599;
  12229. // dto.CheckBoxs.ForEach(x =>
  12230. // {
  12231. // x.Diid = 2599;
  12232. // });
  12233. // dto.GroupCosts.ForEach(x =>
  12234. // {
  12235. // x.Diid = 2599;
  12236. // });
  12237. // dto.CostTypeHotelNumbers.ForEach(x =>
  12238. // {
  12239. // x.Diid = 2599;
  12240. // });
  12241. // dto.GroupCostParameters.ForEach(x =>
  12242. // {
  12243. // x.DiId = 2599;
  12244. // });
  12245. //}
  12246. #endregion
  12247. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12248. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12249. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12250. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12251. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12252. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12253. try
  12254. {
  12255. _sqlSugar.BeginTran();
  12256. isTrue = await _GroupCostRepository.
  12257. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12258. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12259. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12260. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12261. _sqlSugar.CommitTran();
  12262. jw = JsonView(true, "保存成功!", isTrue);
  12263. }
  12264. catch (Exception)
  12265. {
  12266. _sqlSugar.RollbackTran();
  12267. jw = JsonView(false);
  12268. }
  12269. return Ok(jw);
  12270. }
  12271. /// <summary>
  12272. /// 司兼导数据
  12273. /// </summary>
  12274. /// <param name="dto"></param>
  12275. /// <returns></returns>
  12276. [HttpPost]
  12277. public IActionResult GetCarGuides(CarGuidesDto dto)
  12278. {
  12279. JsonView jw = null;
  12280. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12281. jw = JsonView(true, "获取成功!", Data);
  12282. return Ok(jw);
  12283. }
  12284. /// <summary>
  12285. /// 导游数据
  12286. /// </summary>
  12287. /// <param name="dto"></param>
  12288. /// <returns></returns>
  12289. [HttpPost]
  12290. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12291. {
  12292. JsonView jw = null;
  12293. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12294. // 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
  12295. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12296. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12297. jw = JsonView(true, "获取成功!", Data);
  12298. return Ok(jw);
  12299. }
  12300. /// <summary>
  12301. /// 成本车数据
  12302. /// </summary>
  12303. /// <param name="dto"></param>
  12304. /// <returns></returns>
  12305. [HttpPost]
  12306. public IActionResult GetCarInfo(CarGuidesDto dto)
  12307. {
  12308. JsonView jw = null;
  12309. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12310. jw = JsonView(true, "获取成功!", Data);
  12311. return Ok(jw);
  12312. }
  12313. /// <summary>
  12314. /// 景点数据
  12315. /// </summary>
  12316. /// <param name="dto"></param>
  12317. /// <returns></returns>
  12318. [HttpPost]
  12319. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12320. {
  12321. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12322. return Ok(JsonView(true, "获取成功!", Data));
  12323. }
  12324. /// <summary>
  12325. /// 成本通知
  12326. /// </summary>
  12327. /// <param name="dto"></param>
  12328. /// <returns></returns>
  12329. [HttpPost]
  12330. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12331. {
  12332. if (dto.Diid < 0)
  12333. {
  12334. return Ok(JsonView(false));
  12335. }
  12336. JsonView jw = null;
  12337. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12338. if (GroupCostParameter != null)
  12339. {
  12340. int IsShare = 0;
  12341. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12342. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12343. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12344. string msg = string.Empty;
  12345. if (isTrue)
  12346. {
  12347. if (IsShare == 0)
  12348. {
  12349. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12350. }
  12351. else
  12352. {
  12353. #region 企微通知对应岗位用户
  12354. try
  12355. {
  12356. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12357. }
  12358. catch (Exception ex)
  12359. {
  12360. }
  12361. #endregion
  12362. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12363. }
  12364. jw = JsonView(isTrue, msg, new { IsShare });
  12365. }
  12366. else
  12367. {
  12368. msg = "修改失败!";
  12369. jw = JsonView(isTrue, msg);
  12370. }
  12371. }
  12372. else
  12373. {
  12374. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12375. }
  12376. return Ok(jw);
  12377. }
  12378. /// <summary>
  12379. /// 导出报价单
  12380. /// </summary>
  12381. /// <param name="dto"></param>
  12382. /// <returns></returns>
  12383. [HttpPost]
  12384. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12385. {
  12386. if (dto.Diid == 0)
  12387. {
  12388. return Ok(JsonView(false, "请传递团组id"));
  12389. }
  12390. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12391. if (deleInfo.Code != 0)
  12392. {
  12393. return Ok(JsonView(false, "团组信息查询失败!"));
  12394. }
  12395. var di = deleInfo.Data as DelegationInfoWebView;
  12396. if (di != null)
  12397. {
  12398. di.TeamName = di.TeamName.Replace("|", "、");
  12399. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12400. //文件名
  12401. string strFileName = di.TeamName + "-收款账单.doc";
  12402. //获取模板
  12403. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12404. //载入模板
  12405. Document doc = new Document(tmppath);
  12406. decimal TotalPrice = 0.00M;
  12407. string itemStr = string.Empty;
  12408. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12409. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12410. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12411. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12412. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12413. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12414. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12415. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12416. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12417. foreach (var cost in groupCostType)
  12418. {
  12419. var List = cost.ToList();
  12420. if (cost.Key == "A")
  12421. {
  12422. foreach (var ListItem in List)
  12423. {
  12424. if (ListItem.number > 0)
  12425. {
  12426. if (ListItem.code.Contains("TBR"))
  12427. {
  12428. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12429. }
  12430. else
  12431. {
  12432. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12433. }
  12434. TotalPrice += (ListItem.number * ListItem.price);
  12435. }
  12436. }
  12437. }
  12438. else
  12439. {
  12440. itemStr = itemStr.Insert(0, "A段\r\n");
  12441. itemStr += "B段\r\n";
  12442. foreach (var ListItem in List)
  12443. {
  12444. if (ListItem.number > 0)
  12445. {
  12446. if (ListItem.code.Contains("TBR"))
  12447. {
  12448. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12449. }
  12450. else
  12451. {
  12452. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12453. }
  12454. TotalPrice += (ListItem.number * ListItem.price);
  12455. }
  12456. }
  12457. }
  12458. }
  12459. #region 替换Word模板书签内容
  12460. Dictionary<string, string> marks = new Dictionary<string, string>();
  12461. marks.Add("To", di.ClientUnit);//付款方
  12462. marks.Add("ToTel", di.TellPhone);//付款方电话
  12463. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12464. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12465. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12466. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12467. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12468. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12469. marks.Add("PayItemContent", itemStr);//详细信息
  12470. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12471. #endregion
  12472. ////注
  12473. //if (doc.Range.Bookmarks["Attention"] != null)
  12474. //{
  12475. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12476. // mark.Text = frList[0].Attention;
  12477. //}
  12478. foreach (var item in marks.Keys)
  12479. {
  12480. if (doc.Range.Bookmarks[item] != null)
  12481. {
  12482. Bookmark mark = doc.Range.Bookmarks[item];
  12483. mark.Text = marks[item];
  12484. }
  12485. }
  12486. byte[] bytes = null;
  12487. using (MemoryStream stream = new MemoryStream())
  12488. {
  12489. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12490. bytes = stream.ToArray();
  12491. }
  12492. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12493. return Ok(JsonView(true, "", new
  12494. {
  12495. Data = bytes,
  12496. strFileName,
  12497. }));
  12498. }
  12499. else
  12500. {
  12501. return Ok(JsonView(false, "团组信息不存在!"));
  12502. }
  12503. }
  12504. /// <summary>
  12505. /// 导出团组成本
  12506. /// </summary>
  12507. /// <param name="dto"></param>
  12508. /// <returns></returns>
  12509. [HttpPost]
  12510. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12511. {
  12512. var jw = JsonView(false);
  12513. if (dto.Diid == 0)
  12514. {
  12515. return Ok(JsonView(false, "请传递团组id"));
  12516. }
  12517. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12518. if (deleInfo.Code != 0)
  12519. {
  12520. return Ok(JsonView(false, "团组信息查询失败!"));
  12521. }
  12522. var di = deleInfo.Data as DelegationInfoWebView;
  12523. if (di == null)
  12524. {
  12525. return Ok(JsonView(false, "团组信息查询失败!"));
  12526. }
  12527. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12528. WorkbookDesigner designer = new WorkbookDesigner();
  12529. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12530. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12531. for (int i = 0; i < List_GC.Count; i++)
  12532. {
  12533. GroupCost_Excel gc = new GroupCost_Excel();
  12534. gc.Id = List_GC[i].Id;
  12535. gc.Diid = List_GC[i].Diid.ToString();
  12536. gc.DAY = List_GC[i].DAY;
  12537. string week = "";
  12538. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12539. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12540. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12541. gc.ITIN = List_GC[i].ITIN;
  12542. gc.CarType = List_GC[i].CarType;
  12543. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12544. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12545. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12546. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12547. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12548. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12549. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12550. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12551. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12552. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12553. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12554. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12555. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12556. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12557. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12558. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12559. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12560. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12561. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12562. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12563. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12564. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12565. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12566. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12567. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12568. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12569. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12570. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12571. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12572. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12573. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12574. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12575. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12576. List_GC1.Add(gc);
  12577. }
  12578. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12579. dt.TableName = "TB";
  12580. //报表标题等不用dt的值
  12581. designer.SetDataSource("TeamName", dto.title.TeamName);
  12582. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12583. designer.SetDataSource("Tax", dto.title.Tax);
  12584. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12585. designer.SetDataSource("Currency", dto.title.Currency);
  12586. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12587. designer.SetDataSource("Rate", dto.title.Rate);
  12588. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12589. var Aparams = hotels.Find(x => x.Type == "Default");
  12590. if (Aparams == null)
  12591. {
  12592. return Ok(jw);
  12593. }
  12594. //酒店数量
  12595. var txtSGRNumber = Aparams.SGR.ToString();
  12596. var txtTBRNumber = Aparams.TBR.ToString();
  12597. var txtJSESNumber = Aparams.JSES.ToString();
  12598. var txtSUITENumbe = Aparams.SUITE.ToString();
  12599. if (dto.costType == "B")
  12600. {
  12601. Aparams = hotels.Find(x => x.Type == "A");
  12602. var Bparams = hotels.Find(x => x.Type == "B");
  12603. if (Aparams == null || Bparams == null)
  12604. {
  12605. return Ok(jw);
  12606. }
  12607. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12608. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12609. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12610. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12611. }
  12612. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12613. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12614. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12615. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12616. var ws = designer.Workbook.Worksheets[0];
  12617. int Row = List_GC.Count;
  12618. int startIndex = 11;
  12619. int HideRows = 0;
  12620. List<int> hideRowsList = new List<int>();
  12621. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12622. #region A段left数据
  12623. var left = dto.leftInfo.Find(x => x.Type == "A");
  12624. if (left == null)
  12625. {
  12626. return Ok(jw);
  12627. }
  12628. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12629. if (leftBindData != null)
  12630. {
  12631. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12632. designer.SetDataSource("VisaRS", leftBindData.rs);
  12633. designer.SetDataSource("VisaXS", leftBindData.xs);
  12634. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12635. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12636. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12637. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12638. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12639. }
  12640. else
  12641. {
  12642. hideRowsList.Add(Row + startIndex + HideRows);
  12643. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12644. }
  12645. HideRows += 2;
  12646. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12647. if (leftBindData != null)
  12648. {
  12649. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12650. designer.SetDataSource("BXRS", leftBindData.rs);
  12651. designer.SetDataSource("BXXS", leftBindData.xs);
  12652. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12653. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12654. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12655. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12656. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12657. }
  12658. else
  12659. {
  12660. hideRowsList.Add(Row + startIndex + HideRows);
  12661. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12662. }
  12663. HideRows += 2;
  12664. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12665. if (leftBindData != null)
  12666. {
  12667. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12668. designer.SetDataSource("HSRS", leftBindData.rs);
  12669. designer.SetDataSource("HSXS", leftBindData.xs);
  12670. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12671. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12672. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12673. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12674. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12675. }
  12676. else
  12677. {
  12678. hideRowsList.Add(Row + startIndex + HideRows);
  12679. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12680. }
  12681. HideRows += 2;
  12682. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12683. if (leftBindData != null)
  12684. {
  12685. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12686. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12687. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12688. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12689. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12690. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12691. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12692. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12693. }
  12694. else
  12695. {
  12696. hideRowsList.Add(Row + startIndex + HideRows);
  12697. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12698. }
  12699. HideRows += 2;
  12700. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12701. if (leftBindData != null)
  12702. {
  12703. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12704. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12705. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12706. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12707. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12708. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12709. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12710. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12711. }
  12712. else
  12713. {
  12714. hideRowsList.Add(Row + startIndex + HideRows);
  12715. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12716. }
  12717. HideRows += 2;
  12718. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12719. if (leftBindData != null)
  12720. {
  12721. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12722. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12723. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12724. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12725. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12726. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12727. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12728. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12729. }
  12730. else
  12731. {
  12732. hideRowsList.Add(Row + startIndex + HideRows);
  12733. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12734. }
  12735. HideRows += 2;
  12736. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12737. if (leftBindData != null)
  12738. {
  12739. ////TBR
  12740. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12741. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12742. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12743. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12744. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12745. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12746. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12747. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12748. }
  12749. else
  12750. {
  12751. hideRowsList.Add(Row + startIndex + HideRows);
  12752. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12753. }
  12754. HideRows += 2;
  12755. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12756. if (leftBindData != null)
  12757. {
  12758. ////SGR
  12759. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12760. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12761. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12762. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12763. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12764. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12765. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12766. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12767. }
  12768. else
  12769. {
  12770. hideRowsList.Add(Row + startIndex + HideRows);
  12771. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12772. }
  12773. HideRows += 2;
  12774. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12775. if (leftBindData != null)
  12776. {
  12777. ////JS/ES
  12778. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12779. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12780. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12781. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12782. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12783. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12784. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12785. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12786. }
  12787. else
  12788. {
  12789. hideRowsList.Add(Row + startIndex + HideRows);
  12790. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12791. }
  12792. HideRows += 2;
  12793. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12794. if (leftBindData != null)
  12795. {
  12796. ////SUITE
  12797. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12798. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12799. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12800. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12801. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12802. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12803. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12804. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12805. }
  12806. else
  12807. {
  12808. hideRowsList.Add(Row + startIndex + HideRows);
  12809. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12810. }
  12811. HideRows += 2;
  12812. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12813. if (leftBindData != null)
  12814. {
  12815. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12816. designer.SetDataSource("DJRS", leftBindData.rs);
  12817. designer.SetDataSource("DJXS", leftBindData.xs);
  12818. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12819. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12820. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12821. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12822. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12823. }
  12824. else
  12825. {
  12826. hideRowsList.Add(Row + startIndex + HideRows);
  12827. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12828. }
  12829. HideRows += 2;
  12830. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12831. if (leftBindData != null)
  12832. {
  12833. designer.SetDataSource("HCPCB", leftBindData.cb);
  12834. designer.SetDataSource("HCPRS", leftBindData.rs);
  12835. designer.SetDataSource("HCPXS", leftBindData.xs);
  12836. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12837. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12838. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12839. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12840. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12841. }
  12842. else
  12843. {
  12844. hideRowsList.Add(Row + startIndex + HideRows);
  12845. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12846. }
  12847. HideRows += 2;
  12848. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12849. if (leftBindData != null)
  12850. {
  12851. designer.SetDataSource("CPCB", leftBindData.cb);
  12852. designer.SetDataSource("CPRS", leftBindData.rs);
  12853. designer.SetDataSource("CPXS", leftBindData.xs);
  12854. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12855. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12856. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12857. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12858. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12859. }
  12860. else
  12861. {
  12862. hideRowsList.Add(Row + startIndex + HideRows);
  12863. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12864. }
  12865. HideRows += 2;
  12866. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12867. if (leftBindData != null)
  12868. {
  12869. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12870. designer.SetDataSource("GWRS", leftBindData.rs);
  12871. designer.SetDataSource("GWXS", leftBindData.xs);
  12872. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12873. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12874. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12875. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12876. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12877. }
  12878. else
  12879. {
  12880. hideRowsList.Add(Row + startIndex + HideRows);
  12881. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12882. }
  12883. HideRows += 2;
  12884. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12885. if (leftBindData != null)
  12886. {
  12887. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12888. designer.SetDataSource("LYJRS", leftBindData.rs);
  12889. designer.SetDataSource("LYJXS", leftBindData.xs);
  12890. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12891. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12892. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12893. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12894. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12895. }
  12896. else
  12897. {
  12898. hideRowsList.Add(Row + startIndex + HideRows);
  12899. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12900. }
  12901. #endregion
  12902. #region A段Right信息
  12903. var right = dto.rightInfo.Find(x => x.Type == "A");
  12904. if (right == null)
  12905. {
  12906. return Ok(jw);
  12907. }
  12908. HideRows += 4;
  12909. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12910. if (rightBindData != null)
  12911. {
  12912. //经济舱 + 双人间 TBR
  12913. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12914. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12915. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12916. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12917. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12918. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12919. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12920. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12921. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12922. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12923. }
  12924. else
  12925. {
  12926. hideRowsList.Add(Row + startIndex + HideRows);
  12927. }
  12928. HideRows += 2;
  12929. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12930. if (rightBindData != null)
  12931. {
  12932. //经济舱 + 单人间 SGR
  12933. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12934. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12935. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12936. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12937. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12938. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12939. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12940. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12941. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12942. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12943. }
  12944. else
  12945. {
  12946. hideRowsList.Add(Row + startIndex + HideRows);
  12947. }
  12948. HideRows += 2;
  12949. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12950. if (rightBindData != null)
  12951. {
  12952. //公务舱 + 单人间 SGR
  12953. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12954. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12955. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12956. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12957. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12958. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12959. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12960. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12961. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12962. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12963. }
  12964. else
  12965. {
  12966. hideRowsList.Add(Row + startIndex + HideRows);
  12967. }
  12968. HideRows += 2;
  12969. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12970. if (rightBindData != null)
  12971. {
  12972. //公务舱 + 小套房 JSES
  12973. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12974. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12975. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12976. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12977. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12978. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12979. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12980. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12981. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12982. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12983. }
  12984. else
  12985. {
  12986. hideRowsList.Add(Row + startIndex + HideRows);
  12987. }
  12988. HideRows += 2;
  12989. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12990. if (rightBindData != null)
  12991. {
  12992. //公务舱 + 小套房 JSES
  12993. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12994. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12995. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12996. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12997. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12998. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12999. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13000. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13001. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13002. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13003. }
  13004. else
  13005. {
  13006. hideRowsList.Add(Row + startIndex + HideRows);
  13007. }
  13008. HideRows += 2;
  13009. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13010. if (rightBindData != null)
  13011. {
  13012. //经济舱 + 大套房
  13013. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13014. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13015. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13016. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13017. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13018. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13019. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13020. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13021. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13022. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13023. }
  13024. else
  13025. {
  13026. hideRowsList.Add(Row + startIndex + HideRows);
  13027. }
  13028. HideRows += 2;
  13029. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13030. if (rightBindData != null)
  13031. {
  13032. //头等舱 + 小套房 JSES
  13033. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13034. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13035. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13036. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13037. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13038. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13039. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13040. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13041. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13042. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13043. }
  13044. else
  13045. {
  13046. hideRowsList.Add(Row + startIndex + HideRows);
  13047. }
  13048. HideRows += 2;
  13049. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13050. if (rightBindData != null)
  13051. {
  13052. //头等舱 + 大套房
  13053. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13054. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13055. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13056. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13057. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13058. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13059. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13060. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13061. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13062. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13063. }
  13064. else
  13065. {
  13066. hideRowsList.Add(Row + startIndex + HideRows);
  13067. }
  13068. #endregion
  13069. #region B段标题清空
  13070. designer.SetDataSource("CostBDRCB", "");
  13071. designer.SetDataSource("CostBRS", "");
  13072. designer.SetDataSource("CostBXS", "");
  13073. designer.SetDataSource("CostBZCB", "");
  13074. designer.SetDataSource("CostBDRBJ", "");
  13075. designer.SetDataSource("CostBZBJ", "");
  13076. designer.SetDataSource("CostBDRLR", "");
  13077. designer.SetDataSource("CostBZLR", "");
  13078. designer.SetDataSource("CostBDRCBOM", "");
  13079. designer.SetDataSource("CostBRSOM", "");
  13080. designer.SetDataSource("CostBZCBOM", "");
  13081. designer.SetDataSource("CostBDRBJOM", "");
  13082. designer.SetDataSource("CostBZBJOM", "");
  13083. designer.SetDataSource("CostBDRLROM", "");
  13084. designer.SetDataSource("CostBZLROM", "");
  13085. #endregion
  13086. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13087. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13088. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13089. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13090. designer.SetDataSource("DJName", "地接(CNY)");
  13091. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13092. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13093. designer.SetDataSource("GWName", "公务(CNY)");
  13094. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13095. designer.SetDataSource("LYJName", "零用金(CNY)");
  13096. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13097. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13098. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13099. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13100. designer.SetDataSource("BXName", "保险(CNY)");
  13101. designer.SetDataSource("VisaName", "签证(CNY)");
  13102. #region B段基本数据
  13103. if (dto.costType == "B")
  13104. {
  13105. left = dto.leftInfo.Find(x => x.Type == "B");
  13106. if (left == null)
  13107. {
  13108. return Ok(jw);
  13109. }
  13110. #region B段left数据
  13111. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13112. if (leftBindData != null)
  13113. {
  13114. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13115. designer.SetDataSource("BHSRS", leftBindData.rs);
  13116. designer.SetDataSource("BHSXS", leftBindData.xs);
  13117. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13118. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13119. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13120. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13121. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13122. }
  13123. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13124. if (leftBindData != null)
  13125. {
  13126. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13127. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13128. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13129. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13130. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13131. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13132. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13133. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13134. }
  13135. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13136. if (leftBindData != null)
  13137. {
  13138. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13139. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13140. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13141. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13142. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13143. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13144. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13145. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13146. }
  13147. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13148. if (leftBindData != null)
  13149. {
  13150. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13151. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13152. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13153. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13154. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13155. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13156. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13157. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13158. }
  13159. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13160. if (leftBindData != null)
  13161. {
  13162. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13163. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13164. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13165. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13166. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13167. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13168. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13169. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13170. }
  13171. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13172. if (leftBindData != null)
  13173. {
  13174. designer.SetDataSource("BCPCB", leftBindData.cb);
  13175. designer.SetDataSource("BCPRS", leftBindData.rs);
  13176. designer.SetDataSource("BCPXS", leftBindData.xs);
  13177. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13178. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13179. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13180. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13181. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13182. }
  13183. //TBR
  13184. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13185. if (leftBindData != null)
  13186. {
  13187. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13188. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13189. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13190. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13191. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13192. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13193. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13194. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13195. }
  13196. //SGR
  13197. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13198. if (leftBindData != null)
  13199. {
  13200. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13201. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13202. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13203. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13204. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13205. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13206. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13207. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13208. }
  13209. //JS/ES
  13210. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13211. if (leftBindData != null)
  13212. {
  13213. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13214. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13215. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13216. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13217. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13218. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13219. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13220. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13221. }
  13222. //SUITE
  13223. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13224. if (leftBindData != null)
  13225. {
  13226. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13227. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13228. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13229. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13230. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13231. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13232. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13233. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13234. }
  13235. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13236. if (leftBindData != null)
  13237. {
  13238. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13239. designer.SetDataSource("BDJRS", leftBindData.rs);
  13240. designer.SetDataSource("BDJXS", leftBindData.xs);
  13241. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13242. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13243. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13244. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13245. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13246. }
  13247. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13248. if (leftBindData != null)
  13249. {
  13250. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13251. designer.SetDataSource("BGWRS", leftBindData.rs);
  13252. designer.SetDataSource("BGWXS", leftBindData.xs);
  13253. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13254. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13255. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13256. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13257. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13258. }
  13259. #region 优化方案
  13260. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13261. //excelBind.Add("零用金", new {
  13262. //cb="",
  13263. //rs="",
  13264. //xs ="",
  13265. //zcb = "",
  13266. //});
  13267. #endregion
  13268. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13269. if (leftBindData != null)
  13270. {
  13271. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13272. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13273. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13274. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13275. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13276. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13277. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13278. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13279. }
  13280. #endregion
  13281. #region B段Right信息
  13282. right = dto.rightInfo.Find(x => x.Type == "B");
  13283. if (right == null)
  13284. {
  13285. return Ok(jw);
  13286. }
  13287. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13288. if (rightBindData != null)
  13289. {
  13290. //经济舱 + 双人间 TBR
  13291. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13292. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13293. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13294. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13295. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13296. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13297. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13298. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13299. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13300. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13301. }
  13302. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13303. if (rightBindData != null)
  13304. {
  13305. //经济舱 + 单人间 SGR
  13306. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  13307. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13308. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13309. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13310. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13311. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13312. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13313. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13314. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13315. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13316. }
  13317. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13318. if (rightBindData != null)
  13319. {
  13320. //公务舱 + 单人间 SGR
  13321. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13322. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13323. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13324. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13325. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13326. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13327. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13328. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13329. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13330. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13331. }
  13332. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13333. if (rightBindData != null)
  13334. {
  13335. //公务舱 + 小套房 JSES
  13336. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13337. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13338. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13339. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13340. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13341. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13342. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13343. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13344. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13345. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13346. }
  13347. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13348. if (rightBindData != null)
  13349. {
  13350. //公务舱 + 小套房 JSES
  13351. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13352. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13353. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13354. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13355. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13356. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13357. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13358. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13359. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13360. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13361. }
  13362. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13363. if (rightBindData != null)
  13364. {
  13365. //经济舱 + 大套房
  13366. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13367. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13368. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13369. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13370. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13371. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13372. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13373. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13374. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13375. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13376. }
  13377. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13378. if (rightBindData != null)
  13379. {
  13380. //头等舱 + 小套房 JSES
  13381. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13382. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13383. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13384. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13385. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13386. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13387. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13388. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13389. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13390. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13391. }
  13392. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13393. if (rightBindData != null)
  13394. {
  13395. //头等舱 + 大套房
  13396. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13397. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13398. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13399. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13400. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13401. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13402. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13403. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13404. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13405. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13406. }
  13407. #endregion
  13408. #region 标题
  13409. designer.SetDataSource("CostBDRCB", "单人成本");
  13410. designer.SetDataSource("CostBRS", "人数");
  13411. designer.SetDataSource("CostBXS", "系数");
  13412. designer.SetDataSource("CostBZCB", "总成本");
  13413. designer.SetDataSource("CostBDRBJ", "单人报价");
  13414. designer.SetDataSource("CostBZBJ", "总报价");
  13415. designer.SetDataSource("CostBDRLR", "单人利润");
  13416. designer.SetDataSource("CostBZLR", "总利润");
  13417. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13418. designer.SetDataSource("CostBRSOM", "人数");
  13419. designer.SetDataSource("CostBZCBOM", "总成本");
  13420. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13421. designer.SetDataSource("CostBZBJOM", "总报价");
  13422. designer.SetDataSource("CostBDRLROM", "单人利润");
  13423. designer.SetDataSource("CostBZLROM", "总利润");
  13424. #endregion
  13425. }
  13426. #endregion
  13427. designer.SetDataSource("TzZCB2", TzZCB2);
  13428. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13429. designer.SetDataSource("TzZLR2", TzZLR2);
  13430. string[] dataSourceKeys = new string[]
  13431. {
  13432. "VF",
  13433. "TGS",
  13434. "TGOF",
  13435. "TGM",
  13436. "TGA",
  13437. "TGTF",
  13438. "TGEF",
  13439. "CFM",
  13440. "CFOF",
  13441. "B",
  13442. "L",
  13443. "D",
  13444. "TBR",
  13445. "SGR",
  13446. "JSES",
  13447. "Suite",
  13448. "TV",
  13449. "1L",
  13450. "IF",
  13451. "EF",
  13452. "BRF",
  13453. "TE",
  13454. "TGT",
  13455. "DRVT",
  13456. "PC",
  13457. "TLF",
  13458. "ECT"
  13459. };
  13460. foreach (var item in dataSourceKeys)
  13461. {
  13462. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13463. if (find != null)
  13464. {
  13465. designer.SetDataSource(item, find.text);
  13466. }
  13467. else
  13468. {
  13469. designer.SetDataSource(item, 0);
  13470. }
  13471. }
  13472. designer.SetDataSource(dt);
  13473. //根据数据源处理生成报表内容
  13474. designer.Process();
  13475. designer.Workbook.Worksheets[0].Name = "清单";
  13476. Worksheet sheet = designer.Workbook.Worksheets[0];
  13477. foreach (var Rowindex in hideRowsList)
  13478. {
  13479. ws.Cells.HideRows(Rowindex, 2);
  13480. }
  13481. byte[] bytes = null;
  13482. string strFileName = di.TeamName + "-团组-成本.xls";
  13483. using (MemoryStream stream = new MemoryStream())
  13484. {
  13485. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13486. bytes = stream.ToArray();
  13487. }
  13488. return Ok(JsonView(true, "", new
  13489. {
  13490. Data = bytes,
  13491. strFileName,
  13492. }));
  13493. }
  13494. /// <summary>
  13495. /// 导出客户报表
  13496. /// </summary>
  13497. /// <returns></returns>
  13498. [HttpPost]
  13499. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13500. {
  13501. var jw = JsonView(false);
  13502. if (dto.Diid == 0)
  13503. {
  13504. return Ok(JsonView(false, "请传递团组id"));
  13505. }
  13506. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13507. if (deleInfo.Code != 0)
  13508. {
  13509. return Ok(JsonView(false, "团组信息查询失败!"));
  13510. }
  13511. var di = deleInfo.Data as DelegationInfoWebView;
  13512. if (di == null)
  13513. {
  13514. return Ok(JsonView(false, "团组信息查询失败!"));
  13515. }
  13516. //文件名
  13517. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13518. //获取模板
  13519. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13520. //载入模板
  13521. Document doc = new Document(tmppath);
  13522. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13523. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13524. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13525. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13526. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13527. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13528. if (AParameter == null)
  13529. {
  13530. return Ok(JsonView(false, "系数不存在!"));
  13531. }
  13532. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13533. , TzAirDesc, TzZCost;
  13534. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13535. = TzAirDesc = TzZCost = string.Empty;
  13536. TzNumber = AParameter.CostTypenumber.ToString();
  13537. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13538. CarGuides1 = dto.CarGuides1;
  13539. Meal = dto.Meal;
  13540. SubsidizedMeals = dto.SubsidizedMeals;
  13541. NightRepair = dto.NightRepair;
  13542. AttractionsTickets = dto.AttractionsTickets;
  13543. MiscellaneousFees = dto.MiscellaneousFees;
  13544. ATip = dto.ATip;
  13545. TzHotelDesc = "";
  13546. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13547. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13548. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13549. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13550. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13551. TzAirDesc = "";
  13552. TzZCost = dto.TzZCost;
  13553. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13554. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13555. var index = 1;
  13556. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13557. foreach (var item in TzHotelDescArr)
  13558. {
  13559. if (AinfoArr != null)
  13560. {
  13561. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13562. if (Ainfo != null)
  13563. {
  13564. if (int.Parse(Ainfo.rs) <= 0)
  13565. {
  13566. continue;
  13567. }
  13568. var hotelText = string.Empty;
  13569. switch (item)
  13570. {
  13571. case "SGR":
  13572. hotelText = "单人间";
  13573. break;
  13574. case "JSES":
  13575. hotelText = "小套房";
  13576. break;
  13577. case "SUITE":
  13578. hotelText = "套房";
  13579. break;
  13580. case "TBR":
  13581. hotelText = "双人间";
  13582. break;
  13583. }
  13584. if (item != "TBR")
  13585. {
  13586. 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";
  13587. }
  13588. else
  13589. {
  13590. 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";
  13591. }
  13592. index++;
  13593. }
  13594. }
  13595. }
  13596. index = 1;
  13597. foreach (var item in TzAirDescArr)
  13598. {
  13599. if (AinfoArr != null)
  13600. {
  13601. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13602. if (Ainfo != null)
  13603. {
  13604. if (int.Parse(Ainfo.rs) <= 0)
  13605. {
  13606. continue;
  13607. }
  13608. 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";
  13609. index++;
  13610. }
  13611. }
  13612. }
  13613. if (dto.costType == "B")
  13614. {
  13615. if (BParameter == null)
  13616. {
  13617. return Ok(JsonView(false, "B段系数不存在!"));
  13618. }
  13619. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13620. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13621. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13622. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13623. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13624. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13625. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13626. foreach (var item in TzHotelDescArr)
  13627. {
  13628. if (AinfoArr != null)
  13629. {
  13630. TzHotelDesc += "B段信息 \r\n";
  13631. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13632. if (Ainfo != null)
  13633. {
  13634. if (int.Parse(Ainfo.rs) <= 0)
  13635. {
  13636. continue;
  13637. }
  13638. var hotelText = string.Empty;
  13639. switch (item)
  13640. {
  13641. case "SGR":
  13642. hotelText = "单人间";
  13643. break;
  13644. case "JSES":
  13645. hotelText = "小套房";
  13646. break;
  13647. case "SUITE":
  13648. hotelText = "套房";
  13649. break;
  13650. case "TBR":
  13651. hotelText = "双人间";
  13652. break;
  13653. }
  13654. if (item != "TBR")
  13655. {
  13656. 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";
  13657. }
  13658. else
  13659. {
  13660. 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";
  13661. }
  13662. index++;
  13663. }
  13664. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13665. }
  13666. }
  13667. index = 1;
  13668. foreach (var item in TzAirDescArr)
  13669. {
  13670. if (AinfoArr != null)
  13671. {
  13672. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13673. if (Ainfo != null)
  13674. {
  13675. if (int.Parse(Ainfo.rs) <= 0)
  13676. {
  13677. continue;
  13678. }
  13679. 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";
  13680. index++;
  13681. }
  13682. }
  13683. }
  13684. }
  13685. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13686. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13687. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13688. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13689. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13690. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13691. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13692. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13693. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13694. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13695. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13696. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13697. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13698. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13699. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13700. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13701. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13702. DickeyValue.Add("TzZCost", TzZCost);
  13703. foreach (var key in DickeyValue.Keys)
  13704. {
  13705. if (doc.Range.Bookmarks[key] != null)
  13706. {
  13707. Bookmark mark = doc.Range.Bookmarks[key];
  13708. mark.Text = DickeyValue[key];
  13709. }
  13710. }
  13711. byte[] bytes = null;
  13712. string strFileName = di.TeamName + "-客户报价.doc";
  13713. using (MemoryStream stream = new MemoryStream())
  13714. {
  13715. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13716. bytes = stream.ToArray();
  13717. }
  13718. return Ok(JsonView(true, "", new
  13719. {
  13720. Data = bytes,
  13721. strFileName,
  13722. }));
  13723. }
  13724. /// <summary>
  13725. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13726. /// </summary>
  13727. /// <param name="dto"></param>
  13728. /// <returns></returns>
  13729. [HttpPost]
  13730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13731. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13732. {
  13733. try
  13734. {
  13735. #region 参数验证
  13736. if (dto.DiId < 0)
  13737. {
  13738. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13739. }
  13740. List<int> cTableIds = new List<int>() {
  13741. 76 ,//酒店预订
  13742. 77 ,//行程
  13743. 79 ,//车/导游地接
  13744. 80 ,//签证
  13745. 81 ,//邀请/公务活
  13746. 82 ,//团组客户保险
  13747. 85 ,//机票预订
  13748. 98 ,//其他款项
  13749. 285 ,//收款退还
  13750. 751 ,//酒店早餐
  13751. 1015 // 超支费用
  13752. };
  13753. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13754. {
  13755. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13756. }
  13757. #endregion
  13758. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13759. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13760. if (_GroupCostParameters.Count <= 0)
  13761. {
  13762. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13763. }
  13764. if (_GroupCostParameters[0].IsShare == 0)
  13765. {
  13766. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13767. }
  13768. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13769. //处理date为空问题
  13770. if (_GroupCosts.Count > 0)
  13771. {
  13772. for (int i = 0; i < _GroupCosts.Count; i++)
  13773. {
  13774. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13775. {
  13776. if (i > 0)
  13777. {
  13778. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13779. }
  13780. }
  13781. }
  13782. }
  13783. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13784. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13785. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13786. string currCode = "";
  13787. #region currCode 验证
  13788. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13789. if (isInt)
  13790. {
  13791. var currData = currDatas.Find(it => it.Id == intCurrency);
  13792. if (currData != null)
  13793. {
  13794. currCode = currData.Name;
  13795. }
  13796. }
  13797. else
  13798. {
  13799. currCode = _GroupCostParameters[0].Currency.Trim();
  13800. }
  13801. #endregion
  13802. //op,酒店单段模式存储
  13803. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13804. {
  13805. CurrencyCode = currCode,
  13806. Rate = _GroupCostParameters[0].Rate,
  13807. CostType = _GroupCostParameters[0].CostType,
  13808. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13809. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13810. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13811. };
  13812. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13813. if (_GroupCostParameters.Count == 2)
  13814. {
  13815. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13816. }
  13817. foreach (var item in _GroupCostParameters)
  13818. {
  13819. decimal _rate = 1;
  13820. decimal _rate1 = item.Rate;
  13821. decimal _scale = 1;
  13822. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13823. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13824. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13825. //if (userInfo != null)
  13826. //{
  13827. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13828. // {
  13829. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13830. // {
  13831. // _scale = 1.00M;
  13832. // }
  13833. // }
  13834. //}
  13835. #endregion
  13836. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13837. {
  13838. CurrencyCode = currCode,
  13839. Rate = _rate1,
  13840. CostType = item.CostType,
  13841. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13842. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13843. CostTypeNumber = item.CostTypenumber
  13844. };
  13845. if (_GroupCostParameters.Count > 1)
  13846. {
  13847. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13848. }
  13849. else
  13850. {
  13851. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13852. }
  13853. if (dto.CTable == 79)//
  13854. {
  13855. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13856. modulePromptInfo.TotalCost = item.DJCB;
  13857. }
  13858. List<string> costTypes = new List<string>() { "A", "B" };
  13859. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13860. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13861. if (_GroupCostsDuplicates.Count() == 1)
  13862. {
  13863. _GroupCostsTypeData = _GroupCosts;
  13864. }
  13865. else
  13866. {
  13867. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13868. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13869. }
  13870. /*
  13871. * 76 酒店预订
  13872. * 77 行程
  13873. * 79 车/导游地接
  13874. * 80 签证
  13875. * 81 邀请/公务活动
  13876. * 82 团组客户保险
  13877. * 85 机票预订
  13878. * 98 其他款项
  13879. * 285 收款退还
  13880. * 751 酒店早餐
  13881. * 1015 超支费用
  13882. */
  13883. switch (dto.CTable)
  13884. {
  13885. case 76: // 酒店预订
  13886. _ModuleSubPromptInfo.AddRange(
  13887. _GroupCostsTypeData.Select(it => new
  13888. {
  13889. it.DAY,
  13890. it.Date,
  13891. it.ACCON,
  13892. it.ITIN,
  13893. it.SGR,
  13894. it.TBR,
  13895. it.JS_ES,
  13896. it.Suite
  13897. })
  13898. );
  13899. break;
  13900. case 79: // 车/导游地接
  13901. _ModuleSubPromptInfo.AddRange(
  13902. _GroupCostsTypeData.Select(it => new
  13903. {
  13904. Date = it.Date, //日期
  13905. CarFee = it.CarCost * _rate * _scale, //车费用
  13906. CarType = it.CarType, //车型
  13907. DriverFee = it.CFS * _rate * _scale, //司机工资
  13908. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13909. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13910. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13911. GuideFee = it.TGS * _rate * _scale, //导游费用
  13912. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13913. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13914. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13915. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13916. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13917. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13918. Breakfast = it.B * _rate * _scale, //早餐费
  13919. Lunch = it.L * _rate * _scale, //午餐费
  13920. Dinner = it.D * _rate * _scale, //晚餐费
  13921. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13922. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13923. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13924. TicketFee = it.EF * _rate * _scale, //门票费
  13925. TicketRemark = it.EFR, //门票费描述
  13926. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13927. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13928. SpentCash = it.PC * _rate * _scale, //零用金
  13929. LeadersFee = it.TLF * _rate * _scale, //领队费
  13930. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13931. })
  13932. );
  13933. break;
  13934. case 85: // 机票
  13935. List<dynamic> datas = new List<dynamic>();
  13936. datas.Add(
  13937. new
  13938. {
  13939. AirType = "经济舱",
  13940. AirNum = item.JJCRS,
  13941. AirDRCB = item.JJCCB,
  13942. AirZCB = (item.JJCRS * item.JJCCB)
  13943. }
  13944. );
  13945. datas.Add(
  13946. new
  13947. {
  13948. AirType = "公务舱",
  13949. AirNum = item.GWCRS,
  13950. AirDRCB = item.GWCCB,
  13951. AirZCB = (item.GWCRS * item.GWCCB)
  13952. }
  13953. );
  13954. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13955. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13956. modulePromptInfo.Data = new
  13957. {
  13958. airFeeData = datas,
  13959. airInitData = initDatas
  13960. };
  13961. _ModulePromptInfos.Add(modulePromptInfo);
  13962. break;
  13963. default:
  13964. break;
  13965. }
  13966. }
  13967. if (dto.CTable != 85)
  13968. {
  13969. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13970. _ModulePromptInfos.Add(_ModulePromptInfo);
  13971. }
  13972. _view.ModulePromptInfos = _ModulePromptInfos;
  13973. return Ok(JsonView(true, "操作成功!", _view));
  13974. }
  13975. catch (Exception ex)
  13976. {
  13977. return Ok(JsonView(false, ex.Message));
  13978. }
  13979. }
  13980. /// <summary>
  13981. /// 根据黑屏代码重新生成行程
  13982. /// </summary>
  13983. /// <param name="dto"></param>
  13984. /// <returns></returns>
  13985. [HttpPost]
  13986. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13987. {
  13988. var jw = JsonView(false);
  13989. var Create = _GroupCostRepository.
  13990. CreateGroupCostByBlackCode(dto.Diid);
  13991. jw.Msg = Create.Msg;
  13992. if (Create.Code == 0)
  13993. {
  13994. jw.Code = 200;
  13995. jw.Data = new
  13996. {
  13997. groupCost = Create.Data,
  13998. blackCodeIsTrue = true
  13999. };
  14000. }
  14001. else
  14002. {
  14003. jw.Code = 400;
  14004. jw.Data = new
  14005. {
  14006. groupCost = Create.Data,
  14007. blackCodeIsTrue = false,
  14008. };
  14009. }
  14010. return Ok(jw);
  14011. }
  14012. /// <summary>
  14013. /// 成本获取OP历史车费用
  14014. /// </summary>
  14015. /// <param name="dto"></param>
  14016. /// <returns></returns>
  14017. [HttpPost]
  14018. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14019. {
  14020. var jw = JsonView(false);
  14021. try
  14022. {
  14023. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14024. //获取现有所有车的数据
  14025. if (!dto.Param.IsNullOrWhiteSpace())
  14026. {
  14027. string sql = $@"
  14028. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14029. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14030. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14031. 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
  14032. AND gctggr.ServiceEndTime is not NULL
  14033. ORDER by gctggrc.id DESC
  14034. ";
  14035. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14036. var numeberResult = await Task.Run(() =>
  14037. {
  14038. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14039. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14040. return numberArr;
  14041. });
  14042. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14043. foreach (var item in numeberResult)
  14044. {
  14045. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14046. {
  14047. Country = "数据异常!",
  14048. City = string.Empty,
  14049. };
  14050. item.Area = find.Country + " " + find.City;
  14051. }
  14052. dbResult.AddRange(numeberResult);
  14053. if (dto.Param.Contains("、"))
  14054. {
  14055. var sp = dto.Param.Split("、");
  14056. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14057. .Where(x =>
  14058. {
  14059. return System.Array.Exists(sp, e =>
  14060. {
  14061. bool where = false;
  14062. if (x.Area != null)
  14063. {
  14064. where = x.Area.Contains(e);
  14065. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14066. {
  14067. return false;
  14068. }
  14069. }
  14070. if (x.PriceName != null && !where)
  14071. {
  14072. where = x.PriceName.Contains(e);
  14073. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14074. {
  14075. return false;
  14076. }
  14077. }
  14078. return where;
  14079. });
  14080. }).ToList();
  14081. }
  14082. else
  14083. {
  14084. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14085. .Where(x =>
  14086. {
  14087. bool where = false;
  14088. if (x.Area != null)
  14089. {
  14090. where = x.Area.Contains(dto.Param);
  14091. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14092. {
  14093. return false;
  14094. }
  14095. }
  14096. if (x.PriceName != null && !where)
  14097. {
  14098. where = x.PriceName.Contains(dto.Param);
  14099. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14100. {
  14101. return false;
  14102. }
  14103. }
  14104. return where;
  14105. }
  14106. )
  14107. .ToList();
  14108. }
  14109. }
  14110. var view = dbResult.Select(x =>
  14111. {
  14112. decimal dp = 0.00M;
  14113. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14114. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14115. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14116. {
  14117. if (startB && endB)
  14118. {
  14119. var timesp = endD.Subtract(startD);
  14120. if ((timesp.Days + 1) != 0)
  14121. {
  14122. dp = x.Price / (timesp.Days + 1);
  14123. }
  14124. }
  14125. }
  14126. else
  14127. {
  14128. dp = x.Price;
  14129. }
  14130. return new
  14131. {
  14132. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14133. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14134. x.Area,
  14135. x.id,
  14136. price = x.Price.ToString("F2"),
  14137. x.PriceName,
  14138. x.PriceContent,
  14139. x.TeamName,
  14140. x.DatePrice,
  14141. dayPrice = dp.ToString("F2"),
  14142. };
  14143. }).OrderByDescending(x => x.id).ToList();
  14144. jw = JsonView(true, "获取成功!", view);
  14145. }
  14146. catch (Exception e)
  14147. {
  14148. jw = JsonView(false, e.Message);
  14149. }
  14150. return Ok(jw);
  14151. }
  14152. #endregion
  14153. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14154. /// <summary>
  14155. /// 酒店预订
  14156. /// 酒店费用列表 根据团组Id查询
  14157. /// </summary>
  14158. /// <param name="_dto"></param>
  14159. /// <returns></returns>
  14160. [HttpPost]
  14161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14162. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14163. {
  14164. #region 参数验证
  14165. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14166. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14167. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14168. #region 团组操作权限验证 76 酒店预定模块
  14169. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14170. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14171. #endregion
  14172. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14173. #region 页面操作权限验证
  14174. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14175. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14176. #endregion
  14177. #endregion
  14178. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14179. }
  14180. /// <summary>
  14181. /// 酒店预订
  14182. /// 基础数据
  14183. /// </summary>
  14184. /// <param name="_dto"></param>
  14185. /// <returns></returns>
  14186. [HttpPost]
  14187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14188. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14189. {
  14190. #region 参数验证
  14191. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14192. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14193. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14194. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14195. #region 页面操作权限验证
  14196. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14197. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14198. #endregion
  14199. #region 团组操作权限验证 76 酒店预定模块
  14200. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14201. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14202. #endregion
  14203. #endregion
  14204. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14205. }
  14206. /// <summary>
  14207. /// 酒店预订
  14208. /// 创建 入住卷号码
  14209. /// </summary>
  14210. /// <param name="_dto"></param>
  14211. /// <returns></returns>
  14212. [HttpPost]
  14213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14214. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14215. {
  14216. #region 参数验证
  14217. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14218. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14219. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14220. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14221. #region 页面操作权限验证
  14222. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14223. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14224. #endregion
  14225. #region 团组操作权限验证 76 酒店预定模块
  14226. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14227. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14228. #endregion
  14229. #endregion
  14230. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14231. if (data.Code != 0)
  14232. {
  14233. return Ok(JsonView(false, data.Msg));
  14234. }
  14235. return Ok(JsonView(true, data.Msg, data.Data));
  14236. }
  14237. /// <summary>
  14238. /// 酒店预订
  14239. /// 详情
  14240. /// </summary>
  14241. /// <param name="_dto"></param>
  14242. /// <returns></returns>
  14243. [HttpPost]
  14244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14245. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14246. {
  14247. #region 参数验证
  14248. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14249. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14250. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14251. #region 团组操作权限验证 76 酒店预定模块
  14252. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14253. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14254. #endregion
  14255. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14256. #region 页面操作权限验证
  14257. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14258. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14259. #endregion
  14260. #endregion
  14261. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14262. }
  14263. /// <summary>
  14264. /// 酒店预订
  14265. /// Add Or Edit
  14266. /// </summary>
  14267. /// <param name="_dto"></param>
  14268. /// <returns></returns>
  14269. [HttpPost]
  14270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14271. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14272. {
  14273. #region 参数验证
  14274. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14275. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14276. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14277. #region 团组操作权限验证 76 酒店预定模块
  14278. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14279. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14280. #endregion
  14281. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14282. #region 页面操作权限验证
  14283. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14284. if (_dto.Id == 0) // Add
  14285. {
  14286. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14287. }
  14288. else if (_dto.Id > 1) // Edit
  14289. {
  14290. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14291. }
  14292. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14293. #endregion
  14294. #endregion
  14295. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14296. if (_view.Code != 200)
  14297. {
  14298. return Ok(_view);
  14299. }
  14300. #region 成本无酒店价格数据进入超支
  14301. _sqlSugar.BeginTran();
  14302. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14303. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14304. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14305. for (int i = 0; i < groupCost.Count; i++)
  14306. {
  14307. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14308. {
  14309. groupCost[i].Date = groupCost[i - 1].Date;
  14310. }
  14311. }
  14312. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14313. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14314. List<Fin_GroupExtraCostDto_OP>();
  14315. if (start_Bool && end_Bool)
  14316. {
  14317. while (start_Time < end_Time)
  14318. {
  14319. foreach (var item in groupCost_Grp)
  14320. {
  14321. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14322. {
  14323. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14324. {
  14325. extraCostList.Add(new
  14326. Fin_GroupExtraCostDto_OP
  14327. {
  14328. Area = _dto.AreaId,
  14329. coefficient = 1.5M,
  14330. createUser = _dto.UserId,
  14331. currency = _dto.CardPriceCurrency,
  14332. diId = _dto.DiId,
  14333. ManagerConfirm = 0,
  14334. SupervisorConfirm = 0,
  14335. SYsupervisorConfirm = 0,
  14336. editType = 1,
  14337. PortType = 1,
  14338. price = _dto.CardPrice,
  14339. PriceCount = 1,
  14340. priceType = 1027,
  14341. priceDetailType = 1044,
  14342. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14343. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14344. });
  14345. }
  14346. }
  14347. }
  14348. start_Time = start_Time.AddDays(1);
  14349. }
  14350. }
  14351. if (extraCostList.Any())
  14352. {
  14353. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14354. }
  14355. _sqlSugar.CommitTran();
  14356. #endregion
  14357. #region 应用推送
  14358. try
  14359. {
  14360. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14361. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14362. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14363. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14364. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14365. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14366. var diId = _dto.DiId;
  14367. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14368. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14369. #region 操作记录
  14370. var opInfo = new Crm_TableOperationRecord()
  14371. {
  14372. TableName = "Grp_HotelReservations",
  14373. PortType = _dto.PortType,
  14374. DataId = hotelId,
  14375. CreateUserId = _dto.UserId
  14376. };
  14377. //var opStatus = OperationEnum.NoOperation;
  14378. if (_dto.Id < 1) //添加操作
  14379. {
  14380. opInfo.OperationItem = OperationEnum.Add;
  14381. }
  14382. else if (_dto.Id > 0)
  14383. {
  14384. opInfo.OperationItem = OperationEnum.Edit;
  14385. }
  14386. string opRemark = string.Empty;
  14387. if (ccpInfo != null)
  14388. {
  14389. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14390. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14391. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14392. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14393. }
  14394. opInfo.Remark = opRemark;
  14395. await _tableorRep.AddAsync(opInfo);
  14396. #endregion
  14397. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14398. //2024-10-21 新增LZ UID
  14399. var userIds = new List<int>() { 21 };
  14400. string title = $"费用审核";
  14401. string content = "";
  14402. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14403. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14404. try
  14405. {
  14406. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14407. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14408. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14409. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14410. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14411. }
  14412. catch (Exception ex)
  14413. {
  14414. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14415. }
  14416. }
  14417. catch (Exception ex)
  14418. {
  14419. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14420. }
  14421. try
  14422. {
  14423. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14424. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14425. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14426. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14427. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14428. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14429. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14430. //自动审核
  14431. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14432. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14433. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14434. //2024-10-21 新增LZ UID
  14435. var userIds = new List<int>() { 21 };
  14436. string title = $"系统通知";
  14437. var diId = _dto.DiId;
  14438. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14439. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14440. string content = "";
  14441. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14442. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14443. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14444. }
  14445. catch (Exception ex)
  14446. {
  14447. }
  14448. #endregion
  14449. return Ok(_view);
  14450. }
  14451. /// <summary>
  14452. /// 酒店自动审核测试
  14453. /// Add Or Edit
  14454. /// </summary>
  14455. /// <param name="diid"></param>
  14456. /// <param name="dataId"></param>
  14457. /// <returns></returns>
  14458. [HttpPost]
  14459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14460. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14461. {
  14462. #region 应用推送
  14463. try
  14464. {
  14465. //自动审核
  14466. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14467. }
  14468. catch (Exception ex)
  14469. {
  14470. return Ok(JsonView(false, "操作失败"));
  14471. }
  14472. #endregion
  14473. return Ok(JsonView(false, "操作成功"));
  14474. }
  14475. /// <summary>
  14476. /// 酒店预订
  14477. /// Del
  14478. /// </summary>
  14479. /// <param name="_dto"></param>
  14480. /// <returns></returns>
  14481. [HttpPost]
  14482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14483. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14484. {
  14485. #region 参数验证
  14486. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14487. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14488. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14489. #region 团组操作权限验证 76 酒店预定模块
  14490. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14491. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14492. #endregion
  14493. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14494. #region 页面操作权限验证
  14495. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14496. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14497. #endregion
  14498. #endregion
  14499. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14500. #region 操作记录
  14501. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14502. {
  14503. TableName = "Grp_HotelReservations",
  14504. PortType = _dto.PortType,
  14505. OperationItem = OperationEnum.Del,
  14506. DataId = _dto.Id,
  14507. CreateUserId = _dto.UserId
  14508. });
  14509. #endregion
  14510. return Ok(data);
  14511. }
  14512. /// <summary>
  14513. /// 酒店预订
  14514. /// 生成VOUCHER
  14515. /// 2024.05.06 之前版本
  14516. /// </summary>
  14517. /// <param name="_dto"></param>
  14518. /// <returns></returns>
  14519. [HttpPost]
  14520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14521. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14522. {
  14523. try
  14524. {
  14525. #region 参数验证
  14526. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14527. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14528. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14529. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14530. #region 团组操作权限验证 76 酒店预定模块
  14531. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14532. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14533. #endregion
  14534. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14535. #region 页面操作权限验证
  14536. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14537. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14538. #endregion
  14539. #endregion
  14540. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14541. //判断数据是否完整
  14542. if (hr != null)
  14543. {
  14544. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14545. {
  14546. string strFileName = "HotelStatement/";
  14547. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14548. if (dele != null)
  14549. strFileName += dele.TourCode;
  14550. //载入模板
  14551. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14552. Document doc = new Document(sss);
  14553. DocumentBuilder builder = new DocumentBuilder(doc);
  14554. #region 替换Word模板书签内容
  14555. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14556. //入住卷预定号码
  14557. if (doc.Range.Bookmarks["VNO"] != null)
  14558. {
  14559. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14560. mark.Text = hr.CheckNumber;
  14561. }
  14562. //酒店时间
  14563. if (doc.Range.Bookmarks["Date"] != null)
  14564. {
  14565. Bookmark mark = doc.Range.Bookmarks["Date"];
  14566. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14567. }
  14568. //团号
  14569. if (doc.Range.Bookmarks["TNo"] != null)
  14570. {
  14571. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14572. mark.Text = dele.TourCode;
  14573. }
  14574. //预定号码
  14575. if (doc.Range.Bookmarks["BookingId"] != null)
  14576. {
  14577. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14578. mark.Text = hr.ReservationsNo;
  14579. }
  14580. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14581. {
  14582. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14583. mark.Text = hr.DetermineNo;
  14584. }
  14585. //酒店城市
  14586. if (doc.Range.Bookmarks["City"] != null)
  14587. {
  14588. Bookmark mark = doc.Range.Bookmarks["City"];
  14589. mark.Text = hr.City;
  14590. }
  14591. //酒店名称
  14592. if (doc.Range.Bookmarks["HName"] != null)
  14593. {
  14594. Bookmark mark = doc.Range.Bookmarks["HName"];
  14595. mark.Text = hr.HotelName;
  14596. }
  14597. //酒店地址
  14598. if (doc.Range.Bookmarks["Address"] != null)
  14599. {
  14600. Bookmark mark = doc.Range.Bookmarks["Address"];
  14601. mark.Text = hr.HotelAddress;
  14602. }
  14603. //酒店电话
  14604. if (doc.Range.Bookmarks["Tel"] != null)
  14605. {
  14606. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14607. mark.Text = hr.HotelTel;
  14608. }
  14609. //酒店传真
  14610. if (doc.Range.Bookmarks["Fax"] != null)
  14611. {
  14612. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14613. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14614. {
  14615. mark.Text = hr.HotelFax;
  14616. }
  14617. }
  14618. //入住时间
  14619. if (doc.Range.Bookmarks["CIn"] != null)
  14620. {
  14621. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14622. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14623. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14624. }
  14625. //退房时间
  14626. if (doc.Range.Bookmarks["COut"] != null)
  14627. {
  14628. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14629. Bookmark mark = doc.Range.Bookmarks["COut"];
  14630. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14631. }
  14632. //客户名称
  14633. if (doc.Range.Bookmarks["GName"] != null)
  14634. {
  14635. string guestName = "";
  14636. string[] clients = new string[] { };
  14637. if (hr.GuestName.Contains(","))
  14638. {
  14639. clients = hr.GuestName.Split(",");
  14640. }
  14641. else
  14642. {
  14643. clients = new string[] { hr.GuestName };
  14644. }
  14645. List<int> clientIds_int = new List<int>();
  14646. if (clients.Length > 0)
  14647. {
  14648. foreach (var item in clients)
  14649. {
  14650. if (item.IsNumeric())
  14651. {
  14652. clientIds_int.Add(int.Parse(item));
  14653. }
  14654. }
  14655. }
  14656. if (clientIds_int.Count > 0)
  14657. {
  14658. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14659. foreach (var client in _clientDatas)
  14660. {
  14661. //男
  14662. if (client.Sex == 0) guestName += $"Mr.";
  14663. //女
  14664. else if (client.Sex == 1) guestName += $"Ms.";
  14665. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14666. {
  14667. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14668. }
  14669. //guestName += $"{client.Pinyin},";
  14670. }
  14671. if (guestName.Length > 0)
  14672. {
  14673. guestName = guestName.Substring(0, guestName.Length - 1);
  14674. }
  14675. }
  14676. else
  14677. {
  14678. guestName = hr.GuestName;
  14679. }
  14680. Bookmark mark = doc.Range.Bookmarks["GName"];
  14681. mark.Text = guestName;
  14682. }
  14683. //房间介绍
  14684. if (doc.Range.Bookmarks["ROOM"] != null)
  14685. {
  14686. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14687. mark.Text = hr.RoomExplanation;
  14688. }
  14689. //报价描述
  14690. if (doc.Range.Bookmarks["NOTE"] != null)
  14691. {
  14692. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14693. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14694. if (ss != null)
  14695. mark.Text = ss.Name;
  14696. }
  14697. //入住时间
  14698. if (doc.Range.Bookmarks["CheckIn"] != null)
  14699. {
  14700. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14701. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14702. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14703. }
  14704. //退房时间
  14705. if (doc.Range.Bookmarks["CheckOut"] != null)
  14706. {
  14707. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14708. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14709. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14710. }
  14711. //日期
  14712. if (doc.Range.Bookmarks["DT"] != null)
  14713. {
  14714. Bookmark mark = doc.Range.Bookmarks["DT"];
  14715. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14716. }
  14717. //名称
  14718. if (doc.Range.Bookmarks["VName"] != null)
  14719. {
  14720. Bookmark mark = doc.Range.Bookmarks["VName"];
  14721. mark.Text = hr.HotelName;
  14722. }
  14723. //号码
  14724. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14725. {
  14726. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14727. mark.Text = hr.CheckNumber;
  14728. }
  14729. #endregion
  14730. strFileName += "VOUCHER.doc";
  14731. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14732. doc.Save(fileDir);
  14733. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14734. return Ok(JsonView(true, "操作成功!", Url));
  14735. }
  14736. else
  14737. {
  14738. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14739. }
  14740. }
  14741. else
  14742. {
  14743. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14744. }
  14745. }
  14746. catch (Exception ex)
  14747. {
  14748. return Ok(JsonView(false, ex.Message));
  14749. }
  14750. }
  14751. /// <summary>
  14752. /// 酒店预订
  14753. /// 生成VOUCHER
  14754. /// 2024.05.06 之后版本
  14755. /// </summary>
  14756. /// <param name="_dto"></param>
  14757. /// <returns></returns>
  14758. [HttpPost]
  14759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14760. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14761. {
  14762. #region 参数验证
  14763. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14764. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14765. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14766. #region 团组操作权限验证 76 酒店预定模块
  14767. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14768. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14769. #endregion
  14770. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14771. #region 页面操作权限验证
  14772. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14773. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14774. #endregion
  14775. #endregion
  14776. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14777. //判断数据是否完整
  14778. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14779. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14780. string strFileName = "HotelStatement/";
  14781. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14782. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14783. #region 数据处理
  14784. List<int> guestIds = new List<int>();
  14785. //int index = 0;
  14786. foreach (var item in hrDtas)
  14787. {
  14788. if (item.GuestName.Contains(","))
  14789. {
  14790. string[] guestIdArr = item.GuestName.Split(',');
  14791. foreach (var guestIdStr in guestIdArr)
  14792. {
  14793. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14794. if (guestBool)
  14795. {
  14796. guestIds.Add(guestId);
  14797. }
  14798. }
  14799. }
  14800. else guestNames += item.GuestName;
  14801. var voucherInfo = new HotelVoucherInfoView()
  14802. {
  14803. HotelName = item.HotelName,
  14804. CheckInDate = item.CheckInDate,
  14805. CheckOutDate = item.CheckOutDate,
  14806. ConfirmationNumber = item.DetermineNo.Trim(),
  14807. RoomType = item.RoomExplanation
  14808. };
  14809. vouchers.Add(voucherInfo);
  14810. }
  14811. if (guestIds.Count > 0)
  14812. {
  14813. guestIds = guestIds.Distinct().ToList();
  14814. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14815. if (guestDatas.Count > 0)
  14816. {
  14817. guestNames = "";
  14818. foreach (var guest in guestDatas)
  14819. {
  14820. string guestName = "";
  14821. if (guest.Sex == 0) guestName += @"MR.";
  14822. else if (guest.Sex == 1) guestName += @"MS.";
  14823. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14824. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14825. guestNames += @$"{guestName.Trim()}、";
  14826. }
  14827. if (guestNames.Length > 0)
  14828. {
  14829. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14830. }
  14831. }
  14832. }
  14833. #endregion
  14834. //载入模板
  14835. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14836. Document doc = new Document(sss);
  14837. DocumentBuilder builder = new DocumentBuilder(doc);
  14838. if (doc.Range.Bookmarks["GuestName"] != null)
  14839. {
  14840. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14841. mark.Text = guestNames;
  14842. }
  14843. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14844. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14845. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14846. for (int i = 1; i <= vouchers.Count; i++)
  14847. {
  14848. HotelVoucherInfoView hviv = vouchers[i - 1];
  14849. builder.MoveToCell(0, i, 0, 0);
  14850. builder.Write(hviv.HotelName);
  14851. builder.MoveToCell(0, i, 1, 0);
  14852. builder.Write(hviv.CheckInDate);
  14853. builder.MoveToCell(0, i, 2, 0);
  14854. builder.Write(hviv.CheckOutDate);
  14855. builder.MoveToCell(0, i, 3, 0);
  14856. builder.Write(hviv.RoomType);
  14857. builder.MoveToCell(0, i, 4, 0);
  14858. builder.Write(hviv.ConfirmationNumber);
  14859. }
  14860. //删除多余行
  14861. int currRowIndex = vouchers.Count + 1;
  14862. int delRows = 21 - currRowIndex;
  14863. if (delRows > 0)
  14864. {
  14865. for (int i = 0; i < delRows; i++)
  14866. {
  14867. table.Rows.RemoveAt(currRowIndex);
  14868. //cultivateRowIndex++;
  14869. }
  14870. }
  14871. strFileName += "VOUCHER.docx";
  14872. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14873. doc.Save(fileDir);
  14874. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14875. return Ok(JsonView(true, "操作成功!", Url));
  14876. }
  14877. /// <summary>
  14878. /// 酒店预订
  14879. /// 生成VOUCHER 批量生成
  14880. /// New
  14881. /// </summary>
  14882. /// <param name="_dto"></param>
  14883. /// <returns></returns>
  14884. [HttpPost]
  14885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14886. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14887. {
  14888. #region 参数验证
  14889. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14890. if (_dto.PageId < 1) _dto.PageId = 28;
  14891. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14892. #region 团组操作权限验证 76 酒店预定模块
  14893. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14894. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14895. #endregion
  14896. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14897. #region 页面操作权限验证
  14898. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14899. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14900. #endregion
  14901. #endregion
  14902. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14903. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14904. .OrderBy(x => x.CheckInDate)
  14905. .ToListAsync();
  14906. //判断数据是否完整
  14907. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14908. string strFileName = "HotelStatement/";
  14909. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14910. if (dele != null)
  14911. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14912. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14913. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14914. .Where(it => it.IsDel == 0)
  14915. .ToListAsync();
  14916. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14917. for (int i = 0; i < hrDtas.Count; i++)
  14918. {
  14919. string guestNames = string.Empty;
  14920. List<int> guestIds = new List<int>();
  14921. var item = hrDtas[i];
  14922. //处理客户姓名
  14923. if (item.GuestName.Contains(","))
  14924. {
  14925. string[] guestIdArr = item.GuestName.Split(',');
  14926. foreach (var guestIdStr in guestIdArr)
  14927. if (int.TryParse(guestIdStr, out int guestId))
  14928. guestIds.Add(guestId);
  14929. }
  14930. else
  14931. {
  14932. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14933. if (guestIdBool)
  14934. {
  14935. guestIds.Add(guestId);
  14936. }
  14937. //NaN
  14938. if (item.GuestName.Contains("NaN"))
  14939. {
  14940. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14941. }
  14942. }
  14943. if (guestIds.Count > 0)
  14944. {
  14945. guestIds = guestIds.Distinct().ToList();
  14946. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14947. if (guestDatas1.Count > 0)
  14948. {
  14949. guestNames = "";
  14950. foreach (var guest in guestDatas1)
  14951. {
  14952. string guestName = "";
  14953. if (guest.Sex == 0) guestName += @"MR.";
  14954. else if (guest.Sex == 1) guestName += @"MS.";
  14955. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14956. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14957. guestNames += @$"{guestName.Trim()}、";
  14958. }
  14959. if (guestNames.Length > 0)
  14960. {
  14961. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14962. }
  14963. }
  14964. }
  14965. //if (!string.IsNullOrEmpty(guestNames))
  14966. //{
  14967. hrDtas[i].GuestName = guestNames;
  14968. //}
  14969. }
  14970. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14971. Document doc = new Document();
  14972. DocumentBuilder builder = new DocumentBuilder(doc);
  14973. try
  14974. {
  14975. builder.MoveToDocumentStart();
  14976. foreach (var item in hrDtas)
  14977. {
  14978. //标题
  14979. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14980. builder.ParagraphFormat.LineSpacing = 1;
  14981. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14982. builder.ParagraphFormat.Style.Font.Size = 9;
  14983. builder.ParagraphFormat.Style.Font.Bold = true;
  14984. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14985. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14986. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14987. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14988. builder.ParagraphFormat.LineSpacing = 1;
  14989. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14990. builder.ParagraphFormat.Style.Font.Size = 9;
  14991. builder.ParagraphFormat.Style.Font.Bold = true;
  14992. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14993. builder.StartTable();
  14994. // 设置边框颜色
  14995. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14996. //设置边框样式
  14997. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14998. //表格
  14999. #region 第一行
  15000. builder.InsertCell();
  15001. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15002. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15003. //builder.CellFormat.AllowAutoFit = false;
  15004. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15005. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15006. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15007. builder.CellFormat.WrapText = true; //自动换行
  15008. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15009. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15010. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15011. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15012. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15013. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15014. builder.Write("TOUR NO:");
  15015. builder.InsertCell();
  15016. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15017. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15018. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15019. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15020. builder.ParagraphFormat.Style.Font.Bold = false;
  15021. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15022. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15023. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15024. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15025. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15026. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15027. builder.Write($"{dele?.TourCode ?? "-"}");
  15028. builder.InsertCell();
  15029. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15030. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15031. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15032. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15033. builder.ParagraphFormat.Style.Font.Bold = false;
  15034. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15035. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15036. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15037. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15038. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15039. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15040. builder.Write($"CITY:");
  15041. builder.InsertCell();
  15042. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15043. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15044. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15045. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15046. builder.ParagraphFormat.Style.Font.Bold = false;
  15047. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15048. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15049. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15050. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15051. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15052. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15053. builder.Write($"{item.City}");
  15054. builder.EndRow();
  15055. #endregion
  15056. #region 第二行
  15057. builder.InsertCell();
  15058. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15059. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15060. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15061. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15062. builder.ParagraphFormat.Style.Font.Bold = false;
  15063. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15064. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15065. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15066. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15067. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15068. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15069. builder.Write("CONFIRMATION NO:");
  15070. builder.InsertCell();
  15071. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15072. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15073. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15074. builder.ParagraphFormat.Style.Font.Bold = false;
  15075. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15076. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15077. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15078. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15079. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15080. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15081. builder.CellFormat.VerticalMerge = CellMerge.None;
  15082. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15083. builder.Write($"{item.DetermineNo}");
  15084. builder.InsertCell();
  15085. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15086. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15087. builder.InsertCell();
  15088. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15089. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15090. builder.EndRow();
  15091. #endregion
  15092. #region 第三行
  15093. builder.InsertCell();
  15094. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15095. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15096. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15097. builder.ParagraphFormat.Style.Font.Bold = false;
  15098. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15099. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15100. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15101. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15102. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15103. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15104. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15105. builder.Write($"HOTEL NAME:");
  15106. builder.InsertCell();
  15107. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15108. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15109. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15110. builder.ParagraphFormat.Style.Font.Bold = false;
  15111. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15112. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15113. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15114. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15115. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15116. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15117. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15118. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15119. builder.Write($"{item.HotelName}");
  15120. builder.InsertCell();
  15121. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15122. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15123. builder.InsertCell();
  15124. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15125. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15126. builder.EndRow();
  15127. #endregion
  15128. #region 第四行
  15129. builder.InsertCell();
  15130. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15131. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15132. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15133. builder.ParagraphFormat.Style.Font.Bold = false;
  15134. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15135. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15136. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15137. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15138. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15139. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15140. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15141. builder.Write($"HOTEL ADDRESS:");
  15142. builder.InsertCell();
  15143. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15144. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15145. builder.ParagraphFormat.Style.Font.Size = 8;
  15146. builder.ParagraphFormat.Style.Font.Bold = false;
  15147. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15148. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15149. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15150. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15151. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15152. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15153. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15154. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15155. builder.Write($"{item.HotelAddress}");
  15156. builder.InsertCell();
  15157. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15158. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15159. builder.InsertCell();
  15160. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15161. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15162. builder.EndRow();
  15163. #endregion
  15164. #region 第五行
  15165. builder.InsertCell();
  15166. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15167. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15168. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15169. builder.ParagraphFormat.Style.Font.Bold = false;
  15170. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15171. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15172. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15173. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15174. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15175. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15176. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15177. builder.Write("TEL:");
  15178. builder.InsertCell();
  15179. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15180. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15181. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15182. builder.ParagraphFormat.Style.Font.Bold = false;
  15183. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15184. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15185. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15186. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15187. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15188. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15189. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15190. builder.Write($"{item.HotelTel}");
  15191. builder.InsertCell();
  15192. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15193. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15194. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15195. builder.ParagraphFormat.Style.Font.Bold = false;
  15196. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15197. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15198. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15199. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15200. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15201. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15202. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15203. builder.Write($"FAX:");
  15204. builder.InsertCell();
  15205. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15206. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15207. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15208. builder.ParagraphFormat.Style.Font.Bold = false;
  15209. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15210. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15211. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15212. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15213. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15214. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15215. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15216. builder.Write($"{item.HotelFax}");
  15217. builder.EndRow();
  15218. #endregion
  15219. #region 第六行
  15220. builder.InsertCell();
  15221. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15222. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15223. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15224. builder.ParagraphFormat.Style.Font.Bold = false;
  15225. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15226. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15227. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15228. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15229. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15230. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15231. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15232. builder.Write("CHECK IN:");
  15233. builder.InsertCell();
  15234. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15235. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15236. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15237. builder.ParagraphFormat.Style.Font.Bold = false;
  15238. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15239. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15240. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15241. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15242. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15243. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15244. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15245. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15246. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15247. builder.Write($"{checkInStr}");
  15248. builder.InsertCell();
  15249. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15250. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15251. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15252. builder.ParagraphFormat.Style.Font.Bold = false;
  15253. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15254. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15255. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15256. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15257. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15258. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15259. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15260. builder.Write($"CHECK OUT:");
  15261. builder.InsertCell();
  15262. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15263. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15264. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15265. builder.ParagraphFormat.Style.Font.Bold = false;
  15266. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15267. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15268. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15269. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15270. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15271. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15272. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15273. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15274. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15275. builder.Write($"{checkOutStr}");
  15276. builder.EndRow();
  15277. #endregion
  15278. #region 第七行
  15279. builder.InsertCell();
  15280. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15281. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15282. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15283. builder.ParagraphFormat.Style.Font.Bold = false;
  15284. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15285. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15286. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15287. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15288. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15289. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15290. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15291. builder.Write($"GUEST NAME:");
  15292. builder.InsertCell();
  15293. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15294. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15295. builder.ParagraphFormat.Style.Font.Size = 8;
  15296. builder.ParagraphFormat.Style.Font.Bold = false;
  15297. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15298. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15299. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15300. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15301. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15302. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15303. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15304. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15305. builder.Write($"{item.GuestName}");
  15306. builder.InsertCell();
  15307. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15308. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15309. builder.InsertCell();
  15310. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15311. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15312. builder.EndRow();
  15313. #endregion
  15314. #region 第八行
  15315. builder.InsertCell();
  15316. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15317. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15318. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15319. builder.ParagraphFormat.Style.Font.Bold = false;
  15320. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15321. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15322. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15323. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15324. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15325. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15326. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15327. builder.Write($"ROOM TYPE:");
  15328. builder.InsertCell();
  15329. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15330. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15331. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15332. builder.ParagraphFormat.Style.Font.Bold = false;
  15333. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15334. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15335. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15336. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15337. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15338. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15339. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15340. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15341. builder.Write($"{item.RoomExplanation}");
  15342. builder.InsertCell();
  15343. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15344. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15345. builder.InsertCell();
  15346. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15347. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15348. builder.EndRow();
  15349. #endregion
  15350. #region 第九行
  15351. builder.InsertCell();
  15352. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15353. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15354. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15355. builder.ParagraphFormat.Style.Font.Bold = false;
  15356. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15357. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15358. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15359. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15360. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15361. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15362. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15363. builder.Write($"NOTE:");
  15364. builder.InsertCell();
  15365. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15366. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15367. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15368. builder.ParagraphFormat.Style.Font.Bold = false;
  15369. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15370. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15371. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15372. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15373. 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.");
  15374. builder.InsertCell();
  15375. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15376. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15377. builder.InsertCell();
  15378. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15379. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15380. builder.EndRow();
  15381. #endregion
  15382. builder.EndTable();
  15383. //换行
  15384. builder.Writeln("");
  15385. builder.Writeln("");
  15386. }
  15387. #region 获取文档中的所有表格 设置文字自适应
  15388. // 获取文档中的所有表格。
  15389. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15390. {
  15391. // 遍历表格中的所有行。
  15392. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15393. {
  15394. foreach (Cell cell in row.Cells)
  15395. {
  15396. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15397. cellFormat.Width = 0;
  15398. }
  15399. }
  15400. }
  15401. #endregion
  15402. #region 设置页眉
  15403. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15404. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15405. if (System.IO.File.Exists(voucherHeaderPath))
  15406. {
  15407. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15408. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15409. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15410. Shape shape = builder.InsertImage(imageBytes);
  15411. // 调整图片位置
  15412. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15413. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15414. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15415. shape.Left = 0; // 将图片距离页面左边缘的距离
  15416. shape.Width = 81; // 设置图片宽度
  15417. shape.Height = 36; // 设置图片高度
  15418. }
  15419. //靠右
  15420. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15421. //// 设置页脚上下边距
  15422. //builder.PageSetup.HeaderDistance = 42;
  15423. // 添加页眉线
  15424. Aspose.Words.Border borderHeader = null;
  15425. try
  15426. {
  15427. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15428. }
  15429. catch (Exception e)
  15430. {
  15431. // TODO Auto-generated catch block
  15432. //e.printStackTrace();
  15433. }
  15434. borderHeader.Shadow = true;
  15435. borderHeader.DistanceFromText = 2;
  15436. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15437. #endregion
  15438. }
  15439. catch (Exception ex)
  15440. {
  15441. }
  15442. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15443. doc.Save(fileDir);
  15444. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15445. return Ok(JsonView(true, "操作成功!", Url));
  15446. }
  15447. /// <summary>
  15448. /// 酒店预订
  15449. /// 生成 预定成本 Excel
  15450. /// </summary>
  15451. /// <param name="_dto"></param>
  15452. /// <returns></returns>
  15453. [HttpPost]
  15454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15455. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15456. {
  15457. #region 参数验证
  15458. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15459. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15460. if (!vadalitorRes.IsValid)
  15461. {
  15462. var errors = new StringBuilder();
  15463. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15464. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15465. }
  15466. #region 团组操作权限验证 76 酒店预定模块
  15467. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15468. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15469. #endregion
  15470. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15471. #region 页面操作权限验证
  15472. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15473. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15474. #endregion
  15475. #endregion
  15476. decimal _rate = 1.00M;
  15477. string _currency = string.Empty;
  15478. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15479. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15480. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15481. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15482. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15483. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15484. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15485. if (_GroupCostParameter == null)
  15486. {
  15487. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15488. bool isIntType = int.TryParse(_currency, out int currId);
  15489. if (isIntType)
  15490. {
  15491. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15492. }
  15493. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15494. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15495. if (currInfo == null)
  15496. {
  15497. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15498. }
  15499. else _rate = currInfo.Rate;
  15500. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15501. {
  15502. _rate = _GroupCostParameter.Rate;
  15503. }
  15504. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15505. //string strFileName = "HotelStatement/";
  15506. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15507. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15508. var rateDatas = new List<dynamic>();
  15509. #region 数据处理
  15510. foreach (var item in hrDtas)
  15511. {
  15512. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15513. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15514. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15515. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15516. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15517. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15518. {
  15519. continue;
  15520. }
  15521. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15522. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15523. string singleRoomFeeStr = string.Empty,
  15524. doubleRoomFeeStr = string.Empty,
  15525. suiteRoomFeeStr = string.Empty,
  15526. otherRoomFeeStr = string.Empty,
  15527. payMoneyStr = string.Empty,
  15528. cardPriceStr = string.Empty;
  15529. if (roomCurr.Equals("CNY"))
  15530. {
  15531. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15532. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15533. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15534. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15535. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15536. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15537. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15538. }
  15539. else
  15540. {
  15541. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15542. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15543. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15544. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15545. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15546. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15547. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15548. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15549. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15550. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15551. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15552. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15553. if (ccpPaymentCurrency.Equals("CNY"))
  15554. {
  15555. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15556. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15557. }
  15558. else
  15559. {
  15560. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15561. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15562. }
  15563. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15564. if (hotelcardPriceCurrency.Equals("CNY"))
  15565. {
  15566. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15567. }
  15568. else
  15569. {
  15570. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15571. }
  15572. }
  15573. string breakfastPriceStr = string.Empty,
  15574. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15575. governmentRentStr = string.Empty,
  15576. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15577. cityTaxStr = string.Empty,
  15578. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15579. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15580. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15581. {
  15582. if (breakfastCurrency1.Equals("CNY"))
  15583. {
  15584. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15585. }
  15586. else
  15587. {
  15588. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15589. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15590. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15591. }
  15592. }
  15593. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15594. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15595. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15596. {
  15597. if (governmentRentCurrency.Equals("CNY"))
  15598. {
  15599. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15600. }
  15601. else
  15602. {
  15603. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15604. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15605. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15606. }
  15607. }
  15608. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15609. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15610. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15611. {
  15612. if (cityTaxStrCurrency1.Equals("CNY"))
  15613. {
  15614. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15615. }
  15616. else
  15617. {
  15618. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15619. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15620. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15621. }
  15622. }
  15623. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15624. int payDId = roomInfo?.PayDId ?? 0;
  15625. pcfds.Add(new HotelReservations_PCFD_View()
  15626. {
  15627. City = item.City,
  15628. HotelName = item.HotelName,
  15629. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15630. // SingleRoomCount = item.SingleRoomCount,
  15631. SingleRoomPrice = singleRoomFeeStr,
  15632. // DoubleRoomCount = item.DoubleRoomCount,
  15633. DoubleRoomPrice = doubleRoomFeeStr,
  15634. //SuiteRoomCount = item.SuiteRoomCount,
  15635. SuiteRoomPrice = suiteRoomFeeStr,
  15636. OtherRoomPrice = otherRoomFeeStr,
  15637. //OtherRoomCount = item.OtherRoomCount,
  15638. BreakfastPrice = breakfastPriceStr,
  15639. GovernmentRent = governmentRentStr,
  15640. CityTax = cityTaxStr,
  15641. RoomExplanation = item.RoomExplanation,
  15642. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15643. PayTime = roomInfo?.ConsumptionDate,
  15644. BankNo = roomInfo?.BankNo,
  15645. PayMoney = payMoneyStr,
  15646. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15647. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15648. CardPrice = cardPriceStr,
  15649. Remark = ccpInfo.Remark
  15650. });
  15651. }
  15652. #endregion
  15653. //载入模板
  15654. WorkbookDesigner designer = new WorkbookDesigner();
  15655. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15656. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15657. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15658. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15659. var rateDatas1 = rateDatas.Distinct();
  15660. var rateStr = string.Empty;
  15661. foreach (var item in rateDatas1)
  15662. {
  15663. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15664. }
  15665. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15666. designer.SetDataSource("Opertor", userInfo.CnName);
  15667. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15668. dt.TableName = "ViewMyHotelReservations";
  15669. designer.SetDataSource(dt);
  15670. designer.Process();
  15671. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15672. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15673. designer.Workbook.Save(serverPath);
  15674. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15675. #region 删除指定行
  15676. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15677. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15678. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15679. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15680. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15681. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15682. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15683. cssIndex = dt.Columns["CityTax"].Ordinal,
  15684. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15685. remarkIndex = dt.Columns["Remark"].Ordinal;
  15686. //删除指定列
  15687. foreach (DataRow item in dt.Rows)
  15688. {
  15689. string singleStr = item["SingleRoomPrice"].ToString();
  15690. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15691. if (containsDigitButNotZero1) singleDel = false;
  15692. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15693. string doubleStr = item["DoubleRoomPrice"].ToString();
  15694. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15695. if (containsDigitButNotZero2) doubleDel = false;
  15696. string suiteStr = item["SuiteRoomPrice"].ToString();
  15697. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15698. if (containsDigitButNotZero3) suiteDel = false;
  15699. string otherStr = item["OtherRoomPrice"].ToString();
  15700. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15701. if (containsDigitButNotZero4) otherDel = false;
  15702. string zcStr = item["BreakfastPrice"].ToString();
  15703. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15704. if (containsDigitButNotZero5) zcDel = false;
  15705. string dsStr = item["GovernmentRent"].ToString();
  15706. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15707. if (containsDigitButNotZero6) dsDel = false;
  15708. string cssStr = item["CityTax"].ToString();
  15709. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15710. if (containsDigitButNotZero7) cssDel = false;
  15711. string cpStr = item["ConsumptionPatterns"].ToString();
  15712. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15713. string remarkStr = item["Remark"].ToString();
  15714. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15715. }
  15716. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15717. DeleteColumn(serverPath, cpIndex, cpDel);
  15718. DeleteColumn(serverPath, dsIndex, dsDel);
  15719. DeleteColumn(serverPath, cssIndex, cssDel);
  15720. DeleteColumn(serverPath, zcIndex, zcDel);
  15721. DeleteColumn(serverPath, otherIndex, otherDel);
  15722. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15723. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15724. DeleteColumn(serverPath, singleIndex, singleDel);
  15725. #endregion
  15726. //只保留第一个表格
  15727. DeleteSheet(serverPath);
  15728. return Ok(JsonView(true, "操作成功", url = rst));
  15729. }
  15730. else
  15731. {
  15732. _currency = _GroupCostParameter.Currency;
  15733. bool isIntType = int.TryParse(_currency, out int currId);
  15734. if (isIntType)
  15735. {
  15736. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15737. }
  15738. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15739. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15740. if (currInfo == null)
  15741. {
  15742. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15743. }
  15744. if (!_currency.ToUpper().Equals("CNY"))
  15745. {
  15746. _rate = _GroupCostParameter.Rate;
  15747. }
  15748. _rate = currInfo.Rate;
  15749. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15750. //string strFileName = "HotelStatement/";
  15751. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15752. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15753. #region 数据处理
  15754. foreach (var item in hrDtas)
  15755. {
  15756. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15757. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15758. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15759. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15760. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15761. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15762. string singleRoomFeeStr = string.Empty,
  15763. doubleRoomFeeStr = string.Empty,
  15764. suiteRoomFeeStr = string.Empty,
  15765. otherRoomFeeStr = string.Empty,
  15766. payMoneyStr = string.Empty,
  15767. cardPriceStr = string.Empty;
  15768. if (roomCurr.Equals(_currency))
  15769. {
  15770. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15771. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15772. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15773. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15774. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15775. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15776. }
  15777. else
  15778. {
  15779. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15780. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15781. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15782. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15783. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15784. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15785. }
  15786. string breakfastPriceStr = string.Empty,
  15787. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15788. governmentRentStr = string.Empty,
  15789. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15790. cityTaxStrStr = string.Empty,
  15791. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15792. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15793. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15794. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15795. int payDId = roomInfo?.PayDId ?? 0;
  15796. pcfds.Add(new HotelReservations_PCFD_View()
  15797. {
  15798. City = item.City,
  15799. HotelName = item.HotelName,
  15800. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15801. // SingleRoomCount = item.SingleRoomCount,
  15802. SingleRoomPrice = singleRoomFeeStr,
  15803. // DoubleRoomCount = item.DoubleRoomCount,
  15804. DoubleRoomPrice = doubleRoomFeeStr,
  15805. //SuiteRoomCount = item.SuiteRoomCount,
  15806. SuiteRoomPrice = suiteRoomFeeStr,
  15807. OtherRoomPrice = otherRoomFeeStr,
  15808. //OtherRoomCount = item.OtherRoomCount,
  15809. BreakfastPrice = breakfastPriceStr,
  15810. GovernmentRent = governmentRentStr,
  15811. CityTax = cityTaxStrStr,
  15812. RoomExplanation = item.RoomExplanation,
  15813. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15814. PayTime = roomInfo?.ConsumptionDate,
  15815. BankNo = roomInfo?.BankNo,
  15816. PayMoney = payMoneyStr,
  15817. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15818. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15819. CardPrice = cardPriceStr,
  15820. Remark = ccpInfo.Remark
  15821. });
  15822. }
  15823. #endregion
  15824. //载入模板
  15825. WorkbookDesigner designer = new WorkbookDesigner();
  15826. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15827. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15828. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15829. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15830. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15831. designer.SetDataSource("Opertor", userInfo.CnName);
  15832. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15833. dt.TableName = "ViewMyHotelReservations";
  15834. designer.SetDataSource(dt);
  15835. designer.Process();
  15836. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15837. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15838. designer.Workbook.Save(serverPath);
  15839. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15840. #region 删除指定行
  15841. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15842. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15843. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15844. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15845. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15846. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15847. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15848. cssIndex = dt.Columns["CityTax"].Ordinal,
  15849. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15850. remarkIndex = dt.Columns["Remark"].Ordinal;
  15851. //删除指定列
  15852. foreach (DataRow item in dt.Rows)
  15853. {
  15854. string singleStr = item["SingleRoomPrice"].ToString();
  15855. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15856. if (containsDigitButNotZero1) singleDel = false;
  15857. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15858. string doubleStr = item["DoubleRoomPrice"].ToString();
  15859. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15860. if (containsDigitButNotZero2) doubleDel = false;
  15861. string suiteStr = item["SuiteRoomPrice"].ToString();
  15862. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15863. if (containsDigitButNotZero3) suiteDel = false;
  15864. string otherStr = item["OtherRoomPrice"].ToString();
  15865. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15866. if (containsDigitButNotZero4) otherDel = false;
  15867. string zcStr = item["BreakfastPrice"].ToString();
  15868. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15869. if (containsDigitButNotZero5) zcDel = false;
  15870. string dsStr = item["GovernmentRent"].ToString();
  15871. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15872. if (containsDigitButNotZero6) dsDel = false;
  15873. string cssStr = item["CityTax"].ToString();
  15874. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15875. if (containsDigitButNotZero7) cssDel = false;
  15876. string cpStr = item["ConsumptionPatterns"].ToString();
  15877. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15878. string remarkStr = item["Remark"].ToString();
  15879. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15880. }
  15881. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15882. DeleteColumn(serverPath, cpIndex, cpDel);
  15883. DeleteColumn(serverPath, dsIndex, dsDel);
  15884. DeleteColumn(serverPath, cssIndex, cssDel);
  15885. DeleteColumn(serverPath, zcIndex, zcDel);
  15886. DeleteColumn(serverPath, otherIndex, otherDel);
  15887. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15888. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15889. DeleteColumn(serverPath, singleIndex, singleDel);
  15890. #endregion
  15891. //只保留第一个表格
  15892. DeleteSheet(serverPath);
  15893. return Ok(JsonView(true, "操作成功", url = rst));
  15894. }
  15895. //return Ok(JsonView(false));
  15896. }
  15897. /// <summary>
  15898. /// 删除指定列
  15899. /// </summary>
  15900. /// <param name="file"></param>
  15901. /// <param name="columnIndex"></param>
  15902. /// <param name="isDel"></param>
  15903. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15904. {
  15905. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15906. //wb.Save(file);
  15907. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15908. if (sheet1 != null)
  15909. {
  15910. if (isDel)
  15911. {
  15912. Cells cells = sheet1.Cells;
  15913. cells.DeleteColumn(columnIndex);
  15914. }
  15915. }
  15916. wb.Save(file);
  15917. }
  15918. /// <summary>
  15919. /// 删除sheet
  15920. /// </summary>
  15921. /// <param name="file"></param>
  15922. /// <param name="sheetName"></param>
  15923. private void DeleteSheet(string file, string sheetName = "")
  15924. {
  15925. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15926. //wb.Save(file);
  15927. List<string> sheets = new List<string>();
  15928. foreach (var item in wb.Worksheets)
  15929. {
  15930. sheets.Add(item.Name);
  15931. }
  15932. if (sheets.Count > 0)
  15933. {
  15934. sheets.RemoveAt(0);//不删除第一个sheet
  15935. foreach (var item in sheets)
  15936. {
  15937. wb.Worksheets.RemoveAt(item);
  15938. }
  15939. }
  15940. wb.Save(file);
  15941. }
  15942. /// <summary>
  15943. /// 酒店预订
  15944. /// 确认单
  15945. /// </summary>
  15946. /// <param name="_dto"></param>
  15947. /// <returns></returns>
  15948. [HttpPost]
  15949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15950. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15951. {
  15952. try
  15953. {
  15954. #region 参数验证
  15955. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15956. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15957. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15958. #region 团组操作权限验证 76 酒店预定模块
  15959. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15960. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15961. #endregion
  15962. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15963. #region 页面操作权限验证
  15964. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15965. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15966. #endregion
  15967. #endregion
  15968. //团组信息
  15969. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15970. //酒店数据
  15971. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15972. if (listhoteldata.Count < 0)
  15973. {
  15974. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15975. }
  15976. //利datatable存储
  15977. DataTable dt = new DataTable();
  15978. dt.Columns.Add("CheckInDate", typeof(string));
  15979. dt.Columns.Add("City", typeof(string));
  15980. dt.Columns.Add("Hotel", typeof(string));
  15981. dt.Columns.Add("Room", typeof(string));
  15982. for (int i = 0; i < listhoteldata.Count; i++)
  15983. {
  15984. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15985. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15986. while (dayStart < dayEnd)
  15987. {
  15988. string temp = "";
  15989. DataRow row = dt.NewRow();
  15990. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15991. row["City"] = listhoteldata[i].City;
  15992. row["Hotel"] = listhoteldata[i].HotelName;
  15993. if (listhoteldata[i].SingleRoomCount > 0)
  15994. {
  15995. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15996. }
  15997. if (listhoteldata[i].DoubleRoomCount > 0)
  15998. {
  15999. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16000. }
  16001. if (listhoteldata[i].SuiteRoomCount > 0)
  16002. {
  16003. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16004. }
  16005. if (listhoteldata[i].OtherRoomCount > 0)
  16006. {
  16007. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16008. }
  16009. row["Room"] = temp;
  16010. dt.Rows.Add(row);
  16011. dayStart = dayStart.AddDays(1);
  16012. }
  16013. }
  16014. Dictionary<string, string> dic = new Dictionary<string, string>();
  16015. dic.Add("Dele", di.TeamName);
  16016. dic.Add("City", di.VisitCountry);
  16017. //模板路径
  16018. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16019. //载入模板
  16020. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16021. DocumentBuilder builder = new DocumentBuilder(doc);
  16022. foreach (var key in dic.Keys)
  16023. {
  16024. builder.MoveToBookmark(key);
  16025. builder.Write(dic[key]);
  16026. }
  16027. //获取word里所有表格
  16028. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16029. //获取所填表格的序数
  16030. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16031. var rowStart = tableOne.Rows[0]; //获取第1行
  16032. //循环赋值
  16033. for (int i = 0; i < dt.Rows.Count; i++)
  16034. {
  16035. builder.MoveToCell(0, i + 1, 0, 0);
  16036. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16037. builder.MoveToCell(0, i + 1, 1, 0);
  16038. builder.Write(dt.Rows[i]["City"].ToString());
  16039. builder.MoveToCell(0, i + 1, 2, 0);
  16040. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16041. builder.MoveToCell(0, i + 1, 3, 0);
  16042. builder.Write(dt.Rows[i]["Room"].ToString());
  16043. }
  16044. //删除多余行
  16045. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16046. {
  16047. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16048. }
  16049. string strFileName = di.TeamName + "酒店确认单.doc";
  16050. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16051. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16052. return Ok(JsonView(true, "成功", url));
  16053. }
  16054. catch (Exception ex)
  16055. {
  16056. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16057. }
  16058. }
  16059. #endregion
  16060. #region 团组状态
  16061. /// <summary>
  16062. /// 团组状态列表 Page
  16063. /// </summary>
  16064. /// <param name="dto">团组列表请求dto</param>
  16065. /// <returns></returns>
  16066. [HttpPost]
  16067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16068. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16069. {
  16070. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16071. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16072. {
  16073. string sqlWhere = string.Empty;
  16074. if (dto.IsSure == 0) //未完成
  16075. {
  16076. sqlWhere += string.Format(@" And IsSure = 0");
  16077. }
  16078. else if (dto.IsSure == 1) //已完成
  16079. {
  16080. sqlWhere += string.Format(@" And IsSure = 1");
  16081. }
  16082. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16083. {
  16084. string tj = dto.SearchCriteria;
  16085. 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}%')",
  16086. tj, tj, tj, tj, tj);
  16087. }
  16088. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16089. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16090. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16091. From (
  16092. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16093. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16094. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16095. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16096. From Grp_DelegationInfo gdi
  16097. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16098. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16099. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16100. Where gdi.IsDel = 0 {0}
  16101. ) temp ", sqlWhere);
  16102. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16103. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16104. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16105. }
  16106. else
  16107. {
  16108. return Ok(JsonView(false, "查询失败"));
  16109. }
  16110. }
  16111. /// <summary>
  16112. /// 团组状态
  16113. /// 设置操作完成
  16114. /// </summary>
  16115. /// <param name="dto">团组列表请求dto</param>
  16116. /// <returns></returns>
  16117. [HttpPost]
  16118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16119. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16120. {
  16121. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16122. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16123. {
  16124. Id = dto.Id,
  16125. IsSure = 1
  16126. };
  16127. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16128. .UpdateColumns(it => new { it.IsSure })
  16129. .WhereColumns(it => new { it.Id })
  16130. .ExecuteCommandAsync();
  16131. if (result > 0)
  16132. {
  16133. return Ok(JsonView(true, "操作完成!"));
  16134. }
  16135. return Ok(JsonView(false, "操作失败!"));
  16136. }
  16137. #endregion
  16138. #region 保险费用录入
  16139. /// <summary>
  16140. /// 根据团组Id查询保险费用列表
  16141. /// </summary>
  16142. /// <param name="dto"></param>
  16143. /// <returns></returns>
  16144. [HttpPost]
  16145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16146. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16147. {
  16148. Result groupData = await _customersRep.CustomersByDiId(dto);
  16149. if (groupData.Code != 0)
  16150. {
  16151. return Ok(JsonView(false, groupData.Msg));
  16152. }
  16153. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16154. }
  16155. /// <summary>
  16156. /// 根据保险费用Id查询保险费用详细
  16157. /// </summary>
  16158. /// <param name="dto"></param>
  16159. /// <returns></returns>
  16160. [HttpPost]
  16161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16162. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16163. {
  16164. try
  16165. {
  16166. Result groupData = await _customersRep.CustomersById(dto);
  16167. if (groupData.Code != 0)
  16168. {
  16169. return Ok(JsonView(false, groupData.Msg));
  16170. }
  16171. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16172. }
  16173. catch (Exception ex)
  16174. {
  16175. return Ok(JsonView(false, ex.Message));
  16176. }
  16177. }
  16178. /// <summary>
  16179. /// 保险费用录入页面初始化绑定
  16180. /// </summary>
  16181. /// <param name="dto"></param>
  16182. /// <returns></returns>
  16183. [HttpPost]
  16184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16185. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16186. {
  16187. try
  16188. {
  16189. Result groupData = await _customersRep.CustomersInitialize(dto);
  16190. if (groupData.Code != 0)
  16191. {
  16192. return Ok(JsonView(false, groupData.Msg));
  16193. }
  16194. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16195. }
  16196. catch (Exception ex)
  16197. {
  16198. return Ok(JsonView(false, ex.Message));
  16199. }
  16200. }
  16201. /// <summary>
  16202. /// 保险费用操作(Status:1.新增,2.修改)
  16203. /// </summary>
  16204. /// <param name="dto"></param>
  16205. /// <returns></returns>
  16206. [HttpPost]
  16207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16208. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16209. {
  16210. Result groupData = await _customersRep.OpCustomers(dto);
  16211. if (groupData.Code != 0)
  16212. {
  16213. return Ok(JsonView(false, groupData.Msg));
  16214. }
  16215. #region 应用推送
  16216. try
  16217. {
  16218. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16219. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16220. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16221. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16222. //自动审核
  16223. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16224. //2024-10-21 新增LZ UID
  16225. var userIds = new List<int>() { 21 };
  16226. string title = $"系统通知";
  16227. var diId = dto.DiId;
  16228. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16229. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16230. string content = "";
  16231. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16232. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16233. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16234. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16235. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16236. }
  16237. catch (Exception ex)
  16238. {
  16239. }
  16240. #endregion
  16241. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16242. }
  16243. /// <summary>
  16244. /// 保险文件上传
  16245. /// </summary>
  16246. /// <param name="file"></param>
  16247. /// <returns></returns>
  16248. [HttpPost]
  16249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16250. public async Task<IActionResult> UploadCus(IFormFile file)
  16251. {
  16252. try
  16253. {
  16254. if (file != null)
  16255. {
  16256. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16257. //文件名称
  16258. string projectFileName = file.FileName;
  16259. //上传的文件的路径
  16260. string filePath = "";
  16261. if (!Directory.Exists(fileDir))
  16262. {
  16263. Directory.CreateDirectory(fileDir);
  16264. }
  16265. //上传的文件的路径
  16266. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16267. using (FileStream fs = System.IO.File.Create(filePath))
  16268. {
  16269. file.CopyTo(fs);
  16270. fs.Flush();
  16271. }
  16272. return Ok(JsonView(true, "上传成功!", projectFileName));
  16273. }
  16274. else
  16275. {
  16276. return Ok(JsonView(false, "上传失败!"));
  16277. }
  16278. }
  16279. catch (Exception ex)
  16280. {
  16281. return Ok(JsonView(false, "程序错误!"));
  16282. throw;
  16283. }
  16284. }
  16285. /// <summary>
  16286. /// 保险删除指定文件
  16287. /// </summary>
  16288. /// <param name="dto"></param>
  16289. /// <returns></returns>
  16290. [HttpPost]
  16291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16292. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16293. {
  16294. try
  16295. {
  16296. string filePath = "";
  16297. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16298. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16299. //int id = 0;
  16300. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16301. // 删除该文件
  16302. try
  16303. {
  16304. System.IO.File.Delete(filePath);
  16305. 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()
  16306. {
  16307. Attachment = "",
  16308. }).ExecuteCommandAsync();
  16309. if (result != 0)
  16310. {
  16311. return Ok(JsonView(true, "成功!"));
  16312. }
  16313. else
  16314. {
  16315. return Ok(JsonView(false, "失败!"));
  16316. }
  16317. }
  16318. catch (Exception)
  16319. {
  16320. 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()
  16321. {
  16322. Attachment = "",
  16323. }).ExecuteCommandAsync();
  16324. if (result != 0)
  16325. {
  16326. return Ok(JsonView(true, "成功!"));
  16327. }
  16328. else
  16329. {
  16330. return Ok(JsonView(false, "失败!"));
  16331. }
  16332. }
  16333. }
  16334. catch (Exception ex)
  16335. {
  16336. return Ok(JsonView(false, "程序错误!"));
  16337. throw;
  16338. }
  16339. }
  16340. /// <summary>
  16341. /// 保险费用操作(删除)
  16342. /// </summary>
  16343. /// <param name="dto"></param>
  16344. /// <returns></returns>
  16345. [HttpPost]
  16346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16347. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16348. {
  16349. try
  16350. {
  16351. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16352. if (!res)
  16353. {
  16354. return Ok(JsonView(false, "删除失败"));
  16355. }
  16356. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16357. {
  16358. IsDel = 1,
  16359. DeleteUserId = dto.DeleteUserId,
  16360. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16361. }).ExecuteCommandAsync();
  16362. return Ok(JsonView(true, "删除成功!"));
  16363. }
  16364. catch (Exception ex)
  16365. {
  16366. return Ok(JsonView(false, "程序错误!"));
  16367. throw;
  16368. }
  16369. }
  16370. #endregion
  16371. #region 接团客户名单 PageId 104
  16372. /// <summary>
  16373. /// 接团客户名单
  16374. /// 迁移数据(慎用!)
  16375. /// </summary>
  16376. /// <returns></returns>
  16377. [HttpPost]
  16378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16379. public async Task<IActionResult> PostTourClientListChange()
  16380. {
  16381. try
  16382. {
  16383. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16384. //var groupClinetData1
  16385. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16386. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16387. int updateCount = 0;
  16388. if (oldOAClientList.Count > 0)
  16389. {
  16390. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16391. _sqlSugar.BeginTran();
  16392. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16393. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16394. foreach (var item in oldOAClientList)
  16395. {
  16396. int comId = 0;
  16397. string format = "yyyy-MM-dd HH:mm:ss";
  16398. string data11 = "1990-01-01 00:00";
  16399. var data1 = IsValidDate(item.OPdate, format);
  16400. if (data1) data11 = item.OPdate;
  16401. //客户公司验证
  16402. if (!string.IsNullOrEmpty(item.Company))
  16403. {
  16404. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16405. if (clientComInfo == null) // add
  16406. {
  16407. var addInfo = new Crm_CustomerCompany()
  16408. {
  16409. CompanyAbbreviation = "",
  16410. CompanyFullName = item.Company,
  16411. Address = "",
  16412. PostCodes = "",
  16413. LastedOpUserId = item.OPer,
  16414. LastedOpDt = Convert.ToDateTime(data11),
  16415. CreateUserId = item.OPer,
  16416. CreateTime = Convert.ToDateTime(data11),
  16417. IsDel = 0
  16418. };
  16419. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16420. if (comId1 > 0) comId = comId1;
  16421. }
  16422. else comId = clientComInfo.Id;
  16423. }
  16424. //客户人员验证
  16425. int clientId = 0;
  16426. string name = item.LastName + item.Name;
  16427. if (!string.IsNullOrEmpty(name))
  16428. {
  16429. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16430. if (clientInfo == null)
  16431. {
  16432. DateTime? dateTime = null;
  16433. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16434. if (isDt) dateTime = birthDayDt;
  16435. var addInfo1 = new Crm_DeleClient()
  16436. {
  16437. CrmCompanyId = comId,
  16438. DiId = -1,
  16439. LastName = item.LastName,
  16440. FirstName = item.Name,
  16441. OldName = "",
  16442. Pinyin = item.Pinyin,
  16443. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16444. Marriage = 0,
  16445. Phone = item.Phone,
  16446. Job = item.Job,
  16447. BirthDay = dateTime
  16448. };
  16449. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16450. if (clientId1 > 0) clientId = clientId1;
  16451. }
  16452. else clientId = clientInfo.Id;
  16453. }
  16454. if (clientId < 1)
  16455. {
  16456. continue;
  16457. }
  16458. int airType = 0;
  16459. if (item.AirType == "超经舱") airType = 459;
  16460. else if (item.AirType == "公务舱") airType = 458;
  16461. else if (item.AirType == "经济舱") airType = 460;
  16462. else if (item.AirType == "其他") airType = 565;
  16463. else if (item.AirType == "头等舱") airType = 457;
  16464. var _TourClientListEntity = new Grp_TourClientList()
  16465. {
  16466. DiId = item.Diid,
  16467. ClientId = clientId,
  16468. CreateUserId = item.OPer,
  16469. CreateTime = Convert.ToDateTime(data11),
  16470. Remark = item.Remark,
  16471. IsDel = item.Isdel,
  16472. ShippingSpaceTypeId = airType,
  16473. ShippingSpaceSpecialNeeds = item.AirRemark,
  16474. HotelSpecialNeeds = item.RoomType
  16475. };
  16476. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16477. if (_TourClientList > 0)
  16478. {
  16479. updateCount++;
  16480. }
  16481. }
  16482. _sqlSugar.CommitTran();
  16483. }
  16484. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16485. }
  16486. catch (Exception ex)
  16487. {
  16488. _sqlSugar.RollbackTran();
  16489. return Ok(JsonView(false, ex.Message));
  16490. }
  16491. //return Ok(JsonView(true));
  16492. }
  16493. private bool IsValidDate(string dateString, string format)
  16494. {
  16495. DateTime dateValue;
  16496. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16497. return valid;
  16498. }
  16499. /// <summary>
  16500. /// 接团客户名单
  16501. /// 根据团组Id查询List
  16502. /// </summary>
  16503. /// <param name="_dto"></param>
  16504. /// <returns></returns>
  16505. [HttpPost]
  16506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16507. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16508. {
  16509. #region 参数验证
  16510. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16511. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16512. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16513. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16514. #region 页面操作权限验证
  16515. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16516. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16517. #endregion
  16518. #endregion
  16519. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16520. if (viewData.Code != 0)
  16521. {
  16522. return Ok(JsonView(false, viewData.Msg));
  16523. }
  16524. return Ok(JsonView(viewData.Data));
  16525. }
  16526. /// <summary>
  16527. /// 接团客户名单
  16528. /// 基础数据 Init
  16529. /// </summary>
  16530. /// <param name="_dto"></param>
  16531. /// <returns></returns>
  16532. [HttpPost]
  16533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16534. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16535. {
  16536. #region 参数验证
  16537. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16538. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16539. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16540. #region 页面操作权限验证
  16541. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16542. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16543. #endregion
  16544. #endregion
  16545. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16546. }
  16547. /// <summary>
  16548. /// 接团客户名单
  16549. /// 根据 Id查询 Details
  16550. /// </summary>
  16551. /// <param name="_dto"></param>
  16552. /// <returns></returns>
  16553. [HttpPost]
  16554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16555. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16556. {
  16557. #region 参数验证
  16558. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16559. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16560. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16561. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16562. #region 页面操作权限验证
  16563. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16564. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16565. #endregion
  16566. #endregion
  16567. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16568. if (viewData.Code != 0)
  16569. {
  16570. return Ok(JsonView(false, viewData.Msg));
  16571. }
  16572. return Ok(JsonView(viewData.Data));
  16573. }
  16574. /// <summary>
  16575. /// 接团客户名单
  16576. /// Add Or Edit
  16577. /// </summary>
  16578. /// <param name="_dto"></param>
  16579. /// <returns></returns>
  16580. [HttpPost]
  16581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16582. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16583. {
  16584. #region 参数验证
  16585. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16586. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16587. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16588. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16589. #region 页面操作权限验证
  16590. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16591. if (_dto.Id == 0) //添加
  16592. {
  16593. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16594. }
  16595. else if (_dto.Id >= 0) //修改
  16596. {
  16597. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16598. }
  16599. #endregion
  16600. #endregion
  16601. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16602. if (viewData.Code != 0)
  16603. {
  16604. return Ok(JsonView(false, viewData.Msg));
  16605. }
  16606. return Ok(JsonView(true));
  16607. }
  16608. /// <summary>
  16609. /// 接团客户名单
  16610. /// json字符串 AddMultiple(添加多个)
  16611. /// </summary>
  16612. /// <param name="_dto"></param>
  16613. /// <returns></returns>
  16614. [HttpPost]
  16615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16616. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16617. {
  16618. #region 参数验证
  16619. string jsonLabel = _dto.JsonLabel;
  16620. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16621. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16622. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16623. #region 页面操作权限验证
  16624. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16625. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16626. #endregion
  16627. #endregion
  16628. var request = new TourClientListAddMultipleDto();
  16629. request.DiId = _dto.DiId;
  16630. request.UserId = _dto.UserId;
  16631. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16632. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16633. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16634. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16635. var infos = new List<TourClientListInfo>();
  16636. foreach (var data in datas)
  16637. {
  16638. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16639. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16640. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16641. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16642. {
  16643. continue;
  16644. }
  16645. infos.Add(new TourClientListInfo()
  16646. {
  16647. IsAccompany = 1,
  16648. LastName = lastName,
  16649. FirstName = firstName,
  16650. Pinyin = lastNameEn + @"/" + firstNameEn,
  16651. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16652. CompanyFullName = data.CompanyFullName,
  16653. Job = data.Job
  16654. });
  16655. }
  16656. if (infos.Any())
  16657. {
  16658. var viewData = await _tourClientListRep._AddMultiple(request);
  16659. if (viewData.Code != 0)
  16660. {
  16661. return Ok(JsonView(false, viewData.Msg));
  16662. }
  16663. return Ok(JsonView(true));
  16664. }
  16665. return Ok(JsonView(false));
  16666. }
  16667. /// <summary>
  16668. /// 接团客户名单
  16669. /// AddMultiple(添加多个)
  16670. /// </summary>
  16671. /// <param name="_dto"></param>
  16672. /// <returns></returns>
  16673. [HttpPost]
  16674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16675. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16676. {
  16677. #region 参数验证
  16678. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16679. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16680. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16681. #region 页面操作权限验证
  16682. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16683. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16684. #endregion
  16685. #endregion
  16686. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16687. if (viewData.Code != 0)
  16688. {
  16689. return Ok(JsonView(false, viewData.Msg));
  16690. }
  16691. return Ok(JsonView(true));
  16692. }
  16693. /// <summary>
  16694. /// 接团客户名单
  16695. /// Del
  16696. /// </summary>
  16697. /// <param name="_dto"></param>
  16698. /// <returns></returns>
  16699. [HttpPost]
  16700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16701. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16702. {
  16703. #region 参数验证
  16704. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16705. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16706. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16707. #region 页面操作权限验证
  16708. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16709. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16710. #endregion
  16711. #endregion
  16712. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16713. if (viewData.Code != 0)
  16714. {
  16715. return Ok(JsonView(false, viewData.Msg));
  16716. }
  16717. return Ok(JsonView(true));
  16718. }
  16719. /// <summary>
  16720. /// 接团客户名单
  16721. /// 文件下载 客户名单
  16722. /// </summary>
  16723. /// <param name="_dto"></param>
  16724. /// <returns></returns>
  16725. [HttpPost]
  16726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16727. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16728. {
  16729. #region 参数验证
  16730. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16731. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16732. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16733. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16734. #region 页面操作权限验证
  16735. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16736. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16737. #endregion
  16738. #endregion
  16739. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16740. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16741. From Grp_TourClientList tcl
  16742. Left Join
  16743. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16744. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16745. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16746. From Crm_DeleClient dc
  16747. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16748. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16749. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16750. Where dc.IsDel = 0) temp
  16751. On temp.DcId =tcl.ClientId
  16752. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16753. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16754. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16755. //载入模板
  16756. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16757. if (_dto.Language == 1)
  16758. {
  16759. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16760. }
  16761. //载入模板
  16762. var doc = new Document(tempPath);
  16763. DocumentBuilder builder = new DocumentBuilder(doc);
  16764. //获取word里所有表格
  16765. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16766. //获取所填表格的序数
  16767. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16768. var rowStart = tableOne.Rows[0]; //获取第1行
  16769. if (_dto.Language == 0)
  16770. {
  16771. //循环赋值
  16772. for (int i = 0; i < DcList.Count; i++)
  16773. {
  16774. EncryptionProcessor.DecryptProperties(DcList[i]);
  16775. builder.MoveToCell(0, i + 1, 0, 0);
  16776. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16777. builder.MoveToCell(0, i + 1, 1, 0);
  16778. int sex = DcList[i].Sex;
  16779. string sexStr = string.Empty;
  16780. if (sex == 0) sexStr = "男";
  16781. else if (sex == 1) sexStr = "女";
  16782. else sexStr = "未设置";
  16783. builder.Write(sexStr);
  16784. builder.MoveToCell(0, i + 1, 2, 0);
  16785. string birthDay = DcList[i].BirthDay;
  16786. string birthDayStr = string.Empty;
  16787. if (!string.IsNullOrEmpty(birthDay))
  16788. {
  16789. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16790. }
  16791. builder.Write(birthDayStr);
  16792. builder.MoveToCell(0, i + 1, 3, 0);
  16793. string company = "";
  16794. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16795. {
  16796. company = DcList[i].CompanyFullName.ToString();
  16797. }
  16798. builder.Write(company);
  16799. builder.MoveToCell(0, i + 1, 4, 0);
  16800. builder.Write(DcList[i].Job);
  16801. }
  16802. }
  16803. else if (_dto.Language == 1)
  16804. {
  16805. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16806. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16807. List<string> transArrayStr = new List<string>();
  16808. string transStrRes1 = "";
  16809. for (int i = 0; i < DcList.Count; i++)
  16810. {
  16811. var dc = DcList[i];
  16812. EncryptionProcessor.DecryptProperties(dc);
  16813. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16814. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16815. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16816. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16817. else transStrRes1 += $"{str1}|";
  16818. }
  16819. //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";
  16820. string transStrRes = "";
  16821. if (transStrRes1.Length > 0)
  16822. {
  16823. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16824. }
  16825. //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
  16826. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16827. //List<string> transArray = new List<string> { };
  16828. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16829. if (transStrRes.Contains("|"))
  16830. {
  16831. string[] transArray1 = transStrRes.Split('|');
  16832. if (transArray1.Length > 0)
  16833. {
  16834. foreach (var item in transArray1)
  16835. {
  16836. if (item.Contains("&"))
  16837. {
  16838. string[] transArray2 = item.Split('&');
  16839. int index = 0;
  16840. string companyName = "", job = "";
  16841. if (transArray2.Length > 0)
  16842. {
  16843. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16844. if (1 < transArray2.Length) companyName = transArray2[1];
  16845. if (2 < transArray2.Length) job = transArray2[2];
  16846. }
  16847. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16848. }
  16849. }
  16850. }
  16851. }
  16852. //循环赋值
  16853. for (int i = 0; i < DcList.Count; i++)
  16854. {
  16855. string PYName = "";
  16856. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16857. {
  16858. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16859. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16860. PYName = PY_First + " " + PY_Last;
  16861. }
  16862. else
  16863. {
  16864. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16865. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16866. PYName = PY_First + " " + PY_Last;
  16867. }
  16868. builder.MoveToCell(0, i + 1, 0, 0);
  16869. builder.Write(PYName);
  16870. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16871. builder.MoveToCell(0, i + 1, 1, 0);
  16872. builder.Write(sex);
  16873. DateTime birthDt;
  16874. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16875. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16876. builder.MoveToCell(0, i + 1, 2, 0);
  16877. builder.Write(birthday);
  16878. string company = string.Empty, job = string.Empty;
  16879. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16880. if (dcTransInfo != null)
  16881. {
  16882. company = dcTransInfo.CompanyName;
  16883. job = dcTransInfo.Job;
  16884. }
  16885. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16886. {
  16887. //查询对照表
  16888. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16889. if (tempCec != null)
  16890. {
  16891. company = tempCec.enName;
  16892. }
  16893. //翻译
  16894. else
  16895. {
  16896. }
  16897. }
  16898. builder.MoveToCell(0, i + 1, 3, 0);
  16899. builder.Write(company);
  16900. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16901. {
  16902. //查询对照表
  16903. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16904. if (tempPec != null)
  16905. {
  16906. job = tempPec.enName;
  16907. }
  16908. //翻译
  16909. else
  16910. {
  16911. }
  16912. }
  16913. builder.MoveToCell(0, i + 1, 4, 0);
  16914. builder.Write(job);
  16915. }
  16916. }
  16917. //删除多余行
  16918. while (tableOne.Rows.Count > DcList.Count + 1)
  16919. {
  16920. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16921. }
  16922. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16923. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16924. doc.Save(fileDir);
  16925. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16926. return Ok(JsonView(true, "操作成功!", Url));
  16927. }
  16928. private class TranslateInfo
  16929. {
  16930. public int Index { get; set; }
  16931. public string CompanyName { get; set; }
  16932. public string Job { get; set; }
  16933. }
  16934. #endregion
  16935. #region 团组倒推表
  16936. /// <summary>
  16937. /// 倒推表基础数据
  16938. /// Init
  16939. /// </summary>
  16940. /// <returns></returns>
  16941. [HttpPost]
  16942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16943. public async Task<IActionResult> PostInvertedListInit()
  16944. {
  16945. var viewData = await _invertedListRep._Init();
  16946. if (viewData.Code != 0)
  16947. {
  16948. return Ok(JsonView(false, viewData.Msg));
  16949. }
  16950. return Ok(JsonView(viewData.Data));
  16951. }
  16952. /// <summary>
  16953. /// 倒推表
  16954. /// Info
  16955. /// </summary>
  16956. /// <param name="dto"></param>
  16957. /// <returns></returns>
  16958. [HttpPost]
  16959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16960. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16961. {
  16962. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16963. if (viewData.Code != 0)
  16964. {
  16965. return Ok(JsonView(false, viewData.Msg));
  16966. }
  16967. return Ok(JsonView(viewData.Data));
  16968. }
  16969. /// <summary>
  16970. /// 倒推表
  16971. /// Create
  16972. /// </summary>
  16973. /// <param name="dto"></param>
  16974. /// <returns></returns>
  16975. [HttpPost]
  16976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16977. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16978. {
  16979. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16980. if (viewData.Code != 0)
  16981. {
  16982. return Ok(JsonView(false, viewData.Msg));
  16983. }
  16984. return Ok(JsonView(viewData.Data));
  16985. }
  16986. /// <summary>
  16987. /// 倒推表
  16988. /// Update
  16989. /// </summary>
  16990. /// <param name="dto"></param>
  16991. /// <returns></returns>
  16992. [HttpPost]
  16993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16994. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16995. {
  16996. var viewData = await _invertedListRep._Update(dto);
  16997. if (viewData.Code != 0)
  16998. {
  16999. return Ok(JsonView(false, viewData.Msg));
  17000. }
  17001. return Ok(JsonView(viewData.Data));
  17002. }
  17003. /// <summary>
  17004. /// 倒推表
  17005. /// File Download
  17006. /// </summary>
  17007. /// <param name="dto"></param>
  17008. /// <returns></returns>
  17009. [HttpPost]
  17010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17011. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17012. {
  17013. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17014. if (info2.Code != 0)
  17015. {
  17016. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17017. }
  17018. var info1 = info2.Data as InvertedListInfoView;
  17019. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17020. string teamName = "";
  17021. if (info != null) teamName = info.TeamName;
  17022. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17023. var doc = new Document();
  17024. var builder = new DocumentBuilder(doc);
  17025. #region old insert
  17026. ////载入模板
  17027. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17028. //Document doc = new Document(tempPath);
  17029. //DocumentBuilder builder = new DocumentBuilder(doc);
  17030. //利用键值对存放数据
  17031. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17032. //dic.Add("TeamName", teamName);
  17033. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17034. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17035. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17036. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17037. //dic.Add("SQRemark", info1.ApprovalRemark);
  17038. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17039. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17040. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17041. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17042. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17043. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17044. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17045. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17046. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17047. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17048. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17049. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17050. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17051. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17052. //#region 填充word模板书签内容
  17053. //foreach (var key in dic.Keys)
  17054. //{
  17055. // builder.MoveToBookmark(key);
  17056. // builder.Write(dic[key]);
  17057. //}
  17058. //#endregion
  17059. #endregion
  17060. #region New Insert
  17061. string titleFont = $"仿宋",
  17062. contentFont = $"仿宋";
  17063. var fontColor = Color.FromArgb(64, 64, 64);
  17064. //设置标题 团组名称
  17065. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17066. builder.Font.Name = titleFont;
  17067. builder.Font.Color = fontColor;
  17068. builder.Font.Size = 12;
  17069. builder.Font.Bold = true;
  17070. builder.Writeln(teamName);
  17071. //设置副标题 团组出访时间
  17072. builder.Font.Size = 12;
  17073. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17074. builder.Writeln();
  17075. var backgroundColor = Color.FromArgb(199, 199, 199);
  17076. var table = builder.StartTable();
  17077. builder.InsertCell();
  17078. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17079. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17080. builder.CellFormat.Borders.LineWidth = 1;
  17081. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17082. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17083. builder.RowFormat.Height = 40;
  17084. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17085. builder.Font.Name = contentFont;
  17086. builder.Font.Size = 12;
  17087. builder.Font.Bold = true;
  17088. builder.Font.Color = fontColor;
  17089. builder.Write("时间");
  17090. builder.InsertCell();
  17091. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17092. builder.Write("流程");
  17093. builder.InsertCell();
  17094. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17095. builder.Write("说明");
  17096. builder.EndRow();
  17097. //报批资料准备
  17098. if (info1.IsSelectedAirportd)
  17099. {
  17100. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17101. }
  17102. //报批/提供送签资料
  17103. if (info1.IsSelectedApprovalData)
  17104. {
  17105. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17106. }
  17107. //出批件护照办理
  17108. if (info1.IsSelectedIssueApproval)
  17109. {
  17110. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17111. }
  17112. //签证资料准备
  17113. if (info1.IsSelectedVisaInfo)
  17114. {
  17115. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17116. }
  17117. //送签
  17118. if (info1.IsSelectedSendVisa)
  17119. {
  17120. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17121. }
  17122. //出签
  17123. if (info1.IsSelectedIssueVisa)
  17124. {
  17125. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17126. }
  17127. //机票
  17128. if (info1.IsSelectedAirTicket)
  17129. {
  17130. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17131. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17132. }
  17133. //酒店
  17134. if (info1.IsSelectedHotel)
  17135. {
  17136. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17137. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17138. }
  17139. //开行前会
  17140. if (info1.IsSelectedPreTripMeeting)
  17141. {
  17142. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17143. }
  17144. //送机
  17145. if (info1.IsSelectedAirportdDropOff)
  17146. {
  17147. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17148. }
  17149. builder.EndTable();
  17150. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17151. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17152. for (int i = 0; i < table.Rows.Count; i++)
  17153. {
  17154. var row = table.Rows[i];
  17155. //设置宽度
  17156. row.Cells[0].CellFormat.Width = 20.00;
  17157. row.Cells[1].CellFormat.Width = 30.00;
  17158. row.Cells[2].CellFormat.Width = 50.00;
  17159. if (i != 0)
  17160. {
  17161. //边框设置
  17162. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17163. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17164. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17165. }
  17166. }
  17167. #region 页脚插入图片
  17168. // 创建页脚
  17169. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17170. doc.FirstSection.HeadersFooters.Add(footer);
  17171. Paragraph para = new Paragraph(doc);
  17172. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17173. footer.AppendChild(para);
  17174. builder.MoveTo(para);
  17175. string imagePath = "./Images/FMGJ_Log.png";
  17176. builder.InsertImage(imagePath);
  17177. #endregion
  17178. #endregion
  17179. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17180. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17181. string filePath = fileDir + $@"InvertedList/{fileName}";
  17182. doc.Save(filePath);
  17183. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17184. return Ok(JsonView(true, "操作成功!", Url));
  17185. }
  17186. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  17187. {
  17188. var fontColor = Color.FromArgb(64, 64, 64);
  17189. builder.InsertCell();
  17190. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17191. builder.RowFormat.Height = 40;
  17192. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17193. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17194. builder.Font.Name = fontName;
  17195. builder.Font.Size = 8;
  17196. builder.Font.Bold = true;
  17197. builder.Font.Color = fontColor;
  17198. builder.Write(dateTime);
  17199. builder.InsertCell();
  17200. builder.Font.Size = 9;
  17201. builder.Font.Bold = true;
  17202. builder.Font.Color = fontColor;
  17203. builder.Write(content);
  17204. builder.InsertCell();
  17205. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17206. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17207. builder.Font.Size = 9;
  17208. builder.Font.Bold = false;
  17209. builder.Font.Color = fontColor;
  17210. builder.Write(reamrk);
  17211. builder.EndRow();
  17212. }
  17213. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  17214. {
  17215. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17216. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17217. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17218. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17219. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17220. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17221. }
  17222. #endregion
  17223. #region 会务倒推表
  17224. /// <summary>
  17225. /// 会务倒推表
  17226. /// Init
  17227. /// </summary>
  17228. /// <returns></returns>
  17229. [HttpPost]
  17230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17231. public async Task<IActionResult> InforRetrogressTableInit()
  17232. {
  17233. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17234. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17235. return Ok(JsonView(false, groupData.Msg));
  17236. }
  17237. /// <summary>
  17238. /// 会务倒推表
  17239. /// ExcelDownload
  17240. /// </summary>
  17241. /// <param name="dto"></param>
  17242. /// <returns></returns>
  17243. [HttpPost]
  17244. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17246. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17247. {
  17248. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17249. var validatorRes = await validator.ValidateAsync(dto);
  17250. if (!validatorRes.IsValid)
  17251. {
  17252. StringBuilder sb = new StringBuilder();
  17253. foreach (var item in validatorRes.Errors)
  17254. {
  17255. sb.AppendLine(item.ErrorMessage);
  17256. }
  17257. return Ok(JsonView(false, sb.ToString()));
  17258. }
  17259. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17260. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17261. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17262. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17263. #region Excel
  17264. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17265. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17266. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17267. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17268. var fileNamePrefix = string.Empty;
  17269. if (days >= 30)
  17270. {
  17271. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17272. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17273. }
  17274. else if (days < 30 && days > 7)
  17275. {
  17276. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17277. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17278. }
  17279. else if (days <= 7)
  17280. {
  17281. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17282. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17283. }
  17284. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17285. fileName = CommonFun.ValidFileName(fileName);
  17286. //载入模板
  17287. WorkbookDesigner designer = new WorkbookDesigner();
  17288. designer.Workbook = new Workbook(tempPath);
  17289. designer.Process();
  17290. if (!Directory.Exists(savePath))
  17291. {
  17292. Directory.CreateDirectory(savePath);
  17293. }
  17294. string serverPath = $"{savePath}{fileName}";
  17295. designer.Workbook.Save(serverPath);
  17296. string rst = $"{servicePath}{ftpPath}{fileName}";
  17297. #endregion
  17298. return Ok(JsonView(new { url = rst }));
  17299. }
  17300. #endregion
  17301. #region 三公签证费用(签证费、代办费)
  17302. /// <summary>
  17303. /// 三公签证费用(签证费、代办费)
  17304. /// List
  17305. /// </summary>
  17306. /// <returns></returns>
  17307. [HttpPost]
  17308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17309. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17310. {
  17311. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17312. if (_view.Code != 0)
  17313. {
  17314. return Ok(JsonView(false, _view.Msg));
  17315. }
  17316. return Ok(JsonView(true, "操作成功!", _view.Data));
  17317. }
  17318. /// <summary>
  17319. /// 三公签证费用(签证费、代办费)
  17320. /// Add Or Update
  17321. /// </summary>
  17322. /// <returns></returns>
  17323. [HttpPost]
  17324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17325. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17326. {
  17327. var _view = await _visaFeeInfoRep._Update(_dto);
  17328. if (_view.Code != 0)
  17329. {
  17330. return Ok(JsonView(false, _view.Msg));
  17331. }
  17332. return Ok(JsonView(true, _view.Msg));
  17333. }
  17334. #endregion
  17335. #region 酒店询价
  17336. /// <summary>
  17337. /// 酒店询价
  17338. /// Init
  17339. /// </summary>
  17340. /// <returns></returns>
  17341. [HttpPost]
  17342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17343. public async Task<IActionResult> PostHotelInquiryInit()
  17344. {
  17345. var res = await _hotelInquiryRep._Init();
  17346. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17347. return Ok(JsonView(true, res.Msg, res.Data));
  17348. }
  17349. /// <summary>
  17350. /// 酒店询价
  17351. /// page Item
  17352. /// </summary>
  17353. /// <param name="_dto"></param>
  17354. /// <returns></returns>
  17355. [HttpPost]
  17356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17357. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17358. {
  17359. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17360. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17361. var view = res.Data as PageDataViewBase;
  17362. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17363. }
  17364. /// <summary>
  17365. /// 酒店询价
  17366. /// info
  17367. /// </summary>
  17368. /// <param name="_dto"></param>
  17369. /// <returns></returns>
  17370. [HttpPost]
  17371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17372. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17373. {
  17374. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17375. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17376. return Ok(JsonView(true, res.Msg, res.Data));
  17377. }
  17378. /// <summary>
  17379. /// 酒店询价
  17380. /// Add Or Edit
  17381. /// </summary>
  17382. /// <param name="_dto"></param>
  17383. /// <returns></returns>
  17384. [HttpPost]
  17385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17386. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17387. {
  17388. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17389. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17390. return Ok(JsonView(true, res.Msg, res.Data));
  17391. }
  17392. /// <summary>
  17393. /// 酒店询价
  17394. /// Del
  17395. /// </summary>
  17396. /// <param name="_dto"></param>
  17397. /// <returns></returns>
  17398. [HttpPost]
  17399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17400. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17401. {
  17402. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17403. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17404. return Ok(JsonView(true, res.Msg, res.Data));
  17405. }
  17406. #endregion
  17407. #region 下载匹配op行程单
  17408. /// <summary>
  17409. /// 匹配op行程单
  17410. /// Init
  17411. /// </summary>
  17412. /// <param name="dto">团组列表请求dto</param>
  17413. /// <returns></returns>
  17414. [HttpPost]
  17415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17416. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17417. {
  17418. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17419. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17420. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17421. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17422. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17423. .Where(it => it.IsDel == 0)
  17424. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17425. .OrderByDescending(it => it.VisitStartDate)
  17426. .ToList();
  17427. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17428. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17429. var diids = groupInfos.Select(it => it.Id).ToList();
  17430. List<string> countrys = new List<string>();
  17431. foreach (var item in country)
  17432. {
  17433. var data = _groupRepository.FormartTeamName(item);
  17434. var dataArray = _groupRepository.GroupSplitCountry(data);
  17435. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17436. }
  17437. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17438. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17439. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17440. foreach (var item in areaItem)
  17441. {
  17442. string areaStr = item.Value;
  17443. if (!string.IsNullOrEmpty(areaStr))
  17444. {
  17445. string[] str1 = areaStr.Split("-");
  17446. if (str1.Length > 0)
  17447. {
  17448. areaArray.AddRange(str1);
  17449. }
  17450. }
  17451. }
  17452. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17453. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17454. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17455. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17456. .ToList();
  17457. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17458. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17459. .Where(it => countriesIds.Contains(it.Id))
  17460. .Select(it => new { it.Id, Name = it.Name_CN })
  17461. .ToList();
  17462. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17463. .Select(it => it.TeamName).ToList();
  17464. stopwatch.Stop();
  17465. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17466. }
  17467. ///// <summary>
  17468. ///// 匹配op行程单
  17469. ///// Init 查询区域数据
  17470. ///// </summary>
  17471. ///// <param name="dto">团组列表请求dto</param>
  17472. ///// <returns></returns>
  17473. //[HttpPost]
  17474. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17475. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17476. //{
  17477. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17478. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17479. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17480. // if (string.IsNullOrEmpty(countriesDataStr))
  17481. // {
  17482. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17483. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17484. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17485. // }
  17486. // else
  17487. // {
  17488. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17489. // }
  17490. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17491. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17492. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17493. // List<dynamic> childList = new List<dynamic>();
  17494. // int parentId = dto.CountriesId;
  17495. // if (provinceData.Count > 1)
  17496. // {
  17497. // foreach (var item1 in provinceData)
  17498. // {
  17499. // List<dynamic> childList1 = new List<dynamic>();
  17500. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17501. // foreach (var item2 in citiesData1)
  17502. // {
  17503. // List<dynamic> childList2 = new List<dynamic>();
  17504. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17505. // foreach (var item3 in countiesData1)
  17506. // {
  17507. // childList2.Add(new
  17508. // {
  17509. // id = item3.Id,
  17510. // parentId = item2.Id,
  17511. // level = "district",
  17512. // name = item3.Name_CN,
  17513. // });
  17514. // }
  17515. // childList1.Add(new
  17516. // {
  17517. // id = item2.Id,
  17518. // parentId = item1.Id,
  17519. // level = "city",
  17520. // name = item2.Name_CN,
  17521. // childList = childList2
  17522. // });
  17523. // }
  17524. // childList.Add(new
  17525. // {
  17526. // id = item1.Id,
  17527. // parentId = parentId,
  17528. // level = "province",
  17529. // name = item1.Name_CN,
  17530. // childList = childList1
  17531. // });
  17532. // }
  17533. // //城市
  17534. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17535. // foreach (var item2 in citiesData2)
  17536. // {
  17537. // List<dynamic> childList22 = new List<dynamic>();
  17538. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17539. // foreach (var item3 in countiesData1)
  17540. // {
  17541. // childList22.Add(new
  17542. // {
  17543. // id = item3.Id,
  17544. // parentId = item2.Id,
  17545. // level = "district",
  17546. // name = item3.Name_CN,
  17547. // });
  17548. // }
  17549. // childList.Add(new
  17550. // {
  17551. // id = item2.Id,
  17552. // parentId = parentId,
  17553. // level = "city",
  17554. // name = item2.Name_CN,
  17555. // childList = childList22
  17556. // });
  17557. // }
  17558. // }
  17559. // else
  17560. // {
  17561. // foreach (var item2 in citiesData)
  17562. // {
  17563. // string cname = item2.Name_CN;
  17564. // List<dynamic> childList1 = new List<dynamic>();
  17565. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17566. // foreach (var item3 in countiesData1)
  17567. // {
  17568. // childList1.Add(new
  17569. // {
  17570. // Id = item3.Id,
  17571. // parentId = item2.Id,
  17572. // level = "district",
  17573. // name = item3.Name_CN
  17574. // });
  17575. // }
  17576. // childList.Add(new
  17577. // {
  17578. // id = item2.Id,
  17579. // parentId = parentId,
  17580. // level = "city",
  17581. // name = item2.Name_CN,
  17582. // childList = childList1
  17583. // });
  17584. // }
  17585. // }
  17586. // stopwatch.Stop();
  17587. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17588. //}
  17589. /// <summary>
  17590. /// 匹配op行程单
  17591. /// 接团信息列表 Page
  17592. /// </summary>
  17593. /// <param name="dto">团组列表请求dto</param>
  17594. /// <returns></returns>
  17595. [HttpPost]
  17596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17597. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17598. {
  17599. var swatch = new Stopwatch();
  17600. swatch.Start();
  17601. #region 参数验证
  17602. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17603. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17604. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17605. #region 页面操作权限验证
  17606. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17607. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17608. #endregion
  17609. #endregion
  17610. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17611. {
  17612. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17613. //string sqlWhere = "";
  17614. if (!string.IsNullOrEmpty(dto.Country))
  17615. {
  17616. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17617. }
  17618. if (!string.IsNullOrEmpty(dto.Area))
  17619. {
  17620. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17621. }
  17622. if (!string.IsNullOrEmpty(dto.TeamName))
  17623. {
  17624. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17625. }
  17626. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17627. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17628. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17629. swatch.Stop();
  17630. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17631. }
  17632. else
  17633. {
  17634. return Ok(JsonView(false, "查询失败"));
  17635. }
  17636. }
  17637. /// <summary>
  17638. /// 匹配op行程单
  17639. /// 行程单下载
  17640. /// </summary>
  17641. /// <param name="dto">团组列表请求dto</param>
  17642. /// <returns></returns>
  17643. [HttpPost]
  17644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17645. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17646. {
  17647. #region 参数验证
  17648. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17649. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17650. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17651. #region 页面操作权限验证
  17652. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17653. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17654. #endregion
  17655. #endregion
  17656. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17657. {
  17658. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17659. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17660. }
  17661. else
  17662. {
  17663. return Ok(JsonView(false, "下载失败!"));
  17664. }
  17665. }
  17666. #endregion
  17667. #region 国家信息 数据 注释
  17668. //[HttpPost]
  17669. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17670. //{
  17671. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17672. // foreach (var item in dto)
  17673. // {
  17674. // infos.Add(new Grp_GroupsTaskAssignment()
  17675. // {
  17676. // DIId = item,
  17677. // CTId = 82,
  17678. // UId = 248,
  17679. // IsEnable = 1,
  17680. // CreateUserId = 233,
  17681. // CreateTime = DateTime.Now,
  17682. // IsDel = 0
  17683. // });
  17684. // infos.Add(new Grp_GroupsTaskAssignment()
  17685. // {
  17686. // DIId = item,
  17687. // CTId = 82,
  17688. // UId = 286,
  17689. // IsEnable = 1,
  17690. // CreateUserId = 233,
  17691. // CreateTime = DateTime.Now,
  17692. // IsDel = 0
  17693. // });
  17694. // }
  17695. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17696. // return Ok("操作成功");
  17697. //}
  17698. //public class paramJsonDto
  17699. //{
  17700. // public List<CountriesInfo> str { get; set; }
  17701. //}
  17702. //[HttpPost]
  17703. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17704. //{
  17705. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17706. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17707. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17708. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17709. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17710. // _sqlSugar.BeginTran();
  17711. // int countitiesIndex = 0;
  17712. // foreach (var item in dto.str)
  17713. // {
  17714. // dynamic data = item.c;
  17715. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17716. // if (data != null)
  17717. // {
  17718. // countitiesIndex++;
  17719. // foreach (var item1 in data)
  17720. // {
  17721. // string cnname = item1.cn;
  17722. // string enname = item1.en;
  17723. // Sys_Cities provinceInfo = new Sys_Cities()
  17724. // {
  17725. // CountriesId = countriesId,
  17726. // Name_CN = cnname,
  17727. // Name_EN = enname,
  17728. // ParentId = 0,
  17729. // IsCapital = 1,
  17730. // CreateUserId = 208,
  17731. // CreateTime = DateTime.Now,
  17732. // IsDel = 0
  17733. // };
  17734. // if (item1.lv == "province") //省份
  17735. // {
  17736. // provinceInfo.Level = 1;
  17737. // int provinceId = 0;
  17738. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17739. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17740. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17741. // var data1 = item1.c;
  17742. // foreach (var item2 in data1)
  17743. // {
  17744. // if (item2.lv == "city")
  17745. // {
  17746. // string citycnname = item2.cn;
  17747. // string cityenname = item2.en;
  17748. // Sys_Cities cityInfo = new Sys_Cities()
  17749. // {
  17750. // CountriesId = countriesId,
  17751. // ParentId = provinceId,
  17752. // Level = 2,
  17753. // Name_CN = citycnname,
  17754. // Name_EN = cityenname,
  17755. // IsCapital = 1,
  17756. // CreateUserId = 208,
  17757. // CreateTime = DateTime.Now,
  17758. // IsDel = 0
  17759. // };
  17760. // if (item2.c != null)
  17761. // {
  17762. // int cityId = 0;
  17763. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17764. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17765. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17766. // foreach (var item3 in item2.c)
  17767. // {
  17768. // if (item3.lv == "district")
  17769. // {
  17770. // var districtInfo = new Sys_Cities()
  17771. // {
  17772. // CountriesId = countriesId,
  17773. // Name_CN = item3.cn,
  17774. // Name_EN = item3.en,
  17775. // Level = 3,
  17776. // ParentId = cityId,
  17777. // IsCapital = 1,
  17778. // CreateUserId = 208,
  17779. // CreateTime = DateTime.Now,
  17780. // IsDel = 0
  17781. // };
  17782. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17783. // //{
  17784. // districts.Add(districtInfo);
  17785. // //}
  17786. // }
  17787. // }
  17788. // }
  17789. // else
  17790. // {
  17791. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17792. // //{
  17793. // cities.Add(cityInfo);
  17794. // //}
  17795. // }
  17796. // }
  17797. // }
  17798. // }
  17799. // else if (item1.lv == "city")//城市
  17800. // {
  17801. // provinceInfo.Level = 2;
  17802. // if (item1.c != null)
  17803. // {
  17804. // int cityId = 0;
  17805. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17806. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17807. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17808. // foreach (var item3 in item1.c)
  17809. // {
  17810. // if (item3.lv == "district")
  17811. // {
  17812. // var districtInfo = new Sys_Cities()
  17813. // {
  17814. // CountriesId = countriesId,
  17815. // Name_CN = item3.cn,
  17816. // Name_EN = item3.en,
  17817. // Level = 3,
  17818. // ParentId = cityId,
  17819. // IsCapital = 1,
  17820. // CreateUserId = 208,
  17821. // CreateTime = DateTime.Now,
  17822. // IsDel = 0
  17823. // };
  17824. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17825. // //{
  17826. // districts.Add(districtInfo);
  17827. // //}
  17828. // }
  17829. // }
  17830. // }
  17831. // else
  17832. // {
  17833. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17834. // //{
  17835. // cities.Add(provinceInfo);
  17836. // //}
  17837. // }
  17838. // }
  17839. // }
  17840. // }
  17841. // }
  17842. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17843. // cities = cities.Distinct().ToList();
  17844. // districts = districts.Distinct().ToList();
  17845. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17846. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17847. // cities.AddRange(districts);
  17848. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17849. // //_sqlSugar.RollbackTran();
  17850. // _sqlSugar.CommitTran();
  17851. // return Ok(JsonView(false, "操作成功!"));
  17852. //}
  17853. //[HttpPost]
  17854. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17855. //{
  17856. // List<CountitiesInfo> infos = dto.MyProperty;
  17857. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17858. // _sqlSugar.BeginTran();
  17859. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17860. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17861. // foreach (var item in infos)
  17862. // {
  17863. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17864. // if (countryInfo != null)
  17865. // {
  17866. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17867. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17868. // if (cityInfo1 != null)
  17869. // {
  17870. // cityInfo1.IsCapital = 0;
  17871. // cityInfos.Add(cityInfo1);
  17872. // }
  17873. // }
  17874. // }
  17875. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17876. // .UpdateColumns(it => it.IsCapital)
  17877. // .WhereColumns(it => it.Id)
  17878. // .ExecuteCommand();
  17879. // //_sqlSugar.RollbackTran();
  17880. // _sqlSugar.CommitTran();
  17881. // return Ok(JsonView(false, "操作成功!"));
  17882. //}
  17883. //public class CounrtiesDto
  17884. //{
  17885. // public List<CountitiesInfo> MyProperty { get; set; }
  17886. //}
  17887. //public class CountitiesInfo
  17888. //{
  17889. // /// <summary>
  17890. // /// 圣约翰
  17891. // /// </summary>
  17892. // public string capital_name_chinese { get; set; }
  17893. // /// <summary>
  17894. // ///
  17895. // /// </summary>
  17896. // public string capital_name { get; set; }
  17897. // /// <summary>
  17898. // ///
  17899. // /// </summary>
  17900. // public string country_type { get; set; }
  17901. // /// <summary>
  17902. // /// 安提瓜和巴布达
  17903. // /// </summary>
  17904. // public string country_name_chinese { get; set; }
  17905. // /// <summary>
  17906. // /// 安提瓜和巴布达
  17907. // /// </summary>
  17908. // public string country_name_chinese_short { get; set; }
  17909. // /// <summary>
  17910. // /// 安提瓜和巴布达
  17911. // /// </summary>
  17912. // public string country_name_chinese_UN { get; set; }
  17913. // /// <summary>
  17914. // ///
  17915. // /// </summary>
  17916. // public string country_name_english_abbreviation { get; set; }
  17917. // /// <summary>
  17918. // ///
  17919. // /// </summary>
  17920. // public string country_name_english_formal { get; set; }
  17921. // /// <summary>
  17922. // ///
  17923. // /// </summary>
  17924. // public string country_name_english_UN { get; set; }
  17925. // /// <summary>
  17926. // ///
  17927. // /// </summary>
  17928. // public string continent_name { get; set; }
  17929. // /// <summary>
  17930. // ///
  17931. // /// </summary>
  17932. // public string subregion_name { get; set; }
  17933. // /// <summary>
  17934. // ///
  17935. // /// </summary>
  17936. // public string country_code2 { get; set; }
  17937. // /// <summary>
  17938. // ///
  17939. // /// </summary>
  17940. // public string country_code3 { get; set; }
  17941. // /// <summary>
  17942. // ///
  17943. // /// </summary>
  17944. // public string phone_code { get; set; }
  17945. //}
  17946. //public class CountriesInfo : BasicInfo
  17947. //{
  17948. // public List<CitiesInfo> c { get; set; }
  17949. //}
  17950. //public class CitiesInfo : BasicInfo
  17951. //{
  17952. // public List<AreaInfo> c { get; set; }
  17953. //}
  17954. //public class AreaInfo : BasicInfo
  17955. //{
  17956. // public List<AreaInfo> c { get; set; }
  17957. //}
  17958. //public class BasicInfo
  17959. //{
  17960. // public string code { get; set; }
  17961. // public string cn { get; set; }
  17962. // public string lv { get; set; }
  17963. // public string en { get; set; }
  17964. //}
  17965. #endregion
  17966. #region 查看邀请方
  17967. /// <summary>
  17968. /// 查看邀请方
  17969. /// 邀请方信息 Init
  17970. /// </summary>
  17971. /// <param name="dto"></param>
  17972. /// <returns></returns>
  17973. [HttpPost]
  17974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17975. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17976. {
  17977. string sqlWhere = string.Empty;
  17978. if (!string.IsNullOrEmpty(dto.Search))
  17979. {
  17980. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17981. }
  17982. string sql = string.Format($@"Select
  17983. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17984. Id,
  17985. UnitName
  17986. From Res_InvitationOfficialActivityData
  17987. Where IsDel = 0
  17988. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17989. RefAsync<int> total = 0;
  17990. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17991. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17992. }
  17993. /// <summary>
  17994. /// 查看邀请方
  17995. /// 国家信息 Init
  17996. /// </summary>
  17997. /// <param name="dto"></param>
  17998. /// <returns></returns>
  17999. [HttpPost]
  18000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18001. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18002. {
  18003. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18004. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18005. var diids = groupInfos.Select(it => it.Id).ToList();
  18006. List<string> countrys = new List<string>();
  18007. foreach (var item in country)
  18008. {
  18009. var data = _groupRepository.FormartTeamName(item);
  18010. var dataArray = _groupRepository.GroupSplitCountry(data);
  18011. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18012. }
  18013. countrys = countrys.Distinct().ToList();
  18014. for (int i = 0; i < countrys.Count; i++)
  18015. {
  18016. string item = countrys[i];
  18017. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18018. {
  18019. countrys.Remove(item);
  18020. i--;
  18021. }
  18022. }
  18023. RefAsync<int> total = 0;
  18024. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18025. .Where(it => countrys.Contains(it.Name_CN))
  18026. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18027. .Select(it => new { id = it.Id, name = it.Name_CN })
  18028. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18029. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18030. }
  18031. /// <summary>
  18032. /// 查看邀请方
  18033. /// 城市信息 Init
  18034. /// </summary>
  18035. /// <param name="dto"></param>
  18036. /// <returns></returns>
  18037. [HttpPost]
  18038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18039. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18040. {
  18041. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18042. RefAsync<int> total = 0;
  18043. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18044. .Where(it => it.CountriesId == dto.CountiesId)
  18045. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18046. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18047. .Select(it => new { id = it.Id, name = it.Name_CN })
  18048. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18049. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18050. }
  18051. /// <summary>
  18052. /// 查看邀请方
  18053. /// 团组名称 Init
  18054. /// </summary>
  18055. /// <param name="dto"></param>
  18056. /// <returns></returns>
  18057. [HttpPost]
  18058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18059. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18060. {
  18061. var watch = new Stopwatch();
  18062. watch.Start();
  18063. RefAsync<int> total = 0;
  18064. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18065. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18066. .Where((oa, di) => oa.IsDel == 0)
  18067. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18068. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18069. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18070. .Distinct()
  18071. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18072. watch.Stop();
  18073. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18074. }
  18075. /// <summary>
  18076. /// 查看邀请方
  18077. /// 团组 & 邀请方信息
  18078. /// </summary>
  18079. /// <param name="dto"></param>
  18080. /// <returns></returns>
  18081. [HttpPost]
  18082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18083. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18084. {
  18085. var watch = new Stopwatch();
  18086. watch.Start();
  18087. RefAsync<int> total = 0;
  18088. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18089. .AS("Grp_DelegationInfo")
  18090. .Includes(x => x.InvitingInfos)
  18091. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18092. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18093. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18094. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18095. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18096. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18097. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18098. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18099. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18100. infos.ForEach(x =>
  18101. {
  18102. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18103. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18104. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18105. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18106. });
  18107. watch.Stop();
  18108. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18109. }
  18110. #endregion
  18111. #region 报批行程
  18112. /// <summary>
  18113. /// 报批行程初始化
  18114. /// </summary>
  18115. /// <param name="dto"></param>
  18116. /// <returns></returns>
  18117. [HttpPost]
  18118. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18119. {
  18120. const int chiNumber = 5;
  18121. var jw = JsonView(false);
  18122. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18123. var group = groupList.First();
  18124. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18125. group = groupList.First(x => x.Id == diid);
  18126. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18127. .Where(x => x.DiId == diid && x.IsDel == 0)
  18128. .ToArray();
  18129. var count = 1;
  18130. foreach (var item in blackCodeList)
  18131. {
  18132. if (string.IsNullOrWhiteSpace(item.Title))
  18133. {
  18134. item.Title = "未设置名称数据" + count;
  18135. }
  18136. count++;
  18137. };
  18138. if (group == null)
  18139. {
  18140. jw.Msg = "暂无团组!";
  18141. return Ok(jw);
  18142. }
  18143. var data = new
  18144. {
  18145. groupList = groupList.Select(x => new
  18146. {
  18147. x.TeamName,
  18148. x.Id
  18149. }),
  18150. content = new ArrayList(),
  18151. groupInfo = new
  18152. {
  18153. group.VisitDays,
  18154. group.TourCode,
  18155. group.VisitPNumber,
  18156. group.TeamName,
  18157. group.Id,
  18158. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18159. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18160. },
  18161. blackCodeList = blackCodeList.Select(x => new
  18162. {
  18163. x.Title,
  18164. x.Id
  18165. }),
  18166. FileTempList = new ArrayList()
  18167. {
  18168. new { Index = 1,FileName = "旧模板" },
  18169. new { Index = 2,FileName = "省外办" },
  18170. new { Index = 3,FileName = "市外办" },
  18171. }
  18172. };
  18173. var resultArr = new ArrayList();
  18174. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18175. #region 默认不生成行程
  18176. //if (content.Count == 0)
  18177. //{
  18178. // var stay = "-";
  18179. // var cityPath = "-";
  18180. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18181. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18182. // .ToList();
  18183. // //添加城市路径以及住宿地
  18184. // //黑屏代码数据
  18185. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18186. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18187. // {
  18188. // jw = JsonView(true, "黑屏代码有误!", data);
  18189. // return Ok(jw);
  18190. // }
  18191. // data = data with
  18192. // {
  18193. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18194. // {
  18195. // x.Title,
  18196. // x.Id,
  18197. // }).ToArray())
  18198. // };
  18199. // foreach (DataRow row in dtBlack.Rows)
  18200. // {
  18201. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18202. // {
  18203. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18204. // return Ok(jw);
  18205. // }
  18206. // }
  18207. // //黑屏代码获取时间区间
  18208. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18209. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18210. // _sqlSugar.BeginTran();
  18211. // for (int i = 0; i < timeArr.Count; i++)
  18212. // {
  18213. // stay = "-";
  18214. // cityPath = "-";
  18215. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18216. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18217. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18218. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18219. // if (tbSelect.Length > 0)
  18220. // {
  18221. // List<string> threeCodeStr = new List<string>();
  18222. // foreach (var item in tbSelect)
  18223. // {
  18224. // var threeCode = item["Three"].ToString() ?? "";
  18225. // if (threeCode.Length == 6)
  18226. // {
  18227. // var start = threeCode.Substring(0, 3);
  18228. // var end = threeCode.Substring(3, 3);
  18229. // if (threeCodeStr.Count == 0)
  18230. // {
  18231. // threeCodeStr.Add(start);
  18232. // threeCodeStr.Add(end);
  18233. // }
  18234. // else
  18235. // {
  18236. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18237. // {
  18238. // threeCodeStr.Add(end);
  18239. // }
  18240. // else
  18241. // {
  18242. // threeCodeStr.Add(start);
  18243. // threeCodeStr.Add(end);
  18244. // }
  18245. // }
  18246. // }
  18247. // }
  18248. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18249. // var last = threeCodeStr.Last();
  18250. // foreach (var item in threeCodeStr)
  18251. // {
  18252. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18253. // if (item.Equals(last))
  18254. // {
  18255. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18256. // }
  18257. // }
  18258. // cityPath = cityPath.Trim('-');
  18259. // }
  18260. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18261. // appro.Diid = diid ?? -1;
  18262. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18263. // appro.Id = thisId;
  18264. // appro.CreateUserId = dto.UserId;
  18265. // appro.CreateTime = DateTime.Now;
  18266. // content.Add(appro);
  18267. // }
  18268. // _sqlSugar.CommitTran();
  18269. //}
  18270. #endregion
  18271. foreach (var x in content)
  18272. {
  18273. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18274. if (chiList.Count < chiNumber)
  18275. {
  18276. for (int i = chiList.Count; i < chiNumber; i++)
  18277. {
  18278. chiList.Add(new Grp_ApprovalTravelDetails());
  18279. }
  18280. }
  18281. resultArr.Add(new
  18282. {
  18283. x.Id,
  18284. x.Date,
  18285. x.Diid,
  18286. chiList = chiList.Select(x1 => new
  18287. {
  18288. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18289. x1.Details,
  18290. x1.ParentId,
  18291. x1.Id
  18292. })
  18293. });
  18294. }
  18295. data = data with
  18296. {
  18297. content = resultArr,
  18298. };
  18299. jw = JsonView(true, "获取成功!", data);
  18300. return Ok(jw);
  18301. }
  18302. /// <summary>
  18303. /// 报批行程删除
  18304. /// </summary>
  18305. /// <param name="dto"></param>
  18306. /// <returns></returns>
  18307. [HttpPost]
  18308. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18309. {
  18310. var jw = JsonView(false);
  18311. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18312. if (group == null)
  18313. {
  18314. jw.Msg = "团组参数有误!";
  18315. return Ok(jw);
  18316. }
  18317. try
  18318. {
  18319. _sqlSugar.BeginTran();
  18320. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18321. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18322. {
  18323. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18324. DeleteUserId = dto.uesrId,
  18325. IsDel = 1
  18326. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18327. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18328. {
  18329. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18330. DeleteUserId = dto.uesrId,
  18331. IsDel = 1
  18332. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18333. _sqlSugar.CommitTran();
  18334. jw = JsonView(true, "删除成功");
  18335. }
  18336. catch (Exception ex)
  18337. {
  18338. jw = JsonView(false, ex.Message);
  18339. }
  18340. return Ok(jw);
  18341. }
  18342. /// <summary>
  18343. /// 报批行程保存
  18344. /// </summary>
  18345. /// <param name="dto"></param>
  18346. /// <returns></returns>
  18347. [HttpPost]
  18348. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18349. {
  18350. var jw = JsonView(false);
  18351. var Find = dto.Arr.Find(x => x.id == 0);
  18352. if (Find != null)
  18353. {
  18354. jw.Msg = "生成的ID为0!";
  18355. return Ok(jw);
  18356. }
  18357. foreach (var item in dto.Arr)
  18358. {
  18359. foreach (var chi in item.chiList)
  18360. {
  18361. if (chi.parentId == 0)
  18362. {
  18363. chi.parentId = item.id;
  18364. }
  18365. }
  18366. }
  18367. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18368. _sqlSugar.BeginTran();
  18369. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18370. {
  18371. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18372. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18373. {
  18374. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18375. DeleteUserId = dto.UserId,
  18376. IsDel = 1
  18377. }).ExecuteCommand();
  18378. }
  18379. try
  18380. {
  18381. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18382. {
  18383. CreateTime = DateTime.Now,
  18384. CreateUserId = dto.UserId,
  18385. Details = x.details,
  18386. ParentId = x.parentId,
  18387. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18388. Remark = "",
  18389. IsDel = 0
  18390. }).ToList()).ExecuteCommand();
  18391. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18392. {
  18393. Id = x.id,
  18394. Details = x.details,
  18395. ParentId = x.parentId,
  18396. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18397. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18398. {
  18399. Details = x.Details,
  18400. ParentId = x.ParentId,
  18401. Time = x.Time
  18402. }).ExecuteCommand();
  18403. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18404. {
  18405. Id = x.id,
  18406. Date = x.date,
  18407. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18408. {
  18409. Date = x.Date
  18410. }).ExecuteCommand();
  18411. _sqlSugar.CommitTran();
  18412. jw = JsonView(true, "保存成功!");
  18413. }
  18414. catch (Exception ex)
  18415. {
  18416. _sqlSugar.RollbackTran();
  18417. jw = JsonView(false, "保存失败!" + ex.Message);
  18418. }
  18419. return Ok(jw);
  18420. }
  18421. /// <summary>
  18422. /// 报批行程生成
  18423. /// </summary>
  18424. /// <param name="dto"></param>
  18425. /// <returns></returns>
  18426. [HttpPost]
  18427. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18428. {
  18429. var jw = JsonView(false);
  18430. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18431. if (group == null)
  18432. {
  18433. jw.Msg = "暂无该团组!";
  18434. return Ok(jw);
  18435. }
  18436. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18437. //黑屏代码数据
  18438. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18439. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18440. {
  18441. jw.Msg = "黑屏代码有误!";
  18442. return Ok(jw);
  18443. }
  18444. foreach (DataRow row in dtBlack.Rows)
  18445. {
  18446. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18447. {
  18448. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18449. return Ok(jw);
  18450. }
  18451. }
  18452. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18453. var resultArr = new ArrayList();
  18454. //if (officialActivitiesArr.Count == 0)
  18455. //{
  18456. // jw.Msg = "暂无公务出访信息!";
  18457. // return Ok(jw);
  18458. //}
  18459. try
  18460. {
  18461. _sqlSugar.BeginTran();
  18462. DeleteApprovalJourney(new
  18463. Domain.Dtos.Groups.DeleteApprovalJourney
  18464. {
  18465. Diid = dto.Diid,
  18466. uesrId = dto.Userid
  18467. });
  18468. var stay = "-";
  18469. var cityPath = "-";
  18470. //添加城市路径以及住宿地
  18471. //黑屏代码获取时间区间
  18472. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18473. var empty = "【未收入该三字码!请机票同事录入】";
  18474. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18475. for (int i = 0; i < timeArr.Count; i++)
  18476. {
  18477. stay = "-";
  18478. cityPath = "-";
  18479. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18480. DateTime NewData = DateTime.Parse(timeArr[i]);
  18481. //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();
  18482. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18483. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18484. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18485. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18486. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18487. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18488. if (tbSelect.Length > 0)
  18489. {
  18490. List<string> threeCodeStr = new List<string>();
  18491. bool isTrade = false;
  18492. string trip = string.Empty;
  18493. var rowLast = tbSelect.Last();
  18494. var rowFirst = tbSelect.First();
  18495. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18496. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18497. var takeOffTime = DateTime.Parse(timeArr[i]);
  18498. var fallToTime = DateTime.Parse(timeArr[i]);
  18499. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18500. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18501. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18502. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18503. foreach (var item in tbSelect)
  18504. {
  18505. var start = string.Empty;
  18506. var end = string.Empty;
  18507. var threeCode = item["Three"].ToString() ?? "";
  18508. if (threeCode.Length == 6)
  18509. {
  18510. start = threeCode.Substring(0, 3);
  18511. end = threeCode.Substring(3, 3);
  18512. if (threeCodeStr.Count == 0)
  18513. {
  18514. threeCodeStr.Add(start);
  18515. threeCodeStr.Add(end);
  18516. }
  18517. else
  18518. {
  18519. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18520. {
  18521. threeCodeStr.Add(end);
  18522. }
  18523. else
  18524. {
  18525. threeCodeStr.Add(start);
  18526. threeCodeStr.Add(end);
  18527. }
  18528. }
  18529. }
  18530. //处理机票信息
  18531. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18532. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18533. if (start_Object == null)
  18534. {
  18535. start_Object = new Res_ThreeCode()
  18536. {
  18537. AirPort = empty,
  18538. AirPort_En = empty,
  18539. City = empty,
  18540. Country = empty,
  18541. Four = empty,
  18542. Three = empty,
  18543. };
  18544. }
  18545. if (end_Object == null)
  18546. {
  18547. end_Object = new Res_ThreeCode()
  18548. {
  18549. AirPort = empty,
  18550. AirPort_En = empty,
  18551. City = empty,
  18552. Country = empty,
  18553. Four = empty,
  18554. Three = empty,
  18555. };
  18556. }
  18557. //机型判断
  18558. string airModel = item["AirModel"].ToString();
  18559. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18560. string flightTime = item["FlightTime"].ToString();
  18561. if (flightTime!.Contains(":"))
  18562. {
  18563. flightTime = flightTime.Replace(":", "小时");
  18564. flightTime += "分钟";
  18565. }
  18566. if (flightTime.Contains("H"))
  18567. {
  18568. flightTime = flightTime.Replace("H", "小时");
  18569. }
  18570. if (flightTime.Contains("M"))
  18571. {
  18572. flightTime = flightTime.Replace("M", "分钟");
  18573. }
  18574. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18575. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18576. {
  18577. flightTime = flightDataTime.Hour > 0
  18578. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18579. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18580. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18581. }
  18582. //航班号
  18583. string flightcode = item["Fliagtcode"].ToString();
  18584. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18585. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18586. if (aircompany == null)
  18587. {
  18588. aircompany = new Res_AirCompany
  18589. {
  18590. CnName = hsEmpty,
  18591. EnName = hsEmpty,
  18592. ShortCode = hsEmpty,
  18593. };
  18594. }
  18595. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18596. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18597. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18598. if (isTrade)
  18599. {
  18600. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18601. }
  18602. else
  18603. {
  18604. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18605. }
  18606. }
  18607. chiarr.Add(new Grp_ApprovalTravelDetails
  18608. {
  18609. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18610. CreateTime = DateTime.Now,
  18611. CreateUserId = dto.Userid,
  18612. ParentId = 0,
  18613. Details = trip
  18614. });
  18615. //添加乘车语句
  18616. chiarr.Add(new Grp_ApprovalTravelDetails
  18617. {
  18618. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  18619. CreateTime = DateTime.Now,
  18620. CreateUserId = dto.Userid,
  18621. ParentId = 0,
  18622. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  18623. });
  18624. if (i != timeArr.Count - 1)
  18625. {
  18626. fallToTime = fallToTime.AddHours(2.5);
  18627. foreach (var item in Times)
  18628. {
  18629. //排列公务时间
  18630. if (fallToTime.Hour < item.Item1)
  18631. {
  18632. chiarr.Add(new Grp_ApprovalTravelDetails
  18633. {
  18634. Time = $"{item.Item2} - {item.Item3}",
  18635. CreateTime = DateTime.Now,
  18636. CreateUserId = dto.Userid,
  18637. ParentId = 0,
  18638. Details = "公务活动"
  18639. });
  18640. }
  18641. }
  18642. }
  18643. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18644. var last = threeCodeStr.Last();
  18645. foreach (var item in threeCodeStr)
  18646. {
  18647. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18648. if (item.Equals(last))
  18649. {
  18650. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18651. }
  18652. }
  18653. cityPath = cityPath.Trim('-');
  18654. }
  18655. else
  18656. {
  18657. foreach (var item in Times)
  18658. {
  18659. chiarr.Add(new Grp_ApprovalTravelDetails
  18660. {
  18661. Time = $"{item.Item2} - {item.Item3}",
  18662. CreateTime = DateTime.Now,
  18663. CreateUserId = dto.Userid,
  18664. ParentId = 0,
  18665. Details = "公务活动"
  18666. });
  18667. }
  18668. }
  18669. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18670. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18671. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")"+ "第" + intToString(i + 1) + "天 ";
  18672. appro.Diid = dto.Diid;
  18673. appro.CreateUserId = dto.Userid;
  18674. appro.CreateTime = DateTime.Now;
  18675. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18676. appro.Id = thisId;
  18677. //foreach (var item in gwinfo)
  18678. //{
  18679. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18680. // chi.Details = "拜访" + item.Client;
  18681. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18682. // {
  18683. // chi.Details += "," + item.ReqSample;
  18684. // }
  18685. // chi.ParentId = thisId;
  18686. // chi.Time = item.Time;
  18687. // chiarr.Add(chi);
  18688. //}
  18689. if (chiarr.Count < 6)
  18690. {
  18691. for (int j = chiarr.Count; j < 6; j++)
  18692. {
  18693. chiarr.Add(new
  18694. Grp_ApprovalTravelDetails());
  18695. }
  18696. }
  18697. resultArr.Add(new
  18698. {
  18699. appro.Id,
  18700. appro.Date,
  18701. appro.Diid,
  18702. chiList = chiarr.Select(x1 => new
  18703. {
  18704. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18705. x1.Details,
  18706. x1.ParentId,
  18707. x1.Id
  18708. })
  18709. });
  18710. }
  18711. _sqlSugar.CommitTran();
  18712. jw = JsonView(true, "生成成功!", resultArr);
  18713. }
  18714. catch (Exception ex)
  18715. {
  18716. jw.Code = 400;
  18717. jw.Msg = "生成失败!" + ex.Message;
  18718. }
  18719. return Ok(jw);
  18720. }
  18721. /// <summary>
  18722. /// 报批行程word导出
  18723. /// </summary>
  18724. /// <param name="dto"></param>
  18725. /// <returns></returns>
  18726. [HttpPost]
  18727. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18728. {
  18729. var jw = JsonView(false);
  18730. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18731. if (group == null)
  18732. {
  18733. jw.Msg = "暂无该团组!";
  18734. return Ok(jw);
  18735. }
  18736. //模板路径
  18737. string tempPath = AppSettingsHelper.Get("WordBasePath")+ "Template/";
  18738. var fileName = string.Empty;
  18739. string titleFont = string.Empty,timeFont = string.Empty, contentFont = string.Empty;
  18740. bool bold = false;
  18741. if (dto.FileIndex == 1)
  18742. {
  18743. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18744. }
  18745. else if (dto.FileIndex == 2)
  18746. {
  18747. fileName = "省外办-报批.docx";
  18748. bold = false;
  18749. titleFont = "方正黑体简体";
  18750. timeFont = "Times New Roman";
  18751. contentFont = "方正仿宋_GBK";
  18752. }
  18753. else if (dto.FileIndex == 3)
  18754. {
  18755. fileName = "市外办-报批.docx";
  18756. titleFont = "方正黑体简体";
  18757. timeFont = "Times New Roman";
  18758. contentFont = "方正仿宋简体";
  18759. }
  18760. tempPath = tempPath + fileName;
  18761. //载入模板
  18762. Document doc = new Document(tempPath);
  18763. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18764. //获取所填表格的序数
  18765. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18766. Aspose.Words.Tables.Row titleRowClone = null;
  18767. Aspose.Words.Tables.Row CenterRowClone = null;
  18768. int index = 0;
  18769. int indexChi = 0;
  18770. int SetIndex = 0;
  18771. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18772. //获取数据,放到datatable
  18773. foreach (var item in ApprovalTravelArr)
  18774. {
  18775. if (index > 0)
  18776. {
  18777. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18778. tableOne.AppendChild(titleRowClone);
  18779. }
  18780. var textTime = item.Date;
  18781. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18782. SetCells(tableOne, doc, SetIndex, 0, textTime,titleFont,bold);
  18783. SetIndex++;
  18784. if (ChiRep.Count > 0)
  18785. {
  18786. foreach (var itemChi in ChiRep)
  18787. {
  18788. var txtTime = itemChi.Time;
  18789. var txtDetail = itemChi.Details;
  18790. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18791. {
  18792. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  18793. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18794. //indexChi++;
  18795. //SetIndex++;
  18796. break;
  18797. }
  18798. if (indexChi > 0)
  18799. {
  18800. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18801. tableOne.AppendChild(CenterRowClone);
  18802. }
  18803. SetCells(tableOne, doc, SetIndex, 0, txtTime,timeFont,bold);
  18804. SetCells(tableOne, doc, SetIndex, 1, txtDetail,contentFont, bold);
  18805. indexChi++;
  18806. SetIndex++;
  18807. }
  18808. }
  18809. //else
  18810. //{
  18811. // if (indexChi > 0)
  18812. // {
  18813. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18814. // tableOne.AppendChild(CenterRowClone);
  18815. // }
  18816. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  18817. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18818. // indexChi++;
  18819. // SetIndex++;
  18820. //}
  18821. index++;
  18822. }
  18823. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  18824. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName,Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18825. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18826. jw.Code = 200;
  18827. jw.Msg = "";
  18828. return Ok(jw);
  18829. }
  18830. private string intToString(int numberVal)
  18831. {
  18832. string numberval = numberVal.ToString();
  18833. Dictionary<char, string> Number = new Dictionary<char, string>();
  18834. Number.Add('1', "一");
  18835. Number.Add('2', "二");
  18836. Number.Add('3', "三");
  18837. Number.Add('4', "四");
  18838. Number.Add('5', "五");
  18839. Number.Add('6', "六");
  18840. Number.Add('7', "七");
  18841. Number.Add('8', "八");
  18842. Number.Add('9', "九");
  18843. string stringNumberVal = string.Empty;
  18844. for (int i = 0; i < numberval.Length; i++)
  18845. {
  18846. if (i == 0)
  18847. {
  18848. stringNumberVal += Number[numberval[i]];
  18849. }
  18850. else if (i >= 1)
  18851. {
  18852. if (numberval[i] == '0')
  18853. {
  18854. stringNumberVal = "十";
  18855. }
  18856. else
  18857. {
  18858. stringNumberVal += "十" + Number[numberval[i]];
  18859. }
  18860. }
  18861. }
  18862. return stringNumberVal;
  18863. }
  18864. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val,string font ,bool bold)
  18865. {
  18866. //获取table中的某个单元格,从0开始
  18867. Cell lshCell = table.Rows[rows].Cells[cells];
  18868. //将单元格中段落移除
  18869. foreach (Paragraph item in lshCell.Paragraphs)
  18870. {
  18871. lshCell.Paragraphs.Remove(item);
  18872. }
  18873. if (val.Contains("\r\n"))
  18874. {
  18875. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18876. foreach (var item in spArr)
  18877. {
  18878. //新建一个段落
  18879. Paragraph p = new Paragraph(doc);
  18880. var r = new Run(doc, item);
  18881. //设置字体
  18882. if (!string.IsNullOrEmpty(font))
  18883. {
  18884. r.Font.Name = font;
  18885. }
  18886. r.Font.Bold = bold;
  18887. //把设置的值赋给之前新建的段落
  18888. p.AppendChild(r);
  18889. //将此段落加到单元格内
  18890. lshCell.AppendChild(p);
  18891. }
  18892. }
  18893. else
  18894. {
  18895. //新建一个段落
  18896. Paragraph p = new Paragraph(doc);
  18897. var r = new Run(doc, val);
  18898. //设置字体
  18899. if (!string.IsNullOrEmpty(font))
  18900. {
  18901. r.Font.Name = font;
  18902. }
  18903. r.Font.Bold = bold;
  18904. //把设置的值赋给之前新建的段落
  18905. p.AppendChild(r);
  18906. //将此段落加到单元格内
  18907. lshCell.AppendChild(p);
  18908. }
  18909. }
  18910. [HttpPost]
  18911. public async Task<IActionResult> ServerHttp(string paramStr)
  18912. {
  18913. paramStr = paramStr.TrimEnd('\'');
  18914. paramStr = paramStr.TrimStart('\'');
  18915. JsonView jw = JsonView(false);
  18916. JObject param = JObject.Parse(paramStr);
  18917. if (!param.ContainsKey("url"))
  18918. {
  18919. jw.Msg = "url null";
  18920. return Ok(jw);
  18921. }
  18922. string url = param["url"]!.ToString();
  18923. var methon = "get";
  18924. Dictionary<string, string> headValues = null;
  18925. string bodyStr = string.Empty;
  18926. if (param.ContainsKey("methon"))
  18927. {
  18928. methon = param["methon"]!.ToString().ToLower();
  18929. }
  18930. if (param.ContainsKey("header"))
  18931. {
  18932. var header = param["header"]!.ToString();
  18933. JObject headerJobject = JObject.Parse(header);
  18934. headValues = new Dictionary<string, string>();
  18935. foreach (JProperty item in headerJobject.Properties())
  18936. {
  18937. var value = item.Value.ToString();
  18938. var head = item.Path;
  18939. headValues.Add(head, value);
  18940. }
  18941. }
  18942. HttpClient client = new HttpClient();
  18943. string responseString = string.Empty;
  18944. StringContent content = null;
  18945. if (headValues != null)
  18946. {
  18947. foreach (var item in headValues.Keys)
  18948. {
  18949. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18950. {
  18951. if (param.ContainsKey("body"))
  18952. {
  18953. bodyStr = param["body"]!.ToString();
  18954. }
  18955. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18956. }
  18957. else
  18958. {
  18959. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18960. }
  18961. }
  18962. }
  18963. try
  18964. {
  18965. if (methon == "get")
  18966. {
  18967. responseString = await client.GetStringAsync(url);
  18968. }
  18969. else if (methon == "post")
  18970. {
  18971. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18972. {
  18973. Content = content
  18974. };
  18975. var response = await client.SendAsync(request);
  18976. try
  18977. {
  18978. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18979. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18980. {
  18981. using (StreamReader reader = new StreamReader(gzipStream))
  18982. {
  18983. responseString = await reader.ReadToEndAsync();
  18984. }
  18985. }
  18986. }
  18987. catch (Exception)
  18988. {
  18989. responseString = await response.Content.ReadAsStringAsync();
  18990. }
  18991. }
  18992. else
  18993. {
  18994. responseString = "methon error";
  18995. }
  18996. jw = JsonView(true, "success", responseString);
  18997. }
  18998. catch (Exception ex)
  18999. {
  19000. jw.Msg = "error " + ex.Message;
  19001. jw.Data = ex.StackTrace;
  19002. }
  19003. finally
  19004. {
  19005. client.Dispose();
  19006. }
  19007. return Ok(jw);
  19008. }
  19009. #endregion
  19010. #region 团组接待意见调查
  19011. /// <summary>
  19012. /// 团组接待意见调查 - 信息管理
  19013. /// 基础数据(团组)
  19014. /// </summary>
  19015. /// <returns></returns>
  19016. [HttpGet]
  19017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19018. public async Task<IActionResult> OpinionaireInit()
  19019. {
  19020. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19021. .Select(x => new
  19022. {
  19023. x.Id,
  19024. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19025. })
  19026. .OrderByDescending(x => x.Id)
  19027. .ToListAsync();
  19028. return Ok(JsonView(groupData, groupData.Count));
  19029. }
  19030. /// <summary>
  19031. /// 团组接待意见调查 - 信息管理
  19032. /// 列表
  19033. /// </summary>
  19034. /// <param name="groupId"></param>
  19035. /// <returns></returns>
  19036. [HttpGet("{groupId}")]
  19037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19038. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19039. {
  19040. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19041. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19042. .Select(x => new
  19043. {
  19044. x.Id,
  19045. x.TourGuideName,
  19046. x.CityName,
  19047. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19048. x.CreateTime
  19049. })
  19050. .OrderBy(x => x.Id)
  19051. .ToListAsync();
  19052. return Ok(JsonView(data));
  19053. }
  19054. /// <summary>
  19055. /// 团组接待意见调查 - 信息管理
  19056. /// 保存
  19057. /// </summary>
  19058. /// <param name="dto"></param>
  19059. /// <returns></returns>
  19060. [HttpPost]
  19061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19062. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19063. {
  19064. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19065. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19066. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19067. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19068. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19069. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19070. _opinionaireRep.BeginTran();
  19071. if (addData != null && addData.Count > 0)
  19072. {
  19073. foreach (var item in addData)
  19074. {
  19075. item.CreateUserId = currUserInfo.UserId;
  19076. item.DiId = dto.DiId;
  19077. }
  19078. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  19079. }
  19080. if (updData != null && updData.Count > 0)
  19081. {
  19082. var upd = await _opinionaireRep._sqlSugar
  19083. .Updateable(updData)
  19084. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19085. .WhereColumns(x => new { x.Id })
  19086. .ExecuteCommandAsync();
  19087. }
  19088. _opinionaireRep.CommitTran();
  19089. return Ok(JsonView("操作成功!"));
  19090. }
  19091. /// <summary>
  19092. /// 团组接待意见调查 - 信息管理
  19093. /// 删除
  19094. /// </summary>
  19095. /// <param name="id"></param>
  19096. /// <returns></returns>
  19097. [HttpDelete("{id}")]
  19098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19099. public async Task<IActionResult> OpinionaireManageDel(int id)
  19100. {
  19101. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19102. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19103. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19104. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19105. if (!del) return Ok(JsonView("操作失败!"));
  19106. return Ok(JsonView("操作成功!"));
  19107. }
  19108. /// <summary>
  19109. /// 团组接待意见调查 - 用户
  19110. /// 列表
  19111. /// </summary>
  19112. /// <param name="diId"></param>
  19113. /// <returns></returns>
  19114. [HttpGet("{diId}")]
  19115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19116. public async Task<IActionResult> OpinionaireUserList(int diId)
  19117. {
  19118. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19119. var sql = string.Format(@"
  19120. SELECT
  19121. o.Id,
  19122. o.DiId,
  19123. di.TeamName AS 'GroupName',
  19124. di.VisitPNumber AS 'PeopleNumber',
  19125. di.ClientName AS 'LeadGroup',
  19126. di.VisitCountry AS 'Travel',
  19127. di.VisitDays AS 'Days',
  19128. o.CityName,
  19129. o.TourGuideName,
  19130. o.Catering,
  19131. o.CateringReason,
  19132. o.Stay,
  19133. o.StayReason,
  19134. o.[Route],
  19135. o.RouteReason,
  19136. o.OfficialActivity,
  19137. o.OfficialActivityReason,
  19138. o.TourGuide,
  19139. o.TourGuideReason,
  19140. o.[Translate],
  19141. o.TranslateReason,
  19142. o.Trip,
  19143. o.TripReason,
  19144. o.ESFileName,
  19145. o.SignatureDate,
  19146. o.Remark
  19147. FROM
  19148. Grp_Opinionaire o
  19149. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19150. WHERE
  19151. o.IsDel = 0
  19152. AND o.DiId = {0}
  19153. ORDER BY
  19154. o.Id ASC", diId);
  19155. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19156. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19157. return Ok(JsonView(data));
  19158. }
  19159. /// <summary>
  19160. /// 团组接待意见调查 - 用户
  19161. /// 保存
  19162. /// </summary>
  19163. /// <param name="dto"></param>
  19164. /// <returns></returns>
  19165. [HttpPost]
  19166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19167. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19168. {
  19169. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19170. foreach (var item in dto)
  19171. {
  19172. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19173. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19174. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19175. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19176. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19177. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19178. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19179. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19180. }
  19181. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19182. if (!Directory.Exists(filePathBase))
  19183. {
  19184. Directory.CreateDirectory(filePathBase);
  19185. }
  19186. #region 上传文件
  19187. var filePaths = new List<string>();
  19188. foreach (var item in dto)
  19189. {
  19190. var file = item.File;
  19191. // 将文件保存到指定位置
  19192. var filePath = Path.Combine(filePathBase, file.FileName);
  19193. using (var stream = new FileStream(filePath, FileMode.Create))
  19194. {
  19195. await file.CopyToAsync(stream);
  19196. }
  19197. //验证文件是否上传成功
  19198. if (!System.IO.File.Exists(filePath))
  19199. {
  19200. foreach (var filePathStr in filePaths)
  19201. {
  19202. System.IO.File.Delete(filePathStr);
  19203. }
  19204. return Ok(JsonView(false, "文件上传失败!"));
  19205. }
  19206. item.ESFileName = file.FileName;
  19207. }
  19208. #endregion
  19209. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19210. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19211. .UpdateColumns(x => new
  19212. {
  19213. x.Catering,
  19214. x.CateringReason,
  19215. x.Stay,
  19216. x.StayReason,
  19217. x.Route,
  19218. x.RouteReason,
  19219. x.OfficialActivity,
  19220. x.OfficialActivityReason,
  19221. x.TourGuide,
  19222. x.TourGuideReason,
  19223. x.Translate,
  19224. x.TranslateReason,
  19225. x.Trip,
  19226. x.TripReason,
  19227. x.ESFileName,
  19228. x.SignatureDate,
  19229. x.Remark
  19230. })
  19231. .WhereColumns(x => new { x.Id })
  19232. .ExecuteCommandAsync();
  19233. if (upd < 1)
  19234. {
  19235. foreach (var filePathStr in filePaths)
  19236. {
  19237. System.IO.File.Delete(filePathStr);
  19238. }
  19239. return Ok(JsonView(false));
  19240. }
  19241. return Ok(JsonView(true));
  19242. }
  19243. #endregion
  19244. #region 团组餐厅相关信息
  19245. /// <summary>
  19246. /// 团组相关餐厅信息
  19247. /// 基础数据(团组)
  19248. /// </summary>
  19249. /// <returns></returns>
  19250. [HttpGet]
  19251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19252. public async Task<IActionResult> RestaurantInit()
  19253. {
  19254. return Ok(await _restaurantRep.InitAsync());
  19255. }
  19256. /// <summary>
  19257. /// 团组相关餐厅信息
  19258. /// Item
  19259. /// </summary>
  19260. /// <param name="dto"></param>
  19261. /// <returns></returns>
  19262. [HttpPost]
  19263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19264. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19265. {
  19266. int portType = dto.PortType,
  19267. groupId = dto.GroupId;
  19268. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19269. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19270. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19271. }
  19272. /// <summary>
  19273. /// 团组相关餐厅信息
  19274. /// List
  19275. /// </summary>
  19276. /// <param name="dto"></param>
  19277. /// <returns></returns>
  19278. [HttpPost]
  19279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19280. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19281. {
  19282. int portType = dto.PortType,
  19283. groupId = dto.GroupId;
  19284. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19285. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19286. var sql = string.Format(@" SELECT
  19287. ri.Id,
  19288. ri.GroupId,
  19289. ri.Date,
  19290. ri.StartTime,
  19291. ri.EndTime,
  19292. CASE WHEN ri.Type = 1 THEN '早餐'
  19293. WHEN ri.Type = 2 THEN '午餐'
  19294. WHEN ri.Type = 3 THEN '晚餐'
  19295. ELSE '其他'
  19296. END AS 'Type',
  19297. ri.Name,
  19298. ri.Address,
  19299. ri.Tel,
  19300. ri.Remark,
  19301. ri.CreateTime,
  19302. u.CnName AS CreateUserName
  19303. FROM
  19304. Grp_RestaurantInfo ri
  19305. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19306. WHERE
  19307. ri.IsDel = 0
  19308. AND ri.GroupId = {0}
  19309. ORDER BY
  19310. ri.Date ASC
  19311. ", groupId);
  19312. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19313. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19314. return Ok(JsonView(infos));
  19315. }
  19316. /// <summary>
  19317. /// 团组相关餐厅信息
  19318. /// Info
  19319. /// </summary>
  19320. /// <param name="dto"></param>
  19321. /// <returns></returns>
  19322. [HttpPost]
  19323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19324. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19325. {
  19326. int portType = dto.PortType,
  19327. id = dto.Id;
  19328. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19329. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19330. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19331. }
  19332. /// <summary>
  19333. /// 团组相关餐厅信息
  19334. /// Op
  19335. /// </summary>
  19336. /// <param name="dto"></param>
  19337. /// <returns></returns>
  19338. [HttpPost]
  19339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19340. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19341. {
  19342. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19343. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19344. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19345. return Ok(await _restaurantRep.OpAsync(dto));
  19346. }
  19347. /// <summary>
  19348. /// 团组相关餐厅信息
  19349. /// Del
  19350. /// </summary>
  19351. /// <param name="dto"></param>
  19352. /// <returns></returns>
  19353. [HttpPost]
  19354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19355. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19356. {
  19357. int userId = dto.DeleteUserId;
  19358. var id = dto.Id;
  19359. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19360. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19361. return Ok(await _restaurantRep.DelAsync(dto));
  19362. }
  19363. #endregion
  19364. // /// <summary>
  19365. // ///
  19366. // /// </summary>
  19367. // /// <param name="_dto"></param>
  19368. // /// <returns></returns>
  19369. // [HttpPost]
  19370. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19371. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19372. // {
  19373. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19374. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19375. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19376. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19377. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19378. // dic_psg.Add("客人", 974);
  19379. // dic_psg.Add("司机", 975);
  19380. // dic_psg.Add("导游", 976);
  19381. // dic_psg.Add("公司内部人员", 977);
  19382. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19383. // foreach (var item in list_visa)
  19384. // {
  19385. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19386. // temp.Id = item.Id;
  19387. // temp.DIId = item.DIId;
  19388. // temp.VisaClient = item.VisaClient;
  19389. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19390. // temp.VisaCurrency = item.VisaCurrency;
  19391. // temp.IsThird = item.IsThird;
  19392. // if (dic_psg.ContainsKey(item.PassengerType))
  19393. // {
  19394. // temp.PassengerType = dic_psg[item.PassengerType];
  19395. // }
  19396. // else {
  19397. // temp.PassengerType = -1;
  19398. // }
  19399. // temp.VisaNumber = item.VisaNumber;
  19400. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19401. // temp.CreateUserId = item.Operators;
  19402. // DateTime dt_ct;
  19403. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19404. // if (b_ct)
  19405. // {
  19406. // temp.CreateTime = dt_ct;
  19407. // }
  19408. // else
  19409. // {
  19410. // temp.CreateTime = DateTime.Now;
  19411. // }
  19412. // temp.DeleteTime = "";
  19413. // temp.DeleteUserId = 0;
  19414. // temp.Remark = item.Remark;
  19415. // if (string.IsNullOrEmpty(temp.Remark)) {
  19416. // temp.Remark = "";
  19417. // }
  19418. // temp.IsDel = item.IsDel;
  19419. // temp.VisaDescription = item.VisaAttachment;
  19420. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19421. //([Id]
  19422. // ,[DIId]
  19423. // ,[VisaClient]
  19424. // ,[VisaPrice]
  19425. // ,[VisaCurrency]
  19426. // ,[IsThird]
  19427. // ,[PassengerType]
  19428. // ,[VisaNumber]
  19429. // ,[VisaFreeNumber]
  19430. // ,[CreateUserId]
  19431. // ,[CreateTime]
  19432. // ,[DeleteTime]
  19433. // ,[DeleteUserId]
  19434. // ,[Remark]
  19435. // ,[IsDel]
  19436. // ,[visaDescription])
  19437. // VALUES
  19438. // ({0},{1},'{2}',{3},{4}
  19439. //,{5},{6},{7},{8},{9}
  19440. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19441. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19442. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19443. //);
  19444. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19445. // }
  19446. // return Ok(JsonView(true, "操作成功!"));
  19447. // }
  19448. /// <summary>
  19449. /// 123132123
  19450. /// </summary>
  19451. /// <param name="_dto"></param>
  19452. /// <returns></returns>
  19453. [HttpPost]
  19454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19455. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19456. {
  19457. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19458. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19459. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19460. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19461. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19462. dicDetail.Add(789, 1034);
  19463. dicDetail.Add(790, 1035);
  19464. dicDetail.Add(791, 1036);
  19465. dicDetail.Add(792, 1037);
  19466. dicDetail.Add(793, 1038);
  19467. dicDetail.Add(794, 1039);
  19468. dicDetail.Add(795, 1040);
  19469. dicDetail.Add(796, 1041);
  19470. dicDetail.Add(797, 1042);
  19471. dicDetail.Add(798, 1043);
  19472. dicDetail.Add(801, 1044);
  19473. dicDetail.Add(802, 1045);
  19474. dicDetail.Add(803, 1046);
  19475. Dictionary<int, int> dic = new Dictionary<int, int>();
  19476. dic.Add(806, 1027);
  19477. dic.Add(807, 1028);
  19478. dic.Add(808, 1029);
  19479. dic.Add(809, 1030);
  19480. dic.Add(810, 1031);
  19481. dic.Add(811, 1032);
  19482. dic.Add(812, 1033);
  19483. foreach (var item in list_visa)
  19484. {
  19485. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19486. temp.Coefficient = item.coefficient;
  19487. DateTime dtCrt;
  19488. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19489. if (b1)
  19490. {
  19491. temp.CreateTime = dtCrt;
  19492. }
  19493. else
  19494. {
  19495. temp.CreateTime = DateTime.Now;
  19496. }
  19497. temp.CreateUserId = item.Operators;
  19498. temp.DeleteTime = "";
  19499. temp.DeleteUserId = 0;
  19500. temp.DiId = int.Parse(item.DIID);
  19501. temp.FilePath = item.FilePath;
  19502. temp.IsDel = item.IsDel;
  19503. temp.Price = item.Price;
  19504. temp.PriceCount = 1;
  19505. temp.PriceCurrency = item.Currency;
  19506. int detailId = 0;
  19507. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19508. {
  19509. detailId = dicDetail[item.PriceTypeDetail];
  19510. }
  19511. temp.PriceDetailType = detailId;
  19512. temp.PriceDt = DateTime.Now;
  19513. temp.PriceName = item.PriceName;
  19514. temp.PriceSum = item.Price;
  19515. int tid = 0;
  19516. if (dic.ContainsKey(item.PriceType))
  19517. {
  19518. tid = dic[item.PriceType];
  19519. }
  19520. temp.PriceType = tid;
  19521. temp.Remark = item.Remark;
  19522. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19523. }
  19524. return Ok(JsonView(true, "操作成功!"));
  19525. }
  19526. [HttpPost]
  19527. public IActionResult TimeTest()
  19528. {
  19529. var jw = JsonView(false, "error");
  19530. _sqlSugar.BeginTran();
  19531. try
  19532. {
  19533. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19534. .Select(x => new Crm_NewClientData
  19535. {
  19536. Id = x.Id,
  19537. Client = x.Client,
  19538. Contact = x.Contact,
  19539. Location = x.Location,
  19540. })
  19541. .ToList();
  19542. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19543. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19544. Stopwatch stopwatch = new Stopwatch();
  19545. // 开始计时
  19546. stopwatch.Start();
  19547. foreach (var item in clientList)
  19548. {
  19549. EncryptionProcessor.DecryptProperties(item);
  19550. }
  19551. stopwatch.Stop();
  19552. jw.Code = 200;
  19553. jw.Data = stopwatch.ElapsedMilliseconds;
  19554. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19555. }
  19556. catch (Exception ex)
  19557. {
  19558. jw.Code = 400;
  19559. jw.Msg = ex.Message;
  19560. }
  19561. return Ok(jw);
  19562. }
  19563. }
  19564. }