GroupsController.cs 1.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using DiffMatchPatch;
  7. using EyeSoft.Runtime.InteropServices;
  8. using Google.Protobuf.WellKnownTypes;
  9. using Microsoft.AspNetCore.Mvc.RazorPages;
  10. using Microsoft.AspNetCore.SignalR;
  11. using Microsoft.EntityFrameworkCore.Metadata.Internal;
  12. using Microsoft.IdentityModel.Tokens;
  13. using Microsoft.VisualBasic;
  14. using MySqlX.XDevAPI.Relational;
  15. using NetTaste;
  16. using NPOI.HSSF.UserModel;
  17. using NPOI.SS.Formula.Functions;
  18. using NPOI.SS.UserModel;
  19. using NPOI.SS.Util;
  20. using NPOI.XSSF.UserModel;
  21. using OASystem.API.Middlewares;
  22. using OASystem.API.OAMethodLib;
  23. using OASystem.API.OAMethodLib.APNs;
  24. using OASystem.API.OAMethodLib.File;
  25. using OASystem.API.OAMethodLib.Hub.HubClients;
  26. using OASystem.API.OAMethodLib.Hub.Hubs;
  27. using OASystem.API.OAMethodLib.JuHeAPI;
  28. using OASystem.API.OAMethodLib.KiMiApi;
  29. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  30. using OASystem.Domain.AesEncryption;
  31. using OASystem.Domain.Attributes;
  32. using OASystem.Domain.Dtos.CRM;
  33. using OASystem.Domain.Dtos.FileDto;
  34. using OASystem.Domain.Dtos.Financial;
  35. using OASystem.Domain.Dtos.Groups;
  36. using OASystem.Domain.Entities.Customer;
  37. using OASystem.Domain.Entities.Financial;
  38. using OASystem.Domain.Entities.Groups;
  39. using OASystem.Domain.ViewModels.Financial;
  40. using OASystem.Domain.ViewModels.Groups;
  41. using OASystem.Domain.ViewModels.JuHeExchangeRate;
  42. using OASystem.Domain.ViewModels.OCR;
  43. using OASystem.Domain.ViewModels.QiYeWeChat;
  44. using OASystem.Domain.ViewModels.Statistics;
  45. using OASystem.Infrastructure.Repositories.CRM;
  46. using OASystem.Infrastructure.Repositories.Financial;
  47. using OASystem.Infrastructure.Repositories.Groups;
  48. using OASystem.Infrastructure.Tools;
  49. using OASystem.RedisRepository;
  50. using Org.BouncyCastle.Crypto;
  51. using Org.BouncyCastle.Utilities;
  52. using Quartz.Util;
  53. using SqlSugar.Extensions;
  54. using System.Collections;
  55. using System.Collections.Generic;
  56. using System.Data;
  57. using System.Diagnostics;
  58. using System.Drawing.Printing;
  59. using System.Globalization;
  60. using System.IO;
  61. using System.IO.Compression;
  62. using System.Reflection;
  63. using System.Text.Json;
  64. using System.Web;
  65. using System.Xml.Linq;
  66. using TencentCloud.Ocr.V20181119.Models;
  67. using static OASystem.API.OAMethodLib.JWTHelper;
  68. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  69. using Bookmark = Aspose.Words.Bookmark;
  70. using Cell = Aspose.Words.Tables.Cell;
  71. using Table = Aspose.Words.Tables.Table;
  72. namespace OASystem.API.Controllers
  73. {
  74. /// <summary>
  75. /// 团组相关
  76. /// </summary>
  77. //[Authorize]
  78. [Route("api/[controller]/[action]")]
  79. public class GroupsController : ControllerBase
  80. {
  81. private readonly ILogger<GroupsController> _logger;
  82. private readonly GrpScheduleRepository _grpScheduleRep;
  83. private readonly IMapper _mapper;
  84. private readonly DelegationInfoRepository _groupRepository;
  85. private readonly TaskAssignmentRepository _taskAssignmentRep;
  86. private readonly AirTicketResRepository _airTicketResRep;
  87. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  88. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  89. private readonly DelegationEnDataRepository _delegationEnDataRep;
  90. private readonly DelegationVisaRepository _delegationVisaRep;
  91. private readonly VisaPriceRepository _visaPriceRep;
  92. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  93. private readonly HotelPriceRepository _hotelPriceRep;
  94. private readonly CustomersRepository _customersRep;
  95. private readonly MessageRepository _message;
  96. private readonly SqlSugarClient _sqlSugar;
  97. private readonly TourClientListRepository _tourClientListRep;
  98. private readonly TeamRateRepository _teamRateRep;
  99. #region 成本相关
  100. private readonly CheckBoxsRepository _checkBoxs;
  101. private readonly GroupCostRepository _GroupCostRepository;
  102. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  103. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  104. #endregion
  105. private readonly SetDataRepository _setDataRep;
  106. private string url;
  107. private string path;
  108. private readonly EnterExitCostRepository _enterExitCostRep;
  109. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  110. private readonly UsersRepository _usersRep;
  111. private readonly IJuHeApiService _juHeApi;
  112. private readonly InvertedListRepository _invertedListRep;
  113. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  114. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  115. private readonly ThreeCodeRepository _threeCodeRepository;
  116. private readonly HotelInquiryRepository _hotelInquiryRep;
  117. private readonly FeeAuditRepository _feeAuditRep;
  118. private readonly VisaCommissionRepository _visaCommissionRep;
  119. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  120. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  121. private readonly List<CurrencyInfo> _currencyInit;
  122. private readonly List<int> _portTypeData;
  123. private readonly TableOperationRecordRepository _tableorRep;
  124. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  125. private readonly RestaurantRepository _restaurantRep;
  126. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  127. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  128. /// <summary>
  129. /// 构造函数
  130. /// </summary>
  131. /// <param name="logger"></param>
  132. /// <param name="mapper"></param>
  133. /// <param name="hubContext"></param>
  134. /// <param name="sqlSugar"></param>
  135. /// <param name="grpScheduleRep"></param>
  136. /// <param name="groupRepository"></param>
  137. /// <param name="taskAssignmentRep"></param>
  138. /// <param name="airTicketResRep"></param>
  139. /// <param name="decreasePaymentsRep"></param>
  140. /// <param name="InvitationOfficialActivitiesRep"></param>
  141. /// <param name="delegationEnDataRep"></param>
  142. /// <param name="enterExitCostRep"></param>
  143. /// <param name="delegationVisaRep"></param>
  144. /// <param name="message"></param>
  145. /// <param name="visaPriceRep"></param>
  146. /// <param name="carTouristGuideGroundRep"></param>
  147. /// <param name="checkBoxs"></param>
  148. /// <param name="GroupCostRepository"></param>
  149. /// <param name="CostTypeHotelNumberRepository"></param>
  150. /// <param name="GroupCostParameterRepository"></param>
  151. /// <param name="hotelPriceRep"></param>
  152. /// <param name="customersRep"></param>
  153. /// <param name="setDataRep"></param>
  154. /// <param name="tourClientListRep"></param>
  155. /// <param name="teamRateRep"></param>
  156. /// <param name="usersRep"></param>
  157. /// <param name="juHeApi"></param>
  158. /// <param name="invertedListRep"></param>
  159. /// <param name="visaFeeInfoRep"></param>
  160. /// <param name="ticketBlackCodeRep"></param>
  161. /// <param name="hotelInquiryRep"></param>
  162. /// <param name="threeCodeRepository"></param>
  163. /// <param name="feeAuditRep"></param>
  164. /// <param name="visaCommissionRep"></param>
  165. /// <param name="ffrRep"></param>
  166. /// <param name="opinionaireRep"></param>
  167. /// <param name="tableorRep"></param>
  168. /// <param name="enterExitCostDraftRep"></param>
  169. /// <param name="restaurantRep"></param>
  170. /// <param name="enterExitCostQuoteRep"></param>
  171. /// <param name="grpOrderPreInfoRep"></param>
  172. public GroupsController(
  173. ILogger<GroupsController> logger,
  174. IMapper mapper,
  175. IHubContext<ChatHub, IChatClient> hubContext,
  176. SqlSugarClient sqlSugar,
  177. GrpScheduleRepository grpScheduleRep,
  178. DelegationInfoRepository groupRepository,
  179. TaskAssignmentRepository taskAssignmentRep,
  180. AirTicketResRepository airTicketResRep,
  181. DecreasePaymentsRepository decreasePaymentsRep,
  182. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  183. DelegationEnDataRepository delegationEnDataRep,
  184. EnterExitCostRepository enterExitCostRep,
  185. DelegationVisaRepository delegationVisaRep,
  186. MessageRepository message,
  187. VisaPriceRepository visaPriceRep,
  188. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  189. CheckBoxsRepository checkBoxs,
  190. GroupCostRepository GroupCostRepository,
  191. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  192. GroupCostParameterRepository GroupCostParameterRepository,
  193. HotelPriceRepository hotelPriceRep,
  194. CustomersRepository customersRep,
  195. SetDataRepository setDataRep,
  196. TourClientListRepository tourClientListRep,
  197. TeamRateRepository teamRateRep,
  198. UsersRepository usersRep,
  199. IJuHeApiService juHeApi,
  200. InvertedListRepository invertedListRep,
  201. VisaFeeInfoRepository visaFeeInfoRep,
  202. TicketBlackCodeRepository ticketBlackCodeRep,
  203. HotelInquiryRepository hotelInquiryRep,
  204. ThreeCodeRepository threeCodeRepository,
  205. FeeAuditRepository feeAuditRep,
  206. VisaCommissionRepository visaCommissionRep,
  207. ForeignReceivablesRepository ffrRep,
  208. OpinionaireRepository opinionaireRep,
  209. TableOperationRecordRepository tableorRep,
  210. EnterExitCostDraftRepository enterExitCostDraftRep,
  211. RestaurantRepository restaurantRep,
  212. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  213. GroupOrderPreInfoRepository grpOrderPreInfoRep
  214. )
  215. {
  216. _logger = logger;
  217. _mapper = mapper;
  218. _grpScheduleRep = grpScheduleRep;
  219. _groupRepository = groupRepository;
  220. _taskAssignmentRep = taskAssignmentRep;
  221. _airTicketResRep = airTicketResRep;
  222. _sqlSugar = sqlSugar;
  223. url = AppSettingsHelper.Get("ExcelBaseUrl");
  224. path = AppSettingsHelper.Get("ExcelBasePath");
  225. if (!System.IO.Directory.Exists(path))
  226. {
  227. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  228. }
  229. _decreasePaymentsRep = decreasePaymentsRep;
  230. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  231. _delegationEnDataRep = delegationEnDataRep;
  232. _enterExitCostRep = enterExitCostRep;
  233. _delegationVisaRep = delegationVisaRep;
  234. _message = message;
  235. _visaPriceRep = visaPriceRep;
  236. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  237. _checkBoxs = checkBoxs;
  238. _GroupCostRepository = GroupCostRepository;
  239. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  240. _GroupCostParameterRepository = GroupCostParameterRepository;
  241. _hotelPriceRep = hotelPriceRep;
  242. _customersRep = customersRep;
  243. _setDataRep = setDataRep;
  244. _tourClientListRep = tourClientListRep;
  245. _teamRateRep = teamRateRep;
  246. _hubContext = hubContext;
  247. _usersRep = usersRep;
  248. _juHeApi = juHeApi;
  249. _invertedListRep = invertedListRep;
  250. _visaFeeInfoRep = visaFeeInfoRep;
  251. _ticketBlackCodeRep = ticketBlackCodeRep;
  252. _hotelInquiryRep = hotelInquiryRep;
  253. _threeCodeRepository = threeCodeRepository;
  254. _feeAuditRep = feeAuditRep;
  255. _visaCommissionRep = visaCommissionRep;
  256. _ffrRep = ffrRep;
  257. _opinionaireRep = opinionaireRep;
  258. _currencyInit = new List<CurrencyInfo>()
  259. {
  260. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  261. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  262. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  263. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  264. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  265. };
  266. _portTypeData = new List<int>() { 2, 3 };
  267. _tableorRep = tableorRep;
  268. _enterExitCostDraftRep = enterExitCostDraftRep;
  269. _restaurantRep = restaurantRep;
  270. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  271. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  272. }
  273. #region 流程管控
  274. /// <summary>
  275. /// 获取团组流程管控信息
  276. /// </summary>
  277. /// <param name="_jsonDto">查询参数</param>
  278. /// <returns></returns>
  279. [HttpPost]
  280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  281. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  282. {
  283. if (string.IsNullOrEmpty(_jsonDto.Paras))
  284. {
  285. return Ok(JsonView(false, "参数为空"));
  286. }
  287. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  288. if (_ScheduleDto != null)
  289. {
  290. if (_ScheduleDto.SearchType == 2)//获取列表
  291. {
  292. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  293. return Ok(JsonView(_grpScheduleViewList));
  294. }
  295. else//获取对象
  296. {
  297. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  298. if (_grpScheduleView != null)
  299. {
  300. return Ok(JsonView(_grpScheduleView));
  301. }
  302. }
  303. }
  304. else
  305. {
  306. return Ok(JsonView(false, "参数反序列化失败"));
  307. }
  308. return Ok(JsonView(false, "暂无数据!"));
  309. }
  310. /// <summary>
  311. /// 修改团组流程管控详细表数据
  312. /// </summary>
  313. /// <param name="dto"></param>
  314. /// <returns></returns>
  315. [HttpPost]
  316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  317. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  318. {
  319. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  320. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  321. .SetColumns(it => it.Duty == _detail.Duty)
  322. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  323. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  324. .SetColumns(it => it.JobContent == _detail.JobContent)
  325. .SetColumns(it => it.Remark == _detail.Remark)
  326. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  327. .Where(s => s.Id == dto.Id)
  328. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  329. .ExecuteCommandAsync();
  330. if (result > 0)
  331. {
  332. return Ok(JsonView(true, "保存成功!"));
  333. }
  334. return Ok(JsonView(false, "保存失败!"));
  335. }
  336. /// <summary>
  337. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  338. /// </summary>
  339. /// <param name="dto"></param>
  340. /// <returns></returns>
  341. [HttpPost]
  342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  343. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  344. {
  345. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  346. _detail.IsDel = 1;
  347. _detail.DeleteUserId = dto.Duty;
  348. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  349. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  350. .SetColumns(it => it.IsDel == _detail.IsDel)
  351. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  352. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  353. .Where(it => it.Id == dto.Id)
  354. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  355. //.WhereColumns(s => s.Id == dto.Id)
  356. .ExecuteCommandAsync();
  357. if (result > 0)
  358. {
  359. return Ok(JsonView(true, "删除成功!"));
  360. }
  361. return Ok(JsonView(false, "删除失败!"));
  362. }
  363. /// <summary>
  364. /// 增加团组流程管控详细表数据
  365. /// </summary>
  366. /// <param name="dto"></param>
  367. /// <returns></returns>
  368. [HttpPost]
  369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  370. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  371. {
  372. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  373. if (DateTime.Now < _detail.ExpectBeginDt)
  374. {
  375. _detail.StepStatus = 0;
  376. }
  377. else
  378. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  379. _detail.StepStatus = 1;
  380. }
  381. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  382. if (result > 0)
  383. {
  384. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  385. return Ok(JsonView(true, "添加成功!", _result));
  386. }
  387. return Ok(JsonView(false, "添加失败!"));
  388. }
  389. #endregion
  390. #region 团组前期信息
  391. /// <summary>
  392. /// 团组前期信息 List
  393. /// </summary>
  394. /// <returns></returns>
  395. [HttpPost]
  396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  397. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  398. {
  399. var search = dto.Search;
  400. int[] nameTempIds = new int[] { 1, 12, 28 },
  401. countryTempIds = new int[] { 2, 13, 29 },
  402. daysTempIds = new int[] { 4, 15, 31 },
  403. ppNumTempIds = new int[] { 6 };
  404. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  405. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  406. .Where((opi, u) => opi.IsDel == 0)
  407. .OrderByDescending((opi, u) => opi.CreateTime)
  408. .Select((opi, u) => new GroupOrderPreInfoListView()
  409. {
  410. Id = opi.Id,
  411. Name = opi.Name,
  412. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains( x.FormTempId)).Select(x => x.Value),
  413. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  414. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  415. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  416. Operator = u.CnName,
  417. OperationTime = opi.CreateTime
  418. })
  419. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  420. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  421. .ToListAsync();
  422. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  423. int total = list.Count;
  424. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  425. var listPageData1 = listPageData
  426. .Skip((dto.PageIndex - 1) * dto.PageSize)
  427. .Take(dto.PageSize)
  428. .ToList();
  429. var infoIds = listPageData1.Select(x => x.Id).ToList();
  430. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  431. .Where(x => x.IsDel == 0 && x.STid == 109)
  432. .ToArrayAsync();
  433. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  434. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  435. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  436. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  437. .ToListAsync();
  438. foreach (var item in listPageData1)
  439. {
  440. var typeDatas1 = typeDatas.Select(x => new
  441. {
  442. Id = x.Id,
  443. Name = x.Name,
  444. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  445. }).ToArray();
  446. item.VersionDetails = typeDatas1;
  447. }
  448. return Ok(JsonView(listPageData1, listPageData1.Count));
  449. }
  450. /// <summary>
  451. /// 团组前期信息 Init
  452. /// </summary>
  453. /// <returns></returns>
  454. [HttpGet("{userId}")]
  455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  456. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  457. {
  458. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  459. }
  460. /// <summary>
  461. /// 国家数据源
  462. /// </summary>
  463. /// <param name="pageIndex">当前页码</param>
  464. /// <param name="pageSize">每页条数</param>
  465. /// <param name="search">查询条件</param>
  466. /// <returns></returns>
  467. [HttpGet]
  468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  469. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  470. {
  471. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  472. if (pageIndex == 0 && pageSize == 0)
  473. {
  474. //所有数据
  475. return Ok(JsonView(countrys, countrys.Count));
  476. }
  477. //分页
  478. int skip = (pageIndex - 1) * pageSize;
  479. int take = pageSize;
  480. if (!string.IsNullOrEmpty(search))
  481. {
  482. IEnumerable<char> charSequence = search.Select(c => c);
  483. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  484. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  485. return Ok(JsonView(pageData, pageResult1.Count));
  486. }
  487. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  488. return Ok(JsonView(pageResult2, countrys.Count));
  489. }
  490. /// <summary>
  491. /// 城市数据源
  492. /// </summary>
  493. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  494. /// <param name="pageIndex">当前页码</param>
  495. /// <param name="pageSize">每页条数</param>
  496. /// <param name="search">查询条件</param>
  497. /// <returns></returns>
  498. [HttpGet("{countryLabel}")]
  499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  500. public async Task<IActionResult> CityByCountry(
  501. string countryLabel,
  502. [FromQuery] int pageIndex,
  503. [FromQuery] int pageSize,
  504. [FromQuery] string search)
  505. {
  506. countryLabel = HttpUtility.UrlDecode(countryLabel);
  507. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  508. var citys = Array.Empty<string?>();
  509. if (countryList.Any())
  510. {
  511. var cityDatas = await _sqlSugar
  512. .Queryable<Grp_NationalTravelFee>()
  513. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  514. .ToArrayAsync();
  515. foreach (var item in cityDatas)
  516. {
  517. if (item.City.Contains("城市"))
  518. {
  519. item.City = item.Country + "-所有城市";
  520. }
  521. }
  522. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  523. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  524. }
  525. if (pageIndex == 0 && pageSize == 0)
  526. {
  527. //所有数据
  528. return Ok(JsonView(citys, citys?.Length ?? 0));
  529. }
  530. //分页
  531. int skip = (pageIndex - 1) * pageSize;
  532. int take = pageSize;
  533. if (!string.IsNullOrEmpty(search))
  534. {
  535. IEnumerable<char> charSequence = search.Select(c => c);
  536. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  537. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  538. return Ok(JsonView(pageData, pageResult1.Count()));
  539. }
  540. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  541. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  542. }
  543. /// <summary>
  544. /// 团组前期信息 Info
  545. /// </summary>
  546. /// <param name="dto">Id</param>
  547. /// <param name="portType">Id</param>
  548. /// <returns></returns>
  549. [HttpGet("{Id}/{TempId}")]
  550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  551. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto,int portType=1)
  552. {
  553. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  554. }
  555. /// <summary>
  556. /// 团组前期信息 移动端 Info
  557. /// </summary>
  558. /// <param name="dto">Id</param>
  559. /// <returns></returns>
  560. [HttpGet("{Id}/{TempId}")]
  561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  562. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  563. {
  564. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  565. }
  566. /// <summary>
  567. /// 团组前期信息 Save
  568. /// </summary>
  569. /// <param name="dto">Id</param>
  570. /// <returns></returns>
  571. [HttpPost]
  572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  573. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  574. {
  575. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  576. }
  577. /// <summary>
  578. /// 团组前期信息 Del
  579. /// </summary>
  580. /// <param name="dto">Id</param>
  581. /// <returns></returns>
  582. [HttpPost]
  583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  584. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  585. {
  586. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  587. }
  588. /// <summary>
  589. /// 团组前期信息 文件下载
  590. /// </summary>
  591. /// <param name="dto">Id</param>
  592. /// <returns></returns>
  593. [HttpGet("{Id}/{TempId}")]
  594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  595. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  596. {
  597. int id = dto.Id, tempId = dto.TempId;
  598. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  599. var data = view.Data as GrpOrderPreInfoView;
  600. #region Excel
  601. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  602. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  603. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  604. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  605. var fileNamePrefix = string.Empty;
  606. if (tempId == 1405)
  607. {
  608. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  609. fileNamePrefix = $"{data.Name}_无商邀版";
  610. }
  611. else if (tempId == 1406)
  612. {
  613. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  614. fileNamePrefix = $"{data.Name}_有商邀版";
  615. }
  616. else
  617. {
  618. //tempId == 1404 默认下载
  619. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  620. fileNamePrefix = $"{data.Name}_单接送机";
  621. }
  622. foreach (var item in data.Items)
  623. {
  624. var obj = item.NewValue;
  625. if (obj == null) item.OriginVal = "";
  626. else if (obj.Equals("有") || obj.Equals("无"))
  627. {
  628. item.OriginVal = obj.ToString();
  629. }
  630. else if (obj is object[] objArray)
  631. {
  632. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  633. item.OriginVal = string.Join("、", stringArray);
  634. }
  635. else if (obj is string[] stringArray)
  636. {
  637. item.OriginVal = string.Join("、", stringArray);
  638. }
  639. else if (obj.Equals("-"))
  640. {
  641. item.OriginVal = "";
  642. }
  643. }
  644. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  645. fileName = CommonFun.ValidFileName(fileName);
  646. //载入模板
  647. WorkbookDesigner designer = new WorkbookDesigner();
  648. designer.Workbook = new Workbook(tempPath);
  649. if (tempId == 1406)
  650. {
  651. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  652. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  653. for (int i = 1; i <= view2.Length; i++)
  654. {
  655. view2[i - 1].Index = i;
  656. }
  657. designer.SetDataSource("View1", view1);
  658. designer.SetDataSource("View2", view2);
  659. }
  660. else
  661. {
  662. designer.SetDataSource("View", data.Items);
  663. }
  664. designer.Process();
  665. if (!Directory.Exists(savePath))
  666. {
  667. Directory.CreateDirectory(savePath);
  668. }
  669. string serverPath = $"{savePath}{fileName}";
  670. designer.Workbook.Save(serverPath);
  671. string rst = $"{servicePath}{ftpPath}{fileName}";
  672. #endregion
  673. return Ok(JsonView(new { url = rst }));
  674. }
  675. #endregion
  676. #region 团组基本信息
  677. /// <summary>
  678. /// 接团信息列表
  679. /// </summary>
  680. /// <param name="dto">团组列表请求dto</param>
  681. /// <returns></returns>
  682. [HttpPost]
  683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  684. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  685. {
  686. var groupData = await _groupRepository.GetGroupList(dto);
  687. if (groupData.Code != 0)
  688. {
  689. return Ok(JsonView(false, groupData.Msg));
  690. }
  691. return Ok(JsonView(groupData.Data));
  692. }
  693. /// <summary>
  694. /// 分页查询团组列表
  695. /// </summary>
  696. /// <param name="dto"></param>
  697. /// <returns></returns>
  698. [HttpPost]
  699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  700. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  701. {
  702. var watch = new Stopwatch();
  703. watch.Start();
  704. RefAsync<int> total = 0;
  705. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  706. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  707. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  708. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  709. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  710. .Distinct()
  711. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  712. watch.Stop();
  713. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  714. }
  715. /// <summary>
  716. /// 接团信息列表 Page Init
  717. /// </summary>
  718. /// <returns></returns>
  719. [HttpPost]
  720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  721. public async Task<IActionResult> PostGroupPageListInit()
  722. {
  723. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  724. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  725. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  726. var _view = new
  727. {
  728. depData = depDatas,
  729. rankData = rankDatas
  730. };
  731. return Ok(JsonView(true, "查询成功!", _view));
  732. }
  733. /// <summary>
  734. /// 接团信息列表 Page
  735. /// </summary>
  736. /// <param name="dto">团组列表请求dto</param>
  737. /// <returns></returns>
  738. [HttpPost]
  739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  740. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  741. {
  742. #region 参数验证
  743. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  744. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  745. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  746. #region 页面操作权限验证
  747. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  748. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  749. #endregion
  750. #endregion
  751. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  752. {
  753. string sqlWhere = string.Empty;
  754. if (dto.IsSure == 0) //未完成
  755. {
  756. sqlWhere += string.Format(@" And IsSure = 0");
  757. }
  758. else if (dto.IsSure == 1) //已完成
  759. {
  760. sqlWhere += string.Format(@" And IsSure = 1");
  761. }
  762. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  763. {
  764. string tj = dto.SearchCriteria;
  765. 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}%')",
  766. tj, tj, tj, tj, tj);
  767. }
  768. if (int.TryParse(dto.Rank, out int rankId))
  769. {
  770. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  771. }
  772. string sqlWhere1 = string.Empty;
  773. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  774. {
  775. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  776. }
  777. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  778. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  779. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  780. JietuanOperator,IsSure,CreateTime,IsBid
  781. From (
  782. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  783. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  784. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  785. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  786. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  787. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  788. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  789. From Grp_DelegationInfo gdi
  790. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  791. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  792. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  793. Where gdi.IsDel = 0 {0}
  794. ) temp {1}", sqlWhere, sqlWhere1);
  795. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  796. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  797. var _view = new
  798. {
  799. PageFuncAuth = pageFunAuthView,
  800. Data = _DelegationList
  801. };
  802. return Ok(JsonView(true, "查询成功!", _view, total));
  803. }
  804. else
  805. {
  806. return Ok(JsonView(false, "查询失败"));
  807. }
  808. }
  809. /// <summary>
  810. /// 团组列表
  811. /// </summary>
  812. /// <returns></returns>
  813. [HttpPost]
  814. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  815. {
  816. #region 参数验证
  817. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  818. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  819. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  820. #region 页面操作权限验证
  821. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  822. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  823. #endregion
  824. #endregion
  825. if (dto.PortType != 1 && dto.PortType != 2)
  826. {
  827. return Ok(JsonView(false, "查询失败!"));
  828. }
  829. string orderbyStr = "order by gdi.CreateTime Desc";
  830. string sqlWhere = string.Empty;
  831. if (dto.IsSure == 0) //未完成
  832. {
  833. sqlWhere += string.Format(@" And IsSure = 0");
  834. }
  835. else if (dto.IsSure == 1) //已完成
  836. {
  837. sqlWhere += string.Format(@" And IsSure = 1");
  838. }
  839. //团组类型
  840. if (dto.TeamDid > 0)
  841. {
  842. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  843. }
  844. //团组名称
  845. if (!string.IsNullOrEmpty(dto.TeamName))
  846. {
  847. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  848. }
  849. //客户名称
  850. if (!string.IsNullOrEmpty(dto.ClientName))
  851. {
  852. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  853. }
  854. //客户单位
  855. if (!string.IsNullOrEmpty(dto.ClientUnit))
  856. {
  857. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  858. }
  859. //出访时间
  860. if (!string.IsNullOrEmpty(dto.visitDataTime))
  861. {
  862. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  863. orderbyStr = "order by gdi.VisitDate";
  864. }
  865. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  866. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  867. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  868. JietuanOperator,IsSure,CreateTime
  869. From (
  870. Select row_number() over({0}) as Row_Number,
  871. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  872. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  873. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  874. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  875. From Grp_DelegationInfo gdi
  876. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  877. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  878. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  879. Where gdi.IsDel = 0 {1}
  880. ) temp ", orderbyStr, sqlWhere);
  881. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  882. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  883. #region 处理所属部门
  884. /*
  885. * 1.sq 和 gyy 等显示 市场部
  886. * 2.王鸽和主管及张总还有管理员号统一国交部
  887. * 2-1. 4 管理员 ,21 张海麟
  888. */
  889. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  890. List<int> userIds1 = new List<int>() { 4, 21 };
  891. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  892. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  893. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  894. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  895. .ToList();
  896. foreach (var item in _DelegationList)
  897. {
  898. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  899. }
  900. #endregion
  901. var _view = new
  902. {
  903. PageFuncAuth = pageFunAuthView,
  904. Data = _DelegationList
  905. };
  906. return Ok(JsonView(true, "查询成功!", _view, total));
  907. }
  908. /// <summary>
  909. /// 接团信息详情
  910. /// </summary>
  911. /// <param name="dto">团组info请求dto</param>
  912. /// <returns></returns>
  913. [HttpPost]
  914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  915. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  916. {
  917. var groupData = await _groupRepository.GetGroupInfo(dto);
  918. if (groupData.Code != 0)
  919. {
  920. return Ok(JsonView(false, groupData.Msg));
  921. }
  922. return Ok(JsonView(groupData.Data));
  923. }
  924. /// <summary>
  925. /// 接团信息 编辑添加
  926. /// 基础信息数据源
  927. /// </summary>
  928. /// <param name="dto"></param>
  929. /// <returns></returns>
  930. [HttpPost]
  931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  932. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  933. {
  934. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  935. if (groupData.Code != 0)
  936. {
  937. return Ok(JsonView(false, groupData.Msg));
  938. }
  939. return Ok(JsonView(groupData.Data));
  940. }
  941. /// <summary>
  942. /// 成本修改团组信息
  943. /// </summary>
  944. /// <param name="dto"></param>
  945. /// <returns></returns>
  946. [HttpPost]
  947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  948. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  949. {
  950. var jw = JsonView(false, "操作失败");
  951. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  952. if (di == null)
  953. {
  954. jw.Msg = "参数有误!";
  955. return Ok(jw);
  956. }
  957. #region 添加出访起止时间
  958. var startTime = new DateTime();
  959. var endTime = new DateTime();
  960. if (DateTime.TryParse(dto.VisitDate, out startTime))
  961. {
  962. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  963. }
  964. else
  965. {
  966. jw.Msg = "参数有误!";
  967. return Ok(jw);
  968. }
  969. #endregion
  970. di.VisitDate = startTime;
  971. di.VisitPNumber = dto.VisitPNumber;
  972. di.VisitDays = dto.VisitDays;
  973. di.VisitStartDate = startTime;
  974. di.VisitEndDate = endTime;
  975. var count = _sqlSugar.Updateable(di)
  976. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays , x.VisitStartDate, x.VisitEndDate })
  977. .ExecuteCommand();
  978. return Ok( count > 0 ? JsonView(true, "操作成功") : jw);
  979. }
  980. /// <summary>
  981. /// 接团信息 编辑添加
  982. /// 省份-城市 基础信息数据源
  983. /// </summary>
  984. /// <param name="dto"></param>
  985. /// <returns></returns>
  986. [HttpPost]
  987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  988. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  989. {
  990. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  991. string search = dto.Search;
  992. var data = await _groupRepository.CityBasicSource();
  993. int total = data.Length;
  994. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  995. .Skip((pageIndex - 1) * pageSize)
  996. .Take(pageSize)
  997. .ToArray();
  998. return Ok(JsonView(data, total));
  999. }
  1000. /// <summary>
  1001. /// 接团信息 操作(增改)
  1002. /// </summary>
  1003. /// <param name="dto"></param>
  1004. /// <returns></returns>
  1005. [HttpPost]
  1006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1007. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1008. {
  1009. // 创建 Stopwatch 实例
  1010. Stopwatch stopwatch = Stopwatch.StartNew();
  1011. decimal ffrPrice = 0.00M;
  1012. DateTime? visitDt = null;
  1013. if (dto.Status == 2)
  1014. {
  1015. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1016. if (groupInfo != null)
  1017. {
  1018. ffrPrice = groupInfo.PaymentMoney;
  1019. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1020. }
  1021. }
  1022. var groupData = await _groupRepository.GroupOperation(dto);
  1023. if (groupData.Code != 0)
  1024. {
  1025. return Ok(JsonView(false, groupData.Msg));
  1026. }
  1027. int diId = 0;
  1028. try
  1029. {
  1030. //添加时 默认加入团组汇率
  1031. if (dto.Status == 1) //添加
  1032. {
  1033. diId = groupData.Data;
  1034. //添加默认币种
  1035. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1036. //默认分配权限
  1037. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1038. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1039. var _managerIds = new List<int>() { 22, 32, 21 };
  1040. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1041. if (userIds.Count > 0)
  1042. {
  1043. userIds.Add(208);
  1044. //创建团组管控
  1045. GroupStepForDelegation.CreateWorkStep(diId);
  1046. //发送消息
  1047. string groupName = dto.TeamName;
  1048. string createGroupUser = string.Empty;
  1049. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1050. if (userInfo != null) createGroupUser = userInfo.CnName;
  1051. string title = $"系统通知";
  1052. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1053. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1054. }
  1055. //默认创建倒推表
  1056. await _invertedListRep._Create(dto.UserId, diId);
  1057. }
  1058. else if (dto.Status == 2)
  1059. {
  1060. diId = dto.Id;
  1061. }
  1062. #region 签证人员团组时间通知
  1063. #region 计算出访起止时间
  1064. var startTime = new DateTime();
  1065. var endTime = new DateTime();
  1066. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1067. {
  1068. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1069. }
  1070. #endregion
  1071. #endregion
  1072. #region 团组操作默认添加/修改收款账单
  1073. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1074. {
  1075. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1076. .Where(x => x.IsDel == 0 &&
  1077. x.Diid == diId &&
  1078. x.Remark.Equals("预付款")
  1079. )
  1080. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1081. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1082. .FirstAsync();
  1083. ffrInfo = new Fin_ForeignReceivables()
  1084. {
  1085. Diid = diId,
  1086. PriceName = dto.ClientUnit,
  1087. Price = dto.PaymentMoney,
  1088. Count = 1,
  1089. Unit = $"元",
  1090. ItemSumPrice = dto.PaymentMoney,
  1091. Rate = 1.0000M,
  1092. Currency = 836,
  1093. AddingWay = 0,
  1094. CreateUserId = dto.UserId,
  1095. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1096. Remark = $"预付款"
  1097. };
  1098. if (ffrInfo == null) //Add
  1099. {
  1100. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1101. }
  1102. else //修改
  1103. {
  1104. await _sqlSugar.Updateable(ffrInfo)
  1105. .UpdateColumns(x => new
  1106. {
  1107. x.PriceName,
  1108. x.Price,
  1109. x.ItemSumPrice,
  1110. x.CreateTime,
  1111. x.CreateUserId
  1112. })
  1113. .WhereColumns(x => x.Id)
  1114. .ExecuteCommandAsync();
  1115. }
  1116. }
  1117. #endregion
  1118. if (diId > 0)
  1119. {
  1120. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1121. }
  1122. // 停止计时
  1123. stopwatch.Stop();
  1124. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1125. }
  1126. catch (Exception ex)
  1127. {
  1128. // 停止计时
  1129. stopwatch.Stop();
  1130. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1131. Logs(ex.Message);
  1132. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1133. }
  1134. // 停止计时
  1135. stopwatch.Stop();
  1136. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1137. }
  1138. /// <summary>
  1139. /// 接团流程操作(增改)
  1140. /// 安卓端使用 建团时添加客户名单
  1141. /// </summary>
  1142. /// <param name="dto"></param>
  1143. /// <returns></returns>
  1144. [HttpPost]
  1145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1146. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1147. {
  1148. #region 参数验证
  1149. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1151. #region 页面操作权限验证
  1152. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1153. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1154. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1155. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1156. #endregion
  1157. #endregion
  1158. try
  1159. {
  1160. //_sqlSugar.BeginTran();
  1161. decimal ffrPrice = 0.00M;
  1162. DateTime? visitDt = null;
  1163. if (dto.Status == 2)
  1164. {
  1165. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1166. if (groupInfo != null)
  1167. {
  1168. ffrPrice = groupInfo.PaymentMoney;
  1169. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1170. }
  1171. }
  1172. var _dto = new GroupOperationDto();
  1173. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1174. var groupData = await _groupRepository.GroupOperation(_dto);
  1175. if (groupData.Code != 0)
  1176. {
  1177. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1178. }
  1179. int diId = 0;
  1180. //添加时 默认加入团组汇率
  1181. if (dto.Status == 1) //添加
  1182. {
  1183. diId = groupData.Data;
  1184. //添加默认币种
  1185. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1186. //默认分配权限
  1187. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1188. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1189. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1190. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1191. if (userIds.Count > 0)
  1192. {
  1193. userIds.Add(208);
  1194. //创建团组管控
  1195. GroupStepForDelegation.CreateWorkStep(diId);
  1196. //发送消息
  1197. string groupName = dto.TeamName;
  1198. string createGroupUser = string.Empty;
  1199. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1200. if (userInfo != null) createGroupUser = userInfo.CnName;
  1201. string title = $"系统通知";
  1202. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1203. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1204. }
  1205. #region 应用推送
  1206. try
  1207. {
  1208. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1209. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1210. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1211. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1212. {
  1213. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1214. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1215. }
  1216. }
  1217. catch (Exception ex)
  1218. {
  1219. }
  1220. #endregion
  1221. //默认创建倒推表
  1222. await _invertedListRep._Create(dto.UserId, diId);
  1223. }
  1224. if (dto.Status == 2)
  1225. {
  1226. diId = dto.Id;
  1227. if (diId == 0)
  1228. {
  1229. //_sqlSugar.RollbackTran();
  1230. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1231. }
  1232. }
  1233. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1234. if (viewData.Code != 0)
  1235. {
  1236. //_sqlSugar.RollbackTran();
  1237. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1238. }
  1239. #region 团组操作默认添加/修改收款账单
  1240. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1241. {
  1242. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1243. .Where(x => x.IsDel == 0 &&
  1244. x.Diid == diId &&
  1245. x.Remark.Equals("预付款")
  1246. )
  1247. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1248. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1249. .FirstAsync();
  1250. ffrInfo = new Fin_ForeignReceivables()
  1251. {
  1252. Diid = diId,
  1253. PriceName = dto.ClientUnit,
  1254. Price = dto.PaymentMoney,
  1255. Count = 1,
  1256. Unit = $"元",
  1257. ItemSumPrice = dto.PaymentMoney,
  1258. Rate = 1.0000M,
  1259. Currency = 836,
  1260. AddingWay = 0,
  1261. CreateUserId = dto.UserId,
  1262. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1263. Remark = $"预付款"
  1264. };
  1265. if (ffrInfo == null) //Add
  1266. {
  1267. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1268. }
  1269. else //修改
  1270. {
  1271. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1272. .UpdateColumns(x => new
  1273. {
  1274. x.PriceName,
  1275. x.Price,
  1276. x.ItemSumPrice,
  1277. x.CreateTime,
  1278. x.CreateUserId
  1279. })
  1280. .WhereColumns(x => x.Id)
  1281. .ExecuteCommandAsync();
  1282. }
  1283. }
  1284. #endregion
  1285. #region 签证人员团组时间通知
  1286. #region 计算出访起止时间
  1287. var startTime = new DateTime();
  1288. var endTime = new DateTime();
  1289. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1290. {
  1291. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1292. }
  1293. #endregion
  1294. if (diId > 0)
  1295. {
  1296. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1297. }
  1298. #endregion
  1299. //_sqlSugar.CommitTran();
  1300. return Ok(JsonView(true, "添加成功"));
  1301. }
  1302. catch (Exception ex)
  1303. {
  1304. _sqlSugar.RollbackTran();
  1305. return Ok(JsonView(false, ex.Message));
  1306. }
  1307. }
  1308. /// <summary>
  1309. /// 接团流程操作(增改)
  1310. /// 安卓端使用 建团时添加客户名单
  1311. /// </summary>
  1312. /// <param name="dto"></param>
  1313. /// <returns></returns>
  1314. [HttpPost]
  1315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1316. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1317. {
  1318. #region 参数验证
  1319. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1320. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1321. #region 页面操作权限验证
  1322. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1323. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1324. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1325. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1326. #endregion
  1327. #endregion
  1328. _sqlSugar.BeginTran();
  1329. decimal ffrPrice = 0.00M;
  1330. DateTime? visitDt = null;
  1331. if (dto.Status == 2)
  1332. {
  1333. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1334. if (groupInfo != null)
  1335. {
  1336. ffrPrice = groupInfo.PaymentMoney;
  1337. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1338. }
  1339. }
  1340. var _dto = new GroupOperationDto();
  1341. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1342. var groupData = await _groupRepository.GroupOperation(_dto);
  1343. if (groupData.Code != 0)
  1344. {
  1345. _sqlSugar.RollbackTran();
  1346. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1347. }
  1348. try
  1349. {
  1350. int diId = 0;
  1351. //添加时 默认加入团组汇率
  1352. if (dto.Status == 1) //添加
  1353. {
  1354. diId = groupData.Data;
  1355. //添加默认币种
  1356. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1357. //默认分配权限
  1358. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1359. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1360. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1361. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1362. if (userIds.Count > 0)
  1363. {
  1364. userIds.Add(208);
  1365. //创建团组管控
  1366. GroupStepForDelegation.CreateWorkStep(diId);
  1367. //发送消息
  1368. string groupName = dto.TeamName;
  1369. string createGroupUser = string.Empty;
  1370. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1371. if (userInfo != null) createGroupUser = userInfo.CnName;
  1372. string title = $"系统通知";
  1373. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1374. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1375. }
  1376. #region 应用推送
  1377. try
  1378. {
  1379. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1380. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1381. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1382. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1383. {
  1384. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1385. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1386. }
  1387. }
  1388. catch (Exception ex)
  1389. {
  1390. _sqlSugar.CommitTran();
  1391. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1392. }
  1393. #endregion
  1394. //默认创建倒推表
  1395. await _invertedListRep._Create(dto.UserId, diId);
  1396. }
  1397. else if (dto.Status == 2)
  1398. {
  1399. diId = dto.Id;
  1400. if (diId == 0)
  1401. {
  1402. _sqlSugar.RollbackTran();
  1403. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1404. }
  1405. }
  1406. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1407. if (viewData.Code != 0)
  1408. {
  1409. _sqlSugar.RollbackTran();
  1410. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1411. }
  1412. #region 团组操作默认添加/修改收款账单
  1413. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1414. {
  1415. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1416. .Where(x => x.IsDel == 0 &&
  1417. x.Diid == diId &&
  1418. x.Remark.Equals("预付款")
  1419. )
  1420. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1421. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1422. .FirstAsync();
  1423. ffrInfo = new Fin_ForeignReceivables()
  1424. {
  1425. Diid = diId,
  1426. PriceName = dto.ClientUnit,
  1427. Price = dto.PaymentMoney,
  1428. Count = 1,
  1429. Unit = $"元",
  1430. ItemSumPrice = dto.PaymentMoney,
  1431. Rate = 1.0000M,
  1432. Currency = 836,
  1433. AddingWay = 0,
  1434. CreateUserId = dto.UserId,
  1435. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1436. Remark = $"预付款"
  1437. };
  1438. if (ffrInfo == null) //Add
  1439. {
  1440. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1441. }
  1442. else //修改
  1443. {
  1444. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1445. .UpdateColumns(x => new
  1446. {
  1447. x.PriceName,
  1448. x.Price,
  1449. x.ItemSumPrice,
  1450. x.CreateTime,
  1451. x.CreateUserId
  1452. })
  1453. .WhereColumns(x => x.Id)
  1454. .ExecuteCommandAsync();
  1455. }
  1456. }
  1457. #endregion
  1458. #region 签证人员团组时间通知
  1459. #region 计算出访起止时间
  1460. var startTime = new DateTime();
  1461. var endTime = new DateTime();
  1462. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1463. {
  1464. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1465. }
  1466. #endregion
  1467. if (diId > 0)
  1468. {
  1469. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1470. }
  1471. #endregion
  1472. _sqlSugar.CommitTran();
  1473. return Ok(JsonView(true));
  1474. }
  1475. catch (Exception ex)
  1476. {
  1477. _sqlSugar.RollbackTran();
  1478. return Ok(JsonView(false, ex.Message));
  1479. }
  1480. }
  1481. /// <summary>
  1482. /// 接团信息 操作(删除)
  1483. /// </summary>
  1484. /// <param name="dto"></param>
  1485. /// <returns></returns>
  1486. [HttpPost]
  1487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1488. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1489. {
  1490. var diId = dto.Id;
  1491. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1492. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1493. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1494. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1495. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1496. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1497. #endregion
  1498. var groupData = await _groupRepository.GroupDel(dto);
  1499. if (groupData.Code != 0)
  1500. {
  1501. return Ok(JsonView(false, groupData.Msg));
  1502. }
  1503. return Ok(JsonView(true));
  1504. }
  1505. /// <summary>
  1506. /// 获取团组销售报价号
  1507. /// 团组添加时 使用
  1508. /// </summary>
  1509. /// <returns></returns>
  1510. [HttpPost]
  1511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1512. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1513. {
  1514. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1515. if (groupData.Code != 0)
  1516. {
  1517. return Ok(JsonView(false, groupData.Msg));
  1518. }
  1519. object salesQuoteNo = new
  1520. {
  1521. SalesQuoteNo = groupData.Data
  1522. };
  1523. return Ok(JsonView(salesQuoteNo));
  1524. }
  1525. /// <summary>
  1526. /// 设置确认出团
  1527. /// </summary>
  1528. /// <param name="dto"></param>
  1529. /// <returns></returns>
  1530. [HttpPost]
  1531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1532. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1533. {
  1534. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1535. if (groupData.Code != 0)
  1536. {
  1537. return Ok(JsonView(false, groupData.Msg));
  1538. }
  1539. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1540. #region OA消息推送
  1541. try
  1542. {
  1543. string groupName = groupInfo.TeamName;
  1544. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1545. string title = $"系统通知";
  1546. string content = $"团组[{groupName}]已确认出团!";
  1547. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1548. }
  1549. catch (Exception ex)
  1550. {
  1551. }
  1552. #endregion
  1553. #region 应用推送
  1554. try
  1555. {
  1556. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1557. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1558. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1559. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1560. {
  1561. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1562. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1563. }
  1564. }
  1565. catch (Exception ex)
  1566. {
  1567. }
  1568. #endregion
  1569. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1570. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1571. }
  1572. /// <summary>
  1573. /// 获取团组名称data And 签证国别Data
  1574. /// </summary>
  1575. /// <param name="dto"></param>
  1576. /// <returns></returns>
  1577. [HttpPost]
  1578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1579. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1580. {
  1581. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1582. if (groupData.Code != 0)
  1583. {
  1584. return Ok(JsonView(false, groupData.Msg));
  1585. }
  1586. return Ok(JsonView(groupData.Data));
  1587. }
  1588. /// <summary>
  1589. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1590. /// </summary>
  1591. /// <returns></returns>
  1592. [HttpPost]
  1593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1594. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1595. {
  1596. try
  1597. {
  1598. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1599. if (groupData.Code != 0)
  1600. {
  1601. return Ok(JsonView(false, groupData.Msg));
  1602. }
  1603. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1604. }
  1605. catch (Exception ex)
  1606. {
  1607. return Ok(JsonView(false, "程序错误!"));
  1608. throw;
  1609. }
  1610. }
  1611. /// <summary>
  1612. /// 团组清单 Excel
  1613. /// </summary>
  1614. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1615. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1616. /// <returns></returns>
  1617. [HttpGet]
  1618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1619. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1620. {
  1621. DateTime _beginDt, _endDt;
  1622. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1623. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1624. if (!beginBool && !endBool)
  1625. {
  1626. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1627. }
  1628. string sql = string.Format(@"
  1629. SELECT
  1630. ROW_NUMBER,
  1631. Id,
  1632. SalesQuoteNo,
  1633. TourCode,
  1634. TeamTypeId,
  1635. TeamType,
  1636. TeamLevId,
  1637. TeamLev,
  1638. TeamName,
  1639. ClientName,
  1640. ClientUnit,
  1641. VisitDate,
  1642. VisitDays,
  1643. VisitPNumber,
  1644. JietuanOperatorId,
  1645. JietuanOperator,
  1646. IsSure,
  1647. CreateUserName,
  1648. IsBid
  1649. FROM
  1650. (
  1651. SELECT
  1652. ROW_NUMBER() OVER(
  1653. ORDER BY
  1654. gdi.VisitDate Desc
  1655. ) AS ROW_NUMBER,
  1656. gdi.Id,
  1657. SalesQuoteNo,
  1658. TourCode,
  1659. ssd.Id TeamTypeId,
  1660. ssd.Name TeamType,
  1661. ssd1.Id TeamLevId,
  1662. ssd1.Name TeamLev,
  1663. TeamName,
  1664. ClientName,
  1665. ClientUnit,
  1666. VisitDate,
  1667. VisitDays,
  1668. VisitPNumber,
  1669. JietuanOperator JietuanOperatorId,
  1670. su.CnName JietuanOperator,
  1671. IsSure,
  1672. gdi.CreateTime,
  1673. su1.CnName As CreateUserName,
  1674. gdi.IsBid
  1675. FROM
  1676. Grp_DelegationInfo gdi
  1677. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1678. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1679. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1680. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1681. WHERE
  1682. gdi.IsDel = 0
  1683. AND gdi.IsBid = 0
  1684. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1685. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1686. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1687. #region 处理所属部门
  1688. /*
  1689. * 1.sq 和 gyy 等显示 市场部
  1690. * 2.王鸽和主管及张总还有管理员号统一国交部
  1691. * 2-1. 4 管理员 ,21 张海麟
  1692. */
  1693. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1694. List<int> userIds1 = new List<int>() { 4, 21 };
  1695. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1696. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1697. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1698. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1699. .ToListAsync();
  1700. var droupIds = groupList.Select(it => it.Id).ToList();
  1701. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1702. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1703. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1704. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1705. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1706. {
  1707. DiId = tcl.DiId,
  1708. LastName = dc.LastName,
  1709. FirstName = dc.FirstName,
  1710. Sex = dc.Sex,
  1711. Birthday = dc.BirthDay,
  1712. Company = cc.CompanyFullName,
  1713. Job = dc.Job,
  1714. CreateTime = tcl.CreateTime,
  1715. })
  1716. .ToList();
  1717. foreach (var item in groupList)
  1718. {
  1719. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1720. string groupFirstName = "";
  1721. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1722. if (currDatas.Any())
  1723. {
  1724. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1725. }
  1726. item.GroupFirst = groupFirstName;
  1727. }
  1728. #endregion
  1729. #region Excel
  1730. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1731. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1732. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1733. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1734. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1735. //载入模板
  1736. WorkbookDesigner designer = new WorkbookDesigner();
  1737. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1738. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1739. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1740. dt.TableName = "GroupList";
  1741. designer.SetDataSource(dt);
  1742. designer.Process();
  1743. if (!Directory.Exists(savePath))
  1744. {
  1745. Directory.CreateDirectory(savePath);
  1746. }
  1747. string serverPath = $"{savePath}{fileName}";
  1748. designer.Workbook.Save(serverPath);
  1749. string rst = $"{servicePath}{ftpPath}{fileName}";
  1750. #endregion
  1751. return Ok(JsonView(true, "操作成功!", rst));
  1752. }
  1753. /// <summary>
  1754. /// 团组合同下载(1.付款80% 2.付全款)
  1755. /// </summary>
  1756. /// <param name="dto"></param>
  1757. /// <returns></returns>
  1758. /// <exception cref="Exception"></exception>
  1759. [HttpPost]
  1760. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1761. {
  1762. var jw = JsonView(false);
  1763. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1764. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1765. if (di == null)
  1766. {
  1767. jw.Msg = "团组Id有误!";
  1768. return Ok(jw);
  1769. }
  1770. #region 权限校验
  1771. var allDownFile = new List<int>() { 21 };
  1772. try
  1773. {
  1774. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1775. .First(x => x.Id == 1418 && x.IsDel == 0);
  1776. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1777. }
  1778. catch (Exception)
  1779. { }
  1780. var guojiaoDownFile = new List<int>() { 330 };
  1781. var shichangDownFile = new List<int>() { 95 };
  1782. if (allDownFile.Contains(dto.UserId))
  1783. {
  1784. }
  1785. else if (guojiaoDownFile.Contains(dto.UserId))
  1786. {
  1787. var guojiaobuDi = new List<int>() { 4, 21 };
  1788. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1789. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1790. .Where((d, u) => u.Id == di.JietuanOperator)
  1791. .Select((d, u) => d.DepName)
  1792. .First();
  1793. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1794. {
  1795. jw.Msg = "暂无下载权限!";
  1796. return Ok(jw);
  1797. }
  1798. }
  1799. else if (shichangDownFile.Contains(dto.UserId))
  1800. {
  1801. var dic = new Dictionary<int, int[]>()
  1802. {
  1803. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1804. };
  1805. try
  1806. {
  1807. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1808. if (sqSetting != null)
  1809. {
  1810. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1811. foreach (var item in result.Keys)
  1812. {
  1813. if (dic.Keys.Contains(item))
  1814. {
  1815. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1816. Array.Copy(dic[item], dilatation, dic[item].Length);
  1817. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1818. dic[item] = dilatation;
  1819. }
  1820. else
  1821. {
  1822. dic.Add(item, result[item]);
  1823. }
  1824. }
  1825. }
  1826. if (!dic[95].Contains(di.CreateUserId))
  1827. {
  1828. jw.Msg = "暂无下载权限!";
  1829. return Ok(jw);
  1830. }
  1831. }
  1832. catch (Exception)
  1833. { }
  1834. }
  1835. else if (dto.UserId == di.CreateUserId)
  1836. {
  1837. }
  1838. else
  1839. {
  1840. jw.Msg = "暂无下载权限!";
  1841. return Ok(jw);
  1842. }
  1843. #endregion
  1844. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1845. .Where(x=>x.DiId == dto.GroupId && x.IsDel == 0)
  1846. .ToListAsync();
  1847. if (!blackCodeList.Any())
  1848. {
  1849. jw.Msg = "该团无机票行程代码!";
  1850. return Ok(jw);
  1851. }
  1852. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1853. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1854. if (groupEnterExitCost == null)
  1855. {
  1856. jw.Msg = "暂无三公费用信息!";
  1857. return Ok(jw);
  1858. }
  1859. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1860. rateList ??= new List<CurrencyInfo>();
  1861. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1862. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1863. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1864. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1865. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1866. .Select((x, a, b) => new
  1867. {
  1868. x.Index,
  1869. itemName = a.Name,
  1870. CurrencyStr = b.Name,
  1871. x.Cost,
  1872. x.SubTotal,
  1873. x.Remark
  1874. })
  1875. .OrderBy((x) => x.Index)
  1876. .ToList();
  1877. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1878. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1879. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1880. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1881. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1882. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1883. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1884. decimal subJJC = 0.00M,
  1885. subGWC = 0.00M,
  1886. subTDC = 0.00M;
  1887. //经济舱
  1888. if (groupEnterExitCost.SumJJC == 1)
  1889. {
  1890. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1891. }
  1892. //公务舱
  1893. if (groupEnterExitCost.SumGWC == 1)
  1894. {
  1895. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1896. }
  1897. //头等舱
  1898. if (groupEnterExitCost.SumTDC == 1)
  1899. {
  1900. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1901. }
  1902. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1903. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1904. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1905. .LeftJoin<Crm_CustomerCompany>((x, s, dc,cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1906. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1907. .Select((x, s, dc, cc) => new groupClints
  1908. {
  1909. Id =x.Id,
  1910. Name =s.Name,
  1911. IsAccompany =x.IsAccompany,
  1912. CompanyFullName =cc.CompanyFullName
  1913. })
  1914. .ToListAsync();
  1915. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1916. //获取舱位人数
  1917. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1918. .GroupBy(x => x.Name)
  1919. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1920. .ToList();
  1921. string cityPath = string.Empty;
  1922. string startCity = string.Empty;
  1923. string endCity = string.Empty;
  1924. foreach (var item in blackCodeList)
  1925. {
  1926. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1927. cityPath += city + "\r\n";
  1928. if (item.Equals(blackCodeList.First()))
  1929. {
  1930. var sp = city.Split('-');
  1931. startCity = sp[0];
  1932. endCity = sp[sp.Length - 1];
  1933. }
  1934. }
  1935. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1936. bookMarkDic.Add("ClientUnit",di.ClientUnit);
  1937. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1938. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1939. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1940. bookMarkDic.Add("CityPath", cityPath);
  1941. bookMarkDic.Add("StartCity", startCity);
  1942. bookMarkDic.Add("EndCity", endCity);
  1943. bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays -1}晚");
  1944. Document doc = null;
  1945. var percentage = 0.8M;
  1946. var fileNameadd = "预付";
  1947. if (dto.FileType == 1)
  1948. {
  1949. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  1950. }
  1951. else if (dto.FileType == 2)
  1952. {
  1953. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  1954. percentage = 1;
  1955. fileNameadd = "全款";
  1956. }
  1957. else
  1958. {
  1959. throw new Exception("FileType有误!");
  1960. }
  1961. DocumentBuilder builder = new DocumentBuilder(doc);
  1962. decimal totalPrice = 0.00M;
  1963. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  1964. if (firstTable != null)
  1965. {
  1966. // 遍历表格的行和单元格
  1967. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  1968. {
  1969. for (int i = 0; i < row.Cells.Count; i++)
  1970. {
  1971. var cell = row.Cells[i];
  1972. // 读取单元格内容
  1973. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  1974. if (cellTextFirst.Contains("舱位"))
  1975. {
  1976. break;
  1977. }
  1978. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  1979. {
  1980. if (i == 2)
  1981. {
  1982. if (cellTextFirst == "经济舱")
  1983. {
  1984. // 设置单元格内容
  1985. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1986. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  1987. }
  1988. else
  1989. {
  1990. // 设置单元格内容
  1991. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1992. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  1993. }
  1994. }
  1995. if (i == 3)
  1996. {
  1997. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1998. if (count != null)
  1999. {
  2000. // 设置单元格内容
  2001. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2002. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2003. }
  2004. }
  2005. if (i == 4)
  2006. {
  2007. var rowPrice = 0.00M;
  2008. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2009. count ??= 0;
  2010. if (cellTextFirst == "经济舱")
  2011. {
  2012. rowPrice = subJJC * (int)count;
  2013. }
  2014. else
  2015. {
  2016. rowPrice = subGWC * (int)count;
  2017. }
  2018. totalPrice += rowPrice;
  2019. // 设置单元格内容
  2020. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2021. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2022. }
  2023. }
  2024. }
  2025. }
  2026. }
  2027. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2028. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2029. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2030. //--合同表格部分
  2031. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2032. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2033. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2034. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2035. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日")+"-"+di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2036. bookMarkDic.Add("CityPath1", cityPath);
  2037. bookMarkDic.Add("CityPath2", cityPath);
  2038. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2039. if (contractTable != null)
  2040. {
  2041. //数据源
  2042. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2043. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2044. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2045. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2046. .Select((it, y, s) => new
  2047. {
  2048. it.Cost,
  2049. it.SubTotal,
  2050. it.Type,
  2051. y.Id,
  2052. y.City,
  2053. s.Name,
  2054. CurrencyCodeCn = s.Remark
  2055. })
  2056. .ToList()
  2057. .Select(x => new
  2058. {
  2059. CurrencyCode = x.Name,
  2060. CityId = x.Id,
  2061. x.City,
  2062. VisitPNumber = di.VisitPNumber,
  2063. x.Type,
  2064. x.Cost,
  2065. x.SubTotal,
  2066. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2067. x.CurrencyCodeCn,
  2068. });
  2069. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2070. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2071. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2072. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2073. List<tableSetting> tableSettings = new List<tableSetting>()
  2074. {
  2075. new tableSetting{ Index = 1 , Property = "City"},
  2076. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  2077. new tableSetting{ Index = 3 , Property = "Cost"},
  2078. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  2079. //new tableSetting{ Index = 5 , Property = ""},
  2080. //new tableSetting{ Index = 6 , Property = ""},
  2081. new tableSetting{ Index = 7 , Property = "Rate"},
  2082. //new tableSetting{ Index = 8 , Property = ""},
  2083. };
  2084. //1.住宿费
  2085. int cloneRow = 8;
  2086. int startDayPrice = 8; //写入index
  2087. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2088. foreach (var dac in dac1)
  2089. {
  2090. var first = dac.First();
  2091. var dayCount = dac.Count();
  2092. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2093. for (int i = 1; i < row.Cells.Count; i++)
  2094. {
  2095. var cell = row.Cells[i];
  2096. var findProperty = tableSettings.Find(x => x.Index == i);
  2097. if (findProperty != null)
  2098. {
  2099. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2100. // 设置单元格内容
  2101. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2102. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2103. }
  2104. else
  2105. {
  2106. switch (i)
  2107. {
  2108. case 5:
  2109. cell.FirstParagraph.Runs.Clear();
  2110. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2111. break;
  2112. case 6:
  2113. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2114. cell.FirstParagraph.Runs.Clear();
  2115. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2116. break;
  2117. case 8:
  2118. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2119. cell.FirstParagraph.Runs.Clear();
  2120. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2121. ZSPriceSum += xiaojiRMB;
  2122. break;
  2123. default:
  2124. break;
  2125. }
  2126. }
  2127. }
  2128. startDayPrice++;
  2129. if (!dac1.Last().Equals(dac))
  2130. {
  2131. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2132. // 将克隆的行追加到原行后面
  2133. contractTable.Rows.Insert(startDayPrice, newRow);
  2134. }
  2135. else
  2136. {
  2137. cloneRow += dac1.Count() + 1;
  2138. startDayPrice = cloneRow;
  2139. }
  2140. }
  2141. //2.伙食费
  2142. foreach (var dac in dac2)
  2143. {
  2144. var first = dac.First();
  2145. var dayCount = dac.Count();
  2146. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2147. for (int i = 1; i < row.Cells.Count; i++)
  2148. {
  2149. var cell = row.Cells[i];
  2150. var findProperty = tableSettings.Find(x => x.Index == i);
  2151. if (findProperty != null)
  2152. {
  2153. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2154. // 设置单元格内容
  2155. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2156. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2157. }
  2158. else
  2159. {
  2160. switch (i)
  2161. {
  2162. case 5:
  2163. cell.FirstParagraph.Runs.Clear();
  2164. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2165. break;
  2166. case 6:
  2167. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2168. cell.FirstParagraph.Runs.Clear();
  2169. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2170. break;
  2171. case 8:
  2172. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2173. cell.FirstParagraph.Runs.Clear();
  2174. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2175. HSPriceSum += xiaojiRMB;
  2176. break;
  2177. default:
  2178. break;
  2179. }
  2180. }
  2181. }
  2182. startDayPrice++;
  2183. if (!dac2.Last().Equals(dac))
  2184. {
  2185. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2186. // 将克隆的行追加到原行后面
  2187. contractTable.Rows.Insert(startDayPrice, newRow);
  2188. }
  2189. else
  2190. {
  2191. cloneRow += dac2.Count() + 1;
  2192. startDayPrice = cloneRow;
  2193. }
  2194. }
  2195. //3.公杂费
  2196. foreach (var dac in dac3)
  2197. {
  2198. var first = dac.First();
  2199. var dayCount = dac.Count();
  2200. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2201. for (int i = 1; i < row.Cells.Count; i++)
  2202. {
  2203. var cell = row.Cells[i];
  2204. var findProperty = tableSettings.Find(x => x.Index == i);
  2205. if (findProperty != null)
  2206. {
  2207. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2208. // 设置单元格内容
  2209. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2210. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2211. }
  2212. else
  2213. {
  2214. switch (i)
  2215. {
  2216. case 5:
  2217. cell.FirstParagraph.Runs.Clear();
  2218. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2219. break;
  2220. case 6:
  2221. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2222. cell.FirstParagraph.Runs.Clear();
  2223. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2224. break;
  2225. case 8:
  2226. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2227. cell.FirstParagraph.Runs.Clear();
  2228. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2229. GZPriceSum += xiaojiRMB;
  2230. break;
  2231. default:
  2232. break;
  2233. }
  2234. }
  2235. }
  2236. startDayPrice++;
  2237. if (!dac3.Last().Equals(dac))
  2238. {
  2239. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2240. // 将克隆的行追加到原行后面
  2241. contractTable.Rows.Insert(startDayPrice, newRow);
  2242. }
  2243. else
  2244. {
  2245. cloneRow += dac3.Count() + 1;
  2246. startDayPrice = cloneRow;
  2247. }
  2248. }
  2249. //合并单元格
  2250. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2251. {
  2252. var currentRow = contractTable.Rows[i];
  2253. var nextRow = contractTable.Rows[i + 1];
  2254. // 获取当前行和下一行的第一个单元格
  2255. Cell currentCell = currentRow.Cells[0];
  2256. Cell nextCell = nextRow.Cells[0];
  2257. // 检查单元格内容是否一致(去除尾部的换行符)
  2258. string currentText = currentCell.GetText().Trim();
  2259. string nextText = nextCell.GetText().Trim();
  2260. if (currentText == nextText)
  2261. {
  2262. // 如果当前单元格已经被合并,找到合并的起始单元格
  2263. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2264. {
  2265. // 找到合并的起始单元格
  2266. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2267. // 将下一行的单元格设置为合并的后续单元格
  2268. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2269. }
  2270. else
  2271. {
  2272. // 如果当前单元格是合并的起始单元格
  2273. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2274. // 将下一行的单元格设置为合并的后续单元格
  2275. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2276. }
  2277. }
  2278. else
  2279. {
  2280. // 如果内容不一致,重置当前单元格的合并属性
  2281. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2282. {
  2283. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2284. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2285. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2286. }
  2287. else
  2288. {
  2289. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2290. }
  2291. }
  2292. }
  2293. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2294. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2295. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2296. }
  2297. foreach (var bookmarkName in bookMarkDic.Keys)
  2298. {
  2299. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2300. if (bookmark != null)
  2301. {
  2302. if (bookmarkName == "ClientUnit")
  2303. {
  2304. // 移动到书签位置
  2305. builder.MoveTo(bookmark.BookmarkStart);
  2306. // 设置字体样式为下划线
  2307. builder.Font.Underline = Aspose.Words.Underline.Single;
  2308. // 插入书签值
  2309. builder.Write(bookMarkDic[bookmarkName]);
  2310. // 清除字体格式,避免影响后续文本
  2311. builder.Font.ClearFormatting();
  2312. }
  2313. else
  2314. {
  2315. builder.MoveToBookmark(bookmarkName);
  2316. builder.Write(bookMarkDic[bookmarkName]);
  2317. }
  2318. }
  2319. }
  2320. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2321. doc.Save(savePaht);
  2322. jw.Msg = "生成成功!";
  2323. jw.Code = 200;
  2324. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath"))};
  2325. return Ok(jw);
  2326. }
  2327. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2328. {
  2329. int index = rowIndex;
  2330. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2331. {
  2332. index--;
  2333. }
  2334. return index;
  2335. }
  2336. #endregion
  2337. #region 团组&签证
  2338. /// <summary>
  2339. /// 根据团组Id获取签证客户信息List
  2340. /// </summary>
  2341. /// <param name="dto">请求dto</param>
  2342. /// <returns></returns>
  2343. [HttpPost]
  2344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2345. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2346. {
  2347. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2348. if (groupData.Code != 0)
  2349. {
  2350. return Ok(JsonView(false, groupData.Msg));
  2351. }
  2352. return Ok(JsonView(groupData.Data));
  2353. }
  2354. /// <summary>
  2355. /// IOS获取团组签证拍照上传进度01(团组列表)
  2356. /// </summary>
  2357. /// <param name="dto">请求dto</param>
  2358. /// <returns></returns>
  2359. [HttpPost]
  2360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2361. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2362. {
  2363. if (dto == null)
  2364. {
  2365. return Ok(JsonView(false, "参数为空"));
  2366. }
  2367. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2368. return Ok(JsonView(visaList));
  2369. }
  2370. /// <summary>
  2371. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2372. /// </summary>
  2373. /// <returns></returns>
  2374. [HttpPost]
  2375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2376. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2377. {
  2378. if (dto == null)
  2379. {
  2380. return Ok(JsonView(false, "请求错误:"));
  2381. }
  2382. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2383. return Ok(JsonView(list));
  2384. }
  2385. /// <summary>
  2386. /// IOS获取团组签证拍照上传进度03(相册)
  2387. /// </summary>
  2388. /// <returns></returns>
  2389. [HttpPost]
  2390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2391. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2392. {
  2393. if (dto == null)
  2394. {
  2395. return Ok(JsonView(false, "请求错误:"));
  2396. }
  2397. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2398. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2399. list.ForEach(s => s.url = url);
  2400. return Ok(JsonView(list));
  2401. }
  2402. /// <summary>
  2403. /// IOS获取团组签证拍照上传进度04(图片上传)
  2404. /// </summary>
  2405. /// <param name="dto"></param>
  2406. /// <returns></returns>
  2407. [HttpPost]
  2408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2409. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2410. {
  2411. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2412. //if (!string.IsNullOrEmpty(result))
  2413. //{
  2414. //}
  2415. //else {
  2416. // return Ok(JsonView(false, "上传失败"));
  2417. //}
  2418. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2419. int sucNum = 0;
  2420. try
  2421. {
  2422. foreach (var item in dto.base64DataList)
  2423. {
  2424. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2425. string result = DecodeBase64ToImage(item, imageName);
  2426. if (!string.IsNullOrEmpty(result))
  2427. {
  2428. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2429. pic.CreateUserId = dto.CreateUserId;
  2430. pic.PicName = imageName;
  2431. pic.PicPath = result;
  2432. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2433. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2434. if (insertResult > 0)
  2435. {
  2436. sucNum++;
  2437. }
  2438. }
  2439. }
  2440. }
  2441. catch (Exception ex)
  2442. {
  2443. return Ok(JsonView(false, ex.Message));
  2444. }
  2445. string msg = string.Format(@"成功上传{0}张", sucNum);
  2446. return Ok(JsonView(true, msg));
  2447. }
  2448. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2449. {
  2450. string filename = "";//声明一个string类型的相对路径
  2451. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2452. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2453. try//会有异常抛出,try,catch一下
  2454. {
  2455. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2456. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2457. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2458. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2459. //文件名称
  2460. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2461. //上传的文件的路径
  2462. string filePath = "";
  2463. if (!Directory.Exists(fileDir))
  2464. {
  2465. Directory.CreateDirectory(fileDir);
  2466. }
  2467. //上传的文件的路径
  2468. filePath = fileDir + filename;
  2469. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2470. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2471. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2472. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2473. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2474. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2475. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2476. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2477. bitmap.Dispose();
  2478. }
  2479. catch (Exception e)
  2480. {
  2481. string massage = e.Message;
  2482. Logs("IOS图片上传Error:" + massage);
  2483. //filename = e.Message;
  2484. }
  2485. return filename;//返回相对路径
  2486. }
  2487. /// <summary>
  2488. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2489. /// </summary>
  2490. /// <param name="dto"></param>
  2491. /// <returns></returns>
  2492. [HttpPost]
  2493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2494. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2495. {
  2496. if (dto == null)
  2497. {
  2498. return Ok(JsonView(false, "请求错误:"));
  2499. }
  2500. string msg = "参数错误";
  2501. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2502. {
  2503. try
  2504. {
  2505. //_delegationVisaRep.BeginTran();
  2506. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2507. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2508. .Where(s => s.Id == dto.visaProgressCustomerId)
  2509. .ExecuteCommandAsync();
  2510. if (updCount > 0 && dto.publishCode == 1)
  2511. {
  2512. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2513. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2514. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2515. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2516. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2517. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2518. if (groupData == null)
  2519. {
  2520. _delegationVisaRep.RollbackTran();
  2521. }
  2522. string title = string.Format(@"[签证进度更新]");
  2523. string content = string.Format(@"测试文本");
  2524. bool rst = await _message.AddMsg(new MessageDto()
  2525. {
  2526. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2527. IssuerId = dto.publisher,
  2528. Title = title,
  2529. Content = content,
  2530. ReleaseTime = DateTime.Now,
  2531. UIdList = new List<int> {
  2532. 234
  2533. }
  2534. });
  2535. if (rst)
  2536. {
  2537. return Ok(JsonView(true, "发送通知成功"));
  2538. }
  2539. }
  2540. //_delegationVisaRep.CommitTran();
  2541. }
  2542. catch (Exception)
  2543. {
  2544. //_delegationVisaRep.RollbackTran();
  2545. }
  2546. }
  2547. return Ok(JsonView(true, msg));
  2548. }
  2549. #endregion
  2550. #region 团组任务分配
  2551. /// <summary>
  2552. /// 团组任务分配初始化
  2553. /// </summary>
  2554. /// <returns></returns>
  2555. [HttpPost]
  2556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2557. public async Task<IActionResult> GetTaskAssignmen()
  2558. {
  2559. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2560. if (groupData.Code != 0)
  2561. {
  2562. return Ok(JsonView(false, groupData.Msg));
  2563. }
  2564. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2565. }
  2566. /// <summary>
  2567. /// 团组任务分配查询
  2568. /// </summary>
  2569. /// <param name="dto"></param>
  2570. /// <returns></returns>
  2571. [HttpPost]
  2572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2573. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2574. {
  2575. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2576. if (groupData.Code != 0)
  2577. {
  2578. return Ok(JsonView(false, groupData.Msg));
  2579. }
  2580. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2581. }
  2582. /// <summary>
  2583. /// 团组任务分配操作
  2584. /// </summary>
  2585. /// <param name="dto"></param>
  2586. /// <returns></returns>
  2587. [HttpPost]
  2588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2589. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2590. {
  2591. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2592. if (groupData.Code != 0)
  2593. {
  2594. return Ok(JsonView(false, groupData.Msg));
  2595. }
  2596. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2597. }
  2598. /// <summary>
  2599. /// 团组任务分配
  2600. /// 批量分配
  2601. /// 查询团组
  2602. /// </summary>
  2603. /// <param name="dto"></param>
  2604. /// <returns></returns>
  2605. [HttpPost]
  2606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2607. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2608. {
  2609. //参数验证
  2610. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2611. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2612. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2613. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2614. }
  2615. /// <summary>
  2616. /// 团组任务分配
  2617. /// 批量分配
  2618. /// </summary>
  2619. /// <param name="dto"></param>
  2620. /// <returns></returns>
  2621. [HttpPost]
  2622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2623. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2624. {
  2625. //参数验证
  2626. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2627. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2628. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2629. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2630. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2631. }
  2632. #endregion
  2633. #region 团组费用审核
  2634. /// <summary>
  2635. /// 费用审核
  2636. /// 团组列表 Page
  2637. /// </summary>
  2638. /// <param name="_dto">团组列表请求dto</param>
  2639. /// <returns></returns>
  2640. [HttpPost]
  2641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2642. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2643. {
  2644. #region 参数验证
  2645. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2646. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2647. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2648. #region 页面操作权限验证
  2649. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2650. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2651. #endregion
  2652. #endregion
  2653. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2654. {
  2655. string sqlWhere = string.Empty;
  2656. if (_dto.IsSure == 0) //未完成
  2657. {
  2658. sqlWhere += string.Format(@" And IsSure = 0");
  2659. }
  2660. else if (_dto.IsSure == 1) //已完成
  2661. {
  2662. sqlWhere += string.Format(@" And IsSure = 1");
  2663. }
  2664. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2665. {
  2666. string tj = _dto.SearchCriteria;
  2667. 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}%')",
  2668. tj, tj, tj, tj, tj);
  2669. }
  2670. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2671. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2672. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2673. From (
  2674. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2675. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2676. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2677. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2678. From Grp_DelegationInfo gdi
  2679. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2680. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2681. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2682. Where gdi.IsDel = 0 {0}
  2683. ) temp ", sqlWhere);
  2684. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2685. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2686. var _view = new
  2687. {
  2688. PageFuncAuth = pageFunAuthView,
  2689. Data = _DelegationList
  2690. };
  2691. return Ok(JsonView(true, "查询成功!", _view, total));
  2692. }
  2693. else
  2694. {
  2695. return Ok(JsonView(false, "查询失败"));
  2696. }
  2697. }
  2698. /// <summary>
  2699. /// 获取团组费用审核
  2700. /// </summary>
  2701. /// <param name="_dto"></param>
  2702. /// <returns></returns>
  2703. [HttpPost]
  2704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2705. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2706. {
  2707. try
  2708. {
  2709. #region 参数验证
  2710. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2711. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2712. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2713. #region 页面操作权限验证
  2714. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2715. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2716. #endregion
  2717. #endregion
  2718. var _view = new Grp_CreditCardPaymentView();
  2719. var clientNameList = getSimplClientList(_dto.DiId);
  2720. #region 费用清单
  2721. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2722. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2723. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2724. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2725. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2726. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2727. /*
  2728. * 76://酒店预订
  2729. */
  2730. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2731. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2732. /*
  2733. * 79://车/导游地接
  2734. */
  2735. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2736. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2737. /*
  2738. * 80: //签证
  2739. */
  2740. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2741. /*
  2742. *81: //邀请/公务活动
  2743. */
  2744. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2745. /*
  2746. * 82: //团组客户保险
  2747. */
  2748. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2749. /*
  2750. * Lable = 85 机票预订
  2751. */
  2752. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2753. /*
  2754. * 85 机票预定
  2755. */
  2756. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2757. /*
  2758. * 98 其他款项
  2759. */
  2760. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2761. /*
  2762. * 285:收款退还
  2763. */
  2764. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2765. /*
  2766. * 1015: //超支费用
  2767. */
  2768. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2769. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2770. /*
  2771. * 币种信息
  2772. */
  2773. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2774. /*
  2775. * 车/导游地接 费用类型
  2776. */
  2777. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2778. /*
  2779. * 车/导游地接 费用类型
  2780. */
  2781. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2782. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2783. /*
  2784. * 用户信息
  2785. */
  2786. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2787. /*
  2788. * 费用模块
  2789. */
  2790. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2791. string priceModule = string.Empty;
  2792. if (sdPriceName != null)
  2793. {
  2794. priceModule = sdPriceName.Name;
  2795. }
  2796. /*
  2797. * 成本信息
  2798. */
  2799. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2800. decimal _groupRate = 0.0000M;
  2801. string _groupCurrencyCode = "-";
  2802. if (groupCost != null)
  2803. {
  2804. _groupRate = groupCost.Rate;
  2805. if (int.TryParse(groupCost.Currency, out int _currency))
  2806. {
  2807. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2808. }
  2809. else _groupCurrencyCode = groupCost.Currency;
  2810. }
  2811. string costContentSql = $"Select * From Grp_GroupCost";
  2812. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2813. //处理日期为空的天数
  2814. for (int i = 0; i < groupCostDetails.Count; i++)
  2815. if (i != 0)
  2816. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2817. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2818. /*
  2819. * 处理详情数据
  2820. */
  2821. foreach (var entity in entityList)
  2822. {
  2823. var _detail = new Grp_CreditCardPaymentDetailView();
  2824. _detail.Id = entity.Id;
  2825. _detail.PriceName = priceModule;
  2826. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2827. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2828. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2829. //处理金额
  2830. if (entity.CTable == 1015)
  2831. {
  2832. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2833. if (czInfo != null)
  2834. {
  2835. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2836. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2837. }
  2838. }
  2839. /*
  2840. * 应付款金额
  2841. */
  2842. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2843. string PaymentCurrency_WaitPay = "Unknown";
  2844. string hotelCurrncyCode = "Unknown";
  2845. string hotelCurrncyName = "Unknown";
  2846. if (sdPaymentCurrency_WaitPay != null)
  2847. {
  2848. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2849. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2850. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2851. if (hotelCurrncyCode.Equals("CNY"))
  2852. {
  2853. entity.DayRate = 1.0000M;
  2854. }
  2855. }
  2856. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2857. /*
  2858. * 此次付款金额
  2859. */
  2860. decimal CurrPayStr = 0.00M,
  2861. OriginalCurrPay = 0.00M;
  2862. if (entity.PayPercentage == 0)
  2863. {
  2864. if (entity.PayThenMoney != 0)
  2865. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2866. }
  2867. else
  2868. {
  2869. if (entity.PayMoney != 0)
  2870. {
  2871. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2872. }
  2873. }
  2874. //if (_dto.Label == 79)
  2875. //{
  2876. // string original = string.Empty;
  2877. // if (hotelCurrncyCode.Equals("CNY"))
  2878. // {
  2879. // OriginalCurrPay = CurrPayStr;
  2880. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2881. // }
  2882. // else
  2883. // {
  2884. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2885. // //760 EUR(7600.00 CNY)
  2886. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2887. // }
  2888. //}
  2889. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2890. string original = string.Empty;
  2891. if (hotelCurrncyCode.Equals("CNY"))
  2892. {
  2893. OriginalCurrPay = CurrPayStr;
  2894. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2895. }
  2896. else
  2897. {
  2898. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2899. //760 EUR(7600.00 CNY)
  2900. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2901. }
  2902. /*
  2903. * 剩余尾款
  2904. */
  2905. decimal BalanceStr = 0;
  2906. if (CurrPayStr != 0)
  2907. {
  2908. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2909. BalanceStr = 0;
  2910. else
  2911. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2912. }
  2913. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2914. /*
  2915. * Bus名称
  2916. */
  2917. _detail.BusName = "待增加";
  2918. /*
  2919. *费用所属
  2920. */
  2921. switch (entity.CTable)
  2922. {
  2923. case 76://酒店预订
  2924. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2925. if (hotelReservations != null)
  2926. {
  2927. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2928. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2929. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2930. string roomFeeStr = "", roomFeestr1 = "";
  2931. //是否比较房型价格
  2932. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2933. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2934. roomFeeStr += $"<br/>";
  2935. var roomTotal = 0.00M;
  2936. if (hotelReservations.SingleRoomPrice > 0)
  2937. {
  2938. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2939. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2940. //__isSingle = true;
  2941. roomTotal += fee;
  2942. }
  2943. if (hotelReservations.DoubleRoomPrice > 0)
  2944. {
  2945. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2946. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2947. // __isDouble = true;
  2948. roomTotal += fee;
  2949. }
  2950. if (hotelReservations.SuiteRoomPrice > 0)
  2951. {
  2952. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2953. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2954. //__isSuite = true;
  2955. roomTotal += fee;
  2956. }
  2957. if (hotelReservations.OtherRoomPrice > 0)
  2958. {
  2959. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2960. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2961. //__isOther = true;
  2962. roomTotal += fee;
  2963. }
  2964. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2965. else roomFeeStr += " 0.00 * 0";
  2966. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2967. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2968. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2969. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2970. /*
  2971. * 费用类型
  2972. * 1:房费
  2973. * 2:早餐
  2974. * 3:地税
  2975. * 4:城市税
  2976. * </summary>
  2977. */
  2978. //地税
  2979. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2980. if (governmentRentData != null)
  2981. {
  2982. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2983. governmentRentFee = governmentRentData.Price;
  2984. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2985. if (governmentRentCurrData != null)
  2986. {
  2987. governmentRentCode = governmentRentCurrData.Name;
  2988. governmentRentName = $"({governmentRentCurrData.Remark})";
  2989. }
  2990. }
  2991. //城市税
  2992. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2993. if (cityTaxData != null)
  2994. {
  2995. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2996. cityTaxFee = cityTaxData.Price;
  2997. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2998. if (cityTaxCurrData != null)
  2999. {
  3000. cityTaxCode = cityTaxCurrData.Name;
  3001. cityTaxName = $"({cityTaxCurrData.Remark})";
  3002. }
  3003. }
  3004. //酒店早餐
  3005. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3006. if (breakfastData != null)
  3007. {
  3008. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3009. breakfastFee = breakfastData.Price;
  3010. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3011. if (breakfastCurrData != null)
  3012. {
  3013. breakfastCode = breakfastCurrData.Name;
  3014. breakfastName = $"({breakfastCurrData.Remark})";
  3015. }
  3016. }
  3017. //房间费用
  3018. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3019. if (roomData != null)
  3020. {
  3021. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3022. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3023. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3024. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3025. roomFee = roomData.Price;
  3026. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3027. if (roomCurrData != null)
  3028. {
  3029. roomCode = roomCurrData.Name;
  3030. roomName = $"({roomCurrData.Remark})";
  3031. }
  3032. }
  3033. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3034. string hotelCostStr = "";
  3035. decimal hotelCsotTotal = 0.00M;
  3036. if (groupCost != null)
  3037. {
  3038. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3039. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  3040. }
  3041. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3042. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3043. string hotelCost_day = "";
  3044. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3045. foreach (var item in hotelCostDetails1)
  3046. {
  3047. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3048. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3049. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  3050. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3051. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  3052. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3053. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  3054. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3055. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  3056. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3057. hotelCost_day += @$"<br/>";
  3058. }
  3059. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3060. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3061. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3062. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3063. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3064. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3065. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3066. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3067. $"房间说明: {hotelReservations.Remark} <br/>" +
  3068. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3069. $"{hotelBreakfastStr}" +
  3070. $"{hotelGovernmentRentStr}" +
  3071. $"{hotelCityTaxStr}";
  3072. _detail.PriceNameContent = hotelReservations.HotelName;
  3073. }
  3074. break;
  3075. case 79://车/导游地接
  3076. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3077. if (touristGuideGroundReservations != null)
  3078. {
  3079. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3080. {
  3081. _detail.BusName = touristGuideGroundReservations.BusName;
  3082. }
  3083. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3084. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3085. //if (isInt)
  3086. //{
  3087. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3088. // if (cityInfo != null)
  3089. // {
  3090. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3091. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3092. // if (carFeeItem != null)
  3093. // {
  3094. // nameContent += $@"({carFeeItem.Name})";
  3095. // }
  3096. // _detail.PriceNameContent = nameContent;
  3097. // }
  3098. //}
  3099. //else
  3100. //{
  3101. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3102. //}
  3103. var touristGuideGroundReservationsContents =
  3104. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3105. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3106. foreach (var item in touristGuideGroundReservationsContents)
  3107. {
  3108. string typeName = "Unknown";
  3109. string carCurrencyCode = "Unknown";
  3110. string carCurrencyName = "Unknown";
  3111. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3112. if (carTypeData != null) typeName = carTypeData.Name;
  3113. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3114. if (currencyData != null)
  3115. {
  3116. carCurrencyCode = currencyData.Name;
  3117. carCurrencyName = currencyData.Remark;
  3118. }
  3119. //op、成本 币种是否一致
  3120. bool IsCurrencyAgreement = false;
  3121. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3122. string opCostStr = string.Empty;
  3123. decimal opCostTypePrice = 0.00M;
  3124. #region 处理成本各项费用
  3125. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3126. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3127. if (opCost.Count > 0)
  3128. {
  3129. switch (item.SId)
  3130. {
  3131. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3132. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3133. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3134. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3135. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3136. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3137. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3138. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3139. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3140. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3141. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3142. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3143. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3144. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3145. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3146. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3147. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3148. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3149. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3150. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3151. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3152. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3153. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3154. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3155. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3156. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3157. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3158. }
  3159. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  3160. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  3161. }
  3162. #endregion
  3163. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  3164. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  3165. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3166. $"{opTypeStr} {opCostStr}<br/>" +
  3167. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3168. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3169. }
  3170. _detail.PriceMsgContent = priceMsg;
  3171. }
  3172. break;
  3173. case 80: //签证
  3174. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3175. if (visaInfo != null)
  3176. {
  3177. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3178. _detail.PriceNameContent = visaInfo.VisaDescription;
  3179. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3180. }
  3181. break;
  3182. case 81: //邀请/公务活动
  3183. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3184. if (_ioa != null)
  3185. {
  3186. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3187. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3188. sendCurrName = "Unknown", //快递费用币种 Name
  3189. sendCurrCode = "Unknown", //快递费用币种 Code
  3190. eventsCurrName = "Unknown", //公务活动费币种 Name
  3191. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3192. translateCurrName = "Unknown", //公务翻译费 Name
  3193. translateCurrCode = "Unknown"; //公务翻译费 Code
  3194. #region 处理费用币种
  3195. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3196. if (inviteCurrData != null)
  3197. {
  3198. inviteCurrName = inviteCurrData.Remark;
  3199. inviteCurrCode = inviteCurrData.Name;
  3200. }
  3201. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3202. if (sendCurrData != null)
  3203. {
  3204. sendCurrName = sendCurrData.Remark;
  3205. sendCurrCode = sendCurrData.Name;
  3206. }
  3207. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3208. if (eventsCurrData != null)
  3209. {
  3210. eventsCurrName = eventsCurrData.Remark;
  3211. eventsCurrCode = eventsCurrData.Name;
  3212. }
  3213. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3214. if (translateCurrData != null)
  3215. {
  3216. translateCurrName = translateCurrData.Remark;
  3217. translateCurrCode = translateCurrData.Name;
  3218. }
  3219. #endregion
  3220. _detail.PriceNameContent = _ioa.InviterArea;
  3221. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3222. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3223. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3224. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3225. $@"备注:" + _ioa.Remark + "<br/>";
  3226. }
  3227. break;
  3228. case 82: //团组客户保险
  3229. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3230. if (customers != null)
  3231. {
  3232. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3233. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3234. }
  3235. break;
  3236. case 85: //机票预订
  3237. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3238. if (jpRes != null)
  3239. {
  3240. string FlightsDescription = jpRes.FlightsDescription;
  3241. string PriceDescription = jpRes.PriceDescription;
  3242. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3243. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3244. }
  3245. break;
  3246. case 98://其他款项
  3247. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3248. if (gdpRes != null)
  3249. {
  3250. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3251. _detail.PriceNameContent = gdpRes.PriceName;
  3252. }
  3253. break;
  3254. case 285://收款退还
  3255. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3256. if (refundAndOtherMoney != null)
  3257. {
  3258. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3259. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3260. }
  3261. break;
  3262. case 751://酒店早餐
  3263. break;
  3264. case 1015://超支费用
  3265. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3266. if (groupExtraCost != null)
  3267. {
  3268. _detail.PriceNameContent = groupExtraCost.PriceName;
  3269. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3270. }
  3271. break;
  3272. default:
  3273. break;
  3274. }
  3275. /*
  3276. * 申请人
  3277. */
  3278. string operatorName = " - ";
  3279. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3280. if (_opUser != null)
  3281. {
  3282. operatorName = _opUser.CnName;
  3283. }
  3284. _detail.OperatorName = operatorName;
  3285. /*
  3286. * 审核人
  3287. */
  3288. string auditOperatorName = "Unknown";
  3289. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3290. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3291. else
  3292. {
  3293. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3294. if (_adUser != null)
  3295. {
  3296. auditOperatorName = _adUser.CnName;
  3297. }
  3298. }
  3299. _detail.AuditOperatorName = auditOperatorName;
  3300. /*
  3301. * 超预算比例
  3302. */
  3303. string overBudgetStr = "";
  3304. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3305. else if (entity.ExceedBudget == 0)
  3306. {
  3307. if (entity.CTable == 76 || entity.CTable == 79)
  3308. {
  3309. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3310. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3311. }
  3312. else
  3313. {
  3314. overBudgetStr = "未超预算";
  3315. }
  3316. }
  3317. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3318. _detail.OverBudget = overBudgetStr;
  3319. decimal auditFee = 0.00M; //已审核金额 人名币
  3320. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3321. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3322. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3323. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3324. {
  3325. auditedFeeOriginal = entity.PayMoney;
  3326. auditFee = CurrPayStr;
  3327. }
  3328. else if (entity.IsAuditGM == 0)
  3329. {
  3330. unAuditFeeCNY = CurrPayStr;
  3331. unAuditFeeOriginal = OriginalCurrPay;
  3332. OriginalCurrPay = 0.00M;
  3333. }
  3334. /*
  3335. * 费用总计
  3336. */
  3337. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3338. {
  3339. CurrencyId = entity.PaymentCurrency,
  3340. CurrencyName = PaymentCurrency_WaitPay,
  3341. AmountPayable = entity.PayMoney,
  3342. ThisPayment = OriginalCurrPay,
  3343. BalancePayment = BalanceStr,
  3344. AuditedFunds = auditFee,
  3345. AuditedFundsOriginal = auditedFeeOriginal,
  3346. UnAuditFundsCNY = unAuditFeeCNY,
  3347. UnAuditFundsOriginal = unAuditFeeOriginal
  3348. });
  3349. _detail.IsAuditGM = entity.IsAuditGM;
  3350. detailList.Add(_detail);
  3351. }
  3352. #endregion
  3353. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3354. /*
  3355. * 下方描述处理
  3356. */
  3357. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3358. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3359. if (ccpCurrencyPrice != null)
  3360. {
  3361. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3362. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3363. }
  3364. else
  3365. {
  3366. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3367. }
  3368. string amountPayableStr = string.Format(@"应付款总金额: ");
  3369. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3370. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3371. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3372. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3373. foreach (var item in nonDuplicat)
  3374. {
  3375. var currencyName = item.CurrencyName;
  3376. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3377. if (strs.Count > 0)
  3378. {
  3379. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3380. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3381. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3382. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3383. //单独处理此次付款金额
  3384. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3385. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3386. //单独处理已审核费用
  3387. //if (item.CurrencyId == 836) //人民币
  3388. //{
  3389. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3390. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3391. //}
  3392. //else
  3393. //{
  3394. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3395. //}
  3396. if (currencyName.Equals("CNY"))
  3397. {
  3398. //已审核费用
  3399. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3400. //未审核费用
  3401. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3402. }
  3403. else
  3404. {
  3405. //已审核费用
  3406. 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"));
  3407. //未审核费用
  3408. 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"));
  3409. }
  3410. }
  3411. }
  3412. _view.TotalStr1 = amountPayableStr[..^1];
  3413. _view.TotalStr2 = thisPaymentStr[..^1];
  3414. _view.TotalStr3 = balancePaymentStr[..^1];
  3415. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3416. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3417. var _view1 = new
  3418. {
  3419. PageFuncAuth = pageFunAuthView,
  3420. Data = _view
  3421. };
  3422. return Ok(JsonView(_view1));
  3423. }
  3424. catch (Exception ex)
  3425. {
  3426. return Ok(JsonView(false, ex.Message));
  3427. }
  3428. }
  3429. /// <summary>
  3430. /// 费用审核
  3431. /// 修改团组费用审核状态
  3432. /// </summary>
  3433. /// <param name="_dto">参数Json字符串</param>
  3434. /// <returns></returns>
  3435. [HttpPost]
  3436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3437. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3438. {
  3439. #region 参数验证
  3440. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3441. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3442. #endregion
  3443. #region 页面操作权限验证
  3444. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3445. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3446. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3447. #endregion
  3448. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3449. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3450. DateTime dtNow = DateTime.Now;
  3451. _groupRepository.BeginTran();
  3452. int rst = 0;
  3453. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3454. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3455. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3456. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3457. List<dynamic> msgDatas = new List<dynamic>();
  3458. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3459. foreach (var item in idList)
  3460. {
  3461. int CreditId = int.Parse(item);
  3462. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3463. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3464. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3465. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3466. .Where(s => s.Id == CreditId)
  3467. .ExecuteCommandAsync();
  3468. if (result < 1)
  3469. {
  3470. rst = -1;
  3471. _groupRepository.RollbackTran();
  3472. return Ok(JsonView(false, "操作失败并回滚!"));
  3473. }
  3474. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3475. if (creditData != null)
  3476. {
  3477. #region 应用通知配置
  3478. try
  3479. {
  3480. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3481. }
  3482. catch (Exception ex)
  3483. {
  3484. }
  3485. #endregion
  3486. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3487. string groupNameStr = string.Empty;
  3488. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3489. if (groupData != null) groupNameStr = groupData.TeamName;
  3490. string creditTypeStr = string.Empty;
  3491. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3492. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3493. string creditCurrency = string.Empty;
  3494. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3495. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3496. if (creditCurrency.Equals("CNY"))
  3497. {
  3498. creditData.DayRate = 1.0000M;
  3499. }
  3500. if (creditData.PayPercentage == 0.00M)
  3501. {
  3502. creditData.PayPercentage = 100M;
  3503. }
  3504. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3505. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3506. string msgContent = "";
  3507. if (creditCurrency.Equals("CNY"))
  3508. {
  3509. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3510. }
  3511. else
  3512. {
  3513. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3514. }
  3515. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3516. }
  3517. }
  3518. if (rst == 0)
  3519. {
  3520. _groupRepository.CommitTran();
  3521. foreach (var item in msgDatas)
  3522. {
  3523. //发送消息
  3524. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3525. }
  3526. #region 应用推送
  3527. try
  3528. {
  3529. foreach (var ccpId in dic_ccp_user.Keys)
  3530. {
  3531. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3532. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3533. }
  3534. }
  3535. catch (Exception)
  3536. {
  3537. }
  3538. #endregion
  3539. return Ok(JsonView(true, "操作成功!"));
  3540. }
  3541. return Ok(JsonView(false, "操作失败!"));
  3542. }
  3543. #endregion
  3544. #region 机票费用录入
  3545. /// <summary>
  3546. /// 机票录入当前登录人可操作团组
  3547. /// </summary>
  3548. /// <param name="dto"></param>
  3549. /// <returns></returns>
  3550. [HttpPost]
  3551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3552. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3553. {
  3554. try
  3555. {
  3556. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3557. if (groupData.Code != 0)
  3558. {
  3559. return Ok(JsonView(false, groupData.Msg));
  3560. }
  3561. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3562. }
  3563. catch (Exception ex)
  3564. {
  3565. return Ok(JsonView(false, "程序错误!"));
  3566. throw;
  3567. }
  3568. }
  3569. /// <summary>
  3570. /// 机票费用录入列表
  3571. /// </summary>
  3572. /// <param name="dto"></param>
  3573. /// <returns></returns>
  3574. [HttpPost]
  3575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3576. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3577. {
  3578. try
  3579. {
  3580. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3581. if (groupData.Code != 0)
  3582. {
  3583. return Ok(JsonView(false, groupData.Msg));
  3584. }
  3585. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3586. }
  3587. catch (Exception ex)
  3588. {
  3589. return Ok(JsonView(false, ex.Message));
  3590. throw;
  3591. }
  3592. }
  3593. /// <summary>
  3594. /// 根据id查询费用录入信息
  3595. /// </summary>
  3596. /// <param name="dto"></param>
  3597. /// <returns></returns>
  3598. [HttpPost]
  3599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3600. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3601. {
  3602. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3603. if (groupData.Code != 0)
  3604. {
  3605. return Ok(JsonView(false, groupData.Msg));
  3606. }
  3607. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3608. }
  3609. /// <summary>
  3610. /// 机票费用录入操作(Status:1.新增,2.修改)
  3611. /// </summary>
  3612. /// <param name="dto"></param>
  3613. /// <returns></returns>
  3614. [HttpPost]
  3615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3616. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3617. {
  3618. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3619. if (groupData.Code != 0)
  3620. {
  3621. return Ok(JsonView(false, groupData.Msg));
  3622. }
  3623. #region 应用推送
  3624. try
  3625. {
  3626. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3627. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3628. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3629. //2024-10-21 新增LZ UID
  3630. var userIds = new List<int>() { 21 };
  3631. string title = $"系统通知";
  3632. string content = "";
  3633. var diId = dto.AirTicketResOpData.DiId;
  3634. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3635. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3636. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3637. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3638. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3639. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3640. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3641. }
  3642. catch (Exception ex)
  3643. {
  3644. }
  3645. #endregion
  3646. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3647. }
  3648. /// <summary>
  3649. /// 根据舱位类型查询接团客户名单信息
  3650. /// </summary>
  3651. /// <param name="dto"></param>
  3652. /// <returns></returns>
  3653. [HttpPost]
  3654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3655. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3656. {
  3657. try
  3658. {
  3659. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3660. if (crm_Groups.Count != 0)
  3661. {
  3662. List<dynamic> Customer = new List<dynamic>();
  3663. foreach (var item in crm_Groups)
  3664. {
  3665. var data = new
  3666. {
  3667. Id = item.Id,
  3668. Pinyin = item.Pinyin,
  3669. Name = item.LastName + item.FirstName
  3670. };
  3671. Customer.Add(data);
  3672. }
  3673. return Ok(JsonView(true, "查询成功!", Customer));
  3674. }
  3675. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3676. }
  3677. catch (Exception ex)
  3678. {
  3679. return Ok(JsonView(false, "程序错误!"));
  3680. throw;
  3681. }
  3682. }
  3683. /// <summary>
  3684. /// 根据团号获取客户信息
  3685. /// </summary>
  3686. /// <param name="dto"></param>
  3687. /// <returns></returns>
  3688. [HttpPost]
  3689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3690. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3691. {
  3692. var jw = JsonView(false);
  3693. if (dto.DIID < 1)
  3694. {
  3695. jw.Msg += "请输入正确的diid";
  3696. return Ok(jw);
  3697. }
  3698. var arr = getSimplClientList(dto.DIID);
  3699. jw = JsonView(true, "获取成功!", arr);
  3700. return Ok(jw);
  3701. }
  3702. private List<SimplClientInfo> getSimplClientList(int diId)
  3703. {
  3704. 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);
  3705. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3706. foreach (var item in arr)
  3707. {
  3708. EncryptionProcessor.DecryptProperties(item);
  3709. }
  3710. return arr;
  3711. }
  3712. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3713. {
  3714. string result = origin;
  3715. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3716. {
  3717. string[] temparr = origin.Split(',');
  3718. string fistrStr = temparr[0];
  3719. int count = temparr.Count();
  3720. int tempId;
  3721. bool success = int.TryParse(fistrStr, out tempId);
  3722. if (success)
  3723. {
  3724. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3725. if (tempInfo != null)
  3726. {
  3727. if (count > 1)
  3728. {
  3729. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3730. }
  3731. else
  3732. {
  3733. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3734. }
  3735. }
  3736. }
  3737. }
  3738. return result;
  3739. }
  3740. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3741. {
  3742. string result = origin;
  3743. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3744. {
  3745. string[] temparr = origin.Split(',');
  3746. result = "";
  3747. foreach (var item in temparr)
  3748. {
  3749. int tempId;
  3750. bool success = int.TryParse(item, out tempId);
  3751. if (success)
  3752. {
  3753. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3754. if (tempInfo != null)
  3755. {
  3756. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3757. }
  3758. }
  3759. }
  3760. }
  3761. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3762. return result;
  3763. }
  3764. /// <summary>
  3765. /// 机票费用录入,删除
  3766. /// </summary>
  3767. /// <param name="dto"></param>
  3768. /// <returns></returns>
  3769. [HttpPost]
  3770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3771. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3772. {
  3773. try
  3774. {
  3775. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3776. if (res)
  3777. {
  3778. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3779. {
  3780. IsDel = 1,
  3781. DeleteUserId = dto.DeleteUserId,
  3782. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3783. }).ExecuteCommandAsync();
  3784. return Ok(JsonView(true, "删除成功!"));
  3785. }
  3786. return Ok(JsonView(false, "删除失败!"));
  3787. }
  3788. catch (Exception ex)
  3789. {
  3790. return Ok(JsonView(false, "程序错误!"));
  3791. throw;
  3792. }
  3793. }
  3794. /// <summary>
  3795. /// 导出机票录入报表
  3796. /// </summary>
  3797. /// <param name="dto"></param>
  3798. /// <returns></returns>
  3799. [HttpPost]
  3800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3801. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3802. {
  3803. try
  3804. {
  3805. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3806. if (groupData.Code != 0)
  3807. {
  3808. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3809. }
  3810. else
  3811. {
  3812. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3813. if (AirTicketReservations.Count != 0)
  3814. {
  3815. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3816. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3817. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3818. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3819. WorkbookDesigner designer = new WorkbookDesigner();
  3820. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3821. decimal countCost = 0;
  3822. foreach (var item in AirTicketReservations)
  3823. {
  3824. #region 处理客人姓名
  3825. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3826. item.ClientName = clientNames;
  3827. #endregion
  3828. if (item.BankType == "其他")
  3829. {
  3830. item.BankNo = "--";
  3831. }
  3832. else
  3833. {
  3834. if (!string.IsNullOrEmpty(item.BankType))
  3835. {
  3836. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3837. }
  3838. }
  3839. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3840. item.Price = System.Decimal.Round(item.Price, 2);
  3841. countCost += Convert.ToDecimal(item.Price);
  3842. }
  3843. designer.SetDataSource("Export", AirTicketReservations);
  3844. designer.SetDataSource("ExportDiCode", diCode);
  3845. designer.SetDataSource("ExportDiName", diName);
  3846. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3847. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3848. designer.Process();
  3849. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3850. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3851. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3852. return Ok(JsonView(true, "成功", url = rst));
  3853. }
  3854. else
  3855. {
  3856. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3857. }
  3858. }
  3859. }
  3860. catch (Exception ex)
  3861. {
  3862. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3863. throw;
  3864. }
  3865. }
  3866. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3867. /// <summary>
  3868. /// 行程单导出
  3869. /// </summary>
  3870. /// <param name="dto"></param>
  3871. /// <returns></returns>
  3872. [HttpPost]
  3873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3874. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3875. {
  3876. try
  3877. {
  3878. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3879. if (groupData.Code != 0)
  3880. {
  3881. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3882. }
  3883. else
  3884. {
  3885. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3886. if (dto.Language == "CN")
  3887. {
  3888. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3889. DocumentBuilder builder = new DocumentBuilder(doc);
  3890. int tableIndex = 0;//表格索引
  3891. //得到文档中的第一个表格
  3892. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3893. foreach (var item in _AirTicketReservations)
  3894. {
  3895. #region 处理固定数据
  3896. string[] FlightsCode = item.FlightsCode.Split('/');
  3897. if (FlightsCode.Length != 0)
  3898. {
  3899. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3900. if (_AirCompany != null)
  3901. {
  3902. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3903. }
  3904. else
  3905. {
  3906. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3907. }
  3908. }
  3909. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3910. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3911. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3912. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3913. string name = "";
  3914. foreach (string clientName in nameArray)
  3915. {
  3916. if (!name.Contains(clientName))
  3917. {
  3918. name += clientName + ",";
  3919. }
  3920. }
  3921. if (!string.IsNullOrWhiteSpace(name))
  3922. {
  3923. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3924. }
  3925. else
  3926. {
  3927. table.Range.Bookmarks["ClientName"].Text = "--";
  3928. }
  3929. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3930. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3931. table.Range.Bookmarks["JointTicket"].Text = "--";
  3932. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3933. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3934. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3935. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3936. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3937. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3938. #endregion
  3939. #region 循环数据处理
  3940. List<AirInfo> airs = new List<AirInfo>();
  3941. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3942. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3943. for (int i = 0; i < FlightsCode.Length; i++)
  3944. {
  3945. AirInfo air = new AirInfo();
  3946. string[] tempstr = DayArray[i]
  3947. .Replace("\r\n", string.Empty)
  3948. .Replace("\\r\\n", string.Empty)
  3949. .TrimStart().TrimEnd()
  3950. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3951. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3952. string starCity = "";
  3953. if (star_Three != null)
  3954. {
  3955. starCity = star_Three.AirPort;
  3956. }
  3957. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3958. string EndCity = "";
  3959. if (End_Three != null)
  3960. {
  3961. EndCity = End_Three.AirPort;
  3962. }
  3963. air.Destination = starCity + "/" + EndCity;
  3964. air.Flight = FlightsCode[i];
  3965. air.SeatingClass = item.CTypeName;
  3966. string dateTime = tempstr[2];
  3967. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3968. air.FlightDate = DateTemp;
  3969. air.DepartureTime = tempstr[5];
  3970. air.LandingTime = tempstr[6];
  3971. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3972. air.TicketStatus = "--";
  3973. air.Luggage = "--";
  3974. air.DepartureTerminal = "--";
  3975. air.LandingTerminal = "--";
  3976. airs.Add(air);
  3977. }
  3978. int row = 13;
  3979. for (int i = 0; i < airs.Count; i++)
  3980. {
  3981. if (airs.Count > 2)
  3982. {
  3983. for (int j = 0; j < airs.Count - 2; j++)
  3984. {
  3985. var CopyRow = table.Rows[12].Clone(true);
  3986. table.Rows.Add(CopyRow);
  3987. }
  3988. }
  3989. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3990. int index = 0;
  3991. foreach (PropertyInfo property in properties)
  3992. {
  3993. string value = property.GetValue(airs[i]).ToString();
  3994. Cell ishcel0 = table.Rows[row].Cells[index];
  3995. Paragraph p = new Paragraph(doc);
  3996. string s = value;
  3997. p.AppendChild(new Run(doc, s));
  3998. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3999. ishcel0.AppendChild(p);
  4000. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4001. index++;
  4002. }
  4003. row++;
  4004. }
  4005. #endregion
  4006. Paragraph lastParagraph = new Paragraph(doc);
  4007. //第一个表格末尾加段落
  4008. table.ParentNode.InsertAfter(lastParagraph, table);
  4009. //复制第一个表格
  4010. Table cloneTable = (Table)table.Clone(true);
  4011. //在文档末尾段落后面加入复制的表格
  4012. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4013. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4014. {
  4015. int rownewsIndex = 13;
  4016. for (int i = 0; i < 2; i++)
  4017. {
  4018. var CopyRow = table.Rows[12].Clone(true);
  4019. table.Rows.RemoveAt(13);
  4020. table.Rows.Add(CopyRow);
  4021. rownewsIndex++;
  4022. }
  4023. }
  4024. else
  4025. {
  4026. table.Rows.RemoveAt(12);
  4027. }
  4028. cloneTable.Rows.RemoveAt(12);
  4029. }
  4030. if (_AirTicketReservations.Count != 0)
  4031. {
  4032. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4033. if (FlightsCode.Length != 0)
  4034. {
  4035. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4036. if (_AirCompany != null)
  4037. {
  4038. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4039. }
  4040. else
  4041. {
  4042. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4043. }
  4044. }
  4045. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4046. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4047. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4048. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4049. string name = "";
  4050. foreach (string clientName in nameArray)
  4051. {
  4052. if (!name.Contains(clientName))
  4053. {
  4054. name += clientName + ",";
  4055. }
  4056. }
  4057. if (!string.IsNullOrWhiteSpace(name))
  4058. {
  4059. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4060. }
  4061. else
  4062. {
  4063. table.Range.Bookmarks["ClientName"].Text = "--";
  4064. }
  4065. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4066. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4067. table.Range.Bookmarks["JointTicket"].Text = "--";
  4068. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4069. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4070. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4071. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4072. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4073. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4074. }
  4075. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4076. //保存合并后的文档
  4077. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4078. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4079. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4080. return Ok(JsonView(true, "成功!", rst));
  4081. }
  4082. else
  4083. {
  4084. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4085. DocumentBuilder builder = new DocumentBuilder(doc);
  4086. int tableIndex = 0;//表格索引
  4087. //得到文档中的第一个表格
  4088. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4089. List<string> texts = new List<string>();
  4090. foreach (var item in _AirTicketReservations)
  4091. {
  4092. string[] FlightsCode = item.FlightsCode.Split('/');
  4093. if (FlightsCode.Length != 0)
  4094. {
  4095. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4096. if (_AirCompany != null)
  4097. {
  4098. if (!transDic.ContainsKey(_AirCompany.CnName))
  4099. {
  4100. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4101. }
  4102. }
  4103. else
  4104. {
  4105. if (!transDic.ContainsKey("--"))
  4106. {
  4107. transDic.Add("--", "--");
  4108. }
  4109. }
  4110. }
  4111. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4112. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4113. string name = "";
  4114. foreach (string clientName in nameArray)
  4115. {
  4116. name += clientName + ",";
  4117. }
  4118. if (!texts.Contains(name))
  4119. {
  4120. texts.Add(name);
  4121. }
  4122. List<AirInfo> airs = new List<AirInfo>();
  4123. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4124. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4125. for (int i = 0; i < FlightsCode.Length; i++)
  4126. {
  4127. AirInfo air = new AirInfo();
  4128. string[] tempstr = DayArray[i]
  4129. .Replace("\r\n", string.Empty)
  4130. .Replace("\\r\\n", string.Empty)
  4131. .TrimStart().TrimEnd()
  4132. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4133. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4134. if (star_Three != null)
  4135. {
  4136. if (!transDic.ContainsKey(star_Three.AirPort))
  4137. {
  4138. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4139. }
  4140. }
  4141. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4142. if (End_Three != null)
  4143. {
  4144. if (!transDic.ContainsKey(End_Three.AirPort))
  4145. {
  4146. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4147. }
  4148. }
  4149. if (!texts.Contains(item.CTypeName))
  4150. {
  4151. texts.Add(item.CTypeName);
  4152. }
  4153. }
  4154. }
  4155. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4156. if (transData.Count > 0)
  4157. {
  4158. foreach (TranslateResult item in transData)
  4159. {
  4160. if (!transDic.ContainsKey(item.Query))
  4161. {
  4162. transDic.Add(item.Query, item.Translation);
  4163. }
  4164. }
  4165. }
  4166. foreach (var item in _AirTicketReservations)
  4167. {
  4168. #region 处理固定数据
  4169. string[] FlightsCode = item.FlightsCode.Split('/');
  4170. if (FlightsCode.Length != 0)
  4171. {
  4172. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4173. if (_AirCompany != null)
  4174. {
  4175. string str = "--";
  4176. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4177. if (!string.IsNullOrEmpty(translateResult))
  4178. {
  4179. str = translateResult;
  4180. str = _airTicketResRep.Processing(str);
  4181. }
  4182. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4183. }
  4184. else
  4185. {
  4186. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4187. }
  4188. }
  4189. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4190. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4191. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4192. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4193. string names = "";
  4194. foreach (string clientName in nameArray)
  4195. {
  4196. names += clientName + ",";
  4197. }
  4198. if (!string.IsNullOrWhiteSpace(names))
  4199. {
  4200. string str = "--";
  4201. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4202. if (!string.IsNullOrEmpty(translateResult))
  4203. {
  4204. str = translateResult;
  4205. str = _airTicketResRep.Processing(str);
  4206. }
  4207. table.Range.Bookmarks["ClientName"].Text = str;
  4208. }
  4209. else
  4210. {
  4211. table.Range.Bookmarks["ClientName"].Text = "--";
  4212. }
  4213. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4214. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4215. table.Range.Bookmarks["JointTicket"].Text = "--";
  4216. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4217. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4218. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4219. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4220. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4221. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4222. #endregion
  4223. #region 循环数据处理
  4224. List<AirInfo> airs = new List<AirInfo>();
  4225. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4226. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4227. for (int i = 0; i < FlightsCode.Length; i++)
  4228. {
  4229. AirInfo air = new AirInfo();
  4230. string[] tempstr = DayArray[i]
  4231. .Replace("\r\n", string.Empty)
  4232. .Replace("\\r\\n", string.Empty)
  4233. .TrimStart().TrimEnd()
  4234. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4235. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4236. string starCity = "";
  4237. if (star_Three != null)
  4238. {
  4239. string str2 = "--";
  4240. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4241. if (!string.IsNullOrEmpty(translateResult2))
  4242. {
  4243. str2 = translateResult2;
  4244. str2 = _airTicketResRep.Processing(str2);
  4245. }
  4246. starCity = str2;
  4247. }
  4248. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4249. string EndCity = "";
  4250. if (End_Three != null)
  4251. {
  4252. string str1 = "--";
  4253. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4254. if (!string.IsNullOrEmpty(translateResult1))
  4255. {
  4256. str1 = translateResult1;
  4257. str1 = _airTicketResRep.Processing(str1);
  4258. }
  4259. EndCity = str1;
  4260. }
  4261. air.Destination = starCity + "/" + EndCity;
  4262. air.Flight = FlightsCode[i];
  4263. string str = "--";
  4264. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4265. if (!string.IsNullOrEmpty(translateResult))
  4266. {
  4267. str = translateResult;
  4268. str = _airTicketResRep.Processing(str);
  4269. }
  4270. air.SeatingClass = str;
  4271. string dateTime = tempstr[2];
  4272. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4273. air.FlightDate = DateTemp;
  4274. air.DepartureTime = tempstr[5];
  4275. air.LandingTime = tempstr[6];
  4276. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4277. air.TicketStatus = "--";
  4278. air.Luggage = "--";
  4279. air.DepartureTerminal = "--";
  4280. air.LandingTerminal = "--";
  4281. airs.Add(air);
  4282. }
  4283. int row = 13;
  4284. for (int i = 0; i < airs.Count; i++)
  4285. {
  4286. if (airs.Count > 2)
  4287. {
  4288. for (int j = 0; j < airs.Count - 2; j++)
  4289. {
  4290. var CopyRow = table.Rows[12].Clone(true);
  4291. table.Rows.Add(CopyRow);
  4292. }
  4293. }
  4294. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4295. int index = 0;
  4296. foreach (PropertyInfo property in properties)
  4297. {
  4298. string value = property.GetValue(airs[i]).ToString();
  4299. Cell ishcel0 = table.Rows[row].Cells[index];
  4300. Paragraph p = new Paragraph(doc);
  4301. string s = value;
  4302. p.AppendChild(new Run(doc, s));
  4303. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4304. ishcel0.AppendChild(p);
  4305. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4306. //ishcel0.CellFormat.VerticalAlignment=
  4307. index++;
  4308. }
  4309. row++;
  4310. }
  4311. #endregion
  4312. Paragraph lastParagraph = new Paragraph(doc);
  4313. //第一个表格末尾加段落
  4314. table.ParentNode.InsertAfter(lastParagraph, table);
  4315. //复制第一个表格
  4316. Table cloneTable = (Table)table.Clone(true);
  4317. //在文档末尾段落后面加入复制的表格
  4318. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4319. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4320. {
  4321. int rownewsIndex = 13;
  4322. for (int i = 0; i < 2; i++)
  4323. {
  4324. var CopyRow = table.Rows[12].Clone(true);
  4325. table.Rows.RemoveAt(13);
  4326. table.Rows.Add(CopyRow);
  4327. rownewsIndex++;
  4328. }
  4329. }
  4330. else
  4331. {
  4332. table.Rows.RemoveAt(12);
  4333. }
  4334. cloneTable.Rows.RemoveAt(12);
  4335. }
  4336. if (_AirTicketReservations.Count != 0)
  4337. {
  4338. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4339. if (FlightsCode.Length != 0)
  4340. {
  4341. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4342. if (_AirCompany != null)
  4343. {
  4344. string str = "--";
  4345. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4346. if (!string.IsNullOrEmpty(translateResult))
  4347. {
  4348. str = translateResult;
  4349. str = _airTicketResRep.Processing(str);
  4350. }
  4351. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4352. }
  4353. else
  4354. {
  4355. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4356. }
  4357. }
  4358. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4359. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4360. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4361. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4362. string names = "";
  4363. foreach (string clientName in nameArray)
  4364. {
  4365. names += clientName + ",";
  4366. }
  4367. if (!string.IsNullOrWhiteSpace(names))
  4368. {
  4369. string str = "--";
  4370. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4371. if (!string.IsNullOrEmpty(translateResult))
  4372. {
  4373. str = translateResult;
  4374. str = _airTicketResRep.Processing(str);
  4375. }
  4376. table.Range.Bookmarks["ClientName"].Text = str;
  4377. }
  4378. else
  4379. {
  4380. table.Range.Bookmarks["ClientName"].Text = "--";
  4381. }
  4382. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4383. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4384. table.Range.Bookmarks["JointTicket"].Text = "--";
  4385. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4386. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4387. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4388. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4389. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4390. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4391. }
  4392. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4393. //保存合并后的文档
  4394. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4395. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4396. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4397. return Ok(JsonView(true, "成功!", rst));
  4398. }
  4399. }
  4400. }
  4401. catch (Exception ex)
  4402. {
  4403. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4404. throw;
  4405. }
  4406. }
  4407. #endregion
  4408. #region 团组增减款项 --> 其他款项
  4409. /// <summary>
  4410. /// 团组增减款项下拉框绑定
  4411. /// </summary>
  4412. /// <param name="dto"></param>
  4413. /// <returns></returns>
  4414. [HttpPost]
  4415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4416. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4417. {
  4418. #region 参数验证
  4419. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4420. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4421. #endregion
  4422. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4423. }
  4424. /// <summary>
  4425. /// 根据团组Id查询团组增减款项
  4426. /// </summary>
  4427. /// <param name="dto"></param>
  4428. /// <returns></returns>
  4429. [HttpPost]
  4430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4431. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4432. {
  4433. #region 参数验证
  4434. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4435. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4436. #endregion
  4437. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4438. }
  4439. /// <summary>
  4440. /// 团组增减款项操作(Status:1.新增,2.修改)
  4441. /// </summary>
  4442. /// <param name="dto"></param>
  4443. /// <returns></returns>
  4444. [HttpPost]
  4445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4446. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4447. {
  4448. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4449. if (groupData.Code != 200)
  4450. {
  4451. return Ok(JsonView(false, groupData.Msg));
  4452. }
  4453. #region 应用推送
  4454. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4455. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4456. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4457. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4458. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4459. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4460. //自动审核
  4461. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4462. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4463. //2024-10-21 新增LZ UID
  4464. var userIds = new List<int>() { 21 };
  4465. string title = $"系统通知";
  4466. string content = "";
  4467. var diId = dto.DiId;
  4468. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4469. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4470. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4471. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4472. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4473. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4474. #endregion
  4475. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4476. }
  4477. /// <summary>
  4478. /// 团组增减款项操作 删除
  4479. /// </summary>
  4480. /// <param name="dto"></param>
  4481. /// <returns></returns>
  4482. [HttpPost]
  4483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4484. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4485. {
  4486. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4487. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4488. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4489. if (res.Code == 0)
  4490. {
  4491. return Ok(JsonView(true, "删除成功!"));
  4492. }
  4493. return Ok(JsonView(false, "删除失败!"));
  4494. }
  4495. /// <summary>
  4496. /// 根据团组增减款项Id查询
  4497. /// </summary>
  4498. /// <param name="dto"></param>
  4499. /// <returns></returns>
  4500. [HttpPost]
  4501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4502. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4503. {
  4504. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4505. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4506. }
  4507. /// <summary>
  4508. /// 查询供应商名称
  4509. /// </summary>
  4510. /// <param name="dto"></param>
  4511. /// <returns></returns>
  4512. [HttpPost]
  4513. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4514. {
  4515. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4516. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4517. ?? new List<Grp_DecreasePayments>();
  4518. dbResult = dbResult.Distinct(new
  4519. ProductComparer()).ToList();
  4520. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4521. {
  4522. x.Id,
  4523. x.SupplierAddress,
  4524. x.SupplierArea,
  4525. x.SupplierContact,
  4526. x.SupplierContactNumber,
  4527. x.SupplierEmail,
  4528. x.SupplierName,
  4529. x.SupplierSocialAccount,
  4530. x.SupplierTypeId,
  4531. }).ToList());
  4532. return Ok(jw);
  4533. }
  4534. /// <summary>
  4535. /// 团组增减款项 OTA匹配
  4536. /// </summary>
  4537. /// <param name="file"></param>
  4538. /// <returns></returns>
  4539. [HttpPost]
  4540. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4541. {
  4542. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4543. string fileName = file.FileName;
  4544. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4545. {
  4546. return Ok(JsonView(false, "请上传Excel文件!"));
  4547. }
  4548. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4549. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4550. if (!Directory.Exists(path))
  4551. {
  4552. Directory.CreateDirectory(path);
  4553. }
  4554. var filePath = @$"{path}/{fileName}";
  4555. //保存文件
  4556. using (FileStream fs = System.IO.File.Create(filePath))
  4557. {
  4558. file.CopyTo(fs);
  4559. fs.Flush();
  4560. }
  4561. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4562. //读取ExcelFile
  4563. DataTable dt = ConvertExcelToDataTable(filePath);
  4564. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4565. dt.TableName = "TB";
  4566. //修改table列名
  4567. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4568. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4569. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4570. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4571. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4572. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4573. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4574. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4575. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4576. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4577. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4578. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4579. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4580. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4581. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4582. var otaOrderNos = new List<string>();
  4583. foreach (DataRow item in dt.Rows)
  4584. {
  4585. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4586. }
  4587. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4588. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4589. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4590. .Select((dp, di) => new
  4591. {
  4592. dp.PriceName,
  4593. dp.OTAOrderNo,
  4594. dp.FeeTotal,
  4595. di.TeamName,
  4596. })
  4597. .ToListAsync();
  4598. foreach (DataRow item in dt.Rows)
  4599. {
  4600. var otaOrderNo = item["OTAOrderNo"].ToString();
  4601. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4602. if (oaData == null) continue;
  4603. item["GroupName"] = oaData.TeamName;
  4604. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4605. }
  4606. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4607. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4608. List<DataTable> datas = new List<DataTable>();
  4609. datas.Add(dt);
  4610. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4611. return Ok(JsonView(true, "操作成功", new { url = url }));
  4612. }
  4613. #region
  4614. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4615. {
  4616. // 创建Workbook对象
  4617. Workbook workbook = new Workbook(excelFilePath);
  4618. // 获取第一个工作表
  4619. Worksheet worksheet = workbook.Worksheets[0];
  4620. // 将工作表转换为DataTable
  4621. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4622. return dataTable;
  4623. }
  4624. #endregion
  4625. #endregion
  4626. #region 文件上传、删除
  4627. /// <summary>
  4628. /// region 文件上传 可以带参数
  4629. /// </summary>
  4630. /// <param name="file"></param>
  4631. /// <returns></returns>
  4632. [HttpPost]
  4633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4634. public async Task<IActionResult> UploadProject(IFormFile file)
  4635. {
  4636. //var TypeName = Request.Headers["TypeName"].ToString();
  4637. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4638. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4639. ////文件名称
  4640. //string projectFileName = file.FileName;
  4641. ////上传的文件的路径
  4642. //string filePath = $"{fileDir}/{projectFileName}";
  4643. //if (TypeName == "A")//A代表团组增减款项
  4644. //{
  4645. // filePath = fileDir + $@"\团组增减款项相关文件";
  4646. // if (!Directory.Exists(filePath))
  4647. // {
  4648. // Directory.CreateDirectory(filePath);
  4649. // }
  4650. // //上传的文件的路径
  4651. // filePath += $@"\{projectFileName}";
  4652. //}
  4653. //else if (TypeName == "B")//B代表商邀相关文件
  4654. //{
  4655. // //上传的文件的路径
  4656. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4657. // if (!Directory.Exists(filePath))
  4658. // {
  4659. // Directory.CreateDirectory(filePath);
  4660. // }
  4661. // //上传的文件的路径
  4662. // filePath = $@"\{projectFileName}";
  4663. //}
  4664. //try
  4665. //{
  4666. // using (FileStream fs = System.IO.File.Create(filePath))
  4667. // {
  4668. // file.CopyTo(fs);
  4669. // fs.Flush();
  4670. // }
  4671. //}
  4672. //catch (Exception ex)
  4673. //{
  4674. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4675. //}
  4676. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4677. try
  4678. {
  4679. var TypeName = Request.Headers["TypeName"].ToString();
  4680. if (file != null)
  4681. {
  4682. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4683. //文件名称
  4684. string projectFileName = file.FileName;
  4685. //上传的文件的路径
  4686. string filePath = $"{fileDir}/{projectFileName}";
  4687. if (TypeName == "A")//A代表团组增减款项
  4688. {
  4689. if (!Directory.Exists(fileDir))
  4690. {
  4691. Directory.CreateDirectory(fileDir);
  4692. }
  4693. //上传的文件的路径
  4694. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4695. }
  4696. else if (TypeName == "B")//B代表商邀相关文件
  4697. {
  4698. if (!Directory.Exists(fileDir))
  4699. {
  4700. Directory.CreateDirectory(fileDir);
  4701. }
  4702. //上传的文件的路径
  4703. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4704. }
  4705. using (FileStream fs = System.IO.File.Create(filePath))
  4706. {
  4707. file.CopyTo(fs);
  4708. fs.Flush();
  4709. }
  4710. return Ok(JsonView(true, "上传成功!", projectFileName));
  4711. }
  4712. else
  4713. {
  4714. return Ok(JsonView(false, "上传失败!"));
  4715. }
  4716. }
  4717. catch (Exception ex)
  4718. {
  4719. return Ok(JsonView(false, "程序错误!"));
  4720. }
  4721. }
  4722. /// <summary>
  4723. /// 删除指定文件
  4724. /// </summary>
  4725. /// <param name="dto"></param>
  4726. /// <returns></returns>
  4727. [HttpPost]
  4728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4729. public async Task<IActionResult> DelFile(DelFileDto dto)
  4730. {
  4731. try
  4732. {
  4733. var TypeName = Request.Headers["TypeName"].ToString();
  4734. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4735. string filePath = "";
  4736. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4737. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4738. int id = 0;
  4739. if (TypeName == "A")
  4740. {
  4741. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4742. // 删除该文件
  4743. System.IO.File.Delete(filePath);
  4744. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4745. .Where(a => a.Id == dto.Id)
  4746. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4747. .ExecuteCommandAsync();
  4748. }
  4749. else if (TypeName == "B")
  4750. {
  4751. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4752. // 删除该文件
  4753. System.IO.File.Delete(filePath);
  4754. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4755. if (info != null)
  4756. {
  4757. string[] files = new string[] { };
  4758. if (!string.IsNullOrEmpty(info.Attachment))
  4759. {
  4760. try
  4761. {
  4762. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4763. }
  4764. catch (Exception)
  4765. {
  4766. files = new List<string>() { info.Attachment }.ToArray();
  4767. }
  4768. }
  4769. if (files.Length > 0)
  4770. {
  4771. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4772. string filePath2 = string.Empty;
  4773. if (files1.Length > 0)
  4774. {
  4775. filePath2 = JsonConvert.SerializeObject(files1);
  4776. }
  4777. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4778. .Where(a => a.Id == dto.Id)
  4779. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4780. .ExecuteCommandAsync();
  4781. }
  4782. }
  4783. }
  4784. if (id != 0)
  4785. {
  4786. return Ok(JsonView(true, "成功!"));
  4787. }
  4788. else
  4789. {
  4790. return Ok(JsonView(false, "失败!"));
  4791. }
  4792. }
  4793. catch (Exception ex)
  4794. {
  4795. return Ok(JsonView(false, "程序错误!"));
  4796. throw;
  4797. }
  4798. }
  4799. /// <summary>
  4800. /// 文件上传多个文件 可以带参数
  4801. /// </summary>
  4802. /// <param name="files"></param>
  4803. /// <returns></returns>
  4804. [HttpPost]
  4805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4806. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4807. {
  4808. try
  4809. {
  4810. var TypeName = Request.Headers["TypeName"].ToString();
  4811. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4812. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4813. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4814. var filePahts = new List<string>();
  4815. foreach (var file in files)
  4816. {
  4817. //文件名称
  4818. string projectFileName = file.FileName;
  4819. //上传的文件的路径
  4820. string filePath = $"{fileDir}/{projectFileName}";
  4821. if (TypeName == "A")//A代表团组增减款项
  4822. {
  4823. if (!Directory.Exists(fileDir))
  4824. {
  4825. Directory.CreateDirectory(fileDir);
  4826. }
  4827. //上传的文件的路径
  4828. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4829. }
  4830. else if (TypeName == "B")//B代表商邀相关文件
  4831. {
  4832. if (!Directory.Exists(fileDir))
  4833. {
  4834. Directory.CreateDirectory(fileDir);
  4835. }
  4836. //上传的文件的路径
  4837. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4838. }
  4839. using (FileStream fs = System.IO.File.Create(filePath))
  4840. {
  4841. file.CopyTo(fs);
  4842. fs.Flush();
  4843. }
  4844. filePahts.Add(projectFileName);
  4845. }
  4846. return Ok(JsonView(true, "上传成功!", filePahts));
  4847. }
  4848. catch (Exception ex)
  4849. {
  4850. return Ok(JsonView(false, "程序错误!"));
  4851. }
  4852. }
  4853. #endregion
  4854. #region 商邀费用录入
  4855. /// <summary>
  4856. /// 根据团组Id查询商邀费用列表
  4857. /// </summary>
  4858. /// <param name="dto"></param>
  4859. /// <returns></returns>
  4860. [HttpPost]
  4861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4862. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4863. {
  4864. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4865. if (groupData.Code != 0)
  4866. {
  4867. return Ok(JsonView(false, groupData.Msg));
  4868. }
  4869. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4870. }
  4871. /// <summary>
  4872. /// 商邀费用列表
  4873. /// 下载文件
  4874. /// </summary>
  4875. /// <param name="id"></param>
  4876. /// <returns></returns>
  4877. [HttpGet("{id}")]
  4878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4879. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4880. {
  4881. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4882. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4883. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4884. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4885. var filePaths = new List<string>();
  4886. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4887. try
  4888. {
  4889. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4890. }
  4891. catch (Exception ex)
  4892. {
  4893. filePaths.Add(info.Attachment);
  4894. }
  4895. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4896. for (int i = 0; i < filePaths.Count; i++)
  4897. {
  4898. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4899. }
  4900. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4901. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4902. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4903. {
  4904. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4905. {
  4906. foreach (string filePath in filePaths)
  4907. {
  4908. if (System.IO.File.Exists(filePath))
  4909. {
  4910. // 获取文件名
  4911. string fileName = Path.GetFileName(filePath);
  4912. // 将文件添加到ZIP归档中
  4913. zipArchive.CreateEntryFromFile(filePath, fileName);
  4914. }
  4915. }
  4916. }
  4917. }
  4918. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4919. }
  4920. /// <summary>
  4921. /// 商邀费用 Info Page 基础数据源
  4922. /// </summary>
  4923. /// <returns></returns>
  4924. [HttpPost]
  4925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4926. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4927. {
  4928. try
  4929. {
  4930. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4931. if (groupData.Code != 0)
  4932. {
  4933. return Ok(JsonView(false, groupData.Msg));
  4934. }
  4935. return Ok(JsonView(true, "操作成功", groupData.Data));
  4936. }
  4937. catch (Exception ex)
  4938. {
  4939. return Ok(JsonView(false, ex.Message));
  4940. throw;
  4941. }
  4942. }
  4943. /// <summary>
  4944. /// 根据商邀费用ID查询C表和商邀费用数据
  4945. /// </summary>
  4946. /// <param name="dto"></param>
  4947. /// <returns></returns>
  4948. [HttpPost]
  4949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4950. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4951. {
  4952. try
  4953. {
  4954. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4955. if (groupData.Code != 0)
  4956. {
  4957. return Ok(JsonView(false, groupData.Msg));
  4958. }
  4959. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4960. }
  4961. catch (Exception ex)
  4962. {
  4963. return Ok(JsonView(false, ex.Message));
  4964. throw;
  4965. }
  4966. }
  4967. /// <summary>
  4968. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4969. /// </summary>
  4970. /// <param name="dto"></param>
  4971. /// <returns></returns>
  4972. [HttpPost]
  4973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4974. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4975. {
  4976. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4977. if (groupData.Code != 0)
  4978. {
  4979. return Ok(JsonView(false, groupData.Msg));
  4980. }
  4981. #region 应用推送
  4982. try
  4983. {
  4984. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4985. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4986. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4987. //2024-10-21 新增LZ UID
  4988. var userIds = new List<int>() { 21 };
  4989. string title = $"系统通知";
  4990. string content = "";
  4991. var diId = dto.DiId;
  4992. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4993. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4994. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4995. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4996. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4997. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  4998. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4999. }
  5000. catch (Exception ex)
  5001. {
  5002. }
  5003. #endregion
  5004. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5005. }
  5006. /// <summary>
  5007. /// 商邀删除
  5008. /// </summary>
  5009. /// <param name="dto"></param>
  5010. /// <returns></returns>
  5011. [HttpPost]
  5012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5013. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5014. {
  5015. try
  5016. {
  5017. _sqlSugar.BeginTran();
  5018. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5019. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5020. {
  5021. IsDel = 1,
  5022. DeleteUserId = dto.DeleteUserId,
  5023. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5024. })
  5025. .Where(it => it.Id == dto.Id)
  5026. .ExecuteCommand();
  5027. if (res1 > 0)
  5028. {
  5029. int _diId = 0;
  5030. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5031. if (_ioaInfo != null)
  5032. {
  5033. _diId = _ioaInfo.DiId;
  5034. }
  5035. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5036. .SetColumns(a => new Grp_CreditCardPayment()
  5037. {
  5038. IsDel = 1,
  5039. DeleteUserId = dto.DeleteUserId,
  5040. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5041. })
  5042. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5043. .ExecuteCommand();
  5044. if (res2 > 0)
  5045. {
  5046. _sqlSugar.CommitTran();
  5047. return Ok(JsonView(true, "删除成功!"));
  5048. }
  5049. }
  5050. _sqlSugar.RollbackTran();
  5051. return Ok(JsonView(false, "删除失败"));
  5052. }
  5053. catch (Exception ex)
  5054. {
  5055. _sqlSugar.RollbackTran();
  5056. return Ok(JsonView(false, ex.Message));
  5057. }
  5058. }
  5059. #endregion
  5060. #region 票据上传
  5061. /// <summary>
  5062. /// 团组模块文件上传
  5063. /// </summary>
  5064. /// <param name="dto"></param>
  5065. /// <returns></returns>
  5066. [HttpPost]
  5067. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5068. {
  5069. var jw = JsonView(false);
  5070. long M = 1024 * 1024;
  5071. if (dto.Files == null || dto.Files.Count == 0)
  5072. {
  5073. jw.Msg = "无文件信息!";
  5074. return Ok(jw);
  5075. }
  5076. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5077. {
  5078. jw.Msg = "文件大小超过20M!";
  5079. return Ok(jw);
  5080. }
  5081. //var nameSp = dto.File.FileName.Split(".");
  5082. //if (nameSp.Length < 2)
  5083. //{
  5084. // jw.Msg = "拓展名称有误!";
  5085. // return Ok(jw);
  5086. //}
  5087. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5088. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5089. //{
  5090. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5091. // return Ok(jw);
  5092. //}
  5093. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5094. if (Ctable == null)
  5095. {
  5096. jw.Msg = "Ctable指向有误!";
  5097. return Ok(jw);
  5098. }
  5099. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5100. if (groupInfo == null)
  5101. {
  5102. jw.Msg = "团组信息不存在!";
  5103. return Ok(jw);
  5104. }
  5105. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5106. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5107. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5108. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5109. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5110. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5111. try
  5112. {
  5113. if (!Directory.Exists(fileBase))
  5114. {
  5115. Directory.CreateDirectory(fileBase);
  5116. }
  5117. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5118. foreach (var fileStream in dto.Files)
  5119. {
  5120. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5121. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5122. {
  5123. Cid = dto.Cid,
  5124. CreateTime = DateTime.Now,
  5125. CreateUserId = dto.Userid,
  5126. Ctable = dto.Ctable,
  5127. Diid = dto.Diid,
  5128. IsDel = 0,
  5129. FilePath = saveFilePath,
  5130. FileName = fileStream.FileName
  5131. };
  5132. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5133. {
  5134. fileStream.CopyTo(fs);
  5135. fs.Flush();
  5136. }
  5137. saveArr.Add(file);
  5138. }
  5139. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5140. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5141. jw = JsonView(true, "保存成功!", new
  5142. {
  5143. count = addResult,
  5144. filesName = saveArr.Select(x => x.FileName)
  5145. });
  5146. }
  5147. catch (Exception ex)
  5148. {
  5149. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5150. {
  5151. count = 0,
  5152. filesName = new string[0],
  5153. });
  5154. }
  5155. return Ok(jw);
  5156. }
  5157. /// <summary>
  5158. /// 查询各模块已保存文件
  5159. /// </summary>
  5160. /// <param name="dto"></param>
  5161. /// <returns></returns>
  5162. [HttpPost]
  5163. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5164. {
  5165. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5166. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5167. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5168. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5169. {
  5170. expression = Expressionable.Create<Grp_GroupModelFile>()
  5171. .And(x => visaIds.Contains(x.CreateUserId));
  5172. }
  5173. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5174. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5175. .Where(expression.ToExpression())
  5176. .ToList();
  5177. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5178. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5179. {
  5180. x.FileName,
  5181. x.Id,
  5182. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5183. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5184. })));
  5185. }
  5186. /// <summary>
  5187. /// 下载该团组下的所有文件
  5188. /// </summary>
  5189. /// <param name="dto"></param>
  5190. /// <returns></returns>
  5191. [HttpPost]
  5192. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5193. {
  5194. var jw = JsonView(false);
  5195. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5196. if (groupInfo == null)
  5197. {
  5198. jw.Msg = "团组信息不存在!";
  5199. return Ok(jw);
  5200. }
  5201. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5202. var isModule = Convert.ToBoolean(dto.isModule);
  5203. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5204. IOOperatorHelper io = new IOOperatorHelper();
  5205. if (isModule)
  5206. {
  5207. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5208. foreach (var moduleArr in moduleGroup)
  5209. {
  5210. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5211. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5212. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5213. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5214. foreach (var item in moduleArr)
  5215. {
  5216. if (System.IO.File.Exists(item.FilePath))
  5217. {
  5218. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5219. {
  5220. byte[] bytes = new byte[fileStream.Length];
  5221. fileStream.Read(bytes, 0, bytes.Length);
  5222. fileStream.Close();
  5223. Stream stream = new MemoryStream(bytes);
  5224. chiZips.Add(item.FileName, stream);
  5225. }
  5226. }
  5227. }
  5228. if (chiZips.Count > 0)
  5229. {
  5230. var byts = io.ConvertZipStream(chiZips);
  5231. Stream stream = new MemoryStream(byts);
  5232. Zips.Add(key.Name + "_.zip", stream);
  5233. }
  5234. }
  5235. }
  5236. else
  5237. {
  5238. foreach (var item in dbQuery)
  5239. {
  5240. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5241. {
  5242. byte[] bytes = new byte[fileStream.Length];
  5243. fileStream.Read(bytes, 0, bytes.Length);
  5244. fileStream.Close();
  5245. Stream stream = new MemoryStream(bytes);
  5246. while (Zips.Keys.Contains(item.FileName))
  5247. {
  5248. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5249. }
  5250. Zips.Add(item.FileName, stream);
  5251. }
  5252. }
  5253. }
  5254. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5255. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5256. if (Zips.Count > 0)
  5257. {
  5258. var byts = io.ConvertZipStream(Zips);
  5259. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5260. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5261. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5262. }
  5263. else
  5264. {
  5265. jw.Msg = "暂无生成文件!";
  5266. }
  5267. return Ok(jw);
  5268. }
  5269. /// <summary>
  5270. /// 下载该团组下此模块的所有文件
  5271. /// </summary>
  5272. /// <param name="dto"></param>
  5273. /// <returns></returns>
  5274. [HttpPost]
  5275. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5276. {
  5277. var jw = JsonView(false);
  5278. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5279. if (groupInfo == null)
  5280. {
  5281. jw.Msg = "团组信息不存在!";
  5282. return Ok(jw);
  5283. }
  5284. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5285. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5286. && x.IsDel == 0);
  5287. if (key == null)
  5288. {
  5289. jw.Msg = "Ctable指向错误!";
  5290. return Ok(jw);
  5291. }
  5292. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5293. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5294. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5295. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5296. IOOperatorHelper io = new IOOperatorHelper();
  5297. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5298. foreach (var item in dbQuery)
  5299. {
  5300. if (System.IO.File.Exists(item.FilePath))
  5301. {
  5302. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5303. {
  5304. byte[] bytes = new byte[fileStream.Length];
  5305. fileStream.Read(bytes, 0, bytes.Length);
  5306. fileStream.Close();
  5307. Stream stream = new MemoryStream(bytes);
  5308. while (Zips.Keys.Contains(item.FileName))
  5309. {
  5310. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5311. }
  5312. Zips.Add(item.FileName, stream);
  5313. }
  5314. }
  5315. }
  5316. if (Zips.Count > 0)
  5317. {
  5318. var byts = io.ConvertZipStream(Zips);
  5319. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5320. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5321. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5322. }
  5323. else
  5324. {
  5325. jw.Msg = "暂无生成文件!";
  5326. }
  5327. return Ok(jw);
  5328. }
  5329. /// <summary>
  5330. /// 删除该团组下的指定文件
  5331. /// </summary>
  5332. /// <param name="dto"></param>
  5333. /// <returns></returns>
  5334. [HttpPost]
  5335. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5336. {
  5337. var jw = JsonView(false);
  5338. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5339. if (sing == null)
  5340. {
  5341. jw.Msg = "暂无";
  5342. return Ok(jw);
  5343. }
  5344. if (System.IO.File.Exists(sing.FilePath))
  5345. {
  5346. try
  5347. {
  5348. System.IO.File.Delete(sing.FilePath);
  5349. }
  5350. catch (Exception ex)
  5351. {
  5352. jw.Msg = "删除失败!" + ex.Message;
  5353. return Ok(jw);
  5354. }
  5355. }
  5356. sing.IsDel = 1;
  5357. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5358. sing.DeleteUserId = dto.UserId;
  5359. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5360. jw = JsonView(true, "删除成功!");
  5361. return Ok(jw);
  5362. }
  5363. #endregion
  5364. #region 共享文件上传
  5365. /// <summary>
  5366. /// 共享文件数据初始化
  5367. /// </summary>
  5368. /// <returns></returns>
  5369. [HttpGet]
  5370. public async Task<IActionResult> SharedFileInit(int userid ,int portType)
  5371. {
  5372. var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
  5373. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5374. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5375. .Select(x => x.Id)
  5376. .ToList()
  5377. .Contains(userid);
  5378. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5379. .Where(x => x.STid == 111 && x.IsDel == 0)
  5380. .Select(x => new
  5381. {
  5382. x.Name,
  5383. x.Id,
  5384. }).ToList();
  5385. if (isMarketingDepartment)
  5386. {
  5387. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5388. }
  5389. if (portType == 1)
  5390. {
  5391. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5392. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5393. .Where(x => x.IsDel == 0)
  5394. .OrderByDescending(x=> x.VisitDate )
  5395. .Select(x => new
  5396. {
  5397. x.TeamName,
  5398. x.Id,
  5399. x.CityId,
  5400. })
  5401. .ToList()
  5402. .Select(x=>
  5403. {
  5404. var provinceId = x.CityId;
  5405. var isDefualtVal = true;
  5406. if (provinceId > 0)
  5407. {
  5408. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5409. if (parentId != null)
  5410. {
  5411. isDefualtVal = false;
  5412. provinceId = (int)parentId;
  5413. }
  5414. }
  5415. if (isDefualtVal)
  5416. {
  5417. provinceId = 122; //默认四川
  5418. }
  5419. return new
  5420. {
  5421. x.TeamName,
  5422. x.Id,
  5423. provinceId,
  5424. };
  5425. })
  5426. .ToList();
  5427. return Ok(JsonView(true, "SUCCESS!", new
  5428. {
  5429. dropDownType,
  5430. dropDownGroupList,
  5431. isMarketingDepartment
  5432. }));
  5433. }
  5434. else if (portType == 2 || portType == 3)
  5435. {
  5436. return Ok(JsonView(true, "SUCCESS!", new
  5437. {
  5438. dropDownType,
  5439. isMarketingDepartment
  5440. }));
  5441. }
  5442. else
  5443. {
  5444. return Ok(JsonView(false, "portType有误!"));
  5445. }
  5446. }
  5447. /// <summary>
  5448. /// 共享文件上传
  5449. /// </summary>
  5450. /// <param name="dto"></param>
  5451. /// <returns></returns>
  5452. [HttpPost]
  5453. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5454. {
  5455. var isGroup = new List<int> { 1412 };
  5456. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5457. {
  5458. return Ok(JsonView(false, "该文件需要关联团组!"));
  5459. }
  5460. if (dto.Files == null || dto.Files.Count == 0)
  5461. {
  5462. return Ok(JsonView(false, "无文件信息!"));
  5463. }
  5464. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5465. {
  5466. return Ok(JsonView(false, "文件大小超过20M!"));
  5467. }
  5468. if (dto.Userid < 1)
  5469. {
  5470. return Ok(JsonView(false, "请传入有效的Userid!"));
  5471. }
  5472. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5473. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5474. .Select((u, j) => new
  5475. {
  5476. u.CnName,
  5477. UserId = u.Id,
  5478. j.JobName,
  5479. })
  5480. .First();
  5481. if (jobInfo == null)
  5482. {
  5483. return Ok(JsonView(false, "请传入有效的Userid!"));
  5484. }
  5485. List<string> commonFileExtensions = new List<string>
  5486. {
  5487. // 文本文件
  5488. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5489. // 图片文件
  5490. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5491. // 视频文件
  5492. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5493. // 音频文件
  5494. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5495. // 压缩文件
  5496. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5497. // 数据文件
  5498. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5499. };
  5500. try
  5501. {
  5502. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5503. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5504. commonFileExtensions.AddRange(settingExtend);
  5505. }
  5506. catch (Exception)
  5507. { }
  5508. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5509. if (setdata == null)
  5510. {
  5511. return Ok(JsonView(false, "请传入有效的FileType!"));
  5512. }
  5513. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5514. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5515. if (!Directory.Exists(winPath))
  5516. {
  5517. Directory.CreateDirectory(winPath);
  5518. }
  5519. foreach (var item in dto.Files)
  5520. {
  5521. var houzui = Path.GetExtension(item.FileName);
  5522. if (!commonFileExtensions.Contains(houzui))
  5523. {
  5524. return Ok(JsonView(false, "未知后缀名称!"));
  5525. }
  5526. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5527. var saveFilePath = winPath + fileName;
  5528. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5529. {
  5530. item.CopyTo(fs);
  5531. fs.Flush();
  5532. }
  5533. var fileDetail = new Grp_GroupShareFile()
  5534. {
  5535. CreateUserId = dto.Userid,
  5536. CreateTime = DateTime.Now,
  5537. UploadJob = jobInfo.JobName,
  5538. FileName = fileName,
  5539. FileType = dto.FileType,
  5540. Diid = dto.Diid,
  5541. FilePath = winPath + fileName,
  5542. };
  5543. insertList.Add(fileDetail);
  5544. }
  5545. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5546. return Ok(JsonView(true, "保存成功!"));
  5547. }
  5548. /// <summary>
  5549. /// 查询共享文件列表
  5550. /// </summary>
  5551. /// <param name="dto"></param>
  5552. /// <returns></returns>
  5553. [HttpPost]
  5554. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5555. {
  5556. var isGroup = new List<int> { 1412 };
  5557. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5558. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5559. .And(x => x.Diid == dto.Diid)
  5560. .And(x => x.FileType == dto.FileType)
  5561. .And(x => x.IsDel == 0)
  5562. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5563. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5564. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5565. int totalCount = 0;
  5566. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5567. .Where(queryExpression.ToExpression())
  5568. .OrderBy(x => x.UploadJob)
  5569. .Select(x => new
  5570. {
  5571. x.Id,
  5572. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5573. x.FileName,
  5574. x.FileType,
  5575. x.CreateTime,
  5576. })
  5577. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5578. return Ok(JsonView(true, "SUCCESS!", new
  5579. {
  5580. FileList = dbQuery,
  5581. dto.PageSize,
  5582. dto.PageIndex,
  5583. totalCount
  5584. }));
  5585. }
  5586. /// <summary>
  5587. /// 删除共享文件模块下的指定文件
  5588. /// </summary>
  5589. /// <param name="dto"></param>
  5590. /// <returns></returns>
  5591. [HttpPost]
  5592. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5593. {
  5594. var jw = JsonView(false);
  5595. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5596. if (sing == null)
  5597. {
  5598. jw.Msg = "暂无文件信息!";
  5599. return Ok(jw);
  5600. }
  5601. if (sing.CreateUserId != dto.UserId)
  5602. {
  5603. jw.Msg = "只能删除自己上传的文件!";
  5604. return Ok(jw);
  5605. }
  5606. if (System.IO.File.Exists(sing.FilePath))
  5607. {
  5608. try
  5609. {
  5610. System.IO.File.Delete(sing.FilePath);
  5611. }
  5612. catch (Exception ex)
  5613. {
  5614. jw.Msg = "删除失败!" + ex.Message;
  5615. return Ok(jw);
  5616. }
  5617. }
  5618. sing.IsDel = 1;
  5619. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5620. sing.DeleteUserId = dto.UserId;
  5621. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5622. jw = JsonView(true, "删除成功!");
  5623. return Ok(jw);
  5624. }
  5625. #endregion
  5626. #region 团组英文资料
  5627. /// <summary>
  5628. /// 查询团组英文所有资料
  5629. /// </summary>
  5630. /// <param name="dto"></param>
  5631. /// <returns></returns>
  5632. [HttpPost]
  5633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5634. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5635. {
  5636. try
  5637. {
  5638. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5639. if (groupData.Code != 0)
  5640. {
  5641. return Ok(JsonView(false, groupData.Msg));
  5642. }
  5643. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5644. }
  5645. catch (Exception ex)
  5646. {
  5647. return Ok(JsonView(false, "程序错误!"));
  5648. throw;
  5649. }
  5650. }
  5651. /// <summary>
  5652. /// 团组英文资料操作(Status:1.新增,2.修改)
  5653. /// </summary>
  5654. /// <param name="dto"></param>
  5655. /// <returns></returns>
  5656. [HttpPost]
  5657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5658. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5659. {
  5660. try
  5661. {
  5662. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5663. if (groupData.Code != 0)
  5664. {
  5665. return Ok(JsonView(false, groupData.Msg));
  5666. }
  5667. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5668. }
  5669. catch (Exception ex)
  5670. {
  5671. return Ok(JsonView(false, "程序错误!"));
  5672. throw;
  5673. }
  5674. }
  5675. /// <summary>
  5676. /// 团组英文资料Id查询数据
  5677. /// </summary>
  5678. /// <param name="dto"></param>
  5679. /// <returns></returns>
  5680. [HttpPost]
  5681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5682. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5683. {
  5684. try
  5685. {
  5686. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5687. if (_DelegationEnData != null)
  5688. {
  5689. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5690. }
  5691. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5692. }
  5693. catch (Exception ex)
  5694. {
  5695. return Ok(JsonView(false, "程序错误!"));
  5696. throw;
  5697. }
  5698. }
  5699. /// <summary>
  5700. /// 团组英文资料删除
  5701. /// </summary>
  5702. /// <param name="dto"></param>
  5703. /// <returns></returns>
  5704. [HttpPost]
  5705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5706. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5707. {
  5708. try
  5709. {
  5710. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5711. if (!res)
  5712. {
  5713. return Ok(JsonView(false, "删除失败"));
  5714. }
  5715. return Ok(JsonView(true, "删除成功!"));
  5716. }
  5717. catch (Exception ex)
  5718. {
  5719. return Ok(JsonView(false, "程序错误!"));
  5720. throw;
  5721. }
  5722. }
  5723. #endregion
  5724. #region 导出邀请函
  5725. /// <summary>
  5726. /// 导出邀请函页面初始化
  5727. /// </summary>
  5728. /// <param name="dto"></param>
  5729. /// <returns></returns>
  5730. [HttpPost]
  5731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5732. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5733. {
  5734. try
  5735. {
  5736. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5737. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5738. if (dto.DiId == 0)
  5739. {
  5740. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5741. }
  5742. else
  5743. {
  5744. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5745. }
  5746. return Ok(JsonView(true, "查询成功!", new
  5747. {
  5748. deleClient = crm_Deles,
  5749. delegations = grp_Delegations
  5750. }));
  5751. }
  5752. catch (Exception ex)
  5753. {
  5754. return Ok(JsonView(false, "程序错误!"));
  5755. throw;
  5756. }
  5757. }
  5758. /// <summary>
  5759. /// 导出邀请函
  5760. /// </summary>
  5761. /// <param name="dto"></param>
  5762. /// <returns></returns>
  5763. [HttpPost]
  5764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5765. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5766. {
  5767. #region 参数验证
  5768. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5769. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5770. #endregion
  5771. try
  5772. {
  5773. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5774. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5775. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5776. From Grp_TourClientList tcl
  5777. Left Join
  5778. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5779. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5780. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5781. From Crm_DeleClient dc
  5782. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5783. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5784. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5785. Where dc.IsDel = 0) temp
  5786. On temp.DcId =tcl.ClientId
  5787. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5788. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5789. List<string> texts = new List<string>();
  5790. if (datas.Count != 0)
  5791. {
  5792. foreach (TourClientListDetailsView item in datas)
  5793. {
  5794. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5795. {
  5796. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5797. }
  5798. else
  5799. {
  5800. string name = item.LastName + item.FirstName;
  5801. texts.Add(name);
  5802. }
  5803. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5804. {
  5805. if (!transDic.ContainsKey(item.Job))
  5806. {
  5807. texts.Add(item.Job);
  5808. }
  5809. }
  5810. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5811. {
  5812. texts.Add(item.CompanyFullName);
  5813. }
  5814. }
  5815. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5816. if (transData.Count > 0)
  5817. {
  5818. foreach (TranslateResult item in transData)
  5819. {
  5820. if (!transDic.ContainsKey(item.Query))
  5821. {
  5822. transDic.Add(item.Query, item.Translation);
  5823. }
  5824. }
  5825. }
  5826. List<GuestList> list = new List<GuestList>();
  5827. foreach (TourClientListDetailsView dele in datas)
  5828. {
  5829. GuestList guestList = new GuestList();
  5830. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5831. {
  5832. guestList.Name = dele.Pinyin;
  5833. }
  5834. else
  5835. {
  5836. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5837. guestList.Name = Name;
  5838. }
  5839. if (dele.Sex == 0)
  5840. {
  5841. guestList.Sex = "Male";
  5842. }
  5843. else if (dele.Sex == 1)
  5844. {
  5845. guestList.Sex = "Female";
  5846. }
  5847. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5848. if (!string.IsNullOrEmpty(dele.Job))
  5849. {
  5850. guestList.Job = dele.Job;
  5851. }
  5852. list.Add(guestList);
  5853. }
  5854. //载入模板
  5855. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5856. DocumentBuilder builder = new DocumentBuilder(doc);
  5857. //获取word里所有表格
  5858. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5859. //获取所填表格的序数
  5860. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5861. var rowStart = tableOne.Rows[0]; //获取第1行
  5862. //循环赋值
  5863. for (int i = 0; i < list.Count; i++)
  5864. {
  5865. builder.MoveToCell(0, i + 1, 0, 0);
  5866. builder.Write(list[i].Name.ToString());
  5867. builder.MoveToCell(0, i + 1, 1, 0);
  5868. builder.Write(list[i].Sex.ToString());
  5869. builder.MoveToCell(0, i + 1, 2, 0);
  5870. builder.Write(list[i].DOB.ToString());
  5871. builder.MoveToCell(0, i + 1, 3, 0);
  5872. builder.Write(list[i].Job.ToString());
  5873. }
  5874. //删除多余行
  5875. while (tableOne.Rows.Count > list.Count + 1)
  5876. {
  5877. tableOne.Rows.RemoveAt(list.Count + 1);
  5878. }
  5879. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5880. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5881. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5882. doc.Save(filePath);
  5883. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5884. return Ok(JsonView(true, "操作成功!", Url));
  5885. }
  5886. else
  5887. {
  5888. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5889. }
  5890. }
  5891. catch (Exception ex)
  5892. {
  5893. return Ok(JsonView(false, ex.Message));
  5894. throw;
  5895. }
  5896. }
  5897. #endregion
  5898. #region 团组经理模块 出入境费用
  5899. /// <summary>
  5900. /// 团组模块 - 出入境费用 - 省份基础数据源
  5901. /// </summary>
  5902. /// <returns></returns>
  5903. [HttpGet]
  5904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5905. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5906. {
  5907. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5908. }
  5909. /// <summary>
  5910. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  5911. /// </summary>
  5912. /// <returns></returns>
  5913. [HttpPost]
  5914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5915. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  5916. {
  5917. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  5918. var groupNamFirst = groupNameData.FirstOrDefault();
  5919. //SetDataInfoView
  5920. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  5921. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  5922. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  5923. //验证城市归属并给默认值
  5924. int provinceId = 122;
  5925. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  5926. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  5927. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  5928. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  5929. return Ok(JsonView(true, "查询成功!", new
  5930. {
  5931. GroupNameData = groupNameData,
  5932. CurrencyData = _CurrencyData,
  5933. WordTypeData = wordTypeData,
  5934. ExcelTypeData = excelTypeData,
  5935. CurrencyInit = _currencyInfos,
  5936. ViewPermissionData = viewPermissionData
  5937. }));
  5938. }
  5939. /// <summary>
  5940. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  5941. /// </summary>
  5942. /// <returns></returns>
  5943. [HttpGet("{provinceId}")]
  5944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5945. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  5946. {
  5947. //验证城市归属并给默认值
  5948. if (provinceId < 1) provinceId = 122;
  5949. /*
  5950. * 122 四川
  5951. * 108 贵州
  5952. * 103 重庆
  5953. * 132 云南
  5954. */
  5955. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  5956. return Ok(JsonView(true, "查询成功!", new
  5957. {
  5958. WordTypeData = wordTypeData,
  5959. ExcelTypeData = excelTypeData,
  5960. }));
  5961. }
  5962. /// <summary>
  5963. /// 团组模块 - 出入境费用
  5964. /// 实时汇率 tips
  5965. /// 签证费用 tips
  5966. /// 机票费用 tips
  5967. /// </summary>
  5968. /// <returns></returns>
  5969. [HttpPost]
  5970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5971. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  5972. {
  5973. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  5974. //默认币种显示
  5975. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  5976. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  5977. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  5978. return Ok(JsonView(true, "查询成功!", new
  5979. {
  5980. //GroupNameData = groupNameData.Data,
  5981. visaData = visaData.Data,
  5982. airData = airData,
  5983. reteInfos = reteInfos
  5984. }));
  5985. }
  5986. /// <summary>
  5987. /// 团组模块 - 出入境费用 - Info
  5988. /// </summary>
  5989. /// <returns></returns>
  5990. [HttpPost]
  5991. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  5992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5993. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  5994. {
  5995. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5996. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5997. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  5998. }
  5999. /// <summary>
  6000. /// 团组模块 - 出入境费用 - 设置view权限
  6001. /// </summary>
  6002. /// <returns></returns>
  6003. [HttpPost]
  6004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6005. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6006. {
  6007. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6008. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6009. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6010. var permissions = new List<Grp_EnterExitCostPermission>();
  6011. foreach (var userId in dto.UserIds)
  6012. {
  6013. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6014. }
  6015. if (permissions.Any())
  6016. {
  6017. _sqlSugar.BeginTran();
  6018. try
  6019. {
  6020. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6021. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6022. if (result < 1)
  6023. {
  6024. _sqlSugar.RollbackTran();
  6025. return Ok(JsonView(false));
  6026. }
  6027. }
  6028. catch (Exception ex)
  6029. {
  6030. _sqlSugar.RollbackTran();
  6031. return Ok(JsonView(false, ex.Message));
  6032. }
  6033. _sqlSugar.CommitTran();
  6034. return Ok(JsonView(true));
  6035. }
  6036. return Ok(JsonView(false));
  6037. }
  6038. /// <summary>
  6039. /// 团组模块 - 出入境费用 - Add And Update
  6040. /// </summary>
  6041. /// <returns></returns>
  6042. [HttpPost]
  6043. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6045. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6046. {
  6047. try
  6048. {
  6049. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6050. if (dto.DayOtherPriceData.Any())
  6051. {
  6052. var inserList = dto.DayOtherPriceData
  6053. .Where(x => x.Id == 0)
  6054. .Select(x => new Grp_DayOtherPrice
  6055. {
  6056. Cost = x.Cost,
  6057. Id = x.Id,
  6058. CreateTime = DateTime.Now,
  6059. CreateUserId = dto.UserId,
  6060. Currency = x.Currency,
  6061. Diid = x.DiId,
  6062. Index = x.Index,
  6063. IsDel = 0,
  6064. SetDataId = x.SetDataId,
  6065. SubTotal = x.SubTotal,
  6066. Remark = x.Remark
  6067. })
  6068. .ToList();
  6069. var updateList = dto.DayOtherPriceData
  6070. .Where(x => x.Id != 0)
  6071. .Select(x => new Grp_DayOtherPrice
  6072. {
  6073. Cost = x.Cost,
  6074. Id = x.Id,
  6075. CreateTime = DateTime.Now,
  6076. CreateUserId = dto.UserId,
  6077. Currency = x.Currency,
  6078. Diid = x.DiId,
  6079. Index = x.Index,
  6080. IsDel = 0,
  6081. SetDataId = x.SetDataId,
  6082. SubTotal = x.SubTotal,
  6083. Remark = x.Remark
  6084. })
  6085. .ToList();
  6086. //添加
  6087. _sqlSugar.BeginTran();
  6088. if (inserList.Any())
  6089. {
  6090. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6091. }
  6092. if (updateList.Any())
  6093. {
  6094. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6095. }
  6096. _sqlSugar.CommitTran();
  6097. }
  6098. if (data.Code != 0)
  6099. {
  6100. return Ok(JsonView(false, data.Msg));
  6101. }
  6102. //生成默认文件pdf并且通知人员
  6103. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6104. {
  6105. DiId = dto.DiId,
  6106. ExportType = 1,
  6107. SubTypeId = 1005
  6108. }, "pdf");
  6109. //发送通知
  6110. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6111. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6112. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6113. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6114. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6115. //汇率信息记录
  6116. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6117. return Ok(JsonView(true, data.Msg, data.Data));
  6118. }
  6119. catch (Exception ex)
  6120. {
  6121. return Ok(JsonView(false, ex.Message));
  6122. }
  6123. }
  6124. /// <summary>
  6125. /// 团组模块 - 出入境费用 - Confirm 费用
  6126. /// </summary>
  6127. /// <returns></returns>
  6128. [HttpPost]
  6129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6130. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6131. {
  6132. //TODO:测试完毕需把对应的用户ID更改
  6133. //1、数据表添加字段
  6134. //2、更改字段接口()
  6135. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6136. //3、确认成功 给财务发送消息
  6137. if (_view.Code == 200)
  6138. {
  6139. if (dto.Type == 1)
  6140. {
  6141. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6142. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6143. }
  6144. }
  6145. return Ok(_view);
  6146. }
  6147. /// <summary>
  6148. /// 团组模块 - 出入境费用 - File download
  6149. /// </summary>
  6150. /// <param name="dto"></param>
  6151. /// <returns></returns>
  6152. [HttpPost]
  6153. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6155. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6156. {
  6157. try
  6158. {
  6159. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6160. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6161. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6162. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6163. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6164. 3 团组成员名单 1 团组成员名单", ""));
  6165. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6166. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6167. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6168. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6169. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6170. //数据源
  6171. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6172. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6173. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6174. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6175. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6176. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6177. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6178. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6179. .Select((x, a, b) => new
  6180. {
  6181. x.Index,
  6182. itemName = a.Name,
  6183. CurrencyStr = b.Name,
  6184. x.Cost,
  6185. x.SubTotal,
  6186. x.Remark
  6187. })
  6188. .OrderBy((x) => x.Index)
  6189. .ToList(); //其他款项费用
  6190. var peiceItemCurrencys = new List<string>();
  6191. if (_DayAndCosts.Any())
  6192. {
  6193. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6194. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6195. }
  6196. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6197. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6198. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6199. {
  6200. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6201. }
  6202. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6203. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6204. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6205. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6206. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6207. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6208. .Select((tcl, dc, cc) => new ClientInfo
  6209. {
  6210. LastName = dc.LastName,
  6211. FirstName = dc.FirstName,
  6212. Sex = dc.Sex,
  6213. Birthday = dc.BirthDay,
  6214. Company = cc.CompanyFullName,
  6215. Job = dc.Job
  6216. })
  6217. .ToList();
  6218. foreach (var item in DeleClientList)
  6219. {
  6220. EncryptionProcessor.DecryptProperties(item);
  6221. }
  6222. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6223. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6224. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6225. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6226. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6227. if (dto.ExportType == 1) //明细表
  6228. {
  6229. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6230. {
  6231. //获取模板
  6232. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6233. //载入模板
  6234. Document doc = new Document(tempPath);
  6235. DocumentBuilder builder = new DocumentBuilder(doc);
  6236. //利用键值对存放数据
  6237. Dictionary<string, string> dic = new Dictionary<string, string>();
  6238. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6239. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6240. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6241. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6242. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6243. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6244. //境内费用(其他费用)
  6245. if (_EnterExitCosts.ChoiceOne == 1)
  6246. {
  6247. string row1_1 = "";
  6248. if (_EnterExitCosts.Visa > 0)
  6249. {
  6250. //insidePayTotal += _EnterExitCosts.Visa;
  6251. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6252. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6253. //{
  6254. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6255. //}
  6256. }
  6257. string row1_2 = "";
  6258. if (_EnterExitCosts.YiMiao > 0)
  6259. {
  6260. //insidePayTotal += _EnterExitCosts.YiMiao;
  6261. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6262. }
  6263. if (_EnterExitCosts.HeSuan > 0)
  6264. {
  6265. //insidePayTotal += _EnterExitCosts.HeSuan;
  6266. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6267. }
  6268. if (_EnterExitCosts.Service > 0)
  6269. {
  6270. //insidePayTotal += _EnterExitCosts.Service;
  6271. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6272. }
  6273. string row1_3 = "";
  6274. if (_EnterExitCosts.Safe > 0)
  6275. {
  6276. //insidePayTotal += _EnterExitCosts.Safe;
  6277. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6278. }
  6279. if (_EnterExitCosts.Ticket > 0)
  6280. {
  6281. //insidePayTotal += _EnterExitCosts.Ticket;
  6282. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6283. }
  6284. string row1 = "";
  6285. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6286. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6287. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6288. row1 += $"备注:{_EnterExitCosts.Remark}";
  6289. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6290. dic.Add("Row1Str", row1);
  6291. }
  6292. string airTotalStr = string.Empty,
  6293. airPriceStr = string.Empty;
  6294. //经济舱
  6295. if (_EnterExitCosts.SumJJC == 1)
  6296. {
  6297. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6298. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6299. }
  6300. //公务舱
  6301. if (_EnterExitCosts.SumGWC == 1)
  6302. {
  6303. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6304. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6305. }
  6306. //头等舱
  6307. if (_EnterExitCosts.SumTDC == 1)
  6308. {
  6309. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6310. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6311. }
  6312. //汇率描述
  6313. string rateStr = "";
  6314. if (peiceItemCurrencyInfos.Any())
  6315. {
  6316. rateStr = "\r\n汇率描述:";
  6317. foreach (var item in peiceItemCurrencyInfos)
  6318. {
  6319. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6320. }
  6321. }
  6322. string twoItemRemark = "备注:";
  6323. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6324. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6325. dic.Add("AirTotalStr", airTotalStr);
  6326. dic.Add("AirPriceStr", airPriceStr);
  6327. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6328. dic.Add("TwoItemRemark", twoItemRemark);
  6329. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6330. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6331. int table1Row = 0,
  6332. table2Row = 0,
  6333. table3Row = 0,
  6334. table4Row = 0,
  6335. table5Row = 0;
  6336. //住宿费
  6337. if (_EnterExitCosts.ChoiceThree == 1)
  6338. {
  6339. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6340. table1Row = dac1.Count;
  6341. #region 填充word表格内容
  6342. for (int i = 0; i < dac1.Count; i++)
  6343. {
  6344. Grp_DayAndCost dac = dac1[i];
  6345. if (dac == null) continue;
  6346. builder.MoveToCell(0, i, 0, 0);
  6347. builder.Write("第" + dac.Days.ToString() + "晚:");
  6348. builder.MoveToCell(0, i, 1, 0);
  6349. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6350. //builder.Write(dac.Place == null ? "" : dac.Place);
  6351. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6352. builder.MoveToCell(0, i, 2, 0);
  6353. builder.Write("费用标准:");
  6354. string curr = "";
  6355. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6356. if (currData != null)
  6357. {
  6358. curr = currData.Name;
  6359. }
  6360. builder.MoveToCell(0, i, 3, 0);
  6361. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6362. builder.MoveToCell(0, i, 4, 0);
  6363. builder.Write("费用小计:");
  6364. builder.MoveToCell(0, i, 5, 0);
  6365. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6366. }
  6367. #endregion
  6368. }
  6369. else dic.Add("SubZS", "0.00");
  6370. //删除多余行
  6371. while (table1.Rows.Count > table1Row)
  6372. {
  6373. table1.Rows.RemoveAt(table1Row);
  6374. }
  6375. //伙食费
  6376. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6377. if (_EnterExitCosts.ChoiceFour == 1)
  6378. {
  6379. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6380. table2Row = dac2.Count;
  6381. #region 填充word表格内容
  6382. for (int i = 0; i < dac2.Count; i++)
  6383. {
  6384. Grp_DayAndCost dac = dac2[i];
  6385. if (dac == null) continue;
  6386. builder.MoveToCell(1, i, 0, 0);
  6387. builder.Write("第" + dac.Days.ToString() + "天:");
  6388. builder.MoveToCell(1, i, 1, 0);
  6389. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6390. builder.MoveToCell(1, i, 2, 0);
  6391. builder.Write("费用标准:");
  6392. string curr = "";
  6393. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6394. if (currData != null)
  6395. {
  6396. curr = currData.Name;
  6397. }
  6398. builder.MoveToCell(1, i, 3, 0);
  6399. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6400. builder.MoveToCell(1, i, 4, 0);
  6401. builder.Write("费用小计:");
  6402. builder.MoveToCell(1, i, 5, 0);
  6403. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6404. }
  6405. #endregion
  6406. }
  6407. else dic.Add("SubHS", "0.00");
  6408. //删除多余行
  6409. while (table2.Rows.Count > table2Row)
  6410. {
  6411. table2.Rows.RemoveAt(table2Row);
  6412. }
  6413. //公杂费
  6414. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6415. if (_EnterExitCosts.ChoiceFive == 1)
  6416. {
  6417. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6418. table3Row = dac3.Count;
  6419. #region 填充word表格内容
  6420. for (int i = 0; i < dac3.Count; i++)
  6421. {
  6422. Grp_DayAndCost dac = dac3[i];
  6423. if (dac == null) continue;
  6424. builder.MoveToCell(2, i, 0, 0);
  6425. builder.Write("第" + dac.Days.ToString() + "天:");
  6426. builder.MoveToCell(2, i, 1, 0);
  6427. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6428. builder.MoveToCell(2, i, 2, 0);
  6429. builder.Write("费用标准:");
  6430. string curr = "";
  6431. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6432. if (currData != null)
  6433. {
  6434. curr = currData.Name;
  6435. }
  6436. builder.MoveToCell(2, i, 3, 0);
  6437. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6438. builder.MoveToCell(2, i, 4, 0);
  6439. builder.Write("费用小计:");
  6440. builder.MoveToCell(2, i, 5, 0);
  6441. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6442. }
  6443. //删除多余行
  6444. while (table3.Rows.Count > table3Row)
  6445. {
  6446. table3.Rows.RemoveAt(table3Row);
  6447. }
  6448. #endregion
  6449. }
  6450. else dic.Add("SubGZF", "0.00");
  6451. //删除多余行
  6452. while (table3.Rows.Count > table3Row)
  6453. {
  6454. table3.Rows.RemoveAt(table3Row);
  6455. }
  6456. //培训费
  6457. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6458. if (_EnterExitCosts.ChoiceSix == 1)
  6459. {
  6460. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6461. dic.Add("SubPX", pxStr);
  6462. table4Row = dac4.Count;
  6463. #region 填充word表格内容
  6464. for (int i = 0; i < dac4.Count; i++)
  6465. {
  6466. Grp_DayAndCost dac = dac4[i];
  6467. if (dac == null) continue;
  6468. builder.MoveToCell(3, i, 0, 0);
  6469. builder.Write("第" + dac.Days.ToString() + "天:");
  6470. builder.MoveToCell(3, i, 1, 0);
  6471. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6472. builder.MoveToCell(3, i, 2, 0);
  6473. builder.Write("费用标准:");
  6474. string curr = "";
  6475. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6476. if (currData != null)
  6477. {
  6478. curr = currData.Name;
  6479. }
  6480. builder.MoveToCell(3, i, 3, 0);
  6481. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6482. builder.MoveToCell(3, i, 4, 0);
  6483. builder.Write("费用小计:");
  6484. builder.MoveToCell(3, i, 5, 0);
  6485. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6486. }
  6487. #endregion
  6488. }
  6489. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6490. //删除多余行
  6491. while (table4.Rows.Count > table4Row)
  6492. {
  6493. table4.Rows.RemoveAt(table4Row);
  6494. }
  6495. //其他费用
  6496. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6497. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6498. {
  6499. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6500. dic.Add("titleQi", qtStr);
  6501. table5Row = dac5.Count;
  6502. #region 填充word表格内容
  6503. for (int i = 0; i < dac5.Count; i++)
  6504. {
  6505. var dac = dac5[i];
  6506. if (dac == null) continue;
  6507. builder.MoveToCell(4, i, 0, 0);
  6508. builder.Write("第" + dac.Index.ToString() + "项:");
  6509. builder.MoveToCell(4, i, 1, 0);
  6510. builder.Write(dac.itemName);
  6511. builder.MoveToCell(4, i, 2, 0);
  6512. builder.Write("费用标准:");
  6513. builder.MoveToCell(4, i, 3, 0);
  6514. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6515. builder.MoveToCell(4, i, 4, 0);
  6516. builder.Write("费用小计:");
  6517. builder.MoveToCell(4, i, 5, 0);
  6518. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6519. builder.MoveToCell(4, i, 6, 0);
  6520. builder.Write("备注:");
  6521. builder.MoveToCell(4, i, 7, 0);
  6522. builder.Write(dac.Remark);
  6523. }
  6524. #endregion
  6525. }
  6526. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6527. //删除多余行
  6528. while (table5.Rows.Count > table5Row)
  6529. {
  6530. table5.Rows.RemoveAt(table5Row);
  6531. }
  6532. //加上其他费用
  6533. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6534. decimal subJJC = 0.00M,
  6535. subGWC = 0.00M,
  6536. subTDC = 0.00M;
  6537. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6538. string totalLabel = string.Format("全部费用总计:");
  6539. //经济舱
  6540. if (_EnterExitCosts.SumJJC == 1)
  6541. {
  6542. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6543. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6544. }
  6545. //公务舱
  6546. if (_EnterExitCosts.SumGWC == 1)
  6547. {
  6548. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6549. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6550. }
  6551. //头等舱
  6552. if (_EnterExitCosts.SumTDC == 1)
  6553. {
  6554. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6555. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6556. }
  6557. //TotalLabel
  6558. dic.Add("TotalLabel", totalLabel);
  6559. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6560. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6561. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6562. #region 填充word模板书签内容
  6563. foreach (var key in dic.Keys)
  6564. {
  6565. Bookmark bookmark = doc.Range.Bookmarks[key];
  6566. if (bookmark != null)
  6567. {
  6568. builder.MoveToBookmark(key);
  6569. builder.Write(dic[key]);
  6570. }
  6571. }
  6572. #endregion
  6573. #region 设置页眉
  6574. string userLabel = string.Empty;
  6575. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6576. if (currUserInfo != null)
  6577. {
  6578. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6579. if (userInfo != null)
  6580. {
  6581. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6582. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6583. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6584. }
  6585. }
  6586. //设置页脚
  6587. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6588. #endregion
  6589. //文件名
  6590. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6591. AsposeHelper.removewatermark_v2180();
  6592. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6593. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6594. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6595. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6596. }
  6597. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6598. {
  6599. //获取模板
  6600. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6601. //载入模板
  6602. Document doc = new Document(tempPath);
  6603. DocumentBuilder builder = new DocumentBuilder(doc);
  6604. Dictionary<string, string> dic = new Dictionary<string, string>();
  6605. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6606. {
  6607. List<string> list = new List<string>();
  6608. try
  6609. {
  6610. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6611. foreach (var item in spilitArr)
  6612. {
  6613. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6614. var depCode = spDotandEmpty[2].Substring(0, 3);
  6615. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6616. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6617. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6618. list.Add(depName);
  6619. list.Add(arrName);
  6620. }
  6621. list = list.Distinct().ToList();
  6622. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6623. }
  6624. catch (Exception)
  6625. {
  6626. dic.Add("ReturnCode", "行程录入不正确!");
  6627. }
  6628. }
  6629. else
  6630. {
  6631. dic.Add("ReturnCode", "未录入行程!");
  6632. }
  6633. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6634. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6635. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6636. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6637. {
  6638. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6639. dic.Add("Day", sp.Days.ToString());
  6640. }
  6641. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6642. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6643. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6644. //dic.Add("Names", Names);
  6645. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6646. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6647. decimal dac1totalPrice = 0.00M;
  6648. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6649. foreach (var dac in dac1)
  6650. {
  6651. if (dac.SubTotal == 0.00M)
  6652. {
  6653. continue;
  6654. }
  6655. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6656. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6657. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6658. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6659. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6660. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6661. builder.Write(currency);//币种
  6662. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6663. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6664. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6665. builder.Write("");//人数
  6666. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6667. builder.Write("");//天数
  6668. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6669. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6670. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6671. decimal rate = 0.00M;
  6672. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6673. builder.Write(rate.ToString("#0.0000"));//汇率
  6674. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6675. decimal rbmPrice = dac.SubTotal;
  6676. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6677. accommodationStartIndex++;
  6678. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6679. }
  6680. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6681. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6682. {
  6683. table1.Rows.RemoveAt(i - 1);
  6684. foodandotherStartIndex--;
  6685. }
  6686. if (dac2.Count == dac3.Count)//国家 币种 金额
  6687. {
  6688. for (int i = 0; i < dac2.Count; i++)
  6689. {
  6690. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6691. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6692. }
  6693. }
  6694. decimal dac2totalPrice = 0.00M;
  6695. foreach (var dac in dac2)
  6696. {
  6697. if (dac.SubTotal == 0)
  6698. {
  6699. continue;
  6700. }
  6701. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6702. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6703. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6704. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6705. builder.Write(currency);//币种
  6706. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6707. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6708. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6709. builder.Write("");//人数
  6710. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6711. builder.Write("");//天数
  6712. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6713. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6714. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6715. decimal rate = 0.00M;
  6716. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6717. builder.Write(rate.ToString("#0.0000"));//汇率
  6718. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6719. decimal rbmPrice = dac.SubTotal;
  6720. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6721. foodandotherStartIndex++;
  6722. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6723. }
  6724. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6725. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6726. {
  6727. table1.Rows.RemoveAt(i - 1);
  6728. }
  6729. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6730. string otherFeeStr = "";
  6731. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6732. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6733. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6734. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6735. foreach (var otherInfo in dac5)
  6736. {
  6737. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6738. }
  6739. #endregion
  6740. if (otherFeeStr.Length > 0)
  6741. {
  6742. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6743. otherFeeStr = $"({otherFeeStr})";
  6744. dic.Add("OtherFeeStr", otherFeeStr);
  6745. }
  6746. //总计
  6747. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6748. //国际旅费
  6749. string outsideAir = string.Empty;
  6750. string allPriceAir = string.Empty;
  6751. if (_EnterExitCosts.SumJJC == 1)
  6752. {
  6753. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6754. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6755. }
  6756. if (_EnterExitCosts.SumGWC == 1)
  6757. {
  6758. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6759. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6760. }
  6761. if (_EnterExitCosts.SumTDC == 1)
  6762. {
  6763. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6764. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6765. }
  6766. dic.Add("InTravelPrice", $"({outsideAir})");
  6767. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6768. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6769. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6770. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6771. foreach (var key in dic.Keys)
  6772. {
  6773. builder.MoveToBookmark(key);
  6774. builder.Write(dic[key]);
  6775. }
  6776. //模板文件名
  6777. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6778. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6779. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6780. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6781. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6782. }
  6783. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6784. {
  6785. //获取模板
  6786. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6787. //载入模板
  6788. WorkbookDesigner designer = new WorkbookDesigner();
  6789. designer.Workbook = new Workbook(tempPath);
  6790. Dictionary<string, string> dic = new Dictionary<string, string>();
  6791. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6792. {
  6793. List<string> list = new List<string>();
  6794. try
  6795. {
  6796. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6797. foreach (var item in spilitArr)
  6798. {
  6799. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6800. var depCode = spDotandEmpty[2].Substring(0, 3);
  6801. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6802. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6803. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6804. list.Add(depName);
  6805. list.Add(arrName);
  6806. }
  6807. list = list.Distinct().ToList();
  6808. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6809. }
  6810. catch (Exception)
  6811. {
  6812. dic.Add("ReturnCode", "行程录入不正确!");
  6813. }
  6814. }
  6815. else
  6816. {
  6817. dic.Add("ReturnCode", "未录入行程!");
  6818. }
  6819. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6820. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6821. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6822. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6823. {
  6824. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6825. dic.Add("Day", sp.Days.ToString());
  6826. }
  6827. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6828. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6829. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6830. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6831. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6832. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6833. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6834. designer.SetDataSource("Name", Names);
  6835. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6836. designer.SetDataSource("Day", dic["Day"] + "天");
  6837. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6838. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6839. int startIndex = 10;
  6840. const int startIndexcopy = 10;
  6841. if (dac2.Count == dac3.Count)//国家 币种 金额
  6842. {
  6843. for (int i = 0; i < dac2.Count; i++)
  6844. {
  6845. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6846. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6847. }
  6848. }
  6849. DataTable dtdac1 = new DataTable();
  6850. List<string> place = new List<string>();
  6851. dtdac1.Columns.AddRange(new DataColumn[] {
  6852. new DataColumn(){ ColumnName = "city"},
  6853. new DataColumn(){ ColumnName = "curr"},
  6854. new DataColumn(){ ColumnName = "criterion"},
  6855. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6856. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6857. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6858. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6859. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6860. });
  6861. DataTable dtdac2 = new DataTable();
  6862. dtdac2.Columns.AddRange(new DataColumn[] {
  6863. new DataColumn(){ ColumnName = "city"},
  6864. new DataColumn(){ ColumnName = "curr"},
  6865. new DataColumn(){ ColumnName = "criterion"},
  6866. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6867. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6868. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6869. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6870. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6871. });
  6872. dtdac1.TableName = "tb1";
  6873. dtdac2.TableName = "tb2";
  6874. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6875. foreach (var item in dac1)
  6876. {
  6877. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6878. if (place.Contains(item.Place))
  6879. {
  6880. continue;
  6881. }
  6882. DataRow row = dtdac1.NewRow();
  6883. row["city"] = item.Place;
  6884. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6885. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6886. row["curr"] = currency;
  6887. row["rate"] = rate.ToString("#0.0000");
  6888. row["criterion"] = item.Cost.ToString("#0.00");
  6889. row["number"] = 1;
  6890. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6891. //row["costRMB"] = rbmPrice;
  6892. dtdac1.Rows.Add(row);
  6893. place.Add(item.Place);
  6894. }
  6895. place = new List<string>();
  6896. foreach (var item in dac2)
  6897. {
  6898. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6899. if (place.Contains(item.Place))
  6900. {
  6901. continue;
  6902. }
  6903. DataRow row = dtdac2.NewRow();
  6904. row["city"] = item.Place;
  6905. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6906. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6907. row["curr"] = currency;
  6908. row["rate"] = rate.ToString("#0.0000");
  6909. row["criterion"] = item.Cost.ToString("#0.00");
  6910. row["number"] = 1;
  6911. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6912. //row["cost"] = item.SubTotal;
  6913. //row["costRMB"] = rbmPrice;
  6914. dtdac2.Rows.Add(row);
  6915. place.Add(item.Place);
  6916. //dac2totalPrice += rbmPrice;
  6917. }
  6918. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  6919. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  6920. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6921. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  6922. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  6923. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  6924. string cell4Str1 = string.Empty;
  6925. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  6926. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  6927. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  6928. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  6929. string cellStr = $" 5.其他费用(";
  6930. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6931. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6932. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6933. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6934. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6935. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6936. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  6937. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  6938. foreach (var otherInfo in dac5)
  6939. {
  6940. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6941. }
  6942. #endregion
  6943. if (cellStr.Length > 8)
  6944. {
  6945. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  6946. }
  6947. cellStr += ")";
  6948. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  6949. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  6950. decimal pxFee = dac4.Sum(it => it.Cost);
  6951. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  6952. string celllastStr1 = "";
  6953. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  6954. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  6955. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  6956. celllastStr1 += $",国际旅费 元";
  6957. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  6958. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  6959. designer.SetDataSource("cell4Str", cell4Str);
  6960. designer.SetDataSource("cellStr", cellStr);
  6961. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  6962. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6963. designer.SetDataSource("celllastStr", celllastStr);
  6964. Workbook wb = designer.Workbook;
  6965. var sheet = wb.Worksheets[0];
  6966. //绑定datatable数据集
  6967. designer.SetDataSource(dtdac1);
  6968. designer.SetDataSource(dtdac2);
  6969. designer.Process();
  6970. var rowStart = dtdac1.Rows.Count;
  6971. while (rowStart > 0)
  6972. {
  6973. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  6974. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6975. startIndex++;
  6976. rowStart--;
  6977. }
  6978. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  6979. startIndex += 1; //总计行
  6980. rowStart = dtdac2.Rows.Count;
  6981. while (rowStart > 0)
  6982. {
  6983. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  6984. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6985. startIndex++;
  6986. rowStart--;
  6987. }
  6988. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  6989. wb.CalculateFormula(true);
  6990. //模板文件名
  6991. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  6992. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6993. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6994. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6995. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6996. }
  6997. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  6998. {
  6999. //获取模板
  7000. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7001. //载入模板
  7002. Document doc = new Document(tempPath);
  7003. DocumentBuilder builder = new DocumentBuilder(doc);
  7004. Dictionary<string, string> dic = new Dictionary<string, string>();
  7005. dic.Add("GroupName", _DelegationInfo.TeamName);
  7006. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7007. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7008. string missionLeaderJob = "";//负责人job
  7009. //int groupNumber = 0; //团人数
  7010. if (DeleClientList.Count > 0)
  7011. {
  7012. missionLeader = DeleClientList[0]?.Name ?? "";
  7013. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7014. }
  7015. dic.Add("MissionLeader", missionLeader); //团负责人
  7016. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7017. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7018. #region MyRegion
  7019. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7020. //{
  7021. // List<string> list = new List<string>();
  7022. // try
  7023. // {
  7024. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7025. // foreach (var item in spilitArr)
  7026. // {
  7027. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7028. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7029. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7030. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7031. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7032. // list.Add(depName);
  7033. // list.Add(arrName);
  7034. // }
  7035. // list = list.Distinct().ToList();
  7036. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7037. // }
  7038. // catch (Exception)
  7039. // {
  7040. // dic.Add("ReturnCode", "行程录入不正确!");
  7041. // }
  7042. //}
  7043. //else
  7044. //{
  7045. // dic.Add("ReturnCode", "未录入行程!");
  7046. //}
  7047. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7048. dic.Add("ReturnCode", string.Join("、", countrys));
  7049. #endregion
  7050. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7051. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7052. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7053. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7054. //{
  7055. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7056. // dic.Add("Day", sp.Days.ToString());
  7057. //}
  7058. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7059. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7060. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7061. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7062. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7063. //培训人员名单
  7064. int cultivateRowIndex = 7;
  7065. foreach (var item in DeleClientList)
  7066. {
  7067. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7068. builder.Write(item.Name);
  7069. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7070. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7071. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7072. string birthDay = "";
  7073. if (item.Birthday != null)
  7074. {
  7075. DateTime dt = Convert.ToDateTime(item.Birthday);
  7076. birthDay = $"{dt.Year}.{dt.Month}";
  7077. }
  7078. builder.Write(birthDay);
  7079. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7080. builder.Write(item.Company);
  7081. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7082. builder.Write(item.Job);
  7083. cultivateRowIndex++;
  7084. }
  7085. //删除多余行
  7086. //cultivateRowIndex -= 2;
  7087. int delRows = 10 + 7 - cultivateRowIndex;
  7088. if (delRows > 0)
  7089. {
  7090. for (int i = 0; i < delRows; i++)
  7091. {
  7092. table1.Rows.RemoveAt(cultivateRowIndex);
  7093. //cultivateRowIndex++;
  7094. }
  7095. }
  7096. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7097. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7098. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7099. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7100. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7101. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7102. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7103. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7104. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7105. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7106. //其他费用
  7107. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7108. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7109. //其他费用合计
  7110. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7111. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7112. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7113. //公务舱合计
  7114. //国际旅费
  7115. //string outsideJJ = "";
  7116. //string allPriceJJ = "";
  7117. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7118. {
  7119. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7120. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7121. }
  7122. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7123. {
  7124. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7125. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7126. }
  7127. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7128. {
  7129. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7130. dic.Add("AirFeeTotal", airFeeTotalStr);
  7131. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7132. dic.Add("FeeTotal", feeTotalStr);
  7133. }
  7134. foreach (var key in dic.Keys)
  7135. {
  7136. builder.MoveToBookmark(key);
  7137. builder.Write(dic[key]);
  7138. }
  7139. //模板文件名
  7140. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7141. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7142. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7143. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7144. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7145. }
  7146. }
  7147. else if (dto.ExportType == 2) //表格
  7148. {
  7149. //利用键值对存放数据
  7150. Dictionary<string, string> dic = new Dictionary<string, string>();
  7151. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7152. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7153. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7154. dic.Add("Day", sp.Days.ToString());
  7155. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7156. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7157. {
  7158. //获取模板
  7159. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7160. //载入模板
  7161. Document doc = new Document(tempPath);
  7162. DocumentBuilder builder = new DocumentBuilder(doc);
  7163. dic.Add("TeamName", _DelegationInfo.TeamName);
  7164. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7165. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7166. string missionLeaderName = "",
  7167. missionLeaderJob = "";
  7168. if (DeleClientList.Count > 0)
  7169. {
  7170. missionLeaderName = DeleClientList[0].Name;
  7171. missionLeaderJob = DeleClientList[0].Job;
  7172. }
  7173. dic.Add("MissionLeaderName", missionLeaderName);
  7174. dic.Add("MissionLeaderJob", missionLeaderJob);
  7175. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7176. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7177. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7178. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7179. int rowCount = 10;//总人数行
  7180. int startRowIndex = 7; //起始行
  7181. for (int i = 0; i < DeleClientList.Count; i++)
  7182. {
  7183. builder.MoveToCell(0, startRowIndex, 0, 0);
  7184. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7185. builder.MoveToCell(0, startRowIndex, 1, 0);
  7186. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7187. builder.Write(sex);//性别
  7188. builder.MoveToCell(0, startRowIndex, 2, 0);
  7189. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7190. builder.MoveToCell(0, startRowIndex, 3, 0);
  7191. builder.Write(DeleClientList[i].Company);//工作单位
  7192. builder.MoveToCell(0, startRowIndex, 4, 0);
  7193. builder.Write(DeleClientList[i].Job);//职务及级别
  7194. builder.MoveToCell(0, startRowIndex, 5, 0);
  7195. builder.Write("");//人员属性
  7196. builder.MoveToCell(0, startRowIndex, 6, 0);
  7197. builder.Write("");//上次出国时间
  7198. startRowIndex++;
  7199. }
  7200. int nullRow = rowCount - DeleClientList.Count;//空行
  7201. for (int i = 0; i < nullRow; i++)
  7202. {
  7203. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7204. }
  7205. foreach (var key in dic.Keys)
  7206. {
  7207. builder.MoveToBookmark(key);
  7208. builder.Write(dic[key]);
  7209. }
  7210. //模板文件名
  7211. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7212. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7213. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7214. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7215. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7216. }
  7217. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7218. {
  7219. //获取模板
  7220. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7221. //载入模板
  7222. Document doc = new Document(tempPath);
  7223. DocumentBuilder builder = new DocumentBuilder(doc);
  7224. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7225. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7226. dic.Add("Names", Names);
  7227. int accommodationRows = 12;
  7228. //int foodandotherRows = 12;
  7229. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7230. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7231. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7232. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7233. int accommodationStartIndex = 6;
  7234. decimal dac1totalPrice = 0.00M;
  7235. foreach (var dac in dac1)
  7236. {
  7237. if (dac.SubTotal == 0)
  7238. {
  7239. continue;
  7240. }
  7241. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7242. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7243. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7244. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7245. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7246. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7247. builder.Write(currency);//币种
  7248. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7249. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7250. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7251. builder.Write("");//人数
  7252. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7253. builder.Write("");//天数
  7254. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7255. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7256. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7257. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7258. builder.Write(rate.ToString("#0.0000"));//汇率
  7259. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7260. decimal rbmPrice = rate * dac.SubTotal;
  7261. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7262. accommodationStartIndex++;
  7263. dac1totalPrice += rbmPrice;
  7264. }
  7265. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7266. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7267. builder.Write("小计");
  7268. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7269. builder.Write(dac1totalPrice.ToString("#0.00"));
  7270. accommodationStartIndex++;
  7271. int nullRow = accommodationRows - dac1.Count;
  7272. //删除空行
  7273. //if (nullRow > 0)
  7274. //{
  7275. // int rowIndex = accommodationStartIndex;
  7276. // for (int i = 0; i < nullRow; i++)
  7277. // {
  7278. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7279. // row.Remove();
  7280. // rowIndex++;
  7281. // }
  7282. //}
  7283. if (dac2.Count == dac3.Count)//国家 币种 金额
  7284. {
  7285. for (int i = 0; i < dac2.Count; i++)
  7286. {
  7287. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7288. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7289. }
  7290. }
  7291. int foodandotherStartIndex = 19;//
  7292. decimal dac2totalPrice = 0.00M;
  7293. foreach (var dac in dac2)
  7294. {
  7295. if (dac.SubTotal == 0)
  7296. {
  7297. continue;
  7298. }
  7299. //foodandotherStartIndex = 12;
  7300. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7301. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7302. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7303. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7304. builder.Write(currency);//币种
  7305. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7306. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7307. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7308. builder.Write("");//人数
  7309. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7310. builder.Write("");//天数
  7311. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7312. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7313. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7314. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7315. builder.Write(rate.ToString("#0.0000"));//汇率
  7316. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7317. decimal rbmPrice = rate * dac.SubTotal;
  7318. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7319. foodandotherStartIndex++;
  7320. dac2totalPrice += rbmPrice;
  7321. }
  7322. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7323. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7324. //删除空行
  7325. //if (dac2.Count < foodandotherRows)
  7326. //{
  7327. // while (table2.Rows.Count > dac2.Count)
  7328. // {
  7329. // table2.Rows.RemoveAt(dac2.Count);
  7330. // }
  7331. //}
  7332. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7333. string otherFeeStr = "";
  7334. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7335. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7336. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7337. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7338. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7339. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7340. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7341. foreach (var otherInfo in dac5)
  7342. {
  7343. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7344. }
  7345. #endregion
  7346. if (otherFeeStr.Length > 0)
  7347. {
  7348. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7349. otherFeeStr = $"({otherFeeStr})";
  7350. dic.Add("OtherFeeStr", otherFeeStr);
  7351. }
  7352. foreach (var key in dic.Keys)
  7353. {
  7354. builder.MoveToBookmark(key);
  7355. builder.Write(dic[key]);
  7356. }
  7357. //模板文件名
  7358. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7359. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7360. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7361. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7362. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7363. }
  7364. }
  7365. else if (dto.ExportType == 3)
  7366. {
  7367. if (dto.SubTypeId == 1) //团组成员名单
  7368. {
  7369. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7370. //获取模板
  7371. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7372. //载入模板
  7373. Document doc = new Document(tempPath);
  7374. DocumentBuilder builder = new DocumentBuilder(doc);
  7375. //获取word里所有表格
  7376. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7377. //获取所填表格的序数
  7378. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7379. var rowStart = tableOne.Rows[0]; //获取第1行
  7380. //循环赋值
  7381. for (int i = 0; i < DeleClientList.Count; i++)
  7382. {
  7383. builder.MoveToCell(0, i + 1, 0, 0);
  7384. builder.Write(DeleClientList[i].Name);
  7385. builder.MoveToCell(0, i + 1, 1, 0);
  7386. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7387. builder.Write(sex);
  7388. builder.MoveToCell(0, i + 1, 2, 0);
  7389. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7390. builder.MoveToCell(0, i + 1, 3, 0);
  7391. builder.Write(DeleClientList[i].Company);
  7392. builder.MoveToCell(0, i + 1, 4, 0);
  7393. builder.Write(DeleClientList[i].Job);
  7394. }
  7395. //删除多余行
  7396. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7397. {
  7398. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7399. }
  7400. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7401. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7402. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7403. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7404. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7405. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7406. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7407. }
  7408. }
  7409. return Ok(JsonView(400, "操作失败!", ""));
  7410. }
  7411. catch (Exception ex)
  7412. {
  7413. return Ok(JsonView(400, ex.Message, ""));
  7414. }
  7415. }
  7416. /// <summary>
  7417. /// 获取三公费用标准city
  7418. /// </summary>
  7419. /// <param name="placeData"></param>
  7420. /// <param name="nationalTravelFeeId"></param>
  7421. /// <returns></returns>
  7422. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7423. {
  7424. string _city = string.Empty;
  7425. if (placeData.Count < 1) return _city;
  7426. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7427. if (data == null) return _city;
  7428. string country = data.Country;
  7429. string city = data.City;
  7430. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7431. else _city = city;
  7432. return _city;
  7433. }
  7434. ///// <summary>
  7435. ///// 团组模块 - 出入境费用 - 明细表导出
  7436. ///// </summary>
  7437. ///// <returns></returns>
  7438. //[HttpPost]
  7439. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7440. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7441. //{
  7442. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7443. // if (data.Code != 0)
  7444. // {
  7445. // return Ok(JsonView(false, data.Msg));
  7446. // }
  7447. // return Ok(JsonView(true, data.Msg, data.Data));
  7448. //}
  7449. /// <summary>
  7450. /// 团组模块 - 出入境费用 - 一键清空
  7451. /// </summary>
  7452. /// <returns></returns>
  7453. [HttpPost]
  7454. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7456. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7457. {
  7458. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7459. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7460. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7461. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7462. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7463. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7464. .SetColumns(x => new Grp_DayOtherPrice
  7465. {
  7466. IsDel = 1,
  7467. DeleteUserId = dto.UserId,
  7468. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7469. })
  7470. .ExecuteCommandAsync();
  7471. if (_view.Code == 0)
  7472. {
  7473. return Ok(JsonView(true, "操作成功"));
  7474. }
  7475. return Ok(JsonView(false, "操作失败"));
  7476. }
  7477. /// <summary>
  7478. /// 团组模块 - 出入境费用 - 子项删除
  7479. /// </summary>
  7480. /// <returns></returns>
  7481. [HttpPost]
  7482. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7484. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7485. {
  7486. try
  7487. {
  7488. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7489. if (data.Code != 0)
  7490. {
  7491. return Ok(JsonView(false, data.Msg));
  7492. }
  7493. return Ok(JsonView(true, "操作成功!", data.Data));
  7494. }
  7495. catch (Exception ex)
  7496. {
  7497. return Ok(JsonView(false, ex.Message));
  7498. }
  7499. }
  7500. /// <summary>
  7501. /// 删除三公其他费用
  7502. /// </summary>
  7503. /// <param name="dto"></param>
  7504. /// <returns></returns>
  7505. [HttpPost]
  7506. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7507. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7508. {
  7509. var jw = JsonView(false, "删除失败!");
  7510. var data = new Grp_DayOtherPrice()
  7511. {
  7512. Id = dto.Id,
  7513. IsDel = 1,
  7514. DeleteUserId = dto.DeleteUserId,
  7515. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7516. };
  7517. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7518. if (del > 0)
  7519. {
  7520. jw.Code = 200;
  7521. jw.Msg = "删除成功!";
  7522. }
  7523. return Ok(jw);
  7524. }
  7525. /// <summary>
  7526. /// 团组模块 - 出入境国家费用标准 List
  7527. /// </summary>
  7528. /// <returns></returns>
  7529. [HttpPost]
  7530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7531. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7532. {
  7533. int provinceId = dto.ProvinceId;
  7534. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7535. var nftData = await _sqlSugar
  7536. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7537. JoinType.Left, ntf.Currency == sd1.Id,
  7538. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7539. JoinType.Left, ntf.ProvinceId == c.Id
  7540. ))
  7541. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7542. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7543. {
  7544. Id = ntf.Id,
  7545. ProvinceId = ntf.ProvinceId,
  7546. ProvinceName = c.Name_CN,
  7547. Continent = ntf.Continent,
  7548. Country = ntf.Country,
  7549. City = ntf.City,
  7550. Currency = ntf.Currency,
  7551. CurrencyCode = sd1.Name,
  7552. CurrencyName = sd1.Remark,
  7553. RoomCost = ntf.RoomCost,
  7554. FoodCost = ntf.FoodCost,
  7555. PublicCost = ntf.PublicCost,
  7556. LastUpdateUserId = ntf.LastUpdateUserId,
  7557. LastUpdateUserName = u.CnName,
  7558. LastUpdateTime = ntf.LastUpdateTime
  7559. })
  7560. .ToListAsync();
  7561. return Ok(JsonView(true, "查询成功!", nftData));
  7562. }
  7563. /// <summary>
  7564. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7565. /// </summary>
  7566. /// <returns></returns>
  7567. [HttpPost]
  7568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7569. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7570. {
  7571. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7572. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7573. List<string> countryData = new List<string>();
  7574. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7575. countryData = countryData.Distinct().ToList();
  7576. List<dynamic> dataSource = new List<dynamic>();
  7577. foreach (var item in countryData)
  7578. {
  7579. var cityData1 = new List<string>();
  7580. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7581. var countryData2 = new
  7582. {
  7583. CountryName = item,
  7584. CityData = cityData1
  7585. };
  7586. if (!dataSource.Contains(countryData2))
  7587. {
  7588. dataSource.Add(countryData2);
  7589. }
  7590. }
  7591. return Ok(JsonView(true, "查询成功!", dataSource));
  7592. }
  7593. /// <summary>
  7594. /// 团组模块 - 出入境国家费用标准 Page List
  7595. /// </summary>
  7596. /// <returns></returns>
  7597. [HttpPost]
  7598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7599. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7600. {
  7601. int portId = dto.PortType,
  7602. pageIndex = dto.PageIndex,
  7603. pageSize = dto.PageSize;
  7604. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7605. if (pageIndex == 0) pageIndex = 1;
  7606. if (pageSize == 0) pageSize = 10;
  7607. RefAsync<int> total = 0;
  7608. var nationalTravelFeeData = await _sqlSugar
  7609. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7610. JoinType.Left, ntf.Currency == sd1.Id,
  7611. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7612. JoinType.Left, ntf.ProvinceId == sd2.Id
  7613. ))
  7614. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7615. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7616. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7617. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7618. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7619. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7620. {
  7621. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7622. Id = ntf.Id,
  7623. ProvinceId = ntf.ProvinceId,
  7624. ProvinceName = sd2.Name_CN,
  7625. Continent = ntf.Continent,
  7626. Country = ntf.Country,
  7627. City = ntf.City,
  7628. Currency = ntf.Currency,
  7629. CurrencyCode = sd1.Name,
  7630. CurrencyName = sd1.Remark,
  7631. RoomCost = ntf.RoomCost,
  7632. FoodCost = ntf.FoodCost,
  7633. PublicCost = ntf.PublicCost,
  7634. LastUpdateUserId = ntf.LastUpdateUserId,
  7635. LastUpdateUserName = u.CnName,
  7636. LastUpdateTime = ntf.LastUpdateTime,
  7637. Remark = ntf.Remark
  7638. })
  7639. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7640. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7641. }
  7642. /// <summary>
  7643. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7644. /// </summary>
  7645. /// <returns></returns>
  7646. [HttpPost]
  7647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7648. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7649. {
  7650. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7651. int portId = dto.PortType;
  7652. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7653. string whereSql = string.Empty;
  7654. if (!string.IsNullOrEmpty(dto.Country))
  7655. {
  7656. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7657. }
  7658. if (!string.IsNullOrEmpty(dto.City))
  7659. {
  7660. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7661. }
  7662. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7663. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7664. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7665. From Grp_NationalTravelFee gntf
  7666. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7667. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7668. Where gntf.Isdel = 0 {0} ", whereSql);
  7669. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7670. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7671. }
  7672. /// <summary>
  7673. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7674. /// </summary>
  7675. /// <returns></returns>
  7676. [HttpPost]
  7677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7678. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7679. {
  7680. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7681. }
  7682. /// <summary>
  7683. /// 团组模块 - 出入境国家费用标准 - Del
  7684. /// </summary>
  7685. /// <returns></returns>
  7686. [HttpPost]
  7687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7688. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7689. {
  7690. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7691. {
  7692. Id = dto.Id,
  7693. DeleteUserId = dto.DeleteUserId,
  7694. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7695. IsDel = 1
  7696. };
  7697. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7698. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7699. .WhereColumns(it => new { it.Id })
  7700. .ExecuteCommandAsync();
  7701. if (delStatus <= 0)
  7702. {
  7703. return Ok(JsonView(false, "删除失败!"));
  7704. }
  7705. return Ok(JsonView(true, "操作成功!"));
  7706. }
  7707. /// <summary>
  7708. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7709. /// 注:Get 请求Headers 加 Token
  7710. /// </summary>
  7711. /// <param name="groupId"></param>
  7712. /// <returns></returns>
  7713. [HttpGet("{groupId}")]
  7714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7715. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7716. {
  7717. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7718. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7719. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7720. data.ForEach(x =>
  7721. {
  7722. x.CreateUserId = _currUserInfo.UserId;
  7723. });
  7724. if (data.Any())
  7725. {
  7726. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7727. if (add > 0)
  7728. {
  7729. return Ok(JsonView(true, "操作成功!"));
  7730. }
  7731. }
  7732. return Ok(JsonView(false, "未操作!"));
  7733. }
  7734. #endregion
  7735. #region 团组经理模块 出入境费用-草稿
  7736. /// <summary>
  7737. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7738. /// </summary>
  7739. /// <returns></returns>
  7740. [HttpGet]
  7741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7742. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7743. {
  7744. var provData = await _groupRepository.ProvinceBasicSource();
  7745. return Ok(JsonView(true, "查询成功!", provData));
  7746. }
  7747. /// <summary>
  7748. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7749. /// </summary>
  7750. /// <returns></returns>
  7751. [HttpGet("{provinceId}")]
  7752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7753. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7754. {
  7755. //验证城市归属并给默认值
  7756. if (provinceId < 1) provinceId = 122;
  7757. /*
  7758. * 122 四川
  7759. * 108 贵州
  7760. * 103 重庆
  7761. * 132 云南
  7762. */
  7763. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7764. return Ok(JsonView(true, "查询成功!", new
  7765. {
  7766. WordTypeData = wordTypeData,
  7767. ExcelTypeData = excelTypeData,
  7768. }));
  7769. }
  7770. /// <summary>
  7771. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7772. /// </summary>
  7773. /// <returns></returns>
  7774. [HttpPost]
  7775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7776. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7777. {
  7778. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7779. .Where(x => x.IsDel == 0)
  7780. .OrderByDescending(x => x.CreateTime)
  7781. .Select(x => new { x.Id, x.DraftName })
  7782. .ToListAsync();
  7783. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7784. //SetDataInfoView
  7785. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7786. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7787. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7788. int provinceId = dto.ProvinceId;
  7789. if (provinceId < 1) provinceId = 122;
  7790. /*
  7791. * 122 四川
  7792. * 108 贵州
  7793. * 103 重庆
  7794. * 132 云南
  7795. */
  7796. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7797. //默认币种显示
  7798. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7799. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7800. return Ok(JsonView(true, "查询成功!", new
  7801. {
  7802. DraftNameDatas = draftNameDatas,
  7803. CurrencyData = _CurrencyData,
  7804. WordTypeData = wordTypeData,
  7805. ExcelTypeData = excelTypeData,
  7806. CurrencyInit = _currencyInfos,
  7807. ViewPermissionData = viewPermissionData
  7808. }));
  7809. }
  7810. /// <summary>
  7811. /// 团组模块 - 出入境费用-草稿
  7812. /// 实时汇率 tips
  7813. /// 机票费用 tips
  7814. /// </summary>
  7815. /// <returns></returns>
  7816. [HttpPost]
  7817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7818. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7819. {
  7820. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7821. return Ok(JsonView(true, "查询成功!", new
  7822. {
  7823. //GroupNameData = groupNameData.Data,
  7824. //visaData = visaData.Data,
  7825. //airData = airData.Data,
  7826. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7827. }));
  7828. }
  7829. /// <summary>
  7830. /// 团组模块 - 出入境费用-草稿
  7831. /// 签证费用 tips
  7832. /// </summary>
  7833. /// <returns></returns>
  7834. [HttpPost]
  7835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7836. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7837. {
  7838. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7839. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7840. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7841. .Select(x => x.NationalTravelFeeId)
  7842. .Distinct()
  7843. .ToListAsync();
  7844. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7845. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7846. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7847. .Select(x => x.Country)
  7848. .Distinct()
  7849. .ToArrayAsync();
  7850. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7851. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7852. return Ok(JsonView(true, "查询成功!", new
  7853. {
  7854. totalAmt = totalAmt,
  7855. remark = remark
  7856. }));
  7857. }
  7858. /// <summary>
  7859. /// 团组模块 - 出入境费用-草稿 - Info
  7860. /// </summary>
  7861. /// <returns></returns>
  7862. [HttpPost]
  7863. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7865. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7866. {
  7867. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7868. }
  7869. /// <summary>
  7870. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7871. /// </summary>
  7872. /// <returns></returns>
  7873. [HttpPost]
  7874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7875. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7876. {
  7877. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7878. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7879. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7880. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7881. foreach (var userId in dto.UserIds)
  7882. {
  7883. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7884. }
  7885. if (permissions.Any())
  7886. {
  7887. _sqlSugar.BeginTran();
  7888. try
  7889. {
  7890. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7891. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7892. if (result < 1)
  7893. {
  7894. _sqlSugar.RollbackTran();
  7895. return Ok(JsonView(false));
  7896. }
  7897. }
  7898. catch (Exception ex)
  7899. {
  7900. _sqlSugar.RollbackTran();
  7901. return Ok(JsonView(false, ex.Message));
  7902. }
  7903. _sqlSugar.CommitTran();
  7904. return Ok(JsonView(true));
  7905. }
  7906. return Ok(JsonView(false));
  7907. }
  7908. /// <summary>
  7909. /// 团组模块 - 出入境费用-草稿 - Add And Update
  7910. /// </summary>
  7911. /// <returns></returns>
  7912. [HttpPost]
  7913. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  7914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7915. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  7916. {
  7917. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  7918. if (data.Code != 0)
  7919. {
  7920. return Ok(JsonView(false, data.Msg));
  7921. }
  7922. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7923. //汇率信息记录
  7924. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7925. return Ok(JsonView(true, data.Msg, data.Data));
  7926. }
  7927. /// <summary>
  7928. /// 团组模块 - 出入境费用-草稿 - File downlaod
  7929. /// </summary>
  7930. /// <param name="dto"></param>
  7931. /// <returns></returns>
  7932. [HttpPost]
  7933. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  7934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7935. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  7936. {
  7937. try
  7938. {
  7939. var id = dto.Id;
  7940. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7941. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7942. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7943. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7944. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7945. 3 团组成员名单 1 团组成员名单", ""));
  7946. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  7947. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  7948. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  7949. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  7950. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  7951. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7952. //数据源
  7953. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7954. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7955. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7956. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7957. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  7958. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7959. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7960. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  7961. .Select((x, a, b) => new
  7962. {
  7963. x.Index,
  7964. itemName = a.Name,
  7965. CurrencyStr = b.Name,
  7966. x.Cost,
  7967. x.SubTotal,
  7968. x.Remark
  7969. })
  7970. .OrderBy((x) => x.Index)
  7971. .ToList(); //其他款项费用
  7972. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7973. var peiceItemCurrencys = new List<string>();
  7974. if (_DayAndCosts.Any())
  7975. {
  7976. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7977. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7978. }
  7979. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7980. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7981. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7982. {
  7983. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7984. }
  7985. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7986. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7987. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7988. if (dto.ExportType == 1) //明细表
  7989. {
  7990. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7991. {
  7992. //获取模板
  7993. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7994. //载入模板
  7995. Document doc = new Document(tempPath);
  7996. DocumentBuilder builder = new DocumentBuilder(doc);
  7997. //利用键值对存放数据
  7998. Dictionary<string, string> dic = new Dictionary<string, string>();
  7999. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8000. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8001. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8002. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8003. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8004. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8005. //境内费用(其他费用)
  8006. if (_EnterExitCosts.ChoiceOne == 1)
  8007. {
  8008. string row1_1 = "";
  8009. if (_EnterExitCosts.Visa > 0)
  8010. {
  8011. //insidePayTotal += _EnterExitCosts.Visa;
  8012. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8013. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8014. //{
  8015. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8016. //}
  8017. }
  8018. string row1_2 = "";
  8019. if (_EnterExitCosts.YiMiao > 0)
  8020. {
  8021. //insidePayTotal += _EnterExitCosts.YiMiao;
  8022. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8023. }
  8024. if (_EnterExitCosts.HeSuan > 0)
  8025. {
  8026. //insidePayTotal += _EnterExitCosts.HeSuan;
  8027. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8028. }
  8029. if (_EnterExitCosts.Service > 0)
  8030. {
  8031. //insidePayTotal += _EnterExitCosts.Service;
  8032. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8033. }
  8034. string row1_3 = "";
  8035. if (_EnterExitCosts.Safe > 0)
  8036. {
  8037. //insidePayTotal += _EnterExitCosts.Safe;
  8038. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8039. }
  8040. if (_EnterExitCosts.Ticket > 0)
  8041. {
  8042. //insidePayTotal += _EnterExitCosts.Ticket;
  8043. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8044. }
  8045. string row1 = "";
  8046. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8047. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8048. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8049. row1 += $"备注:{_EnterExitCosts.Remark}";
  8050. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8051. dic.Add("Row1Str", row1);
  8052. }
  8053. string airTotalStr = string.Empty,
  8054. airPriceStr = string.Empty;
  8055. //经济舱
  8056. if (_EnterExitCosts.SumJJC == 1)
  8057. {
  8058. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8059. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8060. }
  8061. //公务舱
  8062. if (_EnterExitCosts.SumGWC == 1)
  8063. {
  8064. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8065. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8066. }
  8067. //头等舱
  8068. if (_EnterExitCosts.SumTDC == 1)
  8069. {
  8070. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8071. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8072. }
  8073. //汇率描述
  8074. string rateStr = "";
  8075. if (peiceItemCurrencyInfos.Any())
  8076. {
  8077. rateStr = "\r\n汇率描述:";
  8078. foreach (var item in peiceItemCurrencyInfos)
  8079. {
  8080. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8081. }
  8082. }
  8083. string twoItemRemark = "备注:";
  8084. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8085. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8086. dic.Add("AirTotalStr", airTotalStr);
  8087. dic.Add("AirPriceStr", airPriceStr);
  8088. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8089. dic.Add("TwoItemRemark", twoItemRemark);
  8090. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8091. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8092. int table1Row = 0,
  8093. table2Row = 0,
  8094. table3Row = 0,
  8095. table4Row = 0,
  8096. table5Row = 0;
  8097. //住宿费
  8098. if (_EnterExitCosts.ChoiceThree == 1)
  8099. {
  8100. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8101. table1Row = dac1.Count;
  8102. #region 填充word表格内容
  8103. for (int i = 0; i < dac1.Count; i++)
  8104. {
  8105. var dac = dac1[i];
  8106. if (dac == null) continue;
  8107. builder.MoveToCell(0, i, 0, 0);
  8108. builder.Write("第" + dac.Days.ToString() + "晚:");
  8109. builder.MoveToCell(0, i, 1, 0);
  8110. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8111. //builder.Write(dac.Place == null ? "" : dac.Place);
  8112. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8113. builder.MoveToCell(0, i, 2, 0);
  8114. builder.Write("费用标准:");
  8115. string curr = "";
  8116. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8117. if (currData != null)
  8118. {
  8119. curr = currData.Name;
  8120. }
  8121. builder.MoveToCell(0, i, 3, 0);
  8122. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8123. builder.MoveToCell(0, i, 4, 0);
  8124. builder.Write("费用小计:");
  8125. builder.MoveToCell(0, i, 5, 0);
  8126. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8127. }
  8128. #endregion
  8129. }
  8130. else dic.Add("SubZS", "0.00");
  8131. //删除多余行
  8132. while (table1.Rows.Count > table1Row)
  8133. {
  8134. table1.Rows.RemoveAt(table1Row);
  8135. }
  8136. //伙食费
  8137. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8138. if (_EnterExitCosts.ChoiceFour == 1)
  8139. {
  8140. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8141. table2Row = dac2.Count;
  8142. #region 填充word表格内容
  8143. for (int i = 0; i < dac2.Count; i++)
  8144. {
  8145. var dac = dac2[i];
  8146. if (dac == null) continue;
  8147. builder.MoveToCell(1, i, 0, 0);
  8148. builder.Write("第" + dac.Days.ToString() + "天:");
  8149. builder.MoveToCell(1, i, 1, 0);
  8150. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8151. builder.MoveToCell(1, i, 2, 0);
  8152. builder.Write("费用标准:");
  8153. string curr = "";
  8154. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8155. if (currData != null)
  8156. {
  8157. curr = currData.Name;
  8158. }
  8159. builder.MoveToCell(1, i, 3, 0);
  8160. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8161. builder.MoveToCell(1, i, 4, 0);
  8162. builder.Write("费用小计:");
  8163. builder.MoveToCell(1, i, 5, 0);
  8164. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8165. }
  8166. #endregion
  8167. }
  8168. else dic.Add("SubHS", "0.00");
  8169. //删除多余行
  8170. while (table2.Rows.Count > table2Row)
  8171. {
  8172. table2.Rows.RemoveAt(table2Row);
  8173. }
  8174. //公杂费
  8175. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8176. if (_EnterExitCosts.ChoiceFive == 1)
  8177. {
  8178. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8179. table3Row = dac3.Count;
  8180. #region 填充word表格内容
  8181. for (int i = 0; i < dac3.Count; i++)
  8182. {
  8183. var dac = dac3[i];
  8184. if (dac == null) continue;
  8185. builder.MoveToCell(2, i, 0, 0);
  8186. builder.Write("第" + dac.Days.ToString() + "天:");
  8187. builder.MoveToCell(2, i, 1, 0);
  8188. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8189. builder.MoveToCell(2, i, 2, 0);
  8190. builder.Write("费用标准:");
  8191. string curr = "";
  8192. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8193. if (currData != null)
  8194. {
  8195. curr = currData.Name;
  8196. }
  8197. builder.MoveToCell(2, i, 3, 0);
  8198. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8199. builder.MoveToCell(2, i, 4, 0);
  8200. builder.Write("费用小计:");
  8201. builder.MoveToCell(2, i, 5, 0);
  8202. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8203. }
  8204. //删除多余行
  8205. while (table3.Rows.Count > table3Row)
  8206. {
  8207. table3.Rows.RemoveAt(table3Row);
  8208. }
  8209. #endregion
  8210. }
  8211. else dic.Add("SubGZF", "0.00");
  8212. //删除多余行
  8213. while (table3.Rows.Count > table3Row)
  8214. {
  8215. table3.Rows.RemoveAt(table3Row);
  8216. }
  8217. //培训费
  8218. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8219. if (_EnterExitCosts.ChoiceSix == 1)
  8220. {
  8221. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8222. dic.Add("SubPX", pxStr);
  8223. table4Row = dac4.Count;
  8224. #region 填充word表格内容
  8225. for (int i = 0; i < dac4.Count; i++)
  8226. {
  8227. var dac = dac4[i];
  8228. if (dac == null) continue;
  8229. builder.MoveToCell(3, i, 0, 0);
  8230. builder.Write("第" + dac.Days.ToString() + "天:");
  8231. builder.MoveToCell(3, i, 1, 0);
  8232. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8233. builder.MoveToCell(3, i, 2, 0);
  8234. builder.Write("费用标准:");
  8235. string curr = "";
  8236. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8237. if (currData != null)
  8238. {
  8239. curr = currData.Name;
  8240. }
  8241. builder.MoveToCell(3, i, 3, 0);
  8242. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8243. builder.MoveToCell(3, i, 4, 0);
  8244. builder.Write("费用小计:");
  8245. builder.MoveToCell(3, i, 5, 0);
  8246. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8247. }
  8248. #endregion
  8249. }
  8250. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8251. //删除多余行
  8252. while (table4.Rows.Count > table4Row)
  8253. {
  8254. table4.Rows.RemoveAt(table4Row);
  8255. }
  8256. //其他费用
  8257. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8258. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8259. {
  8260. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8261. dic.Add("titleQi", qtStr);
  8262. table5Row = dac5.Count;
  8263. #region 填充word表格内容
  8264. for (int i = 0; i < dac5.Count; i++)
  8265. {
  8266. var dac = dac5[i];
  8267. if (dac == null) continue;
  8268. builder.MoveToCell(4, i, 0, 0);
  8269. builder.Write("第" + dac.Index.ToString() + "项:");
  8270. builder.MoveToCell(4, i, 1, 0);
  8271. builder.Write(dac.itemName);
  8272. builder.MoveToCell(4, i, 2, 0);
  8273. builder.Write("费用标准:");
  8274. builder.MoveToCell(4, i, 3, 0);
  8275. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8276. builder.MoveToCell(4, i, 4, 0);
  8277. builder.Write("费用小计:");
  8278. builder.MoveToCell(4, i, 5, 0);
  8279. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8280. builder.MoveToCell(4, i, 6, 0);
  8281. builder.Write("备注:");
  8282. builder.MoveToCell(4, i, 7, 0);
  8283. builder.Write(dac.Remark);
  8284. }
  8285. #endregion
  8286. }
  8287. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8288. //删除多余行
  8289. while (table5.Rows.Count > table5Row)
  8290. {
  8291. table5.Rows.RemoveAt(table5Row);
  8292. }
  8293. //加上其他费用
  8294. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8295. decimal subJJC = 0.00M,
  8296. subGWC = 0.00M,
  8297. subTDC = 0.00M;
  8298. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8299. string totalLabel = string.Format("全部费用总计:");
  8300. //经济舱
  8301. if (_EnterExitCosts.SumJJC == 1)
  8302. {
  8303. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8304. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8305. }
  8306. //公务舱
  8307. if (_EnterExitCosts.SumGWC == 1)
  8308. {
  8309. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8310. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8311. }
  8312. //头等舱
  8313. if (_EnterExitCosts.SumTDC == 1)
  8314. {
  8315. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8316. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8317. }
  8318. //TotalLabel
  8319. dic.Add("TotalLabel", totalLabel);
  8320. #region 填充word模板书签内容
  8321. foreach (var key in dic.Keys)
  8322. {
  8323. Bookmark bookmark = doc.Range.Bookmarks[key];
  8324. if (bookmark != null)
  8325. {
  8326. builder.MoveToBookmark(key);
  8327. builder.Write(dic[key]);
  8328. }
  8329. }
  8330. #endregion
  8331. //文件名
  8332. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8333. strFileName = CommonFun.ValidFileName(strFileName);
  8334. AsposeHelper.removewatermark_v2180();
  8335. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8336. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8337. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8338. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8339. }
  8340. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8341. {
  8342. //获取模板
  8343. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8344. //载入模板
  8345. Document doc = new Document(tempPath);
  8346. DocumentBuilder builder = new DocumentBuilder(doc);
  8347. Dictionary<string, string> dic = new Dictionary<string, string>();
  8348. string returnCodeLabel = string.Empty;
  8349. if (nationalTravelFeeData.Any())
  8350. {
  8351. List<string> list = new List<string>();
  8352. foreach (var item in nationalTravelFeeData)
  8353. {
  8354. list.Add($"{item.Country}({item.City})");
  8355. }
  8356. list = list.Distinct().ToList();
  8357. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8358. }
  8359. var countryLabel = string.Empty;
  8360. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8361. if (countryData.Any())
  8362. {
  8363. countryLabel = string.Join("、", countryData);
  8364. }
  8365. dic.Add("ReturnCodeAir", returnCodeLabel);
  8366. dic.Add("VisitStartDate", "-");
  8367. dic.Add("VisitEndDate", "-");
  8368. dic.Add("Day", "-");
  8369. dic.Add("VisitCountry", countryLabel);
  8370. dic.Add("ClientUnit", "-");
  8371. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8372. //dic.Add("Names", Names);
  8373. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8374. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8375. decimal dac1totalPrice = 0.00M;
  8376. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8377. foreach (var dac in dac1)
  8378. {
  8379. if (dac.SubTotal == 0.00M)
  8380. {
  8381. continue;
  8382. }
  8383. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8384. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8385. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8386. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8387. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8388. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8389. builder.Write(currency);//币种
  8390. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8391. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8392. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8393. builder.Write("");//人数
  8394. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8395. builder.Write("");//天数
  8396. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8397. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8398. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8399. decimal rate = 0.00M;
  8400. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8401. builder.Write(rate.ToString("#0.0000"));//汇率
  8402. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8403. decimal rbmPrice = dac.SubTotal;
  8404. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8405. accommodationStartIndex++;
  8406. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8407. }
  8408. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8409. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8410. {
  8411. table1.Rows.RemoveAt(i - 1);
  8412. foodandotherStartIndex--;
  8413. }
  8414. if (dac2.Count == dac3.Count)//国家 币种 金额
  8415. {
  8416. for (int i = 0; i < dac2.Count; i++)
  8417. {
  8418. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8419. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8420. }
  8421. }
  8422. decimal dac2totalPrice = 0.00M;
  8423. foreach (var dac in dac2)
  8424. {
  8425. if (dac.SubTotal == 0)
  8426. {
  8427. continue;
  8428. }
  8429. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8430. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8431. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8432. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8433. builder.Write(currency);//币种
  8434. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8435. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8436. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8437. builder.Write("");//人数
  8438. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8439. builder.Write("");//天数
  8440. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8441. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8442. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8443. decimal rate = 0.00M;
  8444. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8445. builder.Write(rate.ToString("#0.0000"));//汇率
  8446. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8447. decimal rbmPrice = dac.SubTotal;
  8448. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8449. foodandotherStartIndex++;
  8450. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8451. }
  8452. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8453. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8454. {
  8455. table1.Rows.RemoveAt(i - 1);
  8456. }
  8457. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8458. string otherFeeStr = "";
  8459. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8460. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8461. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8462. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8463. foreach (var otherInfo in dac5)
  8464. {
  8465. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8466. }
  8467. #endregion
  8468. if (otherFeeStr.Length > 0)
  8469. {
  8470. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8471. otherFeeStr = $"({otherFeeStr})";
  8472. dic.Add("OtherFeeStr", otherFeeStr);
  8473. }
  8474. //总计
  8475. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8476. //国际旅费
  8477. string outsideAir = string.Empty;
  8478. string allPriceAir = string.Empty;
  8479. if (_EnterExitCosts.SumJJC == 1)
  8480. {
  8481. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8482. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8483. }
  8484. if (_EnterExitCosts.SumGWC == 1)
  8485. {
  8486. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8487. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8488. }
  8489. if (_EnterExitCosts.SumTDC == 1)
  8490. {
  8491. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8492. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8493. }
  8494. dic.Add("InTravelPrice", $"({outsideAir})");
  8495. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8496. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8497. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8498. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8499. foreach (var key in dic.Keys)
  8500. {
  8501. builder.MoveToBookmark(key);
  8502. builder.Write(dic[key]);
  8503. }
  8504. //模板文件名
  8505. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8506. strFileName = CommonFun.ValidFileName(strFileName);
  8507. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8508. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8509. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8510. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8511. }
  8512. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8513. {
  8514. //获取模板
  8515. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8516. //载入模板
  8517. WorkbookDesigner designer = new WorkbookDesigner();
  8518. designer.Workbook = new Workbook(tempPath);
  8519. Dictionary<string, string> dic = new Dictionary<string, string>();
  8520. string returnCodeLabel = string.Empty;
  8521. if (nationalTravelFeeData.Any())
  8522. {
  8523. List<string> list = new List<string>();
  8524. foreach (var item in nationalTravelFeeData)
  8525. {
  8526. list.Add($"{item.Country}({item.City})");
  8527. }
  8528. list = list.Distinct().ToList();
  8529. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8530. }
  8531. var countryLabel = string.Empty;
  8532. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8533. if (countryData.Any())
  8534. {
  8535. countryLabel = string.Join("、", countryData);
  8536. }
  8537. dic.Add("ReturnCodeAir", returnCodeLabel);
  8538. dic.Add("VisitStartDate", "-");
  8539. dic.Add("VisitEndDate", "-");
  8540. dic.Add("Day", "0");
  8541. dic.Add("VisitCountry", countryLabel);
  8542. dic.Add("ClientUnit", "-");
  8543. designer.SetDataSource("ClientUnit", "-");
  8544. designer.SetDataSource("VisitCountry", countryLabel);
  8545. designer.SetDataSource("Group", "-");
  8546. designer.SetDataSource("ClientUnitTitle", "-");
  8547. designer.SetDataSource("Name", "-");
  8548. designer.SetDataSource("VisitStartDate", "-");
  8549. designer.SetDataSource("Day", "0");
  8550. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8551. designer.SetDataSource("ReturnCodeAir", "-");
  8552. int startIndex = 10;
  8553. const int startIndexcopy = 10;
  8554. if (dac2.Count == dac3.Count)//国家 币种 金额
  8555. {
  8556. for (int i = 0; i < dac2.Count; i++)
  8557. {
  8558. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8559. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8560. }
  8561. }
  8562. DataTable dtdac1 = new DataTable();
  8563. List<string> place = new List<string>();
  8564. dtdac1.Columns.AddRange(new DataColumn[] {
  8565. new DataColumn(){ ColumnName = "city"},
  8566. new DataColumn(){ ColumnName = "curr"},
  8567. new DataColumn(){ ColumnName = "criterion"},
  8568. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8569. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8570. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8571. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8572. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8573. });
  8574. DataTable dtdac2 = new DataTable();
  8575. dtdac2.Columns.AddRange(new DataColumn[] {
  8576. new DataColumn(){ ColumnName = "city"},
  8577. new DataColumn(){ ColumnName = "curr"},
  8578. new DataColumn(){ ColumnName = "criterion"},
  8579. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8580. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8581. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8582. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8583. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8584. });
  8585. dtdac1.TableName = "tb1";
  8586. dtdac2.TableName = "tb2";
  8587. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8588. foreach (var item in dac1)
  8589. {
  8590. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8591. if (place.Contains(item.Place))
  8592. {
  8593. continue;
  8594. }
  8595. DataRow row = dtdac1.NewRow();
  8596. row["city"] = item.Place;
  8597. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8598. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8599. row["curr"] = currency;
  8600. row["rate"] = rate.ToString("#0.0000");
  8601. row["criterion"] = item.Cost.ToString("#0.00");
  8602. row["number"] = 1;
  8603. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8604. //row["costRMB"] = rbmPrice;
  8605. dtdac1.Rows.Add(row);
  8606. place.Add(item.Place);
  8607. }
  8608. place = new List<string>();
  8609. foreach (var item in dac2)
  8610. {
  8611. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8612. if (place.Contains(item.Place))
  8613. {
  8614. continue;
  8615. }
  8616. DataRow row = dtdac2.NewRow();
  8617. row["city"] = item.Place;
  8618. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8619. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8620. row["curr"] = currency;
  8621. row["rate"] = rate.ToString("#0.0000");
  8622. row["criterion"] = item.Cost.ToString("#0.00");
  8623. row["number"] = 1;
  8624. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8625. //row["cost"] = item.SubTotal;
  8626. //row["costRMB"] = rbmPrice;
  8627. dtdac2.Rows.Add(row);
  8628. place.Add(item.Place);
  8629. //dac2totalPrice += rbmPrice;
  8630. }
  8631. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8632. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8633. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8634. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8635. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8636. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8637. string cell4Str1 = string.Empty;
  8638. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8639. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8640. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8641. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8642. string cellStr = $" 5.其他费用(";
  8643. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8644. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8645. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8646. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8647. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8648. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8649. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8650. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8651. foreach (var otherInfo in dac5)
  8652. {
  8653. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8654. }
  8655. #endregion
  8656. if (cellStr.Length > 8)
  8657. {
  8658. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8659. }
  8660. cellStr += ")";
  8661. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8662. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8663. decimal pxFee = dac4.Sum(it => it.Cost);
  8664. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8665. string celllastStr1 = "";
  8666. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8667. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8668. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8669. celllastStr1 += $",国际旅费 元";
  8670. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8671. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8672. designer.SetDataSource("cell4Str", cell4Str);
  8673. designer.SetDataSource("cellStr", cellStr);
  8674. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8675. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8676. designer.SetDataSource("celllastStr", celllastStr);
  8677. Workbook wb = designer.Workbook;
  8678. var sheet = wb.Worksheets[0];
  8679. //绑定datatable数据集
  8680. designer.SetDataSource(dtdac1);
  8681. designer.SetDataSource(dtdac2);
  8682. designer.Process();
  8683. var rowStart = dtdac1.Rows.Count;
  8684. while (rowStart > 0)
  8685. {
  8686. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8687. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8688. startIndex++;
  8689. rowStart--;
  8690. }
  8691. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8692. startIndex += 1; //总计行
  8693. rowStart = dtdac2.Rows.Count;
  8694. while (rowStart > 0)
  8695. {
  8696. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8697. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8698. startIndex++;
  8699. rowStart--;
  8700. }
  8701. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8702. wb.CalculateFormula(true);
  8703. //模板文件名
  8704. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8705. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8706. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8707. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8708. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8709. }
  8710. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8711. {
  8712. //获取模板
  8713. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8714. //载入模板
  8715. Document doc = new Document(tempPath);
  8716. DocumentBuilder builder = new DocumentBuilder(doc);
  8717. Dictionary<string, string> dic = new Dictionary<string, string>();
  8718. dic.Add("GroupName", "-");
  8719. dic.Add("ClientUnit", "-");
  8720. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8721. //string missionLeaderJob = "";//负责人job
  8722. //int groupNumber = 0; //团人数
  8723. dic.Add("MissionLeader", "-"); //团负责人
  8724. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8725. dic.Add("GroupNumber", "0"); //团人数
  8726. dic.Add("Day", "0");
  8727. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8728. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8729. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8730. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8731. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8732. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8733. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8734. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8735. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8736. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8737. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8738. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8739. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8740. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8741. //其他费用
  8742. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8743. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8744. //其他费用合计
  8745. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8746. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8747. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8748. //公务舱合计
  8749. //国际旅费
  8750. //string outsideJJ = "";
  8751. //string allPriceJJ = "";
  8752. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8753. {
  8754. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8755. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8756. }
  8757. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8758. {
  8759. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8760. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8761. }
  8762. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8763. {
  8764. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8765. dic.Add("AirFeeTotal", airFeeTotalStr);
  8766. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8767. dic.Add("FeeTotal", feeTotalStr);
  8768. }
  8769. foreach (var key in dic.Keys)
  8770. {
  8771. builder.MoveToBookmark(key);
  8772. builder.Write(dic[key]);
  8773. }
  8774. //模板文件名
  8775. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8776. strFileName = CommonFun.ValidFileName(strFileName);
  8777. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8778. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8779. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8780. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8781. }
  8782. }
  8783. else if (dto.ExportType == 2) //表格
  8784. {
  8785. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8786. }
  8787. else if (dto.ExportType == 3)
  8788. {
  8789. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8790. }
  8791. return Ok(JsonView(400, "只可导出明细表!", ""));
  8792. }
  8793. catch (Exception ex)
  8794. {
  8795. return Ok(JsonView(400, ex.Message, ""));
  8796. }
  8797. }
  8798. /// <summary>
  8799. /// 获取三公费用标准city
  8800. /// </summary>
  8801. /// <param name="placeData"></param>
  8802. /// <param name="nationalTravelFeeId"></param>
  8803. /// <returns></returns>
  8804. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8805. {
  8806. string _city = string.Empty;
  8807. if (!placeData.Any()) return _city;
  8808. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8809. if (data == null) return _city;
  8810. string country = data.Country;
  8811. string city = data.City;
  8812. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8813. else _city = city;
  8814. return _city;
  8815. }
  8816. /// <summary>
  8817. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8818. /// </summary>
  8819. /// <returns></returns>
  8820. [HttpPost]
  8821. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8823. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8824. {
  8825. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8826. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8827. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8828. if (_view.Code == 0)
  8829. {
  8830. return Ok(JsonView(true, "操作成功"));
  8831. }
  8832. return Ok(JsonView(false, "操作失败"));
  8833. }
  8834. /// <summary>
  8835. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8836. /// </summary>
  8837. /// <returns></returns>
  8838. [HttpPost]
  8839. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8841. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8842. {
  8843. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8844. if (data.Code != 0)
  8845. {
  8846. return Ok(JsonView(false, data.Msg));
  8847. }
  8848. return Ok(JsonView(true, "操作成功!", data.Data));
  8849. }
  8850. /// <summary>
  8851. /// 三公其他费用草稿 删除
  8852. /// </summary>
  8853. /// <param name="dto"></param>
  8854. /// <returns></returns>
  8855. [HttpPost]
  8856. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8857. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8858. {
  8859. var jw = JsonView(false, "删除失败!");
  8860. var data = new Grp_DayOtherPriceDraft()
  8861. {
  8862. Id = dto.Id,
  8863. IsDel = 1,
  8864. DeleteUserId = dto.DeleteUserId,
  8865. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8866. };
  8867. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8868. if (del > 0)
  8869. {
  8870. jw.Code = 200;
  8871. jw.Msg = "删除成功!";
  8872. }
  8873. return Ok(jw);
  8874. }
  8875. /// <summary>
  8876. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8877. /// </summary>
  8878. /// <returns></returns>
  8879. [HttpPost]
  8880. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8881. {
  8882. var jw = JsonView(false);
  8883. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8884. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8885. jw.Code = StatusCodes.Status200OK;
  8886. jw.Msg = "操作成功!";
  8887. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8888. return Ok(jw);
  8889. }
  8890. /// <summary>
  8891. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8892. /// </summary>
  8893. /// <param name="dto"></param>
  8894. /// <returns></returns>
  8895. [HttpPost]
  8896. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8897. {
  8898. int userId = dto.UserId,
  8899. portId = dto.PortType,
  8900. groupId = dto.GroupId,
  8901. draftId = dto.DraftId;
  8902. _portTypeData.Add(1);
  8903. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8904. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8905. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8906. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8907. _sqlSugar.BeginTran();
  8908. try
  8909. {
  8910. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  8911. if (draftDatas == null)
  8912. {
  8913. _sqlSugar.RollbackTran();
  8914. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  8915. }
  8916. //验证可覆盖已有数据 两边创建人需为同一人;
  8917. int draftCreateUserId = draftDatas.CreateUserId,
  8918. formalCreateUserId = 0;
  8919. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8920. if (formalData != null)
  8921. {
  8922. formalCreateUserId = formalData.CreateUserId;
  8923. if (draftCreateUserId != formalCreateUserId)
  8924. {
  8925. _sqlSugar.RollbackTran();
  8926. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  8927. }
  8928. }
  8929. //默认添加查看、编辑权限(创建人、自己)
  8930. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  8931. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8932. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8933. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  8934. newExterData.DiId = groupId;
  8935. newExterData.CreateUserId = userId;
  8936. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  8937. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  8938. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  8939. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  8940. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  8941. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8942. //数据如果存在执行删除
  8943. if (enterExitCostInfo != null)
  8944. {
  8945. _sqlSugar.Updateable<Grp_EnterExitCost>()
  8946. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  8947. .Where(x => x.Id == enterExitCostInfo.Id)
  8948. .ExecuteCommand();
  8949. _sqlSugar.Updateable<Grp_DayAndCost>()
  8950. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8951. .Where(x => x.DiId == groupId)
  8952. .ExecuteCommand();
  8953. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8954. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8955. .Where(x => x.Diid == groupId)
  8956. .ExecuteCommand();
  8957. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  8958. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8959. .Where(x => x.GroupId == groupId)
  8960. .ExecuteCommand();
  8961. }
  8962. //执行insert
  8963. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  8964. if (insertId < 1)
  8965. {
  8966. _sqlSugar.RollbackTran();
  8967. return Ok(JsonView(false, "草稿数据导入失败!"));
  8968. }
  8969. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  8970. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  8971. #region 默认添加权限
  8972. #endregion
  8973. _sqlSugar.CommitTran();
  8974. //执行操作之后
  8975. //生成默认文件pdf并且通知人员
  8976. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8977. {
  8978. DiId = groupId,
  8979. ExportType = 1,
  8980. SubTypeId = 1005
  8981. }, "pdf");
  8982. //发送通知
  8983. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8984. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  8985. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  8986. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  8987. //汇率信息记录
  8988. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  8989. return Ok(JsonView(true));
  8990. }
  8991. catch (Exception ex)
  8992. {
  8993. _sqlSugar.RollbackTran();
  8994. return Ok(JsonView(false, ex.Message));
  8995. }
  8996. }
  8997. #endregion
  8998. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  8999. /// <summary>
  9000. /// 获取币种基础数据(含逻辑处理)
  9001. /// </summary>
  9002. /// <returns></returns>
  9003. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9004. {
  9005. return await GeneralMethod.EnterExitCostInitRate();
  9006. }
  9007. /// <summary>
  9008. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9009. /// </summary>
  9010. /// <returns></returns>
  9011. [HttpPost]
  9012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9013. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9014. {
  9015. //验证城市归属并给默认值
  9016. int provinceId = dto.ProvinceId;
  9017. if (provinceId < 1) provinceId = 122;
  9018. var dataSource = await _sqlSugar
  9019. .Queryable<Sys_SetData>()
  9020. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9021. .ToListAsync();
  9022. var fileTypes = new List<EecSetDataInfoView>();
  9023. //三公费用-Word明细类型
  9024. var wordTypeData = dataSource
  9025. .Where(it => it.STid == 72)
  9026. .Select(x => new EecSetDataInfoView
  9027. {
  9028. ParentId = 1,
  9029. Id = x.Id,
  9030. Name = x.Name
  9031. })
  9032. .ToArray();
  9033. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9034. var excelTypeData = dataSource
  9035. .Where(it => it.STid == 73)
  9036. .Select(x => new EecSetDataInfoView
  9037. {
  9038. ParentId = 2,
  9039. Id = x.Id,
  9040. Name = x.Name
  9041. })
  9042. .ToArray();
  9043. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9044. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9045. fileTypes.Add(groupNameList);
  9046. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9047. //默认币种显示
  9048. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9049. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9050. return Ok(JsonView(true, "查询成功!", new
  9051. {
  9052. FileTypeData = fileTypes,
  9053. CurrencyInit = _currencyInfos,
  9054. viewPermissionData = viewPermissionData
  9055. }));
  9056. }
  9057. /// <summary>
  9058. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9059. /// </summary>
  9060. /// <returns></returns>
  9061. [HttpPost]
  9062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9063. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9064. {
  9065. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9066. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9067. RefAsync<int> total = 0;
  9068. int diId = 0;
  9069. var status = int.TryParse(dto.GroupName, out diId);
  9070. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9071. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9072. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9073. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9074. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9075. .OrderByDescending(x => x.VisitStartDate)
  9076. .Select(x => new EnterExitCostMobileGroupView()
  9077. {
  9078. Id = x.Id,
  9079. GroupName = x.TeamName,
  9080. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9081. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9082. ProvinceId = x.CityId
  9083. })
  9084. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9085. //处理省份Id
  9086. if (data.Any())
  9087. {
  9088. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9089. if (provCityDatas.Any())
  9090. {
  9091. foreach (var item in data)
  9092. {
  9093. var provinceId = item.ProvinceId;
  9094. var isDefualtVal = true;
  9095. if (provinceId > 0)
  9096. {
  9097. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9098. if (parentId != null)
  9099. {
  9100. isDefualtVal = false;
  9101. item.ProvinceId = (int)parentId;
  9102. }
  9103. }
  9104. if (isDefualtVal)
  9105. {
  9106. item.ProvinceId = 122; //默认四川
  9107. }
  9108. }
  9109. }
  9110. }
  9111. //处理是否显示
  9112. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9113. {
  9114. foreach (var item in data)
  9115. {
  9116. item.IsView = true;
  9117. }
  9118. }
  9119. return Ok(JsonView(true, "查询成功!", data, total));
  9120. }
  9121. /// <summary>
  9122. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9123. /// </summary>
  9124. /// <returns></returns>
  9125. [HttpPost]
  9126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9127. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9128. {
  9129. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9130. RefAsync<int> total = 0;
  9131. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9132. .Where(x => x.IsDel == 0 && x.STid == 66)
  9133. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9134. .Select(x => new
  9135. {
  9136. id = x.Id,
  9137. name = x.Name,
  9138. remark = x.Remark,
  9139. })
  9140. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9141. return Ok(JsonView(true, "查询成功!", data, total));
  9142. }
  9143. /// <summary>
  9144. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9145. /// </summary>
  9146. /// <returns></returns>
  9147. [HttpPost]
  9148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9149. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9150. {
  9151. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9152. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9153. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9154. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9155. var groupOtherRateData = groupRateData.TeamRates;
  9156. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9157. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9158. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9159. groupOtherRateData = groupOtherRateData
  9160. .Select(x => new TeamRateDescAddCurrencyIdView
  9161. {
  9162. CurrencyId = x.CurrencyId,
  9163. CurrencyName = x.CurrencyName,
  9164. CurrencyCode = x.CurrencyCode,
  9165. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9166. }).ToList();
  9167. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9168. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9169. }
  9170. /// <summary>
  9171. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9172. /// </summary>
  9173. /// <returns></returns>
  9174. [HttpPost]
  9175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9176. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9177. {
  9178. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9179. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9180. var tipsData = new List<int>() { 1, 2, 3 };
  9181. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9182. if (dto.TipsType == 1)
  9183. {
  9184. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9185. }
  9186. else if (dto.TipsType == 2)
  9187. {
  9188. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9189. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9190. }
  9191. else if (dto.TipsType == 3)
  9192. {
  9193. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9194. return Ok(JsonView(true, "查询成功!", airData));
  9195. }
  9196. return Ok(JsonView(false));
  9197. }
  9198. /// <summary>
  9199. /// 团组模块 - 出入境国家费用标准-移动端 List
  9200. /// </summary>
  9201. /// <returns></returns>
  9202. [HttpPost]
  9203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9204. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9205. {
  9206. Stopwatch sw = new Stopwatch();
  9207. sw.Start();
  9208. int provinceId = dto.ProvinceId;
  9209. if (provinceId < 1) provinceId = 122; // 默认四川
  9210. RefAsync<int> total = 0;
  9211. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9212. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9213. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9214. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9215. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9216. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9217. .Select((ntf, sd, u, sd1) => new
  9218. {
  9219. Id = ntf.Id,
  9220. Area = $"{ntf.Country}-{ntf.City}",
  9221. Currency = ntf.Currency,
  9222. CurrencyCode = sd.Name,
  9223. CurrencyName = sd.Remark,
  9224. RoomCost = ntf.RoomCost,
  9225. FoodCost = ntf.FoodCost,
  9226. PublicCost = ntf.PublicCost,
  9227. TrainCost = ntf.TrainCost,
  9228. LastUpdateUserId = ntf.LastUpdateUserId,
  9229. LastUpdateUserName = u.CnName,
  9230. LastUpdateTime = ntf.LastUpdateTime
  9231. })
  9232. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9233. sw.Stop();
  9234. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9235. }
  9236. /// <summary>
  9237. /// 团组模块 - 出入境费用-移动端 - Info
  9238. /// </summary>
  9239. /// <returns></returns>
  9240. [HttpPost]
  9241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9242. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9243. {
  9244. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9245. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9246. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9247. return Ok(data);
  9248. }
  9249. /// <summary>
  9250. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9251. /// </summary>
  9252. /// <returns></returns>
  9253. [HttpPost]
  9254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9255. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9256. {
  9257. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9258. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9259. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9260. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9261. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9262. mobileInfo.DiId = dto.DiId;
  9263. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9264. if (eecInfo == null) return Ok(mobileInfo);
  9265. //验证查看权限
  9266. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9267. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9268. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9269. mobileInfo.IsAssignPerm = isSet;
  9270. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9271. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9272. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9273. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9274. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9275. {
  9276. SubId = dac.Id,
  9277. DiId = dac.DiId,
  9278. Type = dac.Type,
  9279. Days = dac.Days,
  9280. NationalTravelFeeId = dac.NationalTravelFeeId,
  9281. Arae = $"{ntf.Country}-{ntf.City}",
  9282. Cost = dac.Cost,
  9283. Currency = dac.Currency,
  9284. CurrencyName = sd.Name,
  9285. SubTotal = dac.SubTotal,
  9286. })
  9287. .ToList();
  9288. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9289. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9290. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9291. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9292. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9293. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9294. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9295. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9296. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9297. //其他款项
  9298. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9299. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9300. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9301. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9302. .OrderBy((dop, sd1, sd2) => dop.Index)
  9303. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9304. {
  9305. SubId = dop.Id,
  9306. DiId = dop.Diid,
  9307. Index = dop.Index,
  9308. SetDataId = dop.SetDataId,
  9309. SetDataName = sd1.Name,
  9310. Cost = dop.Cost,
  9311. Currency = dop.Currency,
  9312. CurrencyName = sd2.Remark,
  9313. SubTotal = dop.SubTotal,
  9314. Remark = dop.Remark,
  9315. })
  9316. .ToArray();
  9317. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9318. return Ok(mobileInfo);
  9319. }
  9320. /// <summary>
  9321. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9322. /// </summary>
  9323. /// <returns></returns>
  9324. [HttpPost]
  9325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9326. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9327. {
  9328. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9329. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9330. //验证查看权限
  9331. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9332. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9333. var userIds = await _sqlSugar
  9334. .Queryable<Grp_EnterExitCostPermission>()
  9335. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9336. .Select(x => x.UserId)
  9337. .ToArrayAsync();
  9338. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9339. var perUsersView = new List<dynamic>();
  9340. foreach (var item in perUsers)
  9341. {
  9342. bool isView1 = false;
  9343. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9344. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9345. }
  9346. return Ok(JsonView(perUsersView));
  9347. }
  9348. /// <summary>
  9349. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9350. /// </summary>
  9351. /// <returns></returns>
  9352. [HttpPost]
  9353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9354. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9355. {
  9356. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9357. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9358. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9359. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9360. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9361. //验证查看权限
  9362. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9363. //if (!isView) return Ok(JsonView(false, msg));
  9364. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9365. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9366. var subType = dto.SubType;
  9367. if (subType == 1) //1:境内费用
  9368. {
  9369. var oneData = new ChoiceOneMobileSubInfoView()
  9370. {
  9371. Id = eecInfo.Id,
  9372. ChoiceOne = eecInfo.ChoiceOne,
  9373. ChoiceOneTotalCost = eecInfo.InsidePay,
  9374. Visa = eecInfo.Visa,
  9375. VisaRemark = eecInfo.VisaRemark,
  9376. YiMiao = eecInfo.YiMiao,
  9377. HeSuan = eecInfo.HeSuan,
  9378. Service = eecInfo.Service,
  9379. Ticket = eecInfo.Ticket,
  9380. Safe = eecInfo.Safe,
  9381. FirstItemRemark = eecInfo.FirstItemRemark
  9382. };
  9383. return Ok(JsonView(oneData));
  9384. }
  9385. else if (subType == 2) //2:国际旅费
  9386. {
  9387. var twoData = new ChoiceTwoMobileSubInfoView()
  9388. {
  9389. Id = eecInfo.Id,
  9390. ChoiceTwoJJ = eecInfo.SumJJC,
  9391. OutsideJJPay = eecInfo.OutsideJJPay,
  9392. ChoiceTwoGW = eecInfo.SumGWC,
  9393. OutsideGWPay = eecInfo.OutsideGWPay,
  9394. ChoiceTwoTD = eecInfo.SumTDC,
  9395. OutsideTDPay = eecInfo.OutsideTDPay,
  9396. AirJJ = eecInfo.AirJJ,
  9397. AirGW = eecInfo.AirGW,
  9398. AirTD = eecInfo.AirTD,
  9399. CityTranffic = eecInfo.CityTranffic,
  9400. TwoItemRemark = eecInfo.TwoItemRemark
  9401. };
  9402. return Ok(JsonView(twoData));
  9403. }
  9404. else if (subType == 3) //3:住宿费
  9405. {
  9406. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9407. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9408. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9409. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9410. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9411. {
  9412. SubId = dac.Id,
  9413. DiId = dac.DiId,
  9414. Type = dac.Type,
  9415. Days = dac.Days,
  9416. NationalTravelFeeId = dac.NationalTravelFeeId,
  9417. Arae = $"{ntf.Country}-{ntf.City}",
  9418. Cost = dac.Cost,
  9419. Currency = dac.Currency,
  9420. CurrencyName = sd.Name,
  9421. SubTotal = dac.SubTotal,
  9422. })
  9423. .ToArray();
  9424. var data = new ChoiceMobileSubInfo3To6View()
  9425. {
  9426. ParentId = eecInfo.Id,
  9427. Choice = eecInfo.ChoiceThree,
  9428. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9429. Details = dayAndCostDatas
  9430. };
  9431. return Ok(JsonView(data));
  9432. }
  9433. else if (subType == 4) //4:伙食费
  9434. {
  9435. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9436. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9437. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9438. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9439. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9440. {
  9441. SubId = dac.Id,
  9442. DiId = dac.DiId,
  9443. Type = dac.Type,
  9444. Days = dac.Days,
  9445. NationalTravelFeeId = dac.NationalTravelFeeId,
  9446. Arae = $"{ntf.Country}-{ntf.City}",
  9447. Cost = dac.Cost,
  9448. Currency = dac.Currency,
  9449. CurrencyName = sd.Name,
  9450. SubTotal = dac.SubTotal,
  9451. })
  9452. .ToArray();
  9453. var data = new ChoiceMobileSubInfo3To6View()
  9454. {
  9455. ParentId = eecInfo.Id,
  9456. Choice = eecInfo.ChoiceFour,
  9457. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9458. Details = dayAndCostDatas
  9459. };
  9460. return Ok(JsonView(data));
  9461. }
  9462. else if (subType == 5) //5:公杂费
  9463. {
  9464. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9465. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9466. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9467. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9468. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9469. {
  9470. SubId = dac.Id,
  9471. DiId = dac.DiId,
  9472. Type = dac.Type,
  9473. Days = dac.Days,
  9474. NationalTravelFeeId = dac.NationalTravelFeeId,
  9475. Arae = $"{ntf.Country}-{ntf.City}",
  9476. Cost = dac.Cost,
  9477. Currency = dac.Currency,
  9478. CurrencyName = sd.Name,
  9479. SubTotal = dac.SubTotal,
  9480. })
  9481. .ToArray();
  9482. var data = new ChoiceMobileSubInfo3To6View()
  9483. {
  9484. ParentId = eecInfo.Id,
  9485. Choice = eecInfo.ChoiceFive,
  9486. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9487. Details = dayAndCostDatas
  9488. };
  9489. return Ok(JsonView(data));
  9490. }
  9491. else if (subType == 6) //6:培训费
  9492. {
  9493. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9494. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9495. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9496. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9497. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9498. {
  9499. SubId = dac.Id,
  9500. DiId = dac.DiId,
  9501. Type = dac.Type,
  9502. Days = dac.Days,
  9503. NationalTravelFeeId = dac.NationalTravelFeeId,
  9504. Arae = $"{ntf.Country}-{ntf.City}",
  9505. Cost = dac.Cost,
  9506. Currency = dac.Currency,
  9507. CurrencyName = sd.Name,
  9508. SubTotal = dac.SubTotal,
  9509. })
  9510. .ToArray();
  9511. var data = new ChoiceMobileSubInfo3To6View()
  9512. {
  9513. ParentId = eecInfo.Id,
  9514. Choice = eecInfo.ChoiceSix,
  9515. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9516. Details = dayAndCostDatas
  9517. };
  9518. return Ok(JsonView(data));
  9519. }
  9520. else if (subType == 7) //7:其他
  9521. {
  9522. //其他款项
  9523. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9524. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9525. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9526. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9527. .OrderBy((dop, sd1, sd2) => dop.Index)
  9528. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9529. {
  9530. SubId = dop.Id,
  9531. DiId = dop.Diid,
  9532. Index = dop.Index,
  9533. SetDataId = dop.SetDataId,
  9534. SetDataName = sd1.Name,
  9535. Cost = dop.Cost,
  9536. Currency = dop.Currency,
  9537. CurrencyName = sd2.Name,
  9538. SubTotal = dop.SubTotal,
  9539. Remark = dop.Remark,
  9540. })
  9541. .ToArray();
  9542. var data = new ChoiceSevenMobileSubInfoView()
  9543. {
  9544. ParentId = eecInfo.Id,
  9545. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9546. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9547. Details = otherData
  9548. };
  9549. return Ok(JsonView(data));
  9550. }
  9551. return Ok(JsonView(false));
  9552. }
  9553. #region op
  9554. /// <summary>
  9555. /// 移动端更新费用消息通知
  9556. /// </summary>
  9557. /// <param name="diid"></param>
  9558. /// <param name="id"></param>
  9559. /// <param name="currUserId"></param>
  9560. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9561. {
  9562. try
  9563. {
  9564. ////生成默认文件pdf并且通知人员
  9565. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9566. //{
  9567. // DiId = diid,
  9568. // ExportType = 1,
  9569. // SubTypeId = 1005
  9570. //}, "pdf");
  9571. ////发送通知
  9572. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9573. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9574. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9575. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9576. ////汇率信息记录
  9577. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9578. }
  9579. catch (Exception ex)
  9580. {
  9581. //记录日志
  9582. throw;
  9583. }
  9584. }
  9585. /// <summary>
  9586. /// 验证出入境费用数据是否存在
  9587. /// 不存在添加
  9588. /// </summary>
  9589. /// <param name="diId"></param>
  9590. /// <param name="currUserId"></param>
  9591. /// <returns></returns>
  9592. /// <exception cref="CustomException"></exception>
  9593. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9594. {
  9595. var parentId = 0;
  9596. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9597. if (info != null)
  9598. {
  9599. parentId = info.Id;
  9600. }
  9601. else
  9602. {
  9603. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9604. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9605. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9606. parentId = addId;
  9607. }
  9608. return parentId;
  9609. }
  9610. /// <summary>
  9611. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9612. /// </summary>
  9613. /// <returns></returns>
  9614. [HttpPost]
  9615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9616. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9617. {
  9618. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9619. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9620. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9621. //验证编辑权限
  9622. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9623. //if (!isEdit) return Ok(JsonView(false, msg));
  9624. var permissions = new List<Grp_EnterExitCostPermission>();
  9625. foreach (var userId in dto.UserIds)
  9626. {
  9627. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9628. }
  9629. if (permissions.Any())
  9630. {
  9631. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9632. {
  9633. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9634. }
  9635. _sqlSugar.BeginTran();
  9636. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9637. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9638. if (result < 1)
  9639. {
  9640. _sqlSugar.RollbackTran();
  9641. return Ok(JsonView(false));
  9642. }
  9643. _sqlSugar.CommitTran();
  9644. return Ok(JsonView(true));
  9645. }
  9646. return Ok(JsonView(false));
  9647. }
  9648. /// <summary>
  9649. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9650. /// </summary>
  9651. /// <returns></returns>
  9652. [HttpPost]
  9653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9654. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9655. {
  9656. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9657. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9658. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9659. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9660. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9661. int id = dto.Id;
  9662. if (id <= 0) //add
  9663. {
  9664. //int provinceId = dto.ProvinceId;
  9665. int groupId = dto.DiId;
  9666. //if (provinceId < 1) provinceId = 122;
  9667. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9668. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9669. if (add < 1) return Ok(JsonView(false));
  9670. id = add;
  9671. }
  9672. else //update
  9673. {
  9674. ////验证编辑权限
  9675. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9676. //if (!isEdit) return Ok(JsonView(false, msg));
  9677. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9678. if (upd < 1) return Ok(JsonView(false));
  9679. }
  9680. #region 汇率变更时更改币种相关费用
  9681. var opDayCosts = new List<Grp_DayAndCost>();
  9682. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9683. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9684. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9685. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9686. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9687. .Select((dac, sd) => new
  9688. {
  9689. dac.Id,
  9690. dac.DiId,
  9691. CurrencyCode = sd.Name,
  9692. dac.Cost
  9693. })
  9694. .ToList();
  9695. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9696. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9697. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9698. .Select((dop, sd) => new
  9699. {
  9700. dop.Id,
  9701. dop.Diid,
  9702. CurrencyCode = sd.Name,
  9703. dop.Cost
  9704. })
  9705. .ToList();
  9706. if (dayCosts.Count > 0)
  9707. {
  9708. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9709. foreach (var dc in new_dayCosts)
  9710. {
  9711. var thisCurrency = dc.Key.ToUpper();
  9712. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9713. if (thisRate == 0.00M) continue;
  9714. foreach (var dcSub in dc)
  9715. {
  9716. opDayCosts.Add(new Grp_DayAndCost()
  9717. {
  9718. Id = dcSub.Id,
  9719. DiId = dcSub.DiId,
  9720. Cost = dcSub.Cost,
  9721. SubTotal = dcSub.Cost * thisRate,
  9722. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9723. });
  9724. }
  9725. }
  9726. if (opDayCosts.Count > 0)
  9727. {
  9728. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9729. }
  9730. }
  9731. if (dayOtherCosts.Count > 0)
  9732. {
  9733. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9734. foreach (var dc in new_dayOtherCosts)
  9735. {
  9736. var thisCurrency = dc.Key.ToUpper();
  9737. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9738. if (thisRate == 0.00M) continue;
  9739. foreach (var dcSub in dc)
  9740. {
  9741. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9742. {
  9743. Id = dcSub.Id,
  9744. Diid = dcSub.Diid,
  9745. Cost = dcSub.Cost,
  9746. SubTotal = dcSub.Cost * thisRate,
  9747. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9748. });
  9749. }
  9750. }
  9751. if (opDayOtherCosts.Count > 0)
  9752. {
  9753. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9754. }
  9755. }
  9756. #endregion
  9757. //消息通知
  9758. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9759. //汇率信息记录
  9760. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9761. return Ok(JsonView(new { parentId = id }));
  9762. }
  9763. /// <summary>
  9764. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9765. /// </summary>
  9766. /// <returns></returns>
  9767. [HttpPost]
  9768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9769. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9770. {
  9771. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9772. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9773. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9774. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9775. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9776. int id = dto.Id;
  9777. if (id <= 0) //add
  9778. {
  9779. checkboxInfo.CreateUserId = dto.CurrUserId;
  9780. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9781. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9782. if (add < 1) return Ok(JsonView(false));
  9783. }
  9784. else //update
  9785. {
  9786. ////验证编辑权限
  9787. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9788. //if (!isEdit) return Ok(JsonView(false, msg));
  9789. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9790. .UpdateColumns(x => new
  9791. {
  9792. x.ChoiceOne,
  9793. x.ChoiceTwo,
  9794. x.SumJJC,
  9795. x.SumGWC,
  9796. x.SumTDC,
  9797. x.ChoiceThree,
  9798. x.ChoiceFour,
  9799. x.ChoiceFive,
  9800. x.ChoiceSix,
  9801. x.OtherExpenses_Checked
  9802. })
  9803. .Where(x => x.Id == id)
  9804. .ExecuteCommandAsync();
  9805. if (upd < 1) return Ok(JsonView(false));
  9806. }
  9807. return Ok(JsonView(new { parentId = id }));
  9808. }
  9809. /// <summary>
  9810. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9811. /// </summary>
  9812. /// <returns></returns>
  9813. [HttpPost]
  9814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9815. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9816. {
  9817. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9818. // if (provinceId < 1) provinceId = 122;
  9819. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9820. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9821. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9822. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9823. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9824. var checkboxInfo = new Grp_EnterExitCost()
  9825. {
  9826. Id = id,
  9827. //ProvinceId = provinceId,
  9828. DiId = diId,
  9829. CreateUserId = currUserId
  9830. };
  9831. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9832. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9833. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9834. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9835. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9836. if (id <= 0) //add
  9837. {
  9838. checkboxInfo.CreateUserId = dto.CurrUserId;
  9839. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9840. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9841. if (add < 1) return Ok(JsonView(false));
  9842. }
  9843. else //update
  9844. {
  9845. ////验证编辑权限
  9846. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9847. //if (!isEdit) return Ok(JsonView(false, msg));
  9848. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9849. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9850. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9851. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9852. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9853. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9854. .Where(x => x.Id == id)
  9855. .ExecuteCommandAsync();
  9856. if (upd < 1) return Ok(JsonView(false));
  9857. }
  9858. return Ok(JsonView(new { parentId = id }));
  9859. }
  9860. /// <summary>
  9861. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9862. /// </summary>
  9863. /// <returns></returns>
  9864. [HttpPost]
  9865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9866. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9867. {
  9868. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9869. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9870. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9871. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9872. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9873. info.FirstItemRemark = dto.FirstItemRemark;
  9874. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9875. int id = dto.Id;
  9876. if (id <= 0) //add
  9877. {
  9878. info.CreateUserId = dto.CurrUserId;
  9879. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9880. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9881. if (add < 1) return Ok(JsonView(false));
  9882. id = add;
  9883. }
  9884. else //update
  9885. {
  9886. ////验证编辑权限
  9887. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9888. //if (!isEdit) return Ok(JsonView(false, msg));
  9889. var upd = await _sqlSugar.Updateable(info)
  9890. .UpdateColumns(x => new
  9891. {
  9892. x.ChoiceOne,
  9893. x.InsidePay,
  9894. x.VisaRemark,
  9895. x.Visa,
  9896. x.Service,
  9897. x.Safe,
  9898. x.Ticket,
  9899. x.HeSuan,
  9900. x.YiMiao,
  9901. x.FirstItemRemark
  9902. })
  9903. .Where(x => x.Id == id)
  9904. .ExecuteCommandAsync();
  9905. if (upd < 1) return Ok(JsonView(false));
  9906. }
  9907. //消息通知
  9908. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9909. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9910. }
  9911. /// <summary>
  9912. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9913. /// </summary>
  9914. /// <returns></returns>
  9915. [HttpPost]
  9916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9917. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9918. {
  9919. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9920. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9921. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9922. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9923. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9924. info.DiId = dto.DiId;
  9925. //info.ProvinceId = dto.ProvinceId;
  9926. info.OutsideJJPay = dto.OutsideJJPay;
  9927. info.OutsideGWPay = dto.OutsideGWPay;
  9928. info.OutsideTDPay = dto.OutsideTDPay;
  9929. info.AirJJ = dto.AirJJ;
  9930. info.AirGW = dto.AirGW;
  9931. info.AirTD = dto.AirTD;
  9932. info.CityTranffic = dto.CityTranffic;
  9933. info.TwoItemRemark = dto.TwoItemRemark;
  9934. info.SumJJC = dto.ChoiceTwoJJ;
  9935. info.SumGWC = dto.ChoiceTwoGW;
  9936. info.SumTDC = dto.ChoiceTwoTD;
  9937. int id = dto.Id;
  9938. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9939. if (id <= 0) //add
  9940. {
  9941. info.CreateUserId = dto.CurrUserId;
  9942. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9943. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9944. if (addId <= 0) return Ok(JsonView(false));
  9945. id = addId;
  9946. }
  9947. else //update
  9948. {
  9949. ////验证编辑权限
  9950. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9951. //if (!isEdit) return Ok(JsonView(false, msg));
  9952. var upd = await _sqlSugar.Updateable(info)
  9953. .UpdateColumns(x => new
  9954. {
  9955. x.SumJJC,
  9956. x.OutsideJJPay,
  9957. x.SumGWC,
  9958. x.OutsideGWPay,
  9959. x.SumTDC,
  9960. x.OutsideTDPay,
  9961. x.AirJJ,
  9962. x.AirGW,
  9963. x.AirTD,
  9964. x.CityTranffic,
  9965. x.TwoItemRemark
  9966. })
  9967. .Where(x => x.Id == id)
  9968. .ExecuteCommandAsync();
  9969. if (upd < 1) return Ok(JsonView(false));
  9970. }
  9971. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9972. gwcItemTotal = info.AirGW + info.CityTranffic;
  9973. tdcItemTotal = info.AirTD + info.CityTranffic;
  9974. //消息通知
  9975. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9976. return Ok(JsonView(new
  9977. {
  9978. parentId = id,
  9979. choiceTwoJJ = dto.ChoiceTwoJJ,
  9980. jjcItemTotal = jjcItemTotal,
  9981. choiceTwoGW = dto.ChoiceTwoGW,
  9982. gwcItemTotal = gwcItemTotal,
  9983. choiceTwoTD = dto.ChoiceTwoTD,
  9984. tdcItemTotal = tdcItemTotal
  9985. }));
  9986. }
  9987. /// <summary>
  9988. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9989. /// </summary>
  9990. /// <returns></returns>
  9991. [HttpPost]
  9992. [ApiExplorerSettings(IgnoreApi = true)]
  9993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9994. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  9995. {
  9996. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9997. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9998. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9999. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10000. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10001. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10002. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10003. var infos = infos1.Select(x => new Grp_DayAndCost
  10004. {
  10005. Id = x.Id,
  10006. DiId = dto.DiId,
  10007. Type = dto.FeeType,
  10008. Days = x.Days,
  10009. NationalTravelFeeId = x.NationalTravelFeeId,
  10010. Cost = x.Cost,
  10011. Currency = x.Currency,
  10012. SubTotal = x.SubTotal,
  10013. CreateUserId = dto.CurrUserId
  10014. })
  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.Days,
  10029. x.NationalTravelFeeId,
  10030. x.Cost,
  10031. x.Currency,
  10032. x.SubTotal
  10033. })
  10034. .WhereColumns(x => new { x.Id })
  10035. .ExecuteCommandAsync();
  10036. if (upd < 1) return Ok(JsonView(false));
  10037. }
  10038. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10039. //消息通知
  10040. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10041. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10042. return Ok(JsonView(new { itemTotal = itemTotal }));
  10043. }
  10044. /// <summary>
  10045. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10046. /// </summary>
  10047. /// <returns></returns>
  10048. [HttpPost]
  10049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10050. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10051. {
  10052. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10053. int subId = dto.SubId, feeType = dto.FeeType;
  10054. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10055. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10056. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10057. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10058. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10059. subInfo.Id = subId;
  10060. subInfo.DiId = dto.DiId;
  10061. if (feeType == 3) subInfo.Type = 1;
  10062. else if (feeType == 4) subInfo.Type = 2;
  10063. else if (feeType == 5) subInfo.Type = 3;
  10064. else if (feeType == 6) subInfo.Type = 4;
  10065. subInfo.CreateUserId = dto.CurrUserId;
  10066. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10067. if (parentId < 1) return Ok(JsonView(false));
  10068. //子表op
  10069. if (subId < 1)
  10070. {
  10071. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10072. if (subAdd < 1) return Ok(JsonView(false));
  10073. }
  10074. else
  10075. {
  10076. ////验证编辑权限
  10077. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10078. //if (!isEdit) return Ok(JsonView(false, msg));
  10079. var subUpd = await _sqlSugar.Updateable(subInfo)
  10080. .UpdateColumns(x => new
  10081. {
  10082. x.Days,
  10083. x.NationalTravelFeeId,
  10084. x.Cost,
  10085. x.Currency,
  10086. x.SubTotal
  10087. })
  10088. .WhereColumns(x => new { x.Id })
  10089. .ExecuteCommandAsync();
  10090. if (subUpd < 1) return Ok(JsonView(false));
  10091. }
  10092. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10093. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10094. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10095. }
  10096. /// <summary>
  10097. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10098. /// </summary>
  10099. /// <returns></returns>
  10100. [HttpPost]
  10101. [ApiExplorerSettings(IgnoreApi = true)]
  10102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10103. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10104. {
  10105. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10106. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10107. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10108. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10109. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10110. {
  10111. Id = x.Id,
  10112. Diid = dto.DiId,
  10113. SetDataId = x.SetDataId,
  10114. Index = x.Index,
  10115. Cost = x.Cost,
  10116. Currency = x.Currency,
  10117. SubTotal = x.SubTotal,
  10118. CreateUserId = dto.CurrUserId,
  10119. Remark = x.Remark
  10120. }).ToList();
  10121. var adds = infos.Where(x => x.Id <= 0).ToList();
  10122. var upds = infos.Where(x => x.Id > 0).ToList();
  10123. if (adds.Count > 0)
  10124. {
  10125. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10126. if (add < 1) return Ok(JsonView(false));
  10127. }
  10128. if (upds.Count > 0)
  10129. {
  10130. var upd = await _sqlSugar.Updateable(adds)
  10131. .UpdateColumns(x => new
  10132. {
  10133. x.Index,
  10134. x.SetDataId,
  10135. x.Cost,
  10136. x.Currency,
  10137. x.SubTotal,
  10138. x.Remark
  10139. })
  10140. .WhereColumns(x => new { x.Id })
  10141. .ExecuteCommandAsync();
  10142. if (upd < 1) return Ok(JsonView(false));
  10143. }
  10144. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10145. //消息通知
  10146. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10147. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10148. return Ok(JsonView(new { itemTotal = itemTotal }));
  10149. }
  10150. /// <summary>
  10151. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10152. /// </summary>
  10153. /// <returns></returns>
  10154. [HttpPost]
  10155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10156. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10157. {
  10158. int subId = dto.SubId;
  10159. int diId = dto.Diid;
  10160. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10161. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10162. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10163. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10164. subInfo.Id = subId;
  10165. subInfo.Diid = dto.Diid;
  10166. subInfo.CreateUserId = dto.CurrUserId;
  10167. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10168. if (parentId < 1) return Ok(JsonView(false));
  10169. #region 子表op
  10170. if (subId < 1)//add
  10171. {
  10172. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10173. if (subAdd < 1) return Ok(JsonView(false));
  10174. }
  10175. else //upd
  10176. {
  10177. ////验证编辑权限
  10178. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10179. //if (!isEdit) return Ok(JsonView(false, msg));
  10180. var subUpd = await _sqlSugar.Updateable(subInfo)
  10181. .UpdateColumns(x => new
  10182. {
  10183. x.Index,
  10184. x.SetDataId,
  10185. x.Cost,
  10186. x.Currency,
  10187. x.SubTotal,
  10188. x.Remark
  10189. })
  10190. .WhereColumns(x => new { x.Id })
  10191. .ExecuteCommandAsync();
  10192. if (subUpd < 1) return Ok(JsonView(false));
  10193. }
  10194. #endregion
  10195. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10196. //消息通知
  10197. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10198. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10199. }
  10200. /// <summary>
  10201. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10202. /// </summary>
  10203. /// <returns></returns>
  10204. [HttpPost]
  10205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10206. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10207. {
  10208. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10209. if (data.Code != 0)
  10210. {
  10211. return Ok(JsonView(false, data.Msg));
  10212. }
  10213. return Ok(JsonView(true, "操作成功!", data.Data));
  10214. }
  10215. /// <summary>
  10216. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10217. /// </summary>
  10218. /// <param name="dto"></param>
  10219. /// <returns></returns>
  10220. [HttpPost]
  10221. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10222. {
  10223. var data = new Grp_DayOtherPrice()
  10224. {
  10225. Id = dto.Id,
  10226. IsDel = 1,
  10227. DeleteUserId = dto.DeleteUserId,
  10228. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10229. };
  10230. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10231. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10232. return Ok(JsonView(false, "删除失败!"));
  10233. }
  10234. #endregion
  10235. #endregion
  10236. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10237. /// <summary>
  10238. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10239. /// </summary>
  10240. /// <returns></returns>
  10241. [HttpGet]
  10242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10243. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10244. {
  10245. var provData = await _groupRepository.ProvinceBasicSource();
  10246. return Ok(JsonView(true, "查询成功!", provData));
  10247. }
  10248. /// <summary>
  10249. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10250. /// </summary>
  10251. /// <returns></returns>
  10252. [HttpPost]
  10253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10254. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10255. {
  10256. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10257. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10258. RefAsync<int> total = 0;
  10259. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10260. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10261. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10262. .Select(x => new
  10263. {
  10264. Id = x.Id,
  10265. DraftName = x.DraftName,
  10266. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10267. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10268. .Any()
  10269. })
  10270. .OrderByDescending(x => x.Id)
  10271. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10272. return Ok(JsonView(true, "查询成功!", data, total));
  10273. }
  10274. /// <summary>
  10275. /// 出入境费用-草稿 移动端
  10276. /// 获取币种基础数据(含逻辑处理)
  10277. /// </summary>
  10278. /// <returns></returns>
  10279. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10280. {
  10281. return await GeneralMethod.EnterExitCostInitRate();
  10282. }
  10283. /// <summary>
  10284. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10285. /// </summary>
  10286. /// <returns></returns>
  10287. [HttpPost]
  10288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10289. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10290. {
  10291. //验证城市归属并给默认值
  10292. int provinceId = dto.ProvinceId;
  10293. if (provinceId < 1) provinceId = 122;
  10294. var dataSource = await _sqlSugar
  10295. .Queryable<Sys_SetData>()
  10296. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10297. .ToListAsync();
  10298. //三公费用-Word明细类型
  10299. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10300. .Select(x => new SetDataInfoView
  10301. {
  10302. Id = x.Id,
  10303. Name = x.Name,
  10304. Remark = x.Remark
  10305. })
  10306. .ToList();
  10307. //三公费用-Excel明细类型
  10308. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10309. .Select(x => new SetDataInfoView
  10310. {
  10311. Id = x.Id,
  10312. Name = x.Name,
  10313. Remark = x.Remark
  10314. })
  10315. .ToList();
  10316. //默认币种显示
  10317. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10318. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10319. return Ok(JsonView(true, "查询成功!", new
  10320. {
  10321. WordTypeData = wordTypeData,
  10322. ExcelTypeData = excelTypeData,
  10323. CurrencyInit = _currencyInfos,
  10324. viewPermissionData = viewPermissionData
  10325. }));
  10326. }
  10327. /// <summary>
  10328. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10329. /// </summary>
  10330. /// <returns></returns>
  10331. [HttpPost]
  10332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10333. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10334. {
  10335. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10336. RefAsync<int> total = 0;
  10337. int diId = 0;
  10338. var status = int.TryParse(dto.GroupName, out diId);
  10339. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10340. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10341. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10342. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10343. .OrderByDescending(x => x.VisitStartDate)
  10344. .Select(x => new
  10345. {
  10346. Id = x.Id,
  10347. GroupName = x.TeamName
  10348. })
  10349. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10350. return Ok(JsonView(true, "查询成功!", data, total));
  10351. }
  10352. /// <summary>
  10353. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10354. /// </summary>
  10355. /// <returns></returns>
  10356. [HttpPost]
  10357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10358. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10359. {
  10360. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10361. RefAsync<int> total = 0;
  10362. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10363. .Where(x => x.IsDel == 0 && x.STid == 66)
  10364. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10365. .Select(x => new
  10366. {
  10367. id = x.Id,
  10368. name = x.Name,
  10369. remark = x.Remark,
  10370. })
  10371. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10372. return Ok(JsonView(true, "查询成功!", data, total));
  10373. }
  10374. /// <summary>
  10375. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10376. /// </summary>
  10377. /// <returns></returns>
  10378. [HttpPost]
  10379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10380. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10381. {
  10382. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10383. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10384. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10385. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10386. var groupOtherRateData = groupRateData.TeamRates;
  10387. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10388. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10389. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10390. groupOtherRateData = groupOtherRateData
  10391. .Select(x => new TeamRateDescAddCurrencyIdView
  10392. {
  10393. CurrencyId = x.CurrencyId,
  10394. CurrencyName = x.CurrencyName,
  10395. CurrencyCode = x.CurrencyCode,
  10396. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10397. }).ToList();
  10398. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10399. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10400. }
  10401. /// <summary>
  10402. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10403. /// </summary>
  10404. /// <returns></returns>
  10405. [HttpPost]
  10406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10407. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10408. {
  10409. int portType = dto.PortType;
  10410. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10411. var tipsData = new List<int>() { 1, 2, 3 };
  10412. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10413. if (dto.TipsType == 1)
  10414. {
  10415. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10416. }
  10417. else if (dto.TipsType == 2)
  10418. {
  10419. if (portType == 2)
  10420. {
  10421. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10422. }
  10423. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10424. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10425. .Select(x => x.NationalTravelFeeId)
  10426. .Distinct()
  10427. .ToListAsync();
  10428. if (portType == 2)
  10429. {
  10430. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10431. }
  10432. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10433. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10434. .Select(x => x.Country)
  10435. .Distinct()
  10436. .ToArrayAsync();
  10437. if (portType == 2)
  10438. {
  10439. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10440. }
  10441. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10442. return Ok(JsonView(true, "查询成功!", new
  10443. {
  10444. totalAmt = totalAmt,
  10445. remark = remark
  10446. }));
  10447. }
  10448. else if (dto.TipsType == 3)
  10449. {
  10450. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10451. }
  10452. return Ok(JsonView(false));
  10453. }
  10454. /// <summary>
  10455. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10456. /// </summary>
  10457. /// <returns></returns>
  10458. [HttpPost]
  10459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10460. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10461. {
  10462. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10463. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10464. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10465. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10466. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10467. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10468. var info = new Grp_EnterExitCostDraft()
  10469. {
  10470. ProvinceId = dto.ProvinceId,
  10471. DraftName = dto.DraftName,
  10472. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10473. CreateUserId = dto.CurrUserId
  10474. };
  10475. _sqlSugar.BeginTran();
  10476. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10477. if (draftId < 1)
  10478. {
  10479. _sqlSugar.RollbackTran();
  10480. return Ok(JsonView(false, "草稿创建失败!"));
  10481. }
  10482. //添加默认权限
  10483. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10484. _sqlSugar.CommitTran();
  10485. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10486. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10487. mobileInfo.Id = draftId;
  10488. mobileInfo.DraftName = dto.DraftName;
  10489. mobileInfo.Currencys = rateInfos;
  10490. mobileInfo.IsAssignPerm = assignPerm;
  10491. return Ok(JsonView(mobileInfo));
  10492. }
  10493. /// <summary>
  10494. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10495. /// </summary>
  10496. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10497. /// <summary>
  10498. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10499. /// </summary>
  10500. /// <returns></returns>
  10501. [HttpPost]
  10502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10503. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10504. {
  10505. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10506. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10507. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10508. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10509. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10510. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10511. //验证查看编辑权限
  10512. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10513. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10514. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10515. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10516. mobileInfo.IsAssignPerm = assignPerm;
  10517. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10518. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10519. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10520. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10521. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10522. {
  10523. ParentId = dac.ParentId,
  10524. SubId = dac.Id,
  10525. Type = dac.Type,
  10526. Days = dac.Days,
  10527. NationalTravelFeeId = dac.NationalTravelFeeId,
  10528. Arae = $"{ntf.Country}-{ntf.City}",
  10529. Cost = dac.Cost,
  10530. Currency = dac.Currency,
  10531. CurrencyName = sd.Name,
  10532. SubTotal = dac.SubTotal,
  10533. })
  10534. .ToList();
  10535. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10536. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10537. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10538. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10539. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10540. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10541. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10542. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10543. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10544. //其他款项
  10545. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10546. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10547. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10548. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10549. .OrderBy((dop, sd1, sd2) => dop.Index)
  10550. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10551. {
  10552. ParentId = dop.ParentId,
  10553. SubId = dop.Id,
  10554. Index = dop.Index,
  10555. SetDataId = dop.SetDataId,
  10556. SetDataName = sd1.Name,
  10557. Cost = dop.Cost,
  10558. Currency = dop.Currency,
  10559. CurrencyName = sd2.Remark,
  10560. SubTotal = dop.SubTotal,
  10561. Remark = dop.Remark,
  10562. })
  10563. .ToArray();
  10564. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10565. return Ok(mobileInfo);
  10566. }
  10567. /// <summary>
  10568. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10569. /// </summary>
  10570. /// <returns></returns>
  10571. [HttpPost]
  10572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10573. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10574. {
  10575. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10576. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10577. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10578. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10579. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10580. //验证查看编辑权限
  10581. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10582. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10583. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10584. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10585. var subType = dto.SubType;
  10586. if (subType == 1) //1:境内费用
  10587. {
  10588. var oneData = new ChoiceOneMobileSubInfoView()
  10589. {
  10590. Id = eecInfo.Id,
  10591. ChoiceOne = eecInfo.ChoiceOne,
  10592. ChoiceOneTotalCost = eecInfo.InsidePay,
  10593. Visa = eecInfo.Visa,
  10594. VisaRemark = eecInfo.VisaRemark,
  10595. YiMiao = eecInfo.YiMiao,
  10596. HeSuan = eecInfo.HeSuan,
  10597. Service = eecInfo.Service,
  10598. Ticket = eecInfo.Ticket,
  10599. Safe = eecInfo.Safe,
  10600. FirstItemRemark = eecInfo.FirstItemRemark
  10601. };
  10602. return Ok(JsonView(oneData));
  10603. }
  10604. else if (subType == 2) //2:国际旅费
  10605. {
  10606. var twoData = new ChoiceTwoMobileSubInfoView()
  10607. {
  10608. Id = eecInfo.Id,
  10609. ChoiceTwoJJ = eecInfo.SumJJC,
  10610. OutsideJJPay = eecInfo.OutsideJJPay,
  10611. ChoiceTwoGW = eecInfo.SumGWC,
  10612. OutsideGWPay = eecInfo.OutsideGWPay,
  10613. ChoiceTwoTD = eecInfo.SumTDC,
  10614. OutsideTDPay = eecInfo.OutsideTDPay,
  10615. AirJJ = eecInfo.AirJJ,
  10616. AirGW = eecInfo.AirGW,
  10617. AirTD = eecInfo.AirTD,
  10618. CityTranffic = eecInfo.CityTranffic,
  10619. TwoItemRemark = eecInfo.TwoItemRemark
  10620. };
  10621. return Ok(JsonView(twoData));
  10622. }
  10623. else if (subType == 3) //3:住宿费
  10624. {
  10625. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10626. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10627. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10628. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10629. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10630. {
  10631. ParentId = dac.ParentId,
  10632. SubId = dac.Id,
  10633. Type = dac.Type,
  10634. Days = dac.Days,
  10635. NationalTravelFeeId = dac.NationalTravelFeeId,
  10636. Arae = $"{ntf.Country}-{ntf.City}",
  10637. Cost = dac.Cost,
  10638. Currency = dac.Currency,
  10639. CurrencyName = sd.Name,
  10640. SubTotal = dac.SubTotal,
  10641. })
  10642. .ToArray();
  10643. var data = new ChoiceDraftMobileSubInfo3To6View()
  10644. {
  10645. ParentId = eecInfo.Id,
  10646. Choice = eecInfo.ChoiceThree,
  10647. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10648. Details = dayAndCostDatas
  10649. };
  10650. return Ok(JsonView(data));
  10651. }
  10652. else if (subType == 4) //4:伙食费
  10653. {
  10654. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10655. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10656. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10657. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10658. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10659. {
  10660. ParentId = dac.ParentId,
  10661. SubId = dac.Id,
  10662. Type = dac.Type,
  10663. Days = dac.Days,
  10664. NationalTravelFeeId = dac.NationalTravelFeeId,
  10665. Arae = $"{ntf.Country}-{ntf.City}",
  10666. Cost = dac.Cost,
  10667. Currency = dac.Currency,
  10668. CurrencyName = sd.Name,
  10669. SubTotal = dac.SubTotal,
  10670. })
  10671. .ToArray();
  10672. var data = new ChoiceDraftMobileSubInfo3To6View()
  10673. {
  10674. ParentId = eecInfo.Id,
  10675. Choice = eecInfo.ChoiceFour,
  10676. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10677. Details = dayAndCostDatas
  10678. };
  10679. return Ok(JsonView(data));
  10680. }
  10681. else if (subType == 5) //5:公杂费
  10682. {
  10683. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10684. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10685. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10686. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10687. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10688. {
  10689. ParentId = dac.ParentId,
  10690. SubId = dac.Id,
  10691. Type = dac.Type,
  10692. Days = dac.Days,
  10693. NationalTravelFeeId = dac.NationalTravelFeeId,
  10694. Arae = $"{ntf.Country}-{ntf.City}",
  10695. Cost = dac.Cost,
  10696. Currency = dac.Currency,
  10697. CurrencyName = sd.Name,
  10698. SubTotal = dac.SubTotal,
  10699. })
  10700. .ToArray();
  10701. var data = new ChoiceDraftMobileSubInfo3To6View()
  10702. {
  10703. ParentId = eecInfo.Id,
  10704. Choice = eecInfo.ChoiceFive,
  10705. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10706. Details = dayAndCostDatas
  10707. };
  10708. return Ok(JsonView(data));
  10709. }
  10710. else if (subType == 6) //6:培训费
  10711. {
  10712. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10713. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10714. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10715. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10716. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10717. {
  10718. ParentId = dac.ParentId,
  10719. SubId = dac.Id,
  10720. Type = dac.Type,
  10721. Days = dac.Days,
  10722. NationalTravelFeeId = dac.NationalTravelFeeId,
  10723. Arae = $"{ntf.Country}-{ntf.City}",
  10724. Cost = dac.Cost,
  10725. Currency = dac.Currency,
  10726. CurrencyName = sd.Name,
  10727. SubTotal = dac.SubTotal,
  10728. })
  10729. .ToArray();
  10730. var data = new ChoiceDraftMobileSubInfo3To6View()
  10731. {
  10732. ParentId = eecInfo.Id,
  10733. Choice = eecInfo.ChoiceSix,
  10734. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10735. Details = dayAndCostDatas
  10736. };
  10737. return Ok(JsonView(data));
  10738. }
  10739. else if (subType == 7) //7:其他
  10740. {
  10741. //其他款项
  10742. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10743. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10744. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10745. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10746. .OrderBy((dop, sd1, sd2) => dop.Index)
  10747. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10748. {
  10749. ParentId = dop.ParentId,
  10750. SubId = dop.Id,
  10751. Index = dop.Index,
  10752. SetDataId = dop.SetDataId,
  10753. SetDataName = sd1.Name,
  10754. Cost = dop.Cost,
  10755. Currency = dop.Currency,
  10756. CurrencyName = sd2.Name,
  10757. SubTotal = dop.SubTotal,
  10758. Remark = dop.Remark,
  10759. })
  10760. .ToArray();
  10761. var data = new ChoiceSevenDraftMobileSubInfoView()
  10762. {
  10763. ParentId = eecInfo.Id,
  10764. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10765. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10766. Details = otherData
  10767. };
  10768. return Ok(JsonView(data));
  10769. }
  10770. return Ok(JsonView(false));
  10771. }
  10772. #region op
  10773. /// <summary>
  10774. /// 移动端更新费用消息通知
  10775. /// </summary>
  10776. /// <param name="draftId"></param>
  10777. /// <param name="id"></param>
  10778. /// <param name="currUserId"></param>
  10779. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10780. {
  10781. try
  10782. {
  10783. ////生成默认文件pdf并且通知人员
  10784. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10785. //{
  10786. // DiId = draftId,
  10787. // ExportType = 1,
  10788. // SubTypeId = 1005
  10789. //}, "pdf");
  10790. ////发送通知
  10791. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10792. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10793. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10794. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10795. ////汇率信息记录
  10796. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10797. }
  10798. catch (Exception ex)
  10799. {
  10800. //记录日志
  10801. throw;
  10802. }
  10803. }
  10804. /// <summary>
  10805. /// 验证出入境费用数据是否存在
  10806. /// 不存在添加
  10807. /// </summary>
  10808. /// <param name="draftId"></param>
  10809. /// <param name="currUserId"></param>
  10810. /// <returns></returns>
  10811. /// <exception cref="CustomException"></exception>
  10812. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10813. {
  10814. var parentId = 0;
  10815. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10816. if (info != null) parentId = info.Id;
  10817. else
  10818. {
  10819. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10820. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10821. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10822. parentId = addId;
  10823. }
  10824. return parentId;
  10825. }
  10826. /// <summary>
  10827. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10828. /// </summary>
  10829. /// <returns></returns>
  10830. [HttpPost]
  10831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10832. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10833. {
  10834. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10835. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10836. //验证查看权限
  10837. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10838. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10839. var userIds = await _sqlSugar
  10840. .Queryable<Grp_EnterExitCostDraftPermission>()
  10841. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10842. .Select(x => x.UserId)
  10843. .ToArrayAsync();
  10844. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10845. var perUsersView = new List<dynamic>();
  10846. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10847. var viewPermissionData = new List<PermissionViewUserview>();
  10848. if (feeBasePerm.Any())
  10849. {
  10850. foreach (var item in feeBasePerm)
  10851. {
  10852. if (item.Users.Any())
  10853. {
  10854. viewPermissionData.AddRange(item.Users);
  10855. }
  10856. }
  10857. }
  10858. foreach (var item in perUsers)
  10859. {
  10860. bool isView1 = false;
  10861. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10862. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10863. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10864. }
  10865. return Ok(JsonView(perUsersView));
  10866. }
  10867. /// <summary>
  10868. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10869. /// </summary>
  10870. /// <returns></returns>
  10871. [HttpPost]
  10872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10873. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10874. {
  10875. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10876. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10877. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10878. //验证查看编辑权限
  10879. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10880. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10881. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10882. foreach (var userId in dto.UserIds)
  10883. {
  10884. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10885. }
  10886. if (permissions.Any())
  10887. {
  10888. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10889. {
  10890. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10891. }
  10892. _sqlSugar.BeginTran();
  10893. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10894. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10895. if (result < 1)
  10896. {
  10897. _sqlSugar.RollbackTran();
  10898. return Ok(JsonView(false));
  10899. }
  10900. _sqlSugar.CommitTran();
  10901. return Ok(JsonView(true));
  10902. }
  10903. return Ok(JsonView(false));
  10904. }
  10905. /// <summary>
  10906. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10907. /// </summary>
  10908. /// <returns></returns>
  10909. [HttpPost]
  10910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10911. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  10912. {
  10913. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10914. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10915. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10916. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  10917. int id = dto.DraftId;
  10918. if (id <= 0) //add
  10919. {
  10920. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10921. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10922. if (add < 1) return Ok(JsonView(false));
  10923. id = add;
  10924. }
  10925. else //update
  10926. {
  10927. //验证查看编辑权限
  10928. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10929. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10930. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10931. if (upd < 1) return Ok(JsonView(false));
  10932. }
  10933. return Ok(JsonView(new { parentId = id }));
  10934. }
  10935. /// <summary>
  10936. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  10937. /// </summary>
  10938. /// <returns></returns>
  10939. [HttpPost]
  10940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10941. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  10942. {
  10943. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10944. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10945. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10946. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10947. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10948. int id = dto.DraftId;
  10949. if (id <= 0) //add
  10950. {
  10951. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10952. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10953. if (add < 1) return Ok(JsonView(false));
  10954. id = add;
  10955. }
  10956. else //update
  10957. {
  10958. //验证查看编辑权限
  10959. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10960. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10961. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10962. if (upd < 1) return Ok(JsonView(false));
  10963. }
  10964. #region 汇率变更时更改币种相关费用
  10965. var opDayCosts = new List<Grp_DayAndCostDraft>();
  10966. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  10967. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10968. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10969. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10970. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10971. .Select((dac, sd) => new
  10972. {
  10973. dac.Id,
  10974. dac.ParentId,
  10975. CurrencyCode = sd.Name,
  10976. dac.Cost
  10977. })
  10978. .ToList();
  10979. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10980. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10981. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10982. .Select((dop, sd) => new
  10983. {
  10984. dop.Id,
  10985. dop.ParentId,
  10986. CurrencyCode = sd.Name,
  10987. dop.Cost
  10988. })
  10989. .ToList();
  10990. if (dayCosts.Count > 0)
  10991. {
  10992. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10993. foreach (var dc in new_dayCosts)
  10994. {
  10995. var thisCurrency = dc.Key.ToUpper();
  10996. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10997. if (thisRate == 0.00M) continue;
  10998. foreach (var dcSub in dc)
  10999. {
  11000. opDayCosts.Add(new Grp_DayAndCostDraft()
  11001. {
  11002. Id = dcSub.Id,
  11003. ParentId = dcSub.ParentId,
  11004. Cost = dcSub.Cost,
  11005. SubTotal = dcSub.Cost * thisRate,
  11006. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11007. });
  11008. }
  11009. }
  11010. if (opDayCosts.Count > 0)
  11011. {
  11012. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11013. }
  11014. }
  11015. if (dayOtherCosts.Count > 0)
  11016. {
  11017. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11018. foreach (var dc in new_dayOtherCosts)
  11019. {
  11020. var thisCurrency = dc.Key.ToUpper();
  11021. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11022. if (thisRate == 0.00M) continue;
  11023. foreach (var dcSub in dc)
  11024. {
  11025. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11026. {
  11027. Id = dcSub.Id,
  11028. ParentId = dcSub.ParentId,
  11029. Cost = dcSub.Cost,
  11030. SubTotal = dcSub.Cost * thisRate,
  11031. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11032. });
  11033. }
  11034. }
  11035. if (opDayOtherCosts.Count > 0)
  11036. {
  11037. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11038. }
  11039. }
  11040. #endregion
  11041. ////消息通知
  11042. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11043. ////汇率信息记录
  11044. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11045. return Ok(JsonView(new { parentId = id }));
  11046. }
  11047. /// <summary>
  11048. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11049. /// </summary>
  11050. /// <returns></returns>
  11051. [HttpPost]
  11052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11053. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11054. {
  11055. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11056. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11057. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11058. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11059. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11060. int id = dto.DraftId;
  11061. if (id <= 0) //add
  11062. {
  11063. checkboxInfo.ProvinceId = dto.ProvinceId;
  11064. checkboxInfo.CreateUserId = dto.CurrUserId;
  11065. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11066. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11067. if (add < 1) return Ok(JsonView(false));
  11068. }
  11069. else //update
  11070. {
  11071. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11072. .UpdateColumns(x => new
  11073. {
  11074. x.ChoiceOne,
  11075. x.ChoiceTwo,
  11076. x.SumJJC,
  11077. x.SumGWC,
  11078. x.SumTDC,
  11079. x.ChoiceThree,
  11080. x.ChoiceFour,
  11081. x.ChoiceFive,
  11082. x.ChoiceSix,
  11083. x.OtherExpenses_Checked
  11084. })
  11085. .Where(x => x.Id == id)
  11086. .ExecuteCommandAsync();
  11087. if (upd < 1) return Ok(JsonView(false));
  11088. }
  11089. return Ok(JsonView(new { parentId = id }));
  11090. }
  11091. /// <summary>
  11092. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11093. /// </summary>
  11094. /// <returns></returns>
  11095. [HttpPost]
  11096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11097. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11098. {
  11099. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11100. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11101. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11102. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11103. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11104. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11105. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11106. var checkboxInfo = new Grp_EnterExitCostDraft()
  11107. {
  11108. Id = draftId,
  11109. ProvinceId = dto.ProvinceId,
  11110. CreateUserId = currUserId
  11111. };
  11112. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11113. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11114. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11115. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11116. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11117. if (draftId <= 0) //add
  11118. {
  11119. checkboxInfo.CreateUserId = dto.CurrUserId;
  11120. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11121. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11122. if (add < 1) return Ok(JsonView(false));
  11123. }
  11124. else //update
  11125. {
  11126. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11127. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11128. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11129. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11130. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11131. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11132. .Where(x => x.Id == draftId)
  11133. .ExecuteCommandAsync();
  11134. if (upd < 1) return Ok(JsonView(false));
  11135. }
  11136. return Ok(JsonView(new { parentId = draftId }));
  11137. }
  11138. /// <summary>
  11139. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11140. /// </summary>
  11141. /// <returns></returns>
  11142. [HttpPost]
  11143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11144. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11145. {
  11146. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11147. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11148. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11149. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11150. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11151. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11152. info.ProvinceId = dto.ProvinceId;
  11153. info.FirstItemRemark = dto.FirstItemRemark;
  11154. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11155. if (id <= 0) //add
  11156. {
  11157. info.CreateUserId = dto.CurrUserId;
  11158. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11159. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11160. if (add < 1) return Ok(JsonView(false));
  11161. id = add;
  11162. }
  11163. else //update
  11164. {
  11165. var upd = await _sqlSugar.Updateable(info)
  11166. .UpdateColumns(x => new
  11167. {
  11168. x.ChoiceOne,
  11169. x.InsidePay,
  11170. x.VisaRemark,
  11171. x.Visa,
  11172. x.Service,
  11173. x.Safe,
  11174. x.Ticket,
  11175. x.HeSuan,
  11176. x.YiMiao,
  11177. x.FirstItemRemark
  11178. })
  11179. .Where(x => x.Id == id)
  11180. .ExecuteCommandAsync();
  11181. if (upd < 1) return Ok(JsonView(false));
  11182. }
  11183. ////消息通知
  11184. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11185. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11186. }
  11187. /// <summary>
  11188. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11189. /// </summary>
  11190. /// <returns></returns>
  11191. [HttpPost]
  11192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11193. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11194. {
  11195. int id = dto.DraftId;
  11196. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11197. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11198. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11199. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11200. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11201. info.ProvinceId = dto.ProvinceId;
  11202. info.OutsideJJPay = dto.OutsideJJPay;
  11203. info.OutsideGWPay = dto.OutsideGWPay;
  11204. info.OutsideTDPay = dto.OutsideTDPay;
  11205. info.AirJJ = dto.AirJJ;
  11206. info.AirGW = dto.AirGW;
  11207. info.AirTD = dto.AirTD;
  11208. info.CityTranffic = dto.CityTranffic;
  11209. info.TwoItemRemark = dto.TwoItemRemark;
  11210. info.SumJJC = dto.ChoiceTwoJJ;
  11211. info.SumGWC = dto.ChoiceTwoGW;
  11212. info.SumTDC = dto.ChoiceTwoTD;
  11213. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11214. if (id <= 0) //add
  11215. {
  11216. info.CreateUserId = dto.CurrUserId;
  11217. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11218. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11219. if (addId <= 0) return Ok(JsonView(false));
  11220. id = addId;
  11221. }
  11222. else //update
  11223. {
  11224. var upd = await _sqlSugar.Updateable(info)
  11225. .UpdateColumns(x => new
  11226. {
  11227. x.SumJJC,
  11228. x.OutsideJJPay,
  11229. x.SumGWC,
  11230. x.OutsideGWPay,
  11231. x.SumTDC,
  11232. x.OutsideTDPay,
  11233. x.AirJJ,
  11234. x.AirGW,
  11235. x.AirTD,
  11236. x.CityTranffic,
  11237. x.TwoItemRemark
  11238. })
  11239. .Where(x => x.Id == id)
  11240. .ExecuteCommandAsync();
  11241. if (upd < 1) return Ok(JsonView(false));
  11242. }
  11243. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11244. gwcItemTotal = info.AirGW + info.CityTranffic;
  11245. tdcItemTotal = info.AirTD + info.CityTranffic;
  11246. ////消息通知
  11247. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11248. return Ok(JsonView(new
  11249. {
  11250. parentId = id,
  11251. choiceTwoJJ = dto.ChoiceTwoJJ,
  11252. jjcItemTotal = jjcItemTotal,
  11253. choiceTwoGW = dto.ChoiceTwoGW,
  11254. gwcItemTotal = gwcItemTotal,
  11255. choiceTwoTD = dto.ChoiceTwoTD,
  11256. tdcItemTotal = tdcItemTotal
  11257. }));
  11258. }
  11259. /// <summary>
  11260. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11261. /// </summary>
  11262. /// <returns></returns>
  11263. [HttpPost]
  11264. [ApiExplorerSettings(IgnoreApi = true)]
  11265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11266. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11267. {
  11268. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11269. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11270. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11271. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11272. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11273. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11274. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11275. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11276. {
  11277. Id = x.Id,
  11278. ParentId = dto.DraftId,
  11279. Type = dto.FeeType,
  11280. Days = x.Days,
  11281. NationalTravelFeeId = x.NationalTravelFeeId,
  11282. Cost = x.Cost,
  11283. Currency = x.Currency,
  11284. SubTotal = x.SubTotal,
  11285. CreateUserId = dto.CurrUserId
  11286. })
  11287. .ToList();
  11288. var adds = infos.Where(x => x.Id <= 0).ToList();
  11289. var upds = infos.Where(x => x.Id > 0).ToList();
  11290. if (adds.Count > 0)
  11291. {
  11292. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11293. if (add < 1) return Ok(JsonView(false));
  11294. }
  11295. if (upds.Count > 0)
  11296. {
  11297. var upd = await _sqlSugar.Updateable(adds)
  11298. .UpdateColumns(x => new
  11299. {
  11300. x.Days,
  11301. x.NationalTravelFeeId,
  11302. x.Cost,
  11303. x.Currency,
  11304. x.SubTotal
  11305. })
  11306. .WhereColumns(x => new { x.Id })
  11307. .ExecuteCommandAsync();
  11308. if (upd < 1) return Ok(JsonView(false));
  11309. }
  11310. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11311. ////消息通知
  11312. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11313. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11314. return Ok(JsonView(new { itemTotal = itemTotal }));
  11315. }
  11316. /// <summary>
  11317. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11318. /// </summary>
  11319. /// <returns></returns>
  11320. [HttpPost]
  11321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11322. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11323. {
  11324. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11325. int subId = dto.SubId, feeType = dto.FeeType;
  11326. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11327. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11328. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11329. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11330. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11331. subInfo.Id = subId;
  11332. subInfo.ParentId = dto.DraftId;
  11333. if (feeType == 3) subInfo.Type = 1;
  11334. else if (feeType == 4) subInfo.Type = 2;
  11335. else if (feeType == 5) subInfo.Type = 3;
  11336. else if (feeType == 6) subInfo.Type = 4;
  11337. subInfo.CreateUserId = dto.CurrUserId;
  11338. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11339. if (parentId < 1) return Ok(JsonView(false));
  11340. //子表op
  11341. if (subId < 1)
  11342. {
  11343. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11344. if (subAdd < 1) return Ok(JsonView(false));
  11345. }
  11346. else
  11347. {
  11348. var subUpd = await _sqlSugar.Updateable(subInfo)
  11349. .UpdateColumns(x => new
  11350. {
  11351. x.Days,
  11352. x.NationalTravelFeeId,
  11353. x.Cost,
  11354. x.Currency,
  11355. x.SubTotal
  11356. })
  11357. .WhereColumns(x => new { x.Id })
  11358. .ExecuteCommandAsync();
  11359. if (subUpd < 1) return Ok(JsonView(false));
  11360. }
  11361. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11362. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11363. }
  11364. /// <summary>
  11365. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11366. /// </summary>
  11367. /// <returns></returns>
  11368. [HttpPost]
  11369. [ApiExplorerSettings(IgnoreApi = true)]
  11370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11371. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11372. {
  11373. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11374. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11375. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11376. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11377. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11378. {
  11379. Id = x.Id,
  11380. ParentId = dto.DraftId,
  11381. SetDataId = x.SetDataId,
  11382. Index = x.Index,
  11383. Cost = x.Cost,
  11384. Currency = x.Currency,
  11385. SubTotal = x.SubTotal,
  11386. CreateUserId = dto.CurrUserId,
  11387. Remark = x.Remark
  11388. }).ToList();
  11389. var adds = infos.Where(x => x.Id <= 0).ToList();
  11390. var upds = infos.Where(x => x.Id > 0).ToList();
  11391. if (adds.Count > 0)
  11392. {
  11393. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11394. if (add < 1) return Ok(JsonView(false));
  11395. }
  11396. if (upds.Count > 0)
  11397. {
  11398. var upd = await _sqlSugar.Updateable(adds)
  11399. .UpdateColumns(x => new
  11400. {
  11401. x.Index,
  11402. x.SetDataId,
  11403. x.Cost,
  11404. x.Currency,
  11405. x.SubTotal,
  11406. x.Remark
  11407. })
  11408. .WhereColumns(x => new { x.Id })
  11409. .ExecuteCommandAsync();
  11410. if (upd < 1) return Ok(JsonView(false));
  11411. }
  11412. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11413. //消息通知
  11414. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11415. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11416. return Ok(JsonView(new { itemTotal = itemTotal }));
  11417. }
  11418. /// <summary>
  11419. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11420. /// </summary>
  11421. /// <returns></returns>
  11422. [HttpPost]
  11423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11424. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11425. {
  11426. int subId = dto.SubId, id = dto.DraftId;
  11427. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11428. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11429. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11430. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11431. subInfo.Id = subId;
  11432. subInfo.ParentId = id;
  11433. subInfo.CreateUserId = dto.CurrUserId;
  11434. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11435. if (parentId < 1) return Ok(JsonView(false));
  11436. #region 子表op
  11437. if (subId < 1)//add
  11438. {
  11439. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11440. if (subAdd < 1) return Ok(JsonView(false));
  11441. }
  11442. else //upd
  11443. {
  11444. var subUpd = await _sqlSugar.Updateable(subInfo)
  11445. .UpdateColumns(x => new
  11446. {
  11447. x.Index,
  11448. x.SetDataId,
  11449. x.Cost,
  11450. x.Currency,
  11451. x.SubTotal,
  11452. x.Remark
  11453. })
  11454. .WhereColumns(x => new { x.Id })
  11455. .ExecuteCommandAsync();
  11456. if (subUpd < 1) return Ok(JsonView(false));
  11457. }
  11458. #endregion
  11459. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11460. ////消息通知
  11461. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11462. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11463. }
  11464. /// <summary>
  11465. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11466. /// </summary>
  11467. /// <returns></returns>
  11468. [HttpPost]
  11469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11470. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11471. {
  11472. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11473. if (data.Code != 0)
  11474. {
  11475. return Ok(JsonView(false, data.Msg));
  11476. }
  11477. return Ok(JsonView(true, "操作成功!", data.Data));
  11478. }
  11479. /// <summary>
  11480. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11481. /// </summary>
  11482. /// <param name="dto"></param>
  11483. /// <returns></returns>
  11484. [HttpPost]
  11485. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11486. {
  11487. var data = new Grp_DayOtherPriceDraft()
  11488. {
  11489. Id = dto.Id,
  11490. IsDel = 1,
  11491. DeleteUserId = dto.DeleteUserId,
  11492. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11493. };
  11494. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11495. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11496. return Ok(JsonView(false, "删除失败!"));
  11497. }
  11498. #endregion
  11499. #endregion
  11500. #region 团组经理模块 出入境费用报价表
  11501. /// <summary>
  11502. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11503. /// </summary>
  11504. /// <returns></returns>
  11505. [HttpPost]
  11506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11507. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11508. {
  11509. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11510. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11511. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11512. initRates.Insert(0, cnyInfo);
  11513. liveRates.Insert(0, cnyInfo);
  11514. return Ok(JsonView(true, "查询成功!", new
  11515. {
  11516. InitRates = initRates,
  11517. LiveRates = liveRates
  11518. }));
  11519. }
  11520. /// <summary>
  11521. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11522. /// </summary>
  11523. /// <returns></returns>
  11524. [HttpPost]
  11525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11526. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11527. {
  11528. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11529. }
  11530. /// <summary>
  11531. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11532. /// </summary>
  11533. /// <returns></returns>
  11534. [HttpPost]
  11535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11536. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11537. {
  11538. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11539. }
  11540. /// <summary>
  11541. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11542. /// </summary>
  11543. /// <returns></returns>
  11544. [HttpPost]
  11545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11546. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11547. {
  11548. int groupId = dto.DiId,
  11549. currUserId = dto.CurrUserId;
  11550. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11551. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11552. //验证报价数据是否存在
  11553. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11554. if (isNull != null)
  11555. {
  11556. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11557. if (!info1.Rates.Any())
  11558. {
  11559. var rates = await GeneralMethod.EnterExitCostInitRate();
  11560. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11561. info1.Rates = rates.ToArray();
  11562. }
  11563. return Ok(JsonView(info1));
  11564. }
  11565. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11566. result.GroupId = groupId;
  11567. //处理报价名称
  11568. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11569. if (groupInfo != null)
  11570. {
  11571. var visitCountry = groupInfo.VisitCountry;
  11572. if (!string.IsNullOrEmpty(visitCountry))
  11573. {
  11574. string quoteName = string.Empty;
  11575. if (visitCountry.Contains("|"))
  11576. {
  11577. var countrys = visitCountry.Split("|");
  11578. quoteName = string.Join("、", countrys);
  11579. }
  11580. else quoteName = visitCountry;
  11581. quoteName += $"团组报价表";
  11582. result.Name = quoteName;
  11583. }
  11584. }
  11585. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11586. if (info.Code != StatusCodes.Status200OK)
  11587. {
  11588. if (!result.Rates.Any())
  11589. {
  11590. var rates = await GeneralMethod.EnterExitCostInitRate();
  11591. result.Rates = rates.ToArray();
  11592. }
  11593. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11594. }
  11595. var infoView = info.Data as EnterExitCostInfoView;
  11596. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11597. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11598. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11599. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11600. var eecRates = infoView.Currencys;
  11601. //默认添加人名币
  11602. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11603. {
  11604. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11605. }
  11606. //处理团组人数
  11607. int pplNum = 1;
  11608. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11609. var views = new List<QuoteSubItemInfo>();
  11610. #region 数据填充
  11611. var intTravelCosts = new List<QuoteSubItemInfo>();
  11612. #region 机票费用 1354
  11613. int intTravelIndex = 1;
  11614. if (infoView.SumJJC == 1)
  11615. {
  11616. intTravelCosts.Add(new QuoteSubItemInfo
  11617. {
  11618. ItemId = 1354,
  11619. Index = intTravelIndex,
  11620. FeeName = "经济舱",
  11621. UnitPrice = infoView.AirJJ,
  11622. Currency = "CNY",
  11623. Quantity = 1,
  11624. PplNum = 1,
  11625. TotalAmt = infoView.AirJJ,
  11626. Remark = "",
  11627. });
  11628. intTravelIndex++;
  11629. }
  11630. if (infoView.SumGWC == 1)
  11631. {
  11632. intTravelCosts.Add(new QuoteSubItemInfo
  11633. {
  11634. ItemId = 1354,
  11635. Index = intTravelIndex,
  11636. FeeName = "公务舱",
  11637. UnitPrice = infoView.AirGW,
  11638. Currency = "CNY",
  11639. Quantity = 1,
  11640. PplNum = 1,
  11641. TotalAmt = infoView.AirGW,
  11642. Remark = "",
  11643. });
  11644. intTravelIndex++;
  11645. }
  11646. if (infoView.SumTDC == 1)
  11647. {
  11648. intTravelCosts.Add(new QuoteSubItemInfo
  11649. {
  11650. ItemId = 1354,
  11651. Index = intTravelIndex,
  11652. FeeName = "头等舱",
  11653. UnitPrice = infoView.AirTD,
  11654. Currency = "CNY",
  11655. Quantity = 1,
  11656. PplNum = 1,
  11657. TotalAmt = infoView.AirTD,
  11658. Remark = "",
  11659. });
  11660. intTravelIndex++;
  11661. }
  11662. intTravelCosts.Add(new QuoteSubItemInfo
  11663. {
  11664. ItemId = 1354,
  11665. Index = intTravelIndex,
  11666. FeeName = "城市间交通费用",
  11667. UnitPrice = infoView.CityTranffic,
  11668. Currency = "CNY",
  11669. Quantity = 1,
  11670. PplNum = pplNum,
  11671. TotalAmt = infoView.CityTranffic * pplNum,
  11672. Remark = "",
  11673. });
  11674. views.AddRange(intTravelCosts);
  11675. #endregion
  11676. var accomCosts = new List<QuoteSubItemInfo>();
  11677. #region 住宿费 1355
  11678. if (infoView.QuarterageData.Any())
  11679. {
  11680. int accomIndex = 1;
  11681. int accomItemTypeId = 1355;
  11682. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11683. foreach (var item in groupData)
  11684. {
  11685. string feeName = string.Empty;
  11686. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11687. if (countryInfo != null)
  11688. {
  11689. feeName = countryInfo.Country;
  11690. var city = countryInfo.City;
  11691. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11692. {
  11693. feeName += $"-{city}";
  11694. }
  11695. }
  11696. var hotelInfo = item.FirstOrDefault();
  11697. if (hotelInfo == null) continue;
  11698. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11699. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11700. int quantity = item.ToList().Count;
  11701. accomCosts.Add(new QuoteSubItemInfo
  11702. {
  11703. ItemId = accomItemTypeId,
  11704. Index = accomIndex,
  11705. FeeName = feeName,
  11706. UnitPrice = hotelInfo.Cost,
  11707. Currency = thisCurrency,
  11708. Quantity = quantity,
  11709. PplNum = pplNum,
  11710. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11711. Remark = "",
  11712. });
  11713. accomIndex++;
  11714. }
  11715. views.AddRange(accomCosts);
  11716. }
  11717. #endregion
  11718. var mealCosts = new List<QuoteSubItemInfo>();
  11719. #region 餐饮费 1356
  11720. if (infoView.BoardWagesData.Any())
  11721. {
  11722. var mealIndex = 1;
  11723. int mealItemTypeId = 1356;
  11724. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11725. foreach (var item in groupData)
  11726. {
  11727. string feeName = string.Empty;
  11728. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11729. if (countryInfo != null)
  11730. {
  11731. feeName = countryInfo.Country;
  11732. var city = countryInfo.City;
  11733. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11734. {
  11735. feeName += $"-{city}";
  11736. }
  11737. }
  11738. var mealInfo = item.FirstOrDefault();
  11739. if (mealInfo == null) continue;
  11740. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11741. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11742. int quantity = item.ToList().Count;
  11743. mealCosts.Add(new QuoteSubItemInfo
  11744. {
  11745. ItemId = mealItemTypeId,
  11746. Index = mealIndex,
  11747. FeeName = feeName,
  11748. UnitPrice = mealInfo.Cost,
  11749. Currency = thisCurrency,
  11750. Quantity = quantity,
  11751. PplNum = pplNum,
  11752. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11753. Remark = "",
  11754. });
  11755. mealIndex++;
  11756. }
  11757. views.AddRange(mealCosts);
  11758. }
  11759. #endregion
  11760. var miscCosts = new List<QuoteSubItemInfo>();
  11761. #region 公杂费 1364
  11762. if (infoView.MiscellaneousFeeData.Any())
  11763. {
  11764. var miscIndex = 1;
  11765. int miscItemTypeId = 1364;
  11766. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11767. foreach (var item in groupData)
  11768. {
  11769. string feeName = string.Empty;
  11770. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11771. if (countryInfo != null)
  11772. {
  11773. feeName = countryInfo.Country;
  11774. var city = countryInfo.City;
  11775. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11776. {
  11777. feeName += $"-{city}";
  11778. }
  11779. }
  11780. var miscInfo = item.FirstOrDefault();
  11781. if (miscInfo == null) continue;
  11782. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11783. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11784. int quantity = item.ToList().Count;
  11785. miscCosts.Add(new QuoteSubItemInfo
  11786. {
  11787. ItemId = miscItemTypeId,
  11788. Index = miscIndex,
  11789. FeeName = feeName,
  11790. UnitPrice = miscInfo.Cost,
  11791. Currency = thisCurrency,
  11792. Quantity = quantity,
  11793. PplNum = pplNum,
  11794. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11795. Remark = "",
  11796. });
  11797. miscIndex++;
  11798. }
  11799. views.AddRange(miscCosts);
  11800. }
  11801. #endregion
  11802. #region 签证+保险 1362
  11803. int visaInsIndex = 1;
  11804. int visaInsItemTypeId = 1362;
  11805. if (infoView.Visa > 0)
  11806. {
  11807. views.Add(new QuoteSubItemInfo()
  11808. {
  11809. ItemId = visaInsItemTypeId,
  11810. Index = visaInsIndex,
  11811. FeeName = $"签证",
  11812. UnitPrice = infoView.Visa,
  11813. Currency = $"CNY",
  11814. Quantity = 1,
  11815. PplNum = pplNum,
  11816. TotalAmt = infoView.Visa * pplNum,
  11817. Remark = "",
  11818. });
  11819. visaInsIndex++;
  11820. }
  11821. if (infoView.Safe > 0)
  11822. {
  11823. views.Add(new QuoteSubItemInfo()
  11824. {
  11825. ItemId = visaInsItemTypeId,
  11826. Index = visaInsIndex,
  11827. FeeName = $"保险",
  11828. UnitPrice = infoView.Safe,
  11829. Currency = $"CNY",
  11830. Quantity = 1,
  11831. PplNum = pplNum,
  11832. TotalAmt = infoView.Safe * pplNum,
  11833. Remark = "",
  11834. });
  11835. }
  11836. #endregion
  11837. #region 服务费 1363
  11838. int serviceFeeIndex = 1;
  11839. int serviceFeeItemTypeId = 1363;
  11840. if (infoView.Service > 0)
  11841. {
  11842. views.Add(new QuoteSubItemInfo()
  11843. {
  11844. ItemId = serviceFeeItemTypeId,
  11845. Index = serviceFeeIndex,
  11846. FeeName = $"服务费",
  11847. UnitPrice = infoView.Service,
  11848. Currency = $"CNY",
  11849. Quantity = 1,
  11850. PplNum = pplNum,
  11851. TotalAmt = infoView.Service * pplNum,
  11852. Remark = "",
  11853. });
  11854. }
  11855. #endregion
  11856. #endregion
  11857. if (result.FeeItems.Any())
  11858. {
  11859. result.FeeItems.Select(x =>
  11860. {
  11861. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11862. if (feeInfos.Any()) x.Infos = feeInfos;
  11863. return x;
  11864. }
  11865. ).OrderBy(x => x.Index)
  11866. .ToList();
  11867. if (!result.Rates.Any())
  11868. {
  11869. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  11870. else
  11871. {
  11872. var rates = await GeneralMethod.EnterExitCostInitRate();
  11873. rates.Insert(0,new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11874. result.Rates = rates.ToArray();
  11875. }
  11876. }
  11877. }
  11878. return Ok(JsonView(result));
  11879. }
  11880. /// <summary>
  11881. /// 团组模块 - 出入境费用报价表 - Info
  11882. /// </summary>
  11883. /// <returns></returns>
  11884. [HttpPost]
  11885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11886. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11887. {
  11888. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11889. if (!info.Rates.Any())
  11890. {
  11891. var rates = await GeneralMethod.EnterExitCostInitRate();
  11892. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11893. info.Rates = rates.ToArray();
  11894. }
  11895. return Ok(JsonView(info));
  11896. }
  11897. /// <summary>
  11898. /// 团组模块 - 出入境费用报价表 - OP
  11899. /// </summary>
  11900. /// <returns></returns>
  11901. [HttpPost]
  11902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11903. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11904. {
  11905. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11906. }
  11907. /// <summary>
  11908. /// 团组模块 - 出入境费用报价表 - 删除 项
  11909. /// </summary>
  11910. /// <returns></returns>
  11911. [HttpPost]
  11912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11913. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  11914. {
  11915. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11916. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11917. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  11918. }
  11919. /// <summary>
  11920. /// 团组模块 - 出入境费用报价表 - 导出
  11921. /// </summary>
  11922. /// <returns></returns>
  11923. [HttpPost]
  11924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11925. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  11926. {
  11927. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11928. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11929. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  11930. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  11931. var rates = info.Rates;
  11932. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  11933. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  11934. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  11935. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  11936. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  11937. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  11938. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  11939. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  11940. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  11941. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  11942. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  11943. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  11944. //获取模板
  11945. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  11946. var designer = new WorkbookDesigner();
  11947. designer.Workbook = new Workbook(tempPath);
  11948. designer.SetDataSource("QuoteName", info.Name);
  11949. designer.SetDataSource("CompanyTitle", "公司名称");
  11950. designer.SetDataSource("CompanyLabel", "");
  11951. #region 国际旅费
  11952. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  11953. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  11954. {
  11955. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  11956. StringBuilder label = new StringBuilder();
  11957. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  11958. if (infos.Any())
  11959. {
  11960. label.Append(infos.Sum(x => x.PplNum));
  11961. label.Append("人全程机票:");
  11962. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  11963. label.AppendLine("元");
  11964. }
  11965. foreach (var item in intTravelCosts.Infos)
  11966. {
  11967. label.Append(item.FeeName);
  11968. label.Append(":");
  11969. label.Append(item.UnitPrice.TruncDecimals(2));
  11970. label.Append("元/人*");
  11971. label.Append(item.PplNum);
  11972. label.AppendLine("人");
  11973. }
  11974. if (label.HasValue())
  11975. {
  11976. label.Append("\r\n以上小计:");
  11977. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  11978. label.Append("元");
  11979. }
  11980. designer.SetDataSource("IntTravelLabel", label.ToString());
  11981. }
  11982. #endregion
  11983. #region 住宿费
  11984. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  11985. if (accomCosts!=null && accomCosts.Infos.Any())
  11986. {
  11987. string currencyName = string.Empty,
  11988. countryName = string.Empty;
  11989. decimal rate = 1.0000M;
  11990. StringBuilder label = new StringBuilder();
  11991. label.AppendLine("全程五星酒店,每人1间房");
  11992. foreach (var item in accomCosts.Infos)
  11993. {
  11994. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  11995. string name = string.Empty, thisCountryName = string.Empty;
  11996. if (item.FeeName.Contains("-"))
  11997. {
  11998. var feeName = item.FeeName.Split('-');
  11999. thisCountryName = feeName[0];
  12000. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12001. name = feeName[1];
  12002. }
  12003. else name = item.FeeName;
  12004. string thisFeeName = string.Empty;
  12005. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12006. else thisFeeName = $"\r\n{name}:";
  12007. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12008. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12009. rate = rateInfo?.Rate ?? 1.0000M;
  12010. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12011. label.AppendLine(subLabel);
  12012. }
  12013. if (label.HasValue())
  12014. {
  12015. //以上小计:52440元(美金汇率:7.5 )
  12016. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12017. label.AppendLine(subLabel);
  12018. }
  12019. designer.SetDataSource("AccomLabel", label.ToString());
  12020. }
  12021. #endregion
  12022. #region 餐饮费
  12023. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12024. if (mealCosts != null && mealCosts.Infos.Any())
  12025. {
  12026. string currencyName = string.Empty;
  12027. decimal rate = 1.0000M;
  12028. StringBuilder label = new StringBuilder();
  12029. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12030. foreach (var item in mealCosts.Infos)
  12031. {
  12032. string name = string.Empty;
  12033. if (item.FeeName.Contains("-"))
  12034. {
  12035. var feeName = item.FeeName.Split('-');
  12036. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12037. }
  12038. else name = $"\r\n{item.FeeName}:";
  12039. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12040. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12041. rate = rateInfo?.Rate ?? 1.0000M;
  12042. label.Append(name);
  12043. label.Append(item.UnitPrice.TruncDecimals(2));
  12044. label.Append(currencyName);
  12045. label.Append("/天*");
  12046. label.Append(item.Quantity.ToString("#0"));
  12047. label.Append("*");
  12048. label.Append(item.PplNum);
  12049. label.Append("人\r\n");
  12050. }
  12051. if (label.HasValue())
  12052. {
  12053. label.Append("\r\n以上小计:");
  12054. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12055. label.Append("元\r\n(");
  12056. label.Append("汇率:");
  12057. label.Append(rate.TruncDecimals(4));
  12058. label.Append(")");
  12059. }
  12060. designer.SetDataSource("MealLabel", label.ToString());
  12061. }
  12062. #endregion
  12063. #region 车辆安排
  12064. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12065. if (vehArranges!=null&&vehArranges.Infos.Any())
  12066. {
  12067. string currencyName = string.Empty;
  12068. //decimal rate = 1.0000M;
  12069. StringBuilder label = new StringBuilder();
  12070. foreach (var item in vehArranges.Infos)
  12071. {
  12072. label.AppendLine();
  12073. label.AppendLine();
  12074. label.Append(item.FeeName);
  12075. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12076. }
  12077. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12078. }
  12079. #endregion
  12080. #region 邀请函发放对象
  12081. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12082. designer.SetDataSource("InviteToContent", "");
  12083. #endregion
  12084. #region 邀请函费
  12085. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12086. StringBuilder is_label = new StringBuilder();
  12087. if (inviteCosts != null&&inviteCosts.Infos.Any())
  12088. {
  12089. string currencyName = string.Empty;
  12090. decimal rate = 1.0000M;
  12091. foreach (var item in inviteCosts.Infos)
  12092. {
  12093. //乌兹别克斯坦:2000美金
  12094. currencyName = item.Currency;
  12095. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12096. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12097. is_label.AppendLine(label);
  12098. }
  12099. if (is_label.HasValue())
  12100. {
  12101. //以上小计:28500元(美金汇率:7.5)
  12102. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2),"元", currencyName, rate.TruncDecimals(4));
  12103. is_label.AppendLine(label);
  12104. }
  12105. }
  12106. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12107. #endregion
  12108. #region 邀请函发放时间
  12109. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12110. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12111. #endregion
  12112. #region 公务活动(含翻译)
  12113. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12114. StringBuilder oa_label = new StringBuilder();
  12115. if (officialActs != null && officialActs.Infos.Any())
  12116. {
  12117. string currencyName = string.Empty;
  12118. decimal rate = 1.0000M;
  12119. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12120. foreach (var item in officialActs.Infos)
  12121. {
  12122. //乌兹别克斯坦:1000美金/场
  12123. currencyName = item.Currency;
  12124. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12125. string label_remark = string.Empty;
  12126. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12127. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12128. }
  12129. label_content += "*总费用中未含超出公务活动价格";
  12130. //8场公务活动(以上小计:60000元)
  12131. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12132. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12133. oa_label.AppendLine(label_title);
  12134. oa_label.AppendLine(label_content);
  12135. }
  12136. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12137. #endregion
  12138. #region 签证+保险
  12139. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12140. StringBuilder vi_label = new StringBuilder();
  12141. if (visaIns != null && visaIns.Infos.Any())
  12142. {
  12143. foreach (var item in visaIns.Infos)
  12144. {
  12145. //签证:500元/人
  12146. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12147. vi_label.AppendLine(label);
  12148. }
  12149. if (vi_label.HasValue())
  12150. {
  12151. //以上小计:6000元
  12152. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12153. vi_label.AppendLine(label);
  12154. }
  12155. }
  12156. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12157. #endregion
  12158. #region 服务费
  12159. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12160. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12161. #endregion
  12162. #region 公杂费
  12163. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12164. StringBuilder pm_label = new StringBuilder();
  12165. if (pubMiscs != null && pubMiscs.Infos.Any())
  12166. {
  12167. string currencyName = string.Empty,
  12168. countryName = string.Empty;
  12169. decimal rate = 1.0000M;
  12170. foreach (var item in pubMiscs.Infos)
  12171. {
  12172. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12173. string name = string.Empty, thisCountryName = string.Empty;
  12174. if (item.FeeName.Contains("-"))
  12175. {
  12176. var feeName = item.FeeName.Split('-');
  12177. thisCountryName = feeName[0];
  12178. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12179. name = feeName[1];
  12180. }
  12181. else name = item.FeeName;
  12182. string thisFeeName = string.Empty;
  12183. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12184. else thisFeeName = $"\r\n{name}:";
  12185. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12186. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12187. rate = rateInfo?.Rate ?? 1.0000M;
  12188. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12189. pm_label.AppendLine(label);
  12190. }
  12191. if (pm_label.HasValue())
  12192. {
  12193. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12194. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12195. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12196. pm_label.AppendLine(string.Format("部分发放成员"));
  12197. }
  12198. }
  12199. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12200. #endregion
  12201. #region 税费
  12202. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12203. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12204. #endregion
  12205. #region 合计(单位:元)
  12206. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12207. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12208. #endregion
  12209. #region 汇率 Remark
  12210. var rate_label = new StringBuilder();
  12211. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12212. foreach (var item in rateGroups)
  12213. {
  12214. //美元汇率按\r\n1:7.5
  12215. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12216. rate_label.AppendLine(label);
  12217. }
  12218. designer.SetDataSource("RateLabel", rate_label.ToString());
  12219. #endregion
  12220. designer.Process();
  12221. //文件名
  12222. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12223. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12224. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12225. return Ok(JsonView(true, "成功", url));
  12226. }
  12227. #endregion
  12228. #region 签证费用录入
  12229. /// <summary>
  12230. /// 根据diid查询签证费用列表
  12231. /// </summary>
  12232. /// <param name="dto"></param>
  12233. /// <returns></returns>
  12234. [HttpPost]
  12235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12236. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12237. {
  12238. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12239. if (groupData.Code != 0)
  12240. {
  12241. return Ok(JsonView(false, groupData.Msg));
  12242. }
  12243. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12244. }
  12245. /// <summary>
  12246. /// 根据签证费用Id查询单条数据及c表数据
  12247. /// </summary>
  12248. /// <param name="dto"></param>
  12249. /// <returns></returns>
  12250. [HttpPost]
  12251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12252. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12253. {
  12254. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12255. if (groupData.Code != 0)
  12256. {
  12257. return Ok(JsonView(false, groupData.Msg));
  12258. }
  12259. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12260. }
  12261. /// <summary>
  12262. /// 签证费用删除
  12263. /// </summary>
  12264. /// <param name="dto"></param>
  12265. /// <returns></returns>
  12266. [HttpPost]
  12267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12268. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12269. {
  12270. _sqlSugar.BeginTran();
  12271. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12272. if (!res)
  12273. {
  12274. _sqlSugar.RollbackTran();
  12275. return Ok(JsonView(false, "删除失败"));
  12276. }
  12277. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12278. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12279. .SetColumns(a => new Grp_CreditCardPayment()
  12280. {
  12281. IsDel = 1,
  12282. DeleteUserId = dto.DeleteUserId,
  12283. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12284. })
  12285. .ExecuteCommand();
  12286. if (resSub < 1)
  12287. {
  12288. _sqlSugar.RollbackTran();
  12289. return Ok(JsonView(false, "删除失败"));
  12290. }
  12291. _sqlSugar.CommitTran();
  12292. return Ok(JsonView(true, "删除成功!"));
  12293. }
  12294. /// <summary>
  12295. /// 签证费用录入下拉框初始化
  12296. /// </summary>
  12297. /// <returns></returns>
  12298. [HttpPost]
  12299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12300. public async Task<IActionResult> VisaPriceAddSelect()
  12301. {
  12302. //支付方式
  12303. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12304. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12305. //币种
  12306. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12307. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12308. //乘客类型
  12309. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12310. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12311. //卡类型
  12312. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12313. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12314. //代办费类型
  12315. var agencyFeeTypeData = new List<dynamic>() {
  12316. new { id = 0 , Text = "未选择" },
  12317. new { id = 1 , Text = "小公务" },
  12318. new { id = 2 , Text = "大公务" },
  12319. };
  12320. //签证费用标准国家Data
  12321. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12322. var data = new
  12323. {
  12324. Payment = _Payment,
  12325. CurrencyList = _CurrencyList,
  12326. PassengerType = _PassengerType,
  12327. BankCard = _BankCard,
  12328. AgencyFeeType = agencyFeeTypeData,
  12329. CountryFeeData = visaCountryFeeData
  12330. };
  12331. return Ok(JsonView(true, "查询成功!", data));
  12332. }
  12333. /// <summary>
  12334. /// 签证费用录入操作(Status:1.新增,2.修改)
  12335. /// </summary>
  12336. /// <param name="dto"></param>
  12337. /// <returns></returns>
  12338. [HttpPost]
  12339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12340. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12341. {
  12342. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12343. if (groupData.Code != 0)
  12344. {
  12345. return Ok(JsonView(false, groupData.Msg));
  12346. }
  12347. #region 应用推送
  12348. try
  12349. {
  12350. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12351. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12352. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12353. //2024-10-21 新增LZ UID
  12354. var userIds = new List<int>() { 21 };
  12355. string title = $"系统通知";
  12356. string content = "";
  12357. var diId = dto.DiId;
  12358. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12359. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12360. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12361. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12362. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12363. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12364. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12365. }
  12366. catch (Exception ex)
  12367. {
  12368. }
  12369. #endregion
  12370. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12371. }
  12372. #endregion
  12373. #region 签证提成录入
  12374. /// <summary>
  12375. /// 签证提成录入
  12376. /// 基础数据
  12377. /// </summary>
  12378. /// <returns></returns>
  12379. [HttpGet]
  12380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12381. public async Task<IActionResult> VisaCommissionInit()
  12382. {
  12383. return Ok(await _visaCommissionRep.Init());
  12384. }
  12385. /// <summary>
  12386. /// 签证提成录入
  12387. /// Item
  12388. /// </summary>
  12389. /// <param name="_dto"></param>
  12390. /// <returns></returns>
  12391. [HttpPost]
  12392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12393. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12394. {
  12395. var validator = new VisaCommissionItemDtoValidator();
  12396. var validatorRes = await validator.ValidateAsync(_dto);
  12397. if (!validatorRes.IsValid)
  12398. {
  12399. StringBuilder sb = new StringBuilder();
  12400. foreach (var item in validatorRes.Errors)
  12401. {
  12402. sb.AppendLine(item.ErrorMessage);
  12403. }
  12404. return Ok(JsonView(false, sb.ToString()));
  12405. }
  12406. return Ok(await _visaCommissionRep.Item(_dto));
  12407. }
  12408. /// <summary>
  12409. /// 签证提成录入
  12410. /// Save
  12411. /// </summary>
  12412. /// <param name="_dto"></param>
  12413. /// <returns></returns>
  12414. [HttpPost]
  12415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12416. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12417. {
  12418. //参数验证
  12419. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12420. foreach (var item in _dto.Items)
  12421. {
  12422. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12423. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12424. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12425. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12426. }
  12427. return Ok(await _visaCommissionRep.Save(_dto));
  12428. }
  12429. /// <summary>
  12430. /// 签证提成录入
  12431. /// Create
  12432. /// </summary>
  12433. /// <param name="_dto"></param>
  12434. /// <returns></returns>
  12435. [HttpPost]
  12436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12437. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12438. {
  12439. var validator = new VisaCommissionCreateDtoValidator();
  12440. var validatorRes = await validator.ValidateAsync(_dto);
  12441. if (!validatorRes.IsValid)
  12442. {
  12443. StringBuilder sb = new StringBuilder();
  12444. foreach (var item in validatorRes.Errors)
  12445. {
  12446. sb.AppendLine(item.ErrorMessage);
  12447. }
  12448. return Ok(JsonView(false, sb.ToString()));
  12449. }
  12450. return Ok(await _visaCommissionRep.Create(_dto));
  12451. }
  12452. /// <summary>
  12453. /// 签证提成录入
  12454. /// Put(编辑)
  12455. /// </summary>
  12456. /// <param name="id"></param>
  12457. /// <param name="_dto"></param>
  12458. /// <returns></returns>
  12459. [HttpPut]
  12460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12461. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12462. {
  12463. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12464. var validator = new VisaCommissionCreateDtoValidator();
  12465. var validatorRes = await validator.ValidateAsync(_dto);
  12466. if (!validatorRes.IsValid)
  12467. {
  12468. StringBuilder sb = new StringBuilder();
  12469. foreach (var item in validatorRes.Errors)
  12470. {
  12471. sb.AppendLine(item.ErrorMessage);
  12472. }
  12473. return Ok(JsonView(false, sb.ToString()));
  12474. }
  12475. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12476. }
  12477. /// <summary>
  12478. /// 签证提成录入
  12479. /// Del
  12480. /// </summary>
  12481. /// <param name="id"></param>
  12482. /// <param name="currUserId"></param>
  12483. /// <returns></returns>
  12484. [HttpPost]
  12485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12486. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12487. {
  12488. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12489. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12490. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12491. }
  12492. #endregion
  12493. #region op费用录入
  12494. /// <summary>
  12495. /// 根据diid查询op费用列表
  12496. /// </summary>
  12497. /// <param name="dto"></param>
  12498. /// <returns></returns>
  12499. [HttpPost]
  12500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12501. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12502. {
  12503. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12504. if (groupData.Code != 0)
  12505. {
  12506. return Ok(JsonView(false, groupData.Msg));
  12507. }
  12508. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12509. }
  12510. /// <summary>
  12511. /// 根据op费用Id查询单条数据及c表数据
  12512. /// </summary>
  12513. /// <param name="dto"></param>
  12514. /// <returns></returns>
  12515. [HttpPost]
  12516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12517. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12518. {
  12519. try
  12520. {
  12521. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12522. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12523. var data = new
  12524. {
  12525. CarTouristGuideGround = _groupData,
  12526. CreditCardPayment = _creditCardPayment
  12527. };
  12528. return Ok(JsonView(true, "查询成功!", data));
  12529. }
  12530. catch (Exception ex)
  12531. {
  12532. return Ok(JsonView(false, "程序错误!"));
  12533. }
  12534. }
  12535. /// <summary>
  12536. /// op费用删除
  12537. /// </summary>
  12538. /// <param name="dto"></param>
  12539. /// <returns></returns>
  12540. [HttpPost]
  12541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12542. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12543. {
  12544. try
  12545. {
  12546. _sqlSugar.BeginTran();
  12547. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12548. if (!res)
  12549. {
  12550. return Ok(JsonView(false, "删除失败"));
  12551. }
  12552. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12553. {
  12554. IsDel = 1,
  12555. DeleteUserId = dto.DeleteUserId,
  12556. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12557. }).ExecuteCommandAsync();
  12558. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12559. {
  12560. IsDel = 1,
  12561. DeleteUserId = dto.DeleteUserId,
  12562. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12563. }).ExecuteCommandAsync();
  12564. #region 删除超支相关数据
  12565. //删除导入的超支数据
  12566. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12567. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12568. {
  12569. IsDel = 1,
  12570. DeleteUserId = dto.DeleteUserId,
  12571. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12572. }).ExecuteCommand();
  12573. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12574. {
  12575. IsDel = 1,
  12576. DeleteUserId = dto.DeleteUserId,
  12577. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12578. }).ExecuteCommand();
  12579. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12580. {
  12581. IsDel = 1,
  12582. DeleteUserId = dto.DeleteUserId,
  12583. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12584. }).ExecuteCommand();
  12585. #endregion
  12586. _sqlSugar.CommitTran();
  12587. return Ok(JsonView(true, "删除成功!"));
  12588. }
  12589. catch (Exception ex)
  12590. {
  12591. _sqlSugar.RollbackTran();
  12592. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12593. }
  12594. }
  12595. /// <summary>
  12596. /// op费用录入操作(Status:1.新增,2.修改)
  12597. /// </summary>
  12598. /// <param name="dto"></param>
  12599. /// <returns></returns>
  12600. [HttpPost]
  12601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12602. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12603. {
  12604. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12605. if (groupData.Code != 0)
  12606. {
  12607. return Ok(JsonView(false, groupData.Msg));
  12608. }
  12609. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12610. }
  12611. /// <summary>
  12612. /// 填写费用详细页面初始化绑定
  12613. /// </summary>
  12614. /// <param name="dto"></param>
  12615. /// <returns></returns>
  12616. [HttpPost]
  12617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12618. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12619. {
  12620. try
  12621. {
  12622. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12623. if (groupData.Code != 0)
  12624. {
  12625. return Ok(JsonView(false, groupData.Msg));
  12626. }
  12627. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12628. }
  12629. catch (Exception ex)
  12630. {
  12631. return Ok(JsonView(false, ex.Message));
  12632. }
  12633. }
  12634. /// <summary>
  12635. /// 根据op费用Id查询详细数据
  12636. /// </summary>
  12637. /// <param name="dto"></param>
  12638. /// <returns></returns>
  12639. [HttpPost]
  12640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12641. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12642. {
  12643. try
  12644. {
  12645. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12646. if (groupData.Code != 0)
  12647. {
  12648. return Ok(JsonView(false, groupData.Msg));
  12649. }
  12650. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12651. }
  12652. catch (Exception ex)
  12653. {
  12654. return Ok(JsonView(false, ex.Message));
  12655. }
  12656. }
  12657. /// <summary>
  12658. /// OP费用录入填写详情
  12659. /// </summary>
  12660. /// <param name="dto"></param>
  12661. /// <returns></returns>
  12662. [HttpPost]
  12663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12664. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12665. {
  12666. try
  12667. {
  12668. #region 参数校验
  12669. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12670. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12671. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12672. #endregion
  12673. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12674. if (groupData.Code != 0)
  12675. {
  12676. return Ok(JsonView(false, groupData.Msg));
  12677. }
  12678. //自动审核
  12679. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12680. #region 应用推送
  12681. try
  12682. {
  12683. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12684. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12685. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12686. //2024-10-21 新增LZ UID
  12687. var userIds = new List<int>() { 21 };
  12688. string title = $"系统通知";
  12689. var diId = dto.DiId;
  12690. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12691. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12692. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12693. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12694. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12695. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12696. }
  12697. catch (Exception ex)
  12698. {
  12699. }
  12700. #endregion
  12701. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12702. }
  12703. catch (Exception ex)
  12704. {
  12705. return Ok(JsonView(false, ex.Message));
  12706. }
  12707. }
  12708. /// <summary>
  12709. /// 获取三公详细所有城市
  12710. /// </summary>
  12711. /// <returns></returns>
  12712. [HttpGet]
  12713. public IActionResult OpCarCityResult()
  12714. {
  12715. var jw = JsonView(false);
  12716. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12717. {
  12718. x.Id,
  12719. x.Country,
  12720. x.City,
  12721. }).ToList();
  12722. if (data.Count > 0)
  12723. {
  12724. jw = JsonView(true, "获取成功!", data);
  12725. }
  12726. else
  12727. {
  12728. jw.Msg = "城市数据为空!";
  12729. jw.Data = new string[0];
  12730. }
  12731. return Ok(jw);
  12732. }
  12733. /// <summary>
  12734. /// 导出地接费用明细
  12735. /// </summary>
  12736. /// <param name="dto"></param>
  12737. /// <returns></returns>
  12738. [HttpPost]
  12739. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12740. {
  12741. var jw = JsonView(false);
  12742. if (dto.Diid < 1)
  12743. {
  12744. jw.Msg = "请输入正确的diid!";
  12745. return Ok(jw);
  12746. }
  12747. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12748. if (group == null)
  12749. {
  12750. jw.Msg = "未找到团组信息!";
  12751. return Ok(jw);
  12752. }
  12753. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12754. if (localGuideArr.Count == 0)
  12755. {
  12756. jw.Msg = "该团组暂无地接信息!";
  12757. return Ok(jw);
  12758. }
  12759. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12760. var overspendSoure = new Dictionary<int, int>
  12761. {
  12762. { 91, 982 }, //车
  12763. { 92 , 1059} ,//导游
  12764. { 994 , 1073}, //翻译
  12765. { 988 , 1074 }, //早餐
  12766. { 93 , 1075 }, //午餐
  12767. { 989 , 1076 }, //晚餐
  12768. };
  12769. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  12770. foreach (var groupArr in localGroup)
  12771. {
  12772. var keyValue = groupArr.Key;
  12773. if (int.TryParse(keyValue, out int cityid))
  12774. {
  12775. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  12776. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  12777. }
  12778. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  12779. foreach (var item in groupArr)
  12780. {
  12781. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  12782. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  12783. new Grp_CarTouristGuideGroundReservationsContentExtend
  12784. {
  12785. Count = a.Count,
  12786. CreateTime = a.CreateTime,
  12787. CreateUserId = a.CreateUserId,
  12788. CTGGRId = a.CTGGRId,
  12789. Currency = a.Currency,
  12790. DatePrice = a.DatePrice,
  12791. DeleteTime = a.DeleteTime,
  12792. DeleteUserId = a.DeleteUserId,
  12793. DiId = a.DiId,
  12794. Id = a.Id,
  12795. IsDel = a.IsDel,
  12796. Price = a.Price,
  12797. PriceContent = a.PriceContent,
  12798. Remark = a.Remark,
  12799. SId = a.SId,
  12800. SidName = b.Name,
  12801. Units = a.Units,
  12802. }
  12803. ).ToList();
  12804. if (content.Count > 0)
  12805. {
  12806. contentArr.Add(content);
  12807. }
  12808. }
  12809. //open excel
  12810. //set excel
  12811. //save excel
  12812. try
  12813. {
  12814. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  12815. IWorkbook workbook;
  12816. if (Path.GetExtension(filePath).ToLower() == ".xls")
  12817. {
  12818. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12819. }
  12820. else
  12821. {
  12822. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12823. }
  12824. ISheet sheet = workbook.GetSheetAt(0);
  12825. var rowStartIndex = 2;
  12826. var clounmCount = 10;
  12827. var initStyleRow = sheet.GetRow(2);
  12828. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  12829. //var overspendArrDetail =
  12830. var existsId = new List<CarCompare>();
  12831. var lastElem = arr.Last();
  12832. var thisSid = -1;
  12833. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  12834. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  12835. {
  12836. Name = "未知币种!",
  12837. Remark = "未知币种!",
  12838. };
  12839. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  12840. Action cloneRowFn = () =>
  12841. {
  12842. rowStartIndex++;
  12843. var cloneRow = sheet.CreateRow(rowStartIndex);
  12844. // 复制样式
  12845. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  12846. {
  12847. ICell sourceCell = initStyleRow.GetCell(i);
  12848. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  12849. // 确保单元格存在样式
  12850. if (sourceCell.CellStyle != null)
  12851. {
  12852. targetCell.CellStyle = sourceCell.CellStyle;
  12853. }
  12854. }
  12855. };
  12856. var mergeRow = () =>
  12857. {
  12858. for (int i = 2; i < sheet.LastRowNum; i++)
  12859. {
  12860. var row = sheet.GetRow(i);
  12861. var cellFirst = row.GetCell(0);
  12862. var thisIndex = i + 1;
  12863. while (thisIndex < sheet.LastRowNum)
  12864. {
  12865. var nextRow = sheet.GetRow(thisIndex);
  12866. var nextCellFirst = nextRow.GetCell(0);
  12867. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  12868. {
  12869. thisIndex++;
  12870. }
  12871. else
  12872. {
  12873. break;
  12874. }
  12875. }
  12876. thisIndex--;
  12877. if (thisIndex != i)
  12878. {
  12879. //合并row
  12880. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12881. i, // 起始行索引(0-based)
  12882. thisIndex, // 结束行索引(0-based)
  12883. 0, // 起始列索引(0-based)
  12884. 0 // 结束列索引(0-based)
  12885. );
  12886. sheet.AddMergedRegion(cellRangeAddress);
  12887. i = thisIndex;
  12888. }
  12889. }
  12890. };
  12891. var chaoshiNumber = 0;
  12892. var totalNumber = 0.00M;
  12893. string lastStr = "";
  12894. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  12895. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  12896. {
  12897. b.IsAuditGM,
  12898. x.Id,
  12899. x.Area,
  12900. b.PayPercentage,
  12901. b.PayMoney,
  12902. }).ToList();
  12903. string yesPayment = "", noPayment = "";
  12904. foreach (var item in queryCarArrByCityAndDiid)
  12905. {
  12906. if (item.IsAuditGM == 1)
  12907. {
  12908. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12909. }
  12910. else
  12911. {
  12912. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12913. }
  12914. }
  12915. lastStr = yesPayment + noPayment;
  12916. foreach (var item in arr)
  12917. {
  12918. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  12919. {
  12920. if (thisSid != item.SId)
  12921. {
  12922. if (thisSid == -1)
  12923. {
  12924. thisSid = item.SId;
  12925. }
  12926. else
  12927. {
  12928. //合并小计行
  12929. //创建合并区域的实例
  12930. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12931. rowStartIndex, // 起始行索引(0-based)
  12932. rowStartIndex, // 结束行索引(0-based)
  12933. 0, // 起始列索引(0-based)
  12934. 3 // 结束列索引(0-based)
  12935. );
  12936. sheet.AddMergedRegion(cellRangeAddress);
  12937. var CellStyle = workbook.CreateCellStyle();
  12938. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12939. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12940. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12941. for (int i = 0; i <= clounmCount; i++)
  12942. {
  12943. if (i > 6)
  12944. {
  12945. var CellStyle1 = workbook.CreateCellStyle();
  12946. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12947. IFont Font = workbook.CreateFont(); // 创建字体
  12948. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12949. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12950. CellStyle1.SetFont(Font);
  12951. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12952. }
  12953. else
  12954. {
  12955. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12956. }
  12957. }
  12958. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12959. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12960. //超时合计
  12961. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12962. //超时数
  12963. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12964. //超时合计费用
  12965. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12966. thisSid = item.SId;
  12967. cloneRowFn();
  12968. chaoshiNumber = 0;
  12969. totalNumber = 0;
  12970. }
  12971. }
  12972. IRow row = sheet.GetRow(rowStartIndex);
  12973. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12974. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  12975. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  12976. if (isOpenOverspendSoure)
  12977. {
  12978. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12979. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  12980. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  12981. }
  12982. for (int i = 0; i <= clounmCount; i++)
  12983. {
  12984. var cell = row.GetCell(i);
  12985. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  12986. if (cell == null)
  12987. {
  12988. cell = row.CreateCell(i);
  12989. }
  12990. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  12991. fontRed.CloneStyleFrom(cell.CellStyle);
  12992. IFont Font = workbook.CreateFont(); // 创建字体
  12993. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  12994. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12995. fontRed.SetFont(Font);
  12996. byte[] rgb = new byte[3] { 255, 242, 204 };
  12997. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  12998. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  12999. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13000. if (workbook is XSSFWorkbook)
  13001. {
  13002. BackgroundColor255_242_204.FillForegroundColor = 0;
  13003. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13004. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13005. }
  13006. else
  13007. {
  13008. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13009. }
  13010. if (i == 1 || i > 6)
  13011. {
  13012. if (i > 6)
  13013. {
  13014. fontRed.FillForegroundColor = 0;
  13015. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13016. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13017. }
  13018. cell.CellStyle = fontRed;
  13019. }
  13020. if (i > 2 && i < 7)
  13021. {
  13022. cell.CellStyle = BackgroundColor255_242_204;
  13023. }
  13024. cell.SetCellValue(setCellValue); //写入单元格
  13025. }
  13026. if (overspendSoure.ContainsKey(thisSid))
  13027. {
  13028. var overspendId = overspendSoure[thisSid];
  13029. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13030. }
  13031. cloneRowFn();
  13032. existsId.Add(new CarCompare
  13033. {
  13034. DataPrice = item.DatePrice.ObjToDate(),
  13035. Sid = item.SId
  13036. });
  13037. }
  13038. if (item.Equals(lastElem))
  13039. {
  13040. //合并小计行
  13041. //创建合并区域的实例
  13042. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13043. rowStartIndex, // 起始行索引(0-based)
  13044. rowStartIndex, // 结束行索引(0-based)
  13045. 0, // 起始列索引(0-based)
  13046. 3 // 结束列索引(0-based)
  13047. );
  13048. sheet.AddMergedRegion(cellRangeAddress);
  13049. var CellStyle = workbook.CreateCellStyle();
  13050. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13051. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13052. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13053. for (int i = 0; i <= clounmCount; i++)
  13054. {
  13055. if (i > 6)
  13056. {
  13057. var CellStyle1 = workbook.CreateCellStyle();
  13058. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13059. IFont Font = workbook.CreateFont(); // 创建字体
  13060. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13061. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13062. CellStyle1.SetFont(Font);
  13063. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13064. }
  13065. else
  13066. {
  13067. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13068. }
  13069. }
  13070. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13071. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13072. //超时合计
  13073. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13074. //超时数
  13075. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13076. //超时合计费用
  13077. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13078. cloneRowFn();
  13079. // 创建合并区域的实例
  13080. cellRangeAddress = new CellRangeAddress(
  13081. rowStartIndex, // 起始行索引(0-based)
  13082. rowStartIndex, // 结束行索引(0-based)
  13083. 0, // 起始列索引(0-based)
  13084. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13085. );
  13086. // 添加合并区域
  13087. sheet.AddMergedRegion(cellRangeAddress);
  13088. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13089. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13090. }
  13091. }
  13092. mergeRow();
  13093. // 保存修改后的Excel文件到新文件
  13094. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13095. // new FileStream(newFilePath, FileMode.CreateNew)
  13096. using (var stream = new MemoryStream())
  13097. {
  13098. workbook.Write(stream, true);
  13099. stream.Flush();
  13100. stream.Seek(0, SeekOrigin.Begin);
  13101. MemoryStream memoryStream = new MemoryStream();
  13102. stream.CopyTo(memoryStream);
  13103. memoryStream.Seek(0, SeekOrigin.Begin);
  13104. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13105. }
  13106. workbook.Close();
  13107. workbook.Dispose();
  13108. }
  13109. catch (Exception ex)
  13110. {
  13111. jw.Msg = "出现异常!" + ex.Message;
  13112. return Ok(jw);
  13113. }
  13114. }
  13115. if (Zips.Count > 0)
  13116. {
  13117. IOOperatorHelper io = new IOOperatorHelper();
  13118. var byts = io.ConvertZipStream(Zips);
  13119. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13120. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13121. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13122. }
  13123. else
  13124. {
  13125. jw.Msg = "暂无生成文件!";
  13126. }
  13127. return Ok(jw);
  13128. }
  13129. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13130. {
  13131. string outStr = string.Empty;
  13132. switch (i)
  13133. {
  13134. case 0:
  13135. outStr = arr[0].SidName;
  13136. break;
  13137. case 1:
  13138. outStr = arr[0].DataPriceStr;
  13139. break;
  13140. case 2:
  13141. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13142. break;
  13143. case 4:
  13144. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13145. break;
  13146. case 7:
  13147. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13148. {
  13149. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13150. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13151. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13152. }
  13153. break;
  13154. case 8:
  13155. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13156. {
  13157. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13158. }
  13159. break;
  13160. case 9:
  13161. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13162. {
  13163. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13164. }
  13165. break;
  13166. case 10:
  13167. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13168. {
  13169. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13170. }
  13171. break;
  13172. }
  13173. return outStr;
  13174. }
  13175. #region OP行程单
  13176. /// <summary>
  13177. /// OP行程单初始化
  13178. /// </summary>
  13179. /// <param name="dto"></param>
  13180. /// <returns></returns>
  13181. [HttpPost]
  13182. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13183. {
  13184. var jw = JsonView(false);
  13185. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13186. var group = groupList.First();
  13187. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13188. if (group == null)
  13189. {
  13190. jw.Msg = "暂无团组!";
  13191. return Ok(jw);
  13192. }
  13193. group = groupList.Find(x => x.Id == diid);
  13194. if (group == null)
  13195. {
  13196. jw.Msg = "请输入正确的团组ID!";
  13197. return Ok(jw);
  13198. }
  13199. string city = string.Empty;
  13200. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13201. if (blackCode.Count > 0)
  13202. {
  13203. var black = blackCode.First();
  13204. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  13205. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13206. if (blackSp.Length > 0)
  13207. {
  13208. try
  13209. {
  13210. var cityArrCode = new List<string>(20);
  13211. foreach (var item in blackSp)
  13212. {
  13213. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13214. var IndexSelect = itemSp[2];
  13215. var cityArrCodeLength = cityArrCode.Count - 1;
  13216. var startCity = IndexSelect.Substring(0, 3);
  13217. if (cityArrCodeLength > 0)
  13218. {
  13219. var arrEndCity = cityArrCode[cityArrCodeLength];
  13220. if (arrEndCity != startCity)
  13221. {
  13222. cityArrCode.Add(startCity.ToUpper());
  13223. }
  13224. }
  13225. else
  13226. {
  13227. cityArrCode.Add(startCity.ToUpper());
  13228. }
  13229. var endCity = IndexSelect.Substring(3, 3);
  13230. cityArrCode.Add(endCity.ToUpper());
  13231. }
  13232. var cityThree = string.Empty;
  13233. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13234. cityThree = cityThree.TrimEnd(',');
  13235. if (string.IsNullOrWhiteSpace(cityThree))
  13236. {
  13237. throw new
  13238. Exception("error");
  13239. }
  13240. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13241. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13242. foreach (var item in cityArrCode)
  13243. {
  13244. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13245. if (find != null)
  13246. {
  13247. city += find.City + "/";
  13248. }
  13249. else
  13250. {
  13251. city += item + "三字码未收入/";
  13252. }
  13253. }
  13254. city = city.TrimEnd('/');
  13255. }
  13256. catch (Exception e)
  13257. {
  13258. city = "黑屏代码格式不正确!";
  13259. }
  13260. }
  13261. }
  13262. else
  13263. {
  13264. city = "未录入黑屏代码";
  13265. }
  13266. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13267. {
  13268. Date = x.Date,
  13269. Days = x.Days,
  13270. Diffgroup = x.Diffgroup,
  13271. Diid = x.Diid,
  13272. Traffic_First = x.Traffic_First,
  13273. Traffic_Second = x.Traffic_Second,
  13274. Trip = x.Trip,
  13275. WeekDay = x.WeekDay,
  13276. Id = x.Id
  13277. }).ToList();
  13278. jw.Data = new
  13279. {
  13280. groupList = groupList.Select(x => new
  13281. {
  13282. x.Id,
  13283. x.TeamName,
  13284. x.TourCode
  13285. }).ToList(),
  13286. groupInfo = new
  13287. {
  13288. group.VisitDays,
  13289. group.TourCode,
  13290. group.VisitPNumber,
  13291. group.TeamName,
  13292. city
  13293. },
  13294. OpTravelList
  13295. };
  13296. jw.Code = 200;
  13297. jw.Msg = "操作成功!";
  13298. return Ok(jw);
  13299. }
  13300. /// <summary>
  13301. /// 删除团组行程单
  13302. /// </summary>
  13303. /// <returns></returns>
  13304. [HttpPost]
  13305. public IActionResult DelTravel(DelOpTravelDto dto)
  13306. {
  13307. var jw = JsonView(false);
  13308. if (dto.UserId <= 0 || dto.Diid <= 0)
  13309. {
  13310. jw.Msg = "请输入正确的参数!";
  13311. return Ok(jw);
  13312. }
  13313. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13314. .SetColumns(x => new Grp_TravelList
  13315. {
  13316. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13317. DeleteUserId = dto.UserId,
  13318. IsDel = 1,
  13319. }).ExecuteCommand();
  13320. jw = JsonView(true);
  13321. return Ok(jw);
  13322. }
  13323. /// <summary>
  13324. /// 行程单保存
  13325. /// </summary>
  13326. /// <returns></returns>
  13327. [HttpPost]
  13328. public IActionResult TravelSave(TravelSaveDto dto)
  13329. {
  13330. var jw = JsonView(false);
  13331. if (dto.Arr.Count > 0)
  13332. {
  13333. try
  13334. {
  13335. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13336. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13337. .ToList();
  13338. _sqlSugar.BeginTran();
  13339. foreach (var item in dto.Arr)
  13340. {
  13341. if (item.Id == 0)
  13342. {
  13343. throw new Exception("请传入正确的Id");
  13344. }
  13345. //比较上一次的差异
  13346. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13347. if (findTravel != null)
  13348. {
  13349. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13350. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13351. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13352. }
  13353. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13354. .SetColumns(x => new Grp_TravelList
  13355. {
  13356. Trip = item.Trip
  13357. }).ExecuteCommand();
  13358. }
  13359. _sqlSugar.CommitTran();
  13360. jw = JsonView(true);
  13361. }
  13362. catch (Exception ex)
  13363. {
  13364. _sqlSugar.RollbackTran();
  13365. jw.Msg = "程序异常!" + ex.Message;
  13366. }
  13367. }
  13368. else
  13369. {
  13370. jw.Msg = "请传入正确的参数!";
  13371. }
  13372. return Ok(jw);
  13373. }
  13374. private string CheckStr(string original, string changed)
  13375. {
  13376. // 创建diff_match_patch对象
  13377. var dmp = new diff_match_patch();
  13378. // 计算差异
  13379. List<Diff> diffs = dmp.diff_main(original, changed);
  13380. // 清理和合并差异
  13381. dmp.diff_cleanupSemantic(diffs);
  13382. // 使用StringBuilder构建最终的字符串
  13383. StringBuilder finalString = new StringBuilder();
  13384. // 输出差异结果,并构建变动后的字符串
  13385. foreach (Diff diff in diffs)
  13386. {
  13387. switch (diff.operation)
  13388. {
  13389. case Operation.EQUAL:
  13390. // 相等的部分,直接添加到最终字符串
  13391. finalString.Append(diff.text);
  13392. break;
  13393. case Operation.INSERT:
  13394. // 插入的部分,添加标记并添加到最终字符串
  13395. finalString.Append("[++]" + diff.text + "[++]");
  13396. break;
  13397. case Operation.DELETE:
  13398. // 删除的部分,不添加到最终字符串
  13399. //finalString.Append("[++]" + diff.text + "[++]");
  13400. break;
  13401. }
  13402. }
  13403. // 输出变动后的字符串
  13404. return finalString.ToString();
  13405. }
  13406. private class tagContent
  13407. {
  13408. public DateTime Date { get; set; }
  13409. public string StartTag { get; set; }
  13410. public string EndTag { get; set; }
  13411. public string Content { get; set; }
  13412. public static int tagLength { get { return 3; } }
  13413. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13414. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13415. public bool IsFinally { get; set; }
  13416. }
  13417. private List<string> ExtractContentBetweenTags(string input, string tag)
  13418. {
  13419. List<string> results = new List<string>();
  13420. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13421. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13422. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13423. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13424. string[] strValueArr = new string[1];
  13425. foreach (System.Text.RegularExpressions.Match match in matches)
  13426. {
  13427. var strValue = match.Groups[1].Value;
  13428. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13429. }
  13430. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13431. return results;
  13432. }
  13433. /// <summary>
  13434. /// 导出行程单
  13435. /// </summary>
  13436. /// <param name="dto"></param>
  13437. /// <returns></returns>
  13438. [HttpPost]
  13439. public IActionResult ExportTravel(ExportTravelDto dto)
  13440. {
  13441. var jw = JsonView(false);
  13442. jw.Data = "";
  13443. int diid = 0;
  13444. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13445. if (Find == null)
  13446. {
  13447. jw.Msg = "请选择正确的团组!";
  13448. return Ok(jw);
  13449. }
  13450. else
  13451. {
  13452. diid = Find.Id;
  13453. }
  13454. //数据源
  13455. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13456. DataTable dtBlack = null;
  13457. try
  13458. {
  13459. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13460. }
  13461. catch (Exception)
  13462. {
  13463. jw.Msg = "机票黑屏代码有误!";
  13464. return Ok(jw);
  13465. }
  13466. string CityStr = string.Empty;
  13467. if (dtBlack.Rows.Count == 0)
  13468. {
  13469. jw.Msg = "机票黑屏代码有误!";
  13470. return Ok(jw);
  13471. }
  13472. else
  13473. {
  13474. foreach (DataRow row in dtBlack.Rows)
  13475. {
  13476. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13477. {
  13478. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13479. return Ok(jw);
  13480. }
  13481. }
  13482. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13483. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13484. }
  13485. // 指定的文字
  13486. var targetTextDic = new Dictionary<string, List<string>>();
  13487. //创建数据源Table
  13488. DataTable dtSource = new DataTable();
  13489. dtSource.Columns.Add("Days", typeof(string));
  13490. dtSource.Columns.Add("Date", typeof(string));
  13491. dtSource.Columns.Add("Week", typeof(string));
  13492. dtSource.Columns.Add("Traffic", typeof(string));
  13493. dtSource.Columns.Add("Trip", typeof(string));
  13494. //获取数据,放到datatable
  13495. foreach (var item in _travelList)
  13496. {
  13497. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13498. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13499. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13500. .Replace("[++]", string.Empty);
  13501. DataRow dr = dtSource.NewRow();
  13502. dr["Days"] = item.Days;
  13503. dr["Date"] = item.Date;
  13504. dr["Week"] = item.WeekDay;
  13505. dr["Traffic"] = item.Traffic_First
  13506. + "\r\n"
  13507. + item.Traffic_Second;
  13508. dr["Trip"] = item.Trip;
  13509. dtSource.Rows.Add(dr);
  13510. }
  13511. Dictionary<string, string> dic = new Dictionary<string, string>();
  13512. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13513. dic.Add("City", CityStr);
  13514. dic.Add("Days", Find.VisitDays.ToString());
  13515. dic.Add("DeleCode", Find.TourCode);
  13516. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13517. //模板路径
  13518. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13519. //载入模板
  13520. Document doc = null;
  13521. DocumentBuilder builder = null;
  13522. try
  13523. {
  13524. //载入模板
  13525. doc = new Document(tempPath);
  13526. builder = new DocumentBuilder(doc);
  13527. }
  13528. catch (Exception)
  13529. {
  13530. jw.Msg = "模板位置不存在!";
  13531. return Ok(jw);
  13532. }
  13533. foreach (var key in dic.Keys)
  13534. {
  13535. Bookmark bookmark = doc.Range.Bookmarks[key];
  13536. if (bookmark != null)
  13537. {
  13538. builder.MoveToBookmark(key);
  13539. builder.Write(dic[key]);
  13540. }
  13541. }
  13542. //获取word里所有表格
  13543. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13544. //获取所填表格的序数
  13545. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13546. try
  13547. {
  13548. //循环赋值
  13549. for (int i = 0; i < dtSource.Rows.Count; i++)
  13550. {
  13551. builder.MoveToCell(0, i + 1, 0, 0);
  13552. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13553. builder.MoveToCell(0, i + 1, 1, 0);
  13554. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13555. builder.MoveToCell(0, i + 1, 2, 0);
  13556. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13557. var trip = dtSource.Rows[i]["Trip"].ToString();
  13558. builder.MoveToCell(0, i + 1, 3, 0);
  13559. builder.Write(trip);
  13560. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13561. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13562. // 获取特定索引的段落
  13563. Paragraph paragraph = (Paragraph)paragraphs[0];
  13564. Run run = paragraph.Runs[0];
  13565. Aspose.Words.Font font = run.Font;
  13566. font.Name = "黑体";
  13567. //设置双休红色
  13568. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13569. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13570. paragraph = (Paragraph)paragraphs[1];
  13571. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13572. {
  13573. run = paragraph.Runs[0];
  13574. font = run.Font;
  13575. font.Color = Color.Red;
  13576. }
  13577. }
  13578. }
  13579. catch (Exception ex)
  13580. {
  13581. }
  13582. //删除多余行
  13583. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13584. {
  13585. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13586. }
  13587. var targetTextList = new List<string>();
  13588. // 遍历文档中的表格
  13589. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13590. {
  13591. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13592. {
  13593. var cellIndex = 0;
  13594. foreach (Cell cell in row.Cells)
  13595. {
  13596. if (cellIndex == 1 && row.Cells.Count == 4)
  13597. {
  13598. foreach (var target in targetTextDic.Keys)
  13599. {
  13600. if (cell.GetText().Contains(target))
  13601. {
  13602. targetTextList = targetTextDic[target];
  13603. break;
  13604. }
  13605. }
  13606. }
  13607. // 遍历单元格中的所有段落
  13608. foreach (Paragraph paragraph in cell.Paragraphs)
  13609. {
  13610. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13611. List<Run> runs = new List<Run>();
  13612. foreach (Run run in paragraph.Runs)
  13613. {
  13614. runs.Add(run);
  13615. }
  13616. foreach (Run run in runs)
  13617. {
  13618. foreach (var targetText in targetTextList)
  13619. {
  13620. // 检查文字是否包含指定文字
  13621. if (run.Text.Contains(targetText))
  13622. {
  13623. // 将包含的部分设置为红色
  13624. HighlightText(run, targetText, Color.Red);
  13625. }
  13626. }
  13627. }
  13628. }
  13629. cellIndex++;
  13630. }
  13631. }
  13632. }
  13633. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13634. if (!Directory.Exists(savePath))
  13635. {
  13636. try
  13637. {
  13638. Directory.CreateDirectory(savePath);
  13639. }
  13640. catch
  13641. {
  13642. }
  13643. }
  13644. string path = savePath + Find.TeamName + "出访日程";
  13645. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13646. try
  13647. {
  13648. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13649. string postfix = ".docx";
  13650. if (dto.IsPDF == 1)
  13651. {
  13652. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13653. postfix = ".pdf";
  13654. }
  13655. doc.Save(path + postfix, saveFormat);
  13656. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13657. }
  13658. catch (Exception)
  13659. {
  13660. jw = JsonView(false);
  13661. }
  13662. return Ok(jw);
  13663. }
  13664. /// <summary>
  13665. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13666. /// </summary>
  13667. /// <param name="num"></param>
  13668. /// <returns></returns>
  13669. string GetNum(string num)
  13670. {
  13671. string str = "";
  13672. switch (num)
  13673. {
  13674. case "1":
  13675. str = "一";
  13676. break;
  13677. case "2":
  13678. str = "二";
  13679. break;
  13680. case "3":
  13681. str = "三";
  13682. break;
  13683. case "4":
  13684. str = "四";
  13685. break;
  13686. case "5":
  13687. str = "五";
  13688. break;
  13689. case "6":
  13690. str = "六";
  13691. break;
  13692. case "7":
  13693. str = "七";
  13694. break;
  13695. case "8":
  13696. str = "八";
  13697. break;
  13698. case "9":
  13699. str = "九";
  13700. break;
  13701. case "10":
  13702. str = "十";
  13703. break;
  13704. case "11":
  13705. str = "十一";
  13706. break;
  13707. case "12":
  13708. str = "十二";
  13709. break;
  13710. case "一":
  13711. str = "1";
  13712. break;
  13713. case "二":
  13714. str = "2";
  13715. break;
  13716. case "三":
  13717. str = "3";
  13718. break;
  13719. case "四":
  13720. str = "4";
  13721. break;
  13722. case "五":
  13723. str = "5";
  13724. break;
  13725. case "六":
  13726. str = "6";
  13727. break;
  13728. case "七":
  13729. str = "7";
  13730. break;
  13731. case "八":
  13732. str = "8";
  13733. break;
  13734. case "九":
  13735. str = "9";
  13736. break;
  13737. case "十":
  13738. str = "10";
  13739. break;
  13740. case "十一":
  13741. str = "11";
  13742. break;
  13743. case "十二":
  13744. str = "12";
  13745. break;
  13746. }
  13747. return str;
  13748. }
  13749. // 高亮包含指定文字的部分
  13750. void HighlightText(Run run, string targetText, Color color)
  13751. {
  13752. string text = run.Text;
  13753. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13754. if (startIndex >= 0)
  13755. {
  13756. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13757. // 前部分
  13758. if (startIndex > 0)
  13759. {
  13760. Run beforeRun = (Run)run.Clone(true);
  13761. beforeRun.Text = text.Substring(0, startIndex);
  13762. parentParagraph.InsertBefore(beforeRun, run);
  13763. }
  13764. // 匹配部分
  13765. Run matchRun = (Run)run.Clone(true);
  13766. matchRun.Text = text.Substring(startIndex, targetText.Length);
  13767. matchRun.Font.Color = color;
  13768. parentParagraph.InsertBefore(matchRun, run);
  13769. // 后部分
  13770. if (startIndex + targetText.Length < text.Length)
  13771. {
  13772. Run afterRun = (Run)run.Clone(true);
  13773. afterRun.Text = text.Substring(startIndex + targetText.Length);
  13774. parentParagraph.InsertBefore(afterRun, run);
  13775. }
  13776. // 删除原始Run
  13777. run.Remove();
  13778. }
  13779. }
  13780. #endregion
  13781. #endregion
  13782. #region 团组成本
  13783. /// <summary>
  13784. /// 团组成本数据初始化
  13785. /// </summary>
  13786. /// <param name="dto"></param>
  13787. /// <returns></returns>
  13788. [HttpPost]
  13789. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  13790. {
  13791. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  13792. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  13793. WHEN COUNT(*) >= 0 THEN 'True'
  13794. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  13795. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  13796. ").ToList(); //团组列表
  13797. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  13798. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  13799. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  13800. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  13801. if (groupinfoValue != null)
  13802. {
  13803. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  13804. var spArr = new string[1] { countryArr };
  13805. if (countryArr.Contains("|"))
  13806. {
  13807. spArr = countryArr.Split("|");
  13808. }
  13809. else if (countryArr.Contains("、"))
  13810. {
  13811. spArr = countryArr.Split("、");
  13812. }
  13813. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  13814. {
  13815. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  13816. if (dbQueryCountry != null)
  13817. {
  13818. visaCountryInfoArr.Add(dbQueryCountry);
  13819. }
  13820. }
  13821. }
  13822. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  13823. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  13824. #region 屏蔽黑屏代码生成
  13825. //var create = _GroupCostRepository.
  13826. // CreateGroupCostByBlackCode(dto.Diid);
  13827. //if (groupCost.Count == 0 && create.Code == 0)
  13828. //{
  13829. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  13830. //}
  13831. #endregion
  13832. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  13833. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  13834. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  13835. groupCostMap = groupCostMap.Select(x =>
  13836. {
  13837. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  13838. {
  13839. x.Date = dataForamt.ToString("yyyy-MM-dd");
  13840. }
  13841. return x;
  13842. }).ToList();
  13843. //GroupCostParameter.Add(new
  13844. // Grp_GroupCostParameter());
  13845. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  13846. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  13847. return Ok(JsonView(new
  13848. {
  13849. groupList,
  13850. groupInfo,
  13851. groupChecks,
  13852. groupCost = groupCostMap,
  13853. hotelNumber,
  13854. GroupCostParameter = GroupCostParameterMap,
  13855. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  13856. {
  13857. x.VisaCountry,
  13858. x.VisaPrice,
  13859. x.Id,
  13860. }).ToList(),
  13861. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  13862. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
  13863. hotelIsTrue = hotelIsTrue,
  13864. }));
  13865. }
  13866. /// <summary>
  13867. /// 团组成本信息保存
  13868. /// </summary>
  13869. /// <param name="dto"></param>
  13870. /// <returns></returns>
  13871. [HttpPost]
  13872. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  13873. {
  13874. if (dto.Diid <= 0 || dto.Userid <= 0)
  13875. {
  13876. return Ok(JsonView(false));
  13877. }
  13878. JsonView jw = null;
  13879. bool isTrue = false;
  13880. #region 复制团组成本
  13881. //if (dto.Diid == 2581)
  13882. //{
  13883. // dto.Diid = 2599;
  13884. // dto.CheckBoxs.ForEach(x =>
  13885. // {
  13886. // x.Diid = 2599;
  13887. // });
  13888. // dto.GroupCosts.ForEach(x =>
  13889. // {
  13890. // x.Diid = 2599;
  13891. // });
  13892. // dto.CostTypeHotelNumbers.ForEach(x =>
  13893. // {
  13894. // x.Diid = 2599;
  13895. // });
  13896. // dto.GroupCostParameters.ForEach(x =>
  13897. // {
  13898. // x.DiId = 2599;
  13899. // });
  13900. //}
  13901. #endregion
  13902. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13903. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13904. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13905. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13906. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13907. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13908. try
  13909. {
  13910. _sqlSugar.BeginTran();
  13911. isTrue = await _GroupCostRepository.
  13912. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13913. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13914. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13915. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13916. _sqlSugar.CommitTran();
  13917. jw = JsonView(true, "保存成功!", isTrue);
  13918. }
  13919. catch (Exception)
  13920. {
  13921. _sqlSugar.RollbackTran();
  13922. jw = JsonView(false);
  13923. }
  13924. return Ok(jw);
  13925. }
  13926. /// <summary>
  13927. /// 复制团组成本信息
  13928. /// </summary>
  13929. /// <param name="dto"></param>
  13930. /// <returns></returns>
  13931. [HttpPost]
  13932. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  13933. {
  13934. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  13935. {
  13936. return Ok(JsonView(false,"参数有误!"));
  13937. }
  13938. #region 复制团组成本
  13939. dto.Diid = dto.ToGroupId;
  13940. dto.CheckBoxs.ForEach(x =>
  13941. {
  13942. x.Diid = dto.ToGroupId;
  13943. });
  13944. dto.GroupCosts.ForEach(x =>
  13945. {
  13946. x.Diid = dto.ToGroupId;
  13947. });
  13948. dto.CostTypeHotelNumbers.ForEach(x =>
  13949. {
  13950. x.Diid = dto.ToGroupId;
  13951. });
  13952. dto.GroupCostParameters.ForEach(x =>
  13953. {
  13954. x.DiId = dto.ToGroupId;
  13955. });
  13956. #endregion
  13957. JsonView jw = null;
  13958. bool isTrue = false;
  13959. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13960. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13961. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13962. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13963. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13964. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13965. try
  13966. {
  13967. _sqlSugar.BeginTran();
  13968. isTrue = await _GroupCostRepository.
  13969. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13970. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13971. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13972. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13973. _sqlSugar.CommitTran();
  13974. jw = JsonView(true, "保存成功!", isTrue);
  13975. }
  13976. catch (Exception)
  13977. {
  13978. _sqlSugar.RollbackTran();
  13979. jw = JsonView(false);
  13980. }
  13981. return Ok(jw);
  13982. }
  13983. /// <summary>
  13984. /// 司兼导数据
  13985. /// </summary>
  13986. /// <param name="dto"></param>
  13987. /// <returns></returns>
  13988. [HttpPost]
  13989. public IActionResult GetCarGuides(CarGuidesDto dto)
  13990. {
  13991. JsonView jw = null;
  13992. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  13993. jw = JsonView(true, "获取成功!", Data);
  13994. return Ok(jw);
  13995. }
  13996. /// <summary>
  13997. /// 导游数据
  13998. /// </summary>
  13999. /// <param name="dto"></param>
  14000. /// <returns></returns>
  14001. [HttpPost]
  14002. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14003. {
  14004. JsonView jw = null;
  14005. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14006. // 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
  14007. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14008. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14009. jw = JsonView(true, "获取成功!", Data);
  14010. return Ok(jw);
  14011. }
  14012. /// <summary>
  14013. /// 成本车数据
  14014. /// </summary>
  14015. /// <param name="dto"></param>
  14016. /// <returns></returns>
  14017. [HttpPost]
  14018. public IActionResult GetCarInfo(CarGuidesDto dto)
  14019. {
  14020. JsonView jw = null;
  14021. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14022. jw = JsonView(true, "获取成功!", Data);
  14023. return Ok(jw);
  14024. }
  14025. /// <summary>
  14026. /// 景点数据
  14027. /// </summary>
  14028. /// <param name="dto"></param>
  14029. /// <returns></returns>
  14030. [HttpPost]
  14031. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14032. {
  14033. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14034. return Ok(JsonView(true, "获取成功!", Data));
  14035. }
  14036. /// <summary>
  14037. /// 成本通知
  14038. /// </summary>
  14039. /// <param name="dto"></param>
  14040. /// <returns></returns>
  14041. [HttpPost]
  14042. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14043. {
  14044. if (dto.Diid < 0)
  14045. {
  14046. return Ok(JsonView(false));
  14047. }
  14048. JsonView jw = null;
  14049. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14050. if (GroupCostParameter != null)
  14051. {
  14052. int IsShare = 0;
  14053. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14054. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14055. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14056. string msg = string.Empty;
  14057. if (isTrue)
  14058. {
  14059. if (IsShare == 0)
  14060. {
  14061. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14062. }
  14063. else
  14064. {
  14065. #region 企微通知对应岗位用户
  14066. try
  14067. {
  14068. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14069. }
  14070. catch (Exception ex)
  14071. {
  14072. }
  14073. #endregion
  14074. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14075. }
  14076. jw = JsonView(isTrue, msg, new { IsShare });
  14077. }
  14078. else
  14079. {
  14080. msg = "修改失败!";
  14081. jw = JsonView(isTrue, msg);
  14082. }
  14083. }
  14084. else
  14085. {
  14086. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14087. }
  14088. return Ok(jw);
  14089. }
  14090. /// <summary>
  14091. /// 导出报价单
  14092. /// </summary>
  14093. /// <param name="dto"></param>
  14094. /// <returns></returns>
  14095. [HttpPost]
  14096. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14097. {
  14098. if (dto.Diid == 0)
  14099. {
  14100. return Ok(JsonView(false, "请传递团组id"));
  14101. }
  14102. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14103. if (deleInfo.Code != 0)
  14104. {
  14105. return Ok(JsonView(false, "团组信息查询失败!"));
  14106. }
  14107. var di = deleInfo.Data as DelegationInfoWebView;
  14108. if (di != null)
  14109. {
  14110. di.TeamName = di.TeamName.Replace("|", "、");
  14111. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14112. //文件名
  14113. string strFileName = di.TeamName + "-收款账单.doc";
  14114. //获取模板
  14115. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14116. //载入模板
  14117. Document doc = new Document(tmppath);
  14118. decimal TotalPrice = 0.00M;
  14119. string itemStr = string.Empty;
  14120. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14121. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14122. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14123. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14124. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14125. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14126. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14127. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14128. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14129. foreach (var cost in groupCostType)
  14130. {
  14131. var List = cost.ToList();
  14132. if (cost.Key == "A")
  14133. {
  14134. foreach (var ListItem in List)
  14135. {
  14136. if (ListItem.number > 0)
  14137. {
  14138. if (ListItem.code.Contains("TBR"))
  14139. {
  14140. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14141. }
  14142. else
  14143. {
  14144. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14145. }
  14146. TotalPrice += (ListItem.number * ListItem.price);
  14147. }
  14148. }
  14149. }
  14150. else
  14151. {
  14152. itemStr = itemStr.Insert(0, "A段\r\n");
  14153. itemStr += "B段\r\n";
  14154. foreach (var ListItem in List)
  14155. {
  14156. if (ListItem.number > 0)
  14157. {
  14158. if (ListItem.code.Contains("TBR"))
  14159. {
  14160. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14161. }
  14162. else
  14163. {
  14164. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14165. }
  14166. TotalPrice += (ListItem.number * ListItem.price);
  14167. }
  14168. }
  14169. }
  14170. }
  14171. #region 替换Word模板书签内容
  14172. Dictionary<string, string> marks = new Dictionary<string, string>();
  14173. marks.Add("To", di.ClientUnit);//付款方
  14174. marks.Add("ToTel", di.TellPhone);//付款方电话
  14175. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14176. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14177. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14178. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14179. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14180. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14181. marks.Add("PayItemContent", itemStr);//详细信息
  14182. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14183. #endregion
  14184. ////注
  14185. //if (doc.Range.Bookmarks["Attention"] != null)
  14186. //{
  14187. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14188. // mark.Text = frList[0].Attention;
  14189. //}
  14190. foreach (var item in marks.Keys)
  14191. {
  14192. if (doc.Range.Bookmarks[item] != null)
  14193. {
  14194. Bookmark mark = doc.Range.Bookmarks[item];
  14195. mark.Text = marks[item];
  14196. }
  14197. }
  14198. byte[] bytes = null;
  14199. using (MemoryStream stream = new MemoryStream())
  14200. {
  14201. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14202. bytes = stream.ToArray();
  14203. }
  14204. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14205. return Ok(JsonView(true, "", new
  14206. {
  14207. Data = bytes,
  14208. strFileName,
  14209. }));
  14210. }
  14211. else
  14212. {
  14213. return Ok(JsonView(false, "团组信息不存在!"));
  14214. }
  14215. }
  14216. /// <summary>
  14217. /// 导出团组成本
  14218. /// </summary>
  14219. /// <param name="dto"></param>
  14220. /// <returns></returns>
  14221. [HttpPost]
  14222. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14223. {
  14224. var jw = JsonView(false);
  14225. if (dto.Diid == 0)
  14226. {
  14227. return Ok(JsonView(false, "请传递团组id"));
  14228. }
  14229. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14230. if (deleInfo.Code != 0)
  14231. {
  14232. return Ok(JsonView(false, "团组信息查询失败!"));
  14233. }
  14234. var di = deleInfo.Data as DelegationInfoWebView;
  14235. if (di == null)
  14236. {
  14237. return Ok(JsonView(false, "团组信息查询失败!"));
  14238. }
  14239. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14240. WorkbookDesigner designer = new WorkbookDesigner();
  14241. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14242. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14243. for (int i = 0; i < List_GC.Count; i++)
  14244. {
  14245. GroupCost_Excel gc = new GroupCost_Excel();
  14246. gc.Id = List_GC[i].Id;
  14247. gc.Diid = List_GC[i].Diid.ToString();
  14248. gc.DAY = List_GC[i].DAY;
  14249. string week = "";
  14250. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14251. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14252. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14253. gc.ITIN = List_GC[i].ITIN;
  14254. gc.CarType = List_GC[i].CarType;
  14255. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14256. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14257. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14258. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14259. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14260. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14261. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14262. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14263. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14264. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14265. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14266. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14267. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14268. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14269. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14270. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14271. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14272. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14273. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14274. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14275. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14276. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14277. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14278. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14279. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14280. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14281. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14282. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14283. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14284. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14285. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14286. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14287. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14288. List_GC1.Add(gc);
  14289. }
  14290. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14291. dt.TableName = "TB";
  14292. //报表标题等不用dt的值
  14293. designer.SetDataSource("TeamName", dto.title.TeamName);
  14294. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14295. designer.SetDataSource("Tax", dto.title.Tax);
  14296. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14297. designer.SetDataSource("Currency", dto.title.Currency);
  14298. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14299. designer.SetDataSource("Rate", dto.title.Rate);
  14300. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14301. var Aparams = hotels.Find(x => x.Type == "Default");
  14302. if (Aparams == null)
  14303. {
  14304. return Ok(jw);
  14305. }
  14306. //酒店数量
  14307. var txtSGRNumber = Aparams.SGR.ToString();
  14308. var txtTBRNumber = Aparams.TBR.ToString();
  14309. var txtJSESNumber = Aparams.JSES.ToString();
  14310. var txtSUITENumbe = Aparams.SUITE.ToString();
  14311. if (dto.costType == "B")
  14312. {
  14313. Aparams = hotels.Find(x => x.Type == "A");
  14314. var Bparams = hotels.Find(x => x.Type == "B");
  14315. if (Aparams == null || Bparams == null)
  14316. {
  14317. return Ok(jw);
  14318. }
  14319. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14320. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14321. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14322. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14323. }
  14324. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14325. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14326. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14327. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14328. var ws = designer.Workbook.Worksheets[0];
  14329. int Row = List_GC.Count;
  14330. int startIndex = 11;
  14331. int HideRows = 0;
  14332. List<int> hideRowsList = new List<int>();
  14333. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14334. #region A段left数据
  14335. var left = dto.leftInfo.Find(x => x.Type == "A");
  14336. if (left == null)
  14337. {
  14338. return Ok(jw);
  14339. }
  14340. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14341. if (leftBindData != null)
  14342. {
  14343. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14344. designer.SetDataSource("VisaRS", leftBindData.rs);
  14345. designer.SetDataSource("VisaXS", leftBindData.xs);
  14346. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14347. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14348. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14349. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14350. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14351. }
  14352. else
  14353. {
  14354. hideRowsList.Add(Row + startIndex + HideRows);
  14355. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14356. }
  14357. HideRows += 2;
  14358. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14359. if (leftBindData != null)
  14360. {
  14361. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14362. designer.SetDataSource("BXRS", leftBindData.rs);
  14363. designer.SetDataSource("BXXS", leftBindData.xs);
  14364. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14365. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14366. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14367. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14368. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14369. }
  14370. else
  14371. {
  14372. hideRowsList.Add(Row + startIndex + HideRows);
  14373. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14374. }
  14375. HideRows += 2;
  14376. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14377. if (leftBindData != null)
  14378. {
  14379. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14380. designer.SetDataSource("HSRS", leftBindData.rs);
  14381. designer.SetDataSource("HSXS", leftBindData.xs);
  14382. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14383. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14384. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14385. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14386. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14387. }
  14388. else
  14389. {
  14390. hideRowsList.Add(Row + startIndex + HideRows);
  14391. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14392. }
  14393. HideRows += 2;
  14394. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14395. if (leftBindData != null)
  14396. {
  14397. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14398. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14399. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14400. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14401. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14402. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14403. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14404. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14405. }
  14406. else
  14407. {
  14408. hideRowsList.Add(Row + startIndex + HideRows);
  14409. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14410. }
  14411. HideRows += 2;
  14412. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14413. if (leftBindData != null)
  14414. {
  14415. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14416. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14417. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14418. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14419. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14420. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14421. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14422. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14423. }
  14424. else
  14425. {
  14426. hideRowsList.Add(Row + startIndex + HideRows);
  14427. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14428. }
  14429. HideRows += 2;
  14430. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14431. if (leftBindData != null)
  14432. {
  14433. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14434. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14435. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14436. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14437. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14438. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14439. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14440. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14441. }
  14442. else
  14443. {
  14444. hideRowsList.Add(Row + startIndex + HideRows);
  14445. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14446. }
  14447. HideRows += 2;
  14448. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14449. if (leftBindData != null)
  14450. {
  14451. ////TBR
  14452. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14453. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14454. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14455. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14456. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14457. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14458. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14459. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14460. }
  14461. else
  14462. {
  14463. hideRowsList.Add(Row + startIndex + HideRows);
  14464. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14465. }
  14466. HideRows += 2;
  14467. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14468. if (leftBindData != null)
  14469. {
  14470. ////SGR
  14471. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14472. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14473. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14474. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14475. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14476. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14477. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14478. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14479. }
  14480. else
  14481. {
  14482. hideRowsList.Add(Row + startIndex + HideRows);
  14483. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14484. }
  14485. HideRows += 2;
  14486. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14487. if (leftBindData != null)
  14488. {
  14489. ////JS/ES
  14490. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14491. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14492. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14493. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14494. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14495. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14496. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14497. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14498. }
  14499. else
  14500. {
  14501. hideRowsList.Add(Row + startIndex + HideRows);
  14502. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14503. }
  14504. HideRows += 2;
  14505. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14506. if (leftBindData != null)
  14507. {
  14508. ////SUITE
  14509. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14510. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14511. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14512. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14513. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14514. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14515. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14516. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14517. }
  14518. else
  14519. {
  14520. hideRowsList.Add(Row + startIndex + HideRows);
  14521. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14522. }
  14523. HideRows += 2;
  14524. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14525. if (leftBindData != null)
  14526. {
  14527. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14528. designer.SetDataSource("DJRS", leftBindData.rs);
  14529. designer.SetDataSource("DJXS", leftBindData.xs);
  14530. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14531. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14532. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14533. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14534. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14535. }
  14536. else
  14537. {
  14538. hideRowsList.Add(Row + startIndex + HideRows);
  14539. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14540. }
  14541. HideRows += 2;
  14542. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14543. if (leftBindData != null)
  14544. {
  14545. designer.SetDataSource("HCPCB", leftBindData.cb);
  14546. designer.SetDataSource("HCPRS", leftBindData.rs);
  14547. designer.SetDataSource("HCPXS", leftBindData.xs);
  14548. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14549. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14550. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14551. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14552. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14553. }
  14554. else
  14555. {
  14556. hideRowsList.Add(Row + startIndex + HideRows);
  14557. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14558. }
  14559. HideRows += 2;
  14560. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14561. if (leftBindData != null)
  14562. {
  14563. designer.SetDataSource("CPCB", leftBindData.cb);
  14564. designer.SetDataSource("CPRS", leftBindData.rs);
  14565. designer.SetDataSource("CPXS", leftBindData.xs);
  14566. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14567. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14568. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14569. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14570. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14571. }
  14572. else
  14573. {
  14574. hideRowsList.Add(Row + startIndex + HideRows);
  14575. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14576. }
  14577. HideRows += 2;
  14578. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14579. if (leftBindData != null)
  14580. {
  14581. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14582. designer.SetDataSource("GWRS", leftBindData.rs);
  14583. designer.SetDataSource("GWXS", leftBindData.xs);
  14584. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14585. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14586. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14587. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14588. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14589. }
  14590. else
  14591. {
  14592. hideRowsList.Add(Row + startIndex + HideRows);
  14593. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14594. }
  14595. HideRows += 2;
  14596. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14597. if (leftBindData != null)
  14598. {
  14599. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14600. designer.SetDataSource("LYJRS", leftBindData.rs);
  14601. designer.SetDataSource("LYJXS", leftBindData.xs);
  14602. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14603. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14604. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14605. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14606. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14607. }
  14608. else
  14609. {
  14610. hideRowsList.Add(Row + startIndex + HideRows);
  14611. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14612. }
  14613. #endregion
  14614. #region A段Right信息
  14615. var right = dto.rightInfo.Find(x => x.Type == "A");
  14616. if (right == null)
  14617. {
  14618. return Ok(jw);
  14619. }
  14620. HideRows += 4;
  14621. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14622. if (rightBindData != null)
  14623. {
  14624. //经济舱 + 双人间 TBR
  14625. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14626. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14627. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14628. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14629. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14630. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14631. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14632. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14633. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14634. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14635. }
  14636. else
  14637. {
  14638. hideRowsList.Add(Row + startIndex + HideRows);
  14639. }
  14640. HideRows += 2;
  14641. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14642. if (rightBindData != null)
  14643. {
  14644. //经济舱 + 单人间 SGR
  14645. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14646. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14647. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14648. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14649. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14650. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14651. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14652. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14653. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14654. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14655. }
  14656. else
  14657. {
  14658. hideRowsList.Add(Row + startIndex + HideRows);
  14659. }
  14660. HideRows += 2;
  14661. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14662. if (rightBindData != null)
  14663. {
  14664. //公务舱 + 单人间 SGR
  14665. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14666. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14667. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14668. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14669. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14670. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14671. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14672. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14673. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14674. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14675. }
  14676. else
  14677. {
  14678. hideRowsList.Add(Row + startIndex + HideRows);
  14679. }
  14680. HideRows += 2;
  14681. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14682. if (rightBindData != null)
  14683. {
  14684. //公务舱 + 小套房 JSES
  14685. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14686. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14687. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14688. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14689. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14690. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14691. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14692. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14693. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14694. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14695. }
  14696. else
  14697. {
  14698. hideRowsList.Add(Row + startIndex + HideRows);
  14699. }
  14700. HideRows += 2;
  14701. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14702. if (rightBindData != null)
  14703. {
  14704. //公务舱 + 小套房 JSES
  14705. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14706. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14707. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14708. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14709. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14710. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14711. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14712. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14713. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14714. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14715. }
  14716. else
  14717. {
  14718. hideRowsList.Add(Row + startIndex + HideRows);
  14719. }
  14720. HideRows += 2;
  14721. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14722. if (rightBindData != null)
  14723. {
  14724. //经济舱 + 大套房
  14725. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14726. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14727. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14728. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14729. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14730. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14731. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14732. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14733. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14734. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14735. }
  14736. else
  14737. {
  14738. hideRowsList.Add(Row + startIndex + HideRows);
  14739. }
  14740. HideRows += 2;
  14741. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14742. if (rightBindData != null)
  14743. {
  14744. //头等舱 + 小套房 JSES
  14745. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14746. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14747. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14748. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14749. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14750. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14751. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14752. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14753. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14754. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14755. }
  14756. else
  14757. {
  14758. hideRowsList.Add(Row + startIndex + HideRows);
  14759. }
  14760. HideRows += 2;
  14761. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14762. if (rightBindData != null)
  14763. {
  14764. //头等舱 + 大套房
  14765. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  14766. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  14767. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14768. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  14769. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14770. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14771. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14772. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14773. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14774. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14775. }
  14776. else
  14777. {
  14778. hideRowsList.Add(Row + startIndex + HideRows);
  14779. }
  14780. #endregion
  14781. #region B段标题清空
  14782. designer.SetDataSource("CostBDRCB", "");
  14783. designer.SetDataSource("CostBRS", "");
  14784. designer.SetDataSource("CostBXS", "");
  14785. designer.SetDataSource("CostBZCB", "");
  14786. designer.SetDataSource("CostBDRBJ", "");
  14787. designer.SetDataSource("CostBZBJ", "");
  14788. designer.SetDataSource("CostBDRLR", "");
  14789. designer.SetDataSource("CostBZLR", "");
  14790. designer.SetDataSource("CostBDRCBOM", "");
  14791. designer.SetDataSource("CostBRSOM", "");
  14792. designer.SetDataSource("CostBZCBOM", "");
  14793. designer.SetDataSource("CostBDRBJOM", "");
  14794. designer.SetDataSource("CostBZBJOM", "");
  14795. designer.SetDataSource("CostBDRLROM", "");
  14796. designer.SetDataSource("CostBZLROM", "");
  14797. #endregion
  14798. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  14799. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  14800. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  14801. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  14802. designer.SetDataSource("DJName", "地接(CNY)");
  14803. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  14804. designer.SetDataSource("CPName", "地接-船票(CNY)");
  14805. designer.SetDataSource("GWName", "公务(CNY)");
  14806. designer.SetDataSource("YQHName", "邀请函(CNY)");
  14807. designer.SetDataSource("LYJName", "零用金(CNY)");
  14808. designer.SetDataSource("HSName", "核酸检测(CNY)");
  14809. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  14810. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  14811. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  14812. designer.SetDataSource("BXName", "保险(CNY)");
  14813. designer.SetDataSource("VisaName", "签证(CNY)");
  14814. #region B段基本数据
  14815. if (dto.costType == "B")
  14816. {
  14817. left = dto.leftInfo.Find(x => x.Type == "B");
  14818. if (left == null)
  14819. {
  14820. return Ok(jw);
  14821. }
  14822. #region B段left数据
  14823. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14824. if (leftBindData != null)
  14825. {
  14826. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  14827. designer.SetDataSource("BHSRS", leftBindData.rs);
  14828. designer.SetDataSource("BHSXS", leftBindData.xs);
  14829. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14830. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14831. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14832. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14833. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14834. }
  14835. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14836. if (leftBindData != null)
  14837. {
  14838. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  14839. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  14840. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  14841. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14842. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14843. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14844. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14845. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14846. }
  14847. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14848. if (leftBindData != null)
  14849. {
  14850. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  14851. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  14852. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  14853. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14854. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14855. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14856. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14857. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14858. }
  14859. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14860. if (leftBindData != null)
  14861. {
  14862. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  14863. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  14864. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  14865. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14866. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14867. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14868. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14869. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14870. }
  14871. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14872. if (leftBindData != null)
  14873. {
  14874. designer.SetDataSource("BHCPCB", leftBindData.cb);
  14875. designer.SetDataSource("BHCPRS", leftBindData.rs);
  14876. designer.SetDataSource("BHCPXS", leftBindData.xs);
  14877. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14878. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14879. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14880. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14881. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14882. }
  14883. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14884. if (leftBindData != null)
  14885. {
  14886. designer.SetDataSource("BCPCB", leftBindData.cb);
  14887. designer.SetDataSource("BCPRS", leftBindData.rs);
  14888. designer.SetDataSource("BCPXS", leftBindData.xs);
  14889. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14890. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14891. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14892. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14893. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14894. }
  14895. //TBR
  14896. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14897. if (leftBindData != null)
  14898. {
  14899. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  14900. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  14901. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  14902. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14903. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14904. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14905. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14906. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14907. }
  14908. //SGR
  14909. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14910. if (leftBindData != null)
  14911. {
  14912. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  14913. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  14914. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  14915. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14916. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14917. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14918. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14919. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14920. }
  14921. //JS/ES
  14922. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14923. if (leftBindData != null)
  14924. {
  14925. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  14926. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  14927. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  14928. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14929. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14930. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14931. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14932. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14933. }
  14934. //SUITE
  14935. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14936. if (leftBindData != null)
  14937. {
  14938. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  14939. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  14940. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  14941. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14942. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14943. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14944. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14945. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14946. }
  14947. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14948. if (leftBindData != null)
  14949. {
  14950. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  14951. designer.SetDataSource("BDJRS", leftBindData.rs);
  14952. designer.SetDataSource("BDJXS", leftBindData.xs);
  14953. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14954. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14955. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14956. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14957. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14958. }
  14959. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14960. if (leftBindData != null)
  14961. {
  14962. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  14963. designer.SetDataSource("BGWRS", leftBindData.rs);
  14964. designer.SetDataSource("BGWXS", leftBindData.xs);
  14965. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14966. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14967. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14968. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14969. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14970. }
  14971. #region 优化方案
  14972. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  14973. //excelBind.Add("零用金", new {
  14974. //cb="",
  14975. //rs="",
  14976. //xs ="",
  14977. //zcb = "",
  14978. //});
  14979. #endregion
  14980. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14981. if (leftBindData != null)
  14982. {
  14983. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  14984. designer.SetDataSource("BLYJRS", leftBindData.rs);
  14985. designer.SetDataSource("BLYJXS", leftBindData.xs);
  14986. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14987. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14988. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14989. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14990. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14991. }
  14992. #endregion
  14993. #region B段Right信息
  14994. right = dto.rightInfo.Find(x => x.Type == "B");
  14995. if (right == null)
  14996. {
  14997. return Ok(jw);
  14998. }
  14999. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15000. if (rightBindData != null)
  15001. {
  15002. //经济舱 + 双人间 TBR
  15003. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15004. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15005. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15006. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15007. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15008. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15009. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15010. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15011. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15012. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15013. }
  15014. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15015. if (rightBindData != null)
  15016. {
  15017. //经济舱 + 单人间 SGR
  15018. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15019. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15020. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15021. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15022. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15023. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15024. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15025. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15026. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15027. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15028. }
  15029. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15030. if (rightBindData != null)
  15031. {
  15032. //公务舱 + 单人间 SGR
  15033. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15034. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15035. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15036. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15037. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15038. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15039. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15040. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15041. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15042. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15043. }
  15044. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15045. if (rightBindData != null)
  15046. {
  15047. //公务舱 + 小套房 JSES
  15048. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15049. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15050. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15051. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15052. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15053. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15054. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15055. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15056. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15057. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15058. }
  15059. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15060. if (rightBindData != null)
  15061. {
  15062. //公务舱 + 小套房 JSES
  15063. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15064. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15065. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15066. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15067. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15068. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15069. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15070. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15071. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15072. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15073. }
  15074. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15075. if (rightBindData != null)
  15076. {
  15077. //经济舱 + 大套房
  15078. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15079. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15080. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15081. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15082. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15083. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15084. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15085. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15086. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15087. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15088. }
  15089. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15090. if (rightBindData != null)
  15091. {
  15092. //头等舱 + 小套房 JSES
  15093. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15094. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15095. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15096. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15097. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15098. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15099. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15100. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15101. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15102. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15103. }
  15104. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15105. if (rightBindData != null)
  15106. {
  15107. //头等舱 + 大套房
  15108. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15109. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15110. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15111. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15112. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15113. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15114. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15115. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15116. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15117. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15118. }
  15119. #endregion
  15120. #region 标题
  15121. designer.SetDataSource("CostBDRCB", "单人成本");
  15122. designer.SetDataSource("CostBRS", "人数");
  15123. designer.SetDataSource("CostBXS", "系数");
  15124. designer.SetDataSource("CostBZCB", "总成本");
  15125. designer.SetDataSource("CostBDRBJ", "单人报价");
  15126. designer.SetDataSource("CostBZBJ", "总报价");
  15127. designer.SetDataSource("CostBDRLR", "单人利润");
  15128. designer.SetDataSource("CostBZLR", "总利润");
  15129. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15130. designer.SetDataSource("CostBRSOM", "人数");
  15131. designer.SetDataSource("CostBZCBOM", "总成本");
  15132. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15133. designer.SetDataSource("CostBZBJOM", "总报价");
  15134. designer.SetDataSource("CostBDRLROM", "单人利润");
  15135. designer.SetDataSource("CostBZLROM", "总利润");
  15136. #endregion
  15137. }
  15138. #endregion
  15139. designer.SetDataSource("TzZCB2", TzZCB2);
  15140. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15141. designer.SetDataSource("TzZLR2", TzZLR2);
  15142. string[] dataSourceKeys = new string[]
  15143. {
  15144. "VF",
  15145. "TGS",
  15146. "TGOF",
  15147. "TGM",
  15148. "TGA",
  15149. "TGTF",
  15150. "TGEF",
  15151. "CFM",
  15152. "CFOF",
  15153. "B",
  15154. "L",
  15155. "D",
  15156. "TBR",
  15157. "SGR",
  15158. "JSES",
  15159. "Suite",
  15160. "TV",
  15161. "1L",
  15162. "IF",
  15163. "EF",
  15164. "BRF",
  15165. "TE",
  15166. "TGT",
  15167. "DRVT",
  15168. "PC",
  15169. "TLF",
  15170. "ECT"
  15171. };
  15172. foreach (var item in dataSourceKeys)
  15173. {
  15174. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15175. if (find != null)
  15176. {
  15177. designer.SetDataSource(item, find.text);
  15178. }
  15179. else
  15180. {
  15181. designer.SetDataSource(item, 0);
  15182. }
  15183. }
  15184. designer.SetDataSource(dt);
  15185. //根据数据源处理生成报表内容
  15186. designer.Process();
  15187. designer.Workbook.Worksheets[0].Name = "清单";
  15188. Worksheet sheet = designer.Workbook.Worksheets[0];
  15189. foreach (var Rowindex in hideRowsList)
  15190. {
  15191. ws.Cells.HideRows(Rowindex, 2);
  15192. }
  15193. byte[] bytes = null;
  15194. string strFileName = di.TeamName + "-团组-成本.xls";
  15195. using (MemoryStream stream = new MemoryStream())
  15196. {
  15197. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15198. bytes = stream.ToArray();
  15199. }
  15200. return Ok(JsonView(true, "", new
  15201. {
  15202. Data = bytes,
  15203. strFileName,
  15204. }));
  15205. }
  15206. /// <summary>
  15207. /// 导出客户报表
  15208. /// </summary>
  15209. /// <returns></returns>
  15210. [HttpPost]
  15211. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15212. {
  15213. var jw = JsonView(false);
  15214. if (dto.Diid == 0)
  15215. {
  15216. return Ok(JsonView(false, "请传递团组id"));
  15217. }
  15218. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15219. if (deleInfo.Code != 0)
  15220. {
  15221. return Ok(JsonView(false, "团组信息查询失败!"));
  15222. }
  15223. var di = deleInfo.Data as DelegationInfoWebView;
  15224. if (di == null)
  15225. {
  15226. return Ok(JsonView(false, "团组信息查询失败!"));
  15227. }
  15228. //文件名
  15229. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15230. //获取模板
  15231. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15232. //载入模板
  15233. Document doc = new Document(tmppath);
  15234. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15235. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15236. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15237. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15238. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15239. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15240. if (AParameter == null)
  15241. {
  15242. return Ok(JsonView(false, "系数不存在!"));
  15243. }
  15244. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15245. , TzAirDesc, TzZCost;
  15246. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15247. = TzAirDesc = TzZCost = string.Empty;
  15248. TzNumber = AParameter.CostTypenumber.ToString();
  15249. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15250. CarGuides1 = dto.CarGuides1;
  15251. Meal = dto.Meal;
  15252. SubsidizedMeals = dto.SubsidizedMeals;
  15253. NightRepair = dto.NightRepair;
  15254. AttractionsTickets = dto.AttractionsTickets;
  15255. MiscellaneousFees = dto.MiscellaneousFees;
  15256. ATip = dto.ATip;
  15257. TzHotelDesc = "";
  15258. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15259. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15260. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15261. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15262. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15263. TzAirDesc = "";
  15264. TzZCost = dto.TzZCost;
  15265. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15266. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15267. var index = 1;
  15268. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15269. foreach (var item in TzHotelDescArr)
  15270. {
  15271. if (AinfoArr != null)
  15272. {
  15273. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15274. if (Ainfo != null)
  15275. {
  15276. if (int.Parse(Ainfo.rs) <= 0)
  15277. {
  15278. continue;
  15279. }
  15280. var hotelText = string.Empty;
  15281. switch (item)
  15282. {
  15283. case "SGR":
  15284. hotelText = "单人间";
  15285. break;
  15286. case "JSES":
  15287. hotelText = "小套房";
  15288. break;
  15289. case "SUITE":
  15290. hotelText = "套房";
  15291. break;
  15292. case "TBR":
  15293. hotelText = "双人间";
  15294. break;
  15295. }
  15296. if (item != "TBR")
  15297. {
  15298. 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";
  15299. }
  15300. else
  15301. {
  15302. 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";
  15303. }
  15304. index++;
  15305. }
  15306. }
  15307. }
  15308. index = 1;
  15309. foreach (var item in TzAirDescArr)
  15310. {
  15311. if (AinfoArr != null)
  15312. {
  15313. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15314. if (Ainfo != null)
  15315. {
  15316. if (int.Parse(Ainfo.rs) <= 0)
  15317. {
  15318. continue;
  15319. }
  15320. 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";
  15321. index++;
  15322. }
  15323. }
  15324. }
  15325. if (dto.costType == "B")
  15326. {
  15327. if (BParameter == null)
  15328. {
  15329. return Ok(JsonView(false, "B段系数不存在!"));
  15330. }
  15331. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15332. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15333. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15334. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15335. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15336. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15337. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15338. foreach (var item in TzHotelDescArr)
  15339. {
  15340. if (AinfoArr != null)
  15341. {
  15342. TzHotelDesc += "B段信息 \r\n";
  15343. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15344. if (Ainfo != null)
  15345. {
  15346. if (int.Parse(Ainfo.rs) <= 0)
  15347. {
  15348. continue;
  15349. }
  15350. var hotelText = string.Empty;
  15351. switch (item)
  15352. {
  15353. case "SGR":
  15354. hotelText = "单人间";
  15355. break;
  15356. case "JSES":
  15357. hotelText = "小套房";
  15358. break;
  15359. case "SUITE":
  15360. hotelText = "套房";
  15361. break;
  15362. case "TBR":
  15363. hotelText = "双人间";
  15364. break;
  15365. }
  15366. if (item != "TBR")
  15367. {
  15368. 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";
  15369. }
  15370. else
  15371. {
  15372. 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";
  15373. }
  15374. index++;
  15375. }
  15376. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15377. }
  15378. }
  15379. index = 1;
  15380. foreach (var item in TzAirDescArr)
  15381. {
  15382. if (AinfoArr != null)
  15383. {
  15384. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15385. if (Ainfo != null)
  15386. {
  15387. if (int.Parse(Ainfo.rs) <= 0)
  15388. {
  15389. continue;
  15390. }
  15391. 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";
  15392. index++;
  15393. }
  15394. }
  15395. }
  15396. }
  15397. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15398. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15399. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15400. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15401. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15402. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15403. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15404. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15405. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15406. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15407. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15408. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15409. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15410. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15411. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15412. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15413. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15414. DickeyValue.Add("TzZCost", TzZCost);
  15415. foreach (var key in DickeyValue.Keys)
  15416. {
  15417. if (doc.Range.Bookmarks[key] != null)
  15418. {
  15419. Bookmark mark = doc.Range.Bookmarks[key];
  15420. mark.Text = DickeyValue[key];
  15421. }
  15422. }
  15423. byte[] bytes = null;
  15424. string strFileName = di.TeamName + "-客户报价.doc";
  15425. using (MemoryStream stream = new MemoryStream())
  15426. {
  15427. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15428. bytes = stream.ToArray();
  15429. }
  15430. return Ok(JsonView(true, "", new
  15431. {
  15432. Data = bytes,
  15433. strFileName,
  15434. }));
  15435. }
  15436. /// <summary>
  15437. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15438. /// </summary>
  15439. /// <param name="dto"></param>
  15440. /// <returns></returns>
  15441. [HttpPost]
  15442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15443. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15444. {
  15445. try
  15446. {
  15447. #region 参数验证
  15448. if (dto.DiId < 0)
  15449. {
  15450. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15451. }
  15452. List<int> cTableIds = new List<int>() {
  15453. 76 ,//酒店预订
  15454. 77 ,//行程
  15455. 79 ,//车/导游地接
  15456. 80 ,//签证
  15457. 81 ,//邀请/公务活
  15458. 82 ,//团组客户保险
  15459. 85 ,//机票预订
  15460. 98 ,//其他款项
  15461. 285 ,//收款退还
  15462. 751 ,//酒店早餐
  15463. 1015 // 超支费用
  15464. };
  15465. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15466. {
  15467. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15468. }
  15469. #endregion
  15470. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15471. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15472. if (_GroupCostParameters.Count <= 0)
  15473. {
  15474. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15475. }
  15476. if (_GroupCostParameters[0].IsShare == 0)
  15477. {
  15478. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15479. }
  15480. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15481. //处理date为空问题
  15482. if (_GroupCosts.Count > 0)
  15483. {
  15484. for (int i = 0; i < _GroupCosts.Count; i++)
  15485. {
  15486. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15487. {
  15488. if (i > 0)
  15489. {
  15490. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15491. }
  15492. }
  15493. }
  15494. }
  15495. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15496. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15497. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15498. string currCode = "";
  15499. #region currCode 验证
  15500. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15501. if (isInt)
  15502. {
  15503. var currData = currDatas.Find(it => it.Id == intCurrency);
  15504. if (currData != null)
  15505. {
  15506. currCode = currData.Name;
  15507. }
  15508. }
  15509. else
  15510. {
  15511. currCode = _GroupCostParameters[0].Currency.Trim();
  15512. }
  15513. #endregion
  15514. //op,酒店单段模式存储
  15515. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15516. {
  15517. CurrencyCode = currCode,
  15518. Rate = _GroupCostParameters[0].Rate,
  15519. CostType = _GroupCostParameters[0].CostType,
  15520. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15521. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15522. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15523. };
  15524. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15525. if (_GroupCostParameters.Count == 2)
  15526. {
  15527. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15528. }
  15529. foreach (var item in _GroupCostParameters)
  15530. {
  15531. decimal _rate = 1;
  15532. decimal _rate1 = item.Rate;
  15533. decimal _scale = 1;
  15534. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15535. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15536. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15537. //if (userInfo != null)
  15538. //{
  15539. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15540. // {
  15541. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15542. // {
  15543. // _scale = 1.00M;
  15544. // }
  15545. // }
  15546. //}
  15547. #endregion
  15548. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15549. {
  15550. CurrencyCode = currCode,
  15551. Rate = _rate1,
  15552. CostType = item.CostType,
  15553. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15554. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15555. CostTypeNumber = item.CostTypenumber
  15556. };
  15557. if (_GroupCostParameters.Count > 1)
  15558. {
  15559. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15560. }
  15561. else
  15562. {
  15563. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15564. }
  15565. if (dto.CTable == 79)//
  15566. {
  15567. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15568. modulePromptInfo.TotalCost = item.DJCB;
  15569. }
  15570. List<string> costTypes = new List<string>() { "A", "B" };
  15571. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15572. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15573. if (_GroupCostsDuplicates.Count() == 1)
  15574. {
  15575. _GroupCostsTypeData = _GroupCosts;
  15576. }
  15577. else
  15578. {
  15579. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15580. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15581. }
  15582. /*
  15583. * 76 酒店预订
  15584. * 77 行程
  15585. * 79 车/导游地接
  15586. * 80 签证
  15587. * 81 邀请/公务活动
  15588. * 82 团组客户保险
  15589. * 85 机票预订
  15590. * 98 其他款项
  15591. * 285 收款退还
  15592. * 751 酒店早餐
  15593. * 1015 超支费用
  15594. */
  15595. switch (dto.CTable)
  15596. {
  15597. case 76: // 酒店预订
  15598. _ModuleSubPromptInfo.AddRange(
  15599. _GroupCostsTypeData.Select(it => new
  15600. {
  15601. it.DAY,
  15602. it.Date,
  15603. it.ACCON,
  15604. it.ITIN,
  15605. it.SGR,
  15606. it.TBR,
  15607. it.JS_ES,
  15608. it.Suite
  15609. })
  15610. );
  15611. break;
  15612. case 79: // 车/导游地接
  15613. _ModuleSubPromptInfo.AddRange(
  15614. _GroupCostsTypeData.Select(it => new
  15615. {
  15616. Date = it.Date, //日期
  15617. CarFee = it.CarCost * _rate * _scale, //车费用
  15618. CarType = it.CarType, //车型
  15619. DriverFee = it.CFS * _rate * _scale, //司机工资
  15620. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15621. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15622. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15623. GuideFee = it.TGS * _rate * _scale, //导游费用
  15624. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15625. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15626. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15627. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15628. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15629. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15630. Breakfast = it.B * _rate * _scale, //早餐费
  15631. Lunch = it.L * _rate * _scale, //午餐费
  15632. Dinner = it.D * _rate * _scale, //晚餐费
  15633. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15634. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15635. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15636. TicketFee = it.EF * _rate * _scale, //门票费
  15637. TicketRemark = it.EFR, //门票费描述
  15638. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15639. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15640. SpentCash = it.PC * _rate * _scale, //零用金
  15641. LeadersFee = it.TLF * _rate * _scale, //领队费
  15642. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15643. })
  15644. );
  15645. break;
  15646. case 85: // 机票
  15647. List<dynamic> datas = new List<dynamic>();
  15648. datas.Add(
  15649. new
  15650. {
  15651. AirType = "经济舱",
  15652. AirNum = item.JJCRS,
  15653. AirDRCB = item.JJCCB,
  15654. AirZCB = (item.JJCRS * item.JJCCB)
  15655. }
  15656. );
  15657. datas.Add(
  15658. new
  15659. {
  15660. AirType = "公务舱",
  15661. AirNum = item.GWCRS,
  15662. AirDRCB = item.GWCCB,
  15663. AirZCB = (item.GWCRS * item.GWCCB)
  15664. }
  15665. );
  15666. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15667. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15668. modulePromptInfo.Data = new
  15669. {
  15670. airFeeData = datas,
  15671. airInitData = initDatas
  15672. };
  15673. _ModulePromptInfos.Add(modulePromptInfo);
  15674. break;
  15675. default:
  15676. break;
  15677. }
  15678. }
  15679. if (dto.CTable != 85)
  15680. {
  15681. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15682. _ModulePromptInfos.Add(_ModulePromptInfo);
  15683. }
  15684. _view.ModulePromptInfos = _ModulePromptInfos;
  15685. return Ok(JsonView(true, "操作成功!", _view));
  15686. }
  15687. catch (Exception ex)
  15688. {
  15689. return Ok(JsonView(false, ex.Message));
  15690. }
  15691. }
  15692. /// <summary>
  15693. /// 根据黑屏代码重新生成行程
  15694. /// </summary>
  15695. /// <param name="dto"></param>
  15696. /// <returns></returns>
  15697. [HttpPost]
  15698. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15699. {
  15700. var jw = JsonView(false,"Error");
  15701. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15702. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15703. .Select(x=> new
  15704. {
  15705. x.Id,
  15706. x.Title
  15707. })
  15708. .ToList();
  15709. if (Create.Any())
  15710. {
  15711. jw.Msg = "获取成功!";
  15712. jw.Code = 200;
  15713. jw.Data = new
  15714. {
  15715. BlackCodeListSelect = Create,
  15716. blackCodeIsTrue = true
  15717. };
  15718. }
  15719. else
  15720. {
  15721. jw.Code = 400;
  15722. jw.Data = new
  15723. {
  15724. BlackCodeListSelect = Create,
  15725. blackCodeIsTrue = false,
  15726. };
  15727. }
  15728. return Ok(jw);
  15729. }
  15730. /// <summary>
  15731. /// 根据黑屏代码Id重新生成行程
  15732. /// </summary>
  15733. /// <param name="dto"></param>
  15734. /// <returns></returns>
  15735. [HttpPost]
  15736. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15737. {
  15738. var jw = JsonView(false, "Error");
  15739. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15740. if (result.Code == 0)
  15741. {
  15742. jw.Msg = "获取成功!";
  15743. jw.Code = 200;
  15744. jw.Data = new
  15745. {
  15746. groupCost = result.Data,
  15747. blackCodeIsTrue = true
  15748. };
  15749. }
  15750. else
  15751. {
  15752. jw.Code = 400;
  15753. jw.Data = new
  15754. {
  15755. groupCost = result.Data,
  15756. blackCodeIsTrue = false,
  15757. };
  15758. }
  15759. return Ok(jw);
  15760. }
  15761. /// <summary>
  15762. /// 成本获取OP历史车费用
  15763. /// </summary>
  15764. /// <param name="dto"></param>
  15765. /// <returns></returns>
  15766. [HttpPost]
  15767. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  15768. {
  15769. var jw = JsonView(false);
  15770. try
  15771. {
  15772. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  15773. //获取现有所有车的数据
  15774. if (!dto.Param.IsNullOrWhiteSpace())
  15775. {
  15776. string sql = $@"
  15777. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  15778. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  15779. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  15780. 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
  15781. AND gctggr.ServiceEndTime is not NULL
  15782. ORDER by gctggrc.id DESC
  15783. ";
  15784. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  15785. var numeberResult = await Task.Run(() =>
  15786. {
  15787. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  15788. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  15789. return numberArr;
  15790. });
  15791. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  15792. foreach (var item in numeberResult)
  15793. {
  15794. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  15795. {
  15796. Country = "数据异常!",
  15797. City = string.Empty,
  15798. };
  15799. item.Area = find.Country + " " + find.City;
  15800. }
  15801. dbResult.AddRange(numeberResult);
  15802. if (dto.Param.Contains("、"))
  15803. {
  15804. var sp = dto.Param.Split("、");
  15805. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15806. .Where(x =>
  15807. {
  15808. return System.Array.Exists(sp, e =>
  15809. {
  15810. bool where = false;
  15811. if (x.Area != null)
  15812. {
  15813. where = x.Area.Contains(e);
  15814. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15815. {
  15816. return false;
  15817. }
  15818. }
  15819. if (x.PriceName != null && !where)
  15820. {
  15821. where = x.PriceName.Contains(e);
  15822. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15823. {
  15824. return false;
  15825. }
  15826. }
  15827. return where;
  15828. });
  15829. }).ToList();
  15830. }
  15831. else
  15832. {
  15833. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15834. .Where(x =>
  15835. {
  15836. bool where = false;
  15837. if (x.Area != null)
  15838. {
  15839. where = x.Area.Contains(dto.Param);
  15840. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15841. {
  15842. return false;
  15843. }
  15844. }
  15845. if (x.PriceName != null && !where)
  15846. {
  15847. where = x.PriceName.Contains(dto.Param);
  15848. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15849. {
  15850. return false;
  15851. }
  15852. }
  15853. return where;
  15854. }
  15855. )
  15856. .ToList();
  15857. }
  15858. }
  15859. var view = dbResult.Select(x =>
  15860. {
  15861. decimal dp = 0.00M;
  15862. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  15863. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  15864. if (string.IsNullOrWhiteSpace(x.DatePrice))
  15865. {
  15866. if (startB && endB)
  15867. {
  15868. var timesp = endD.Subtract(startD);
  15869. if ((timesp.Days + 1) != 0)
  15870. {
  15871. dp = x.Price / (timesp.Days + 1);
  15872. }
  15873. }
  15874. }
  15875. else
  15876. {
  15877. dp = x.Price;
  15878. }
  15879. return new
  15880. {
  15881. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  15882. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  15883. x.Area,
  15884. x.id,
  15885. price = x.Price.ToString("F2"),
  15886. x.PriceName,
  15887. x.PriceContent,
  15888. x.TeamName,
  15889. x.DatePrice,
  15890. dayPrice = dp.ToString("F2"),
  15891. };
  15892. }).OrderByDescending(x => x.id).ToList();
  15893. jw = JsonView(true, "获取成功!", view);
  15894. }
  15895. catch (Exception e)
  15896. {
  15897. jw = JsonView(false, e.Message);
  15898. }
  15899. return Ok(jw);
  15900. }
  15901. [HttpPost]
  15902. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  15903. {
  15904. var jw = JsonView(true);
  15905. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  15906. if (string.IsNullOrWhiteSpace(dto.Keyword))
  15907. {
  15908. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15909. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15910. WHEN COUNT(*) >= 0 THEN 'True'
  15911. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15912. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15913. ")
  15914. .ToList();
  15915. }
  15916. else
  15917. {
  15918. string likeKey = string.Empty;
  15919. foreach (var item in dto.Keyword)
  15920. {
  15921. likeKey += "%" + item;
  15922. }
  15923. likeKey += "%";
  15924. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15925. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15926. WHEN COUNT(*) >= 0 THEN 'True'
  15927. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15928. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  15929. ")
  15930. .ToList();
  15931. }
  15932. if (matches.Any())
  15933. {
  15934. jw.Data = matches;
  15935. }
  15936. else
  15937. {
  15938. jw.Code = 201;
  15939. jw.Msg = "empty list";
  15940. jw.Data = new List<string>(1);
  15941. }
  15942. return Ok(jw);
  15943. }
  15944. /// <summary>
  15945. /// 报价Word下载
  15946. /// </summary>
  15947. /// <param name="dto"></param>
  15948. /// <returns></returns>
  15949. [HttpPost]
  15950. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  15951. {
  15952. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  15953. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  15954. if (di == null)
  15955. {
  15956. return Ok(JsonView(false, "团组不存在!"));
  15957. }
  15958. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  15959. if (mainPrice == null || mainPrice.IsShare == 0)
  15960. {
  15961. return Ok(JsonView(false, "团组成本不存在!"));
  15962. }
  15963. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  15964. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  15965. if (costTypeHotelNumbers == null)
  15966. {
  15967. return Ok(JsonView(false, "团组成本不存在!"));
  15968. }
  15969. //文件名
  15970. string strFileName = di.TeamName + "-收款账单.doc";
  15971. //获取模板
  15972. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  15973. //载入模板
  15974. Document doc = new Document(tmppath);
  15975. decimal allPrice = 0.00M;
  15976. string itemStr = string.Empty;
  15977. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  15978. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  15979. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  15980. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  15981. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  15982. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  15983. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  15984. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  15985. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  15986. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  15987. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  15988. {
  15989. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  15990. ("BXRS", "BXCB", "BXXS", "bx"),
  15991. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  15992. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  15993. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  15994. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  15995. ("CPRS", "CPCB", "CPXS", "cp") ,
  15996. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  15997. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  15998. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  15999. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16000. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16001. ("DJRS", "DJCB", "DJXS", "dj") ,
  16002. ("GWRS", "GWCB", "GWXS", "gw") ,
  16003. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16004. };
  16005. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16006. var rightSum = 0.00M;
  16007. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16008. {
  16009. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16010. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16011. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16012. if (prefix == "tbr")
  16013. {
  16014. rsValue *= 2;
  16015. cbValue /= 2;
  16016. }
  16017. if (OtherCostPropertyBJ.Contains(prefix))
  16018. {
  16019. rightSum += cbValue * xsValue;
  16020. }
  16021. }
  16022. var hotelRooms = new Dictionary<string, int>
  16023. {
  16024. { "SGR", costTypeHotelNumbers.SGR },
  16025. { "TBR", costTypeHotelNumbers.TBR },
  16026. { "JSES", costTypeHotelNumbers.JSES },
  16027. { "SUITE", costTypeHotelNumbers.SUITE }
  16028. };
  16029. var flights = new Dictionary<string, int>
  16030. {
  16031. { "经济舱", mainPrice.JJCRS },
  16032. { "公务舱", mainPrice.GWCRS },
  16033. { "头等舱", mainPrice.TDCRS }
  16034. };
  16035. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16036. {
  16037. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16038. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16039. { "头等舱", new[] { "SUITE", "JSES" } }
  16040. };
  16041. var result = new Dictionary<string, int>();
  16042. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16043. foreach (var flight in flights.Keys)
  16044. {
  16045. // 获取当前舱位的匹配规则
  16046. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16047. {
  16048. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16049. }
  16050. }
  16051. #region right计算
  16052. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16053. {
  16054. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16055. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16056. airHotelPriceList.Add(new
  16057. AirHotelPrice
  16058. {
  16059. Name = "经济舱TBR",
  16060. Price = rightSum + air + hotel,
  16061. Count = result["经济舱TBR"] * 2
  16062. });
  16063. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16064. }
  16065. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16066. {
  16067. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16068. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16069. airHotelPriceList.Add(new
  16070. AirHotelPrice
  16071. {
  16072. Name = "经济舱SGR",
  16073. Price = rightSum + air + hotel,
  16074. Count = result["经济舱SGR"]
  16075. });
  16076. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16077. }
  16078. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16079. {
  16080. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16081. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16082. airHotelPriceList.Add(new
  16083. AirHotelPrice
  16084. {
  16085. Name = "公务舱SGR",
  16086. Price = rightSum + air + hotel,
  16087. Count = result["公务舱SGR"]
  16088. });
  16089. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16090. }
  16091. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16092. {
  16093. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16094. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16095. airHotelPriceList.Add(new
  16096. AirHotelPrice
  16097. {
  16098. Name = "公务舱JSES",
  16099. Price = rightSum + air + hotel,
  16100. Count = result["公务舱JSES"]
  16101. });
  16102. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16103. }
  16104. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16105. {
  16106. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16107. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16108. airHotelPriceList.Add(new
  16109. AirHotelPrice
  16110. {
  16111. Name = "公务舱SUITE",
  16112. Price = rightSum + air + hotel,
  16113. Count = result["公务舱SUITE"]
  16114. });
  16115. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16116. }
  16117. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16118. {
  16119. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16120. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16121. airHotelPriceList.Add(new
  16122. AirHotelPrice
  16123. {
  16124. Name = "经济舱SUITE",
  16125. Price = rightSum + air + hotel,
  16126. Count = result["经济舱SUITE"]
  16127. });
  16128. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16129. }
  16130. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16131. {
  16132. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16133. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16134. airHotelPriceList.Add(new
  16135. AirHotelPrice
  16136. {
  16137. Name = "头等舱JSES",
  16138. Price = rightSum + air + hotel,
  16139. Count = result["头等舱JSES"]
  16140. });
  16141. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16142. }
  16143. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16144. {
  16145. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16146. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16147. airHotelPriceList.Add(new
  16148. AirHotelPrice
  16149. {
  16150. Name = "头等舱SUITE",
  16151. Price = rightSum + air + hotel,
  16152. Count = result["头等舱SUITE"]
  16153. });
  16154. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16155. }
  16156. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16157. {
  16158. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16159. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16160. airHotelPriceList.Add(new
  16161. AirHotelPrice
  16162. {
  16163. Name = "经济舱JSES",
  16164. Price = rightSum + air + hotel,
  16165. Count = result["经济舱JSES"]
  16166. });
  16167. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16168. }
  16169. #endregion
  16170. foreach (var item in airSouer.Keys)
  16171. {
  16172. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16173. if (find != null && find.Count > 0)
  16174. {
  16175. if (item.Contains("TBR"))
  16176. {
  16177. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16178. }
  16179. else
  16180. {
  16181. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16182. }
  16183. }
  16184. }
  16185. #region 替换Word模板书签内容
  16186. Dictionary<string, string> marks = new Dictionary<string, string>();
  16187. marks.Add("To", di.ClientUnit);//付款方
  16188. marks.Add("ToTel", di.TellPhone);//付款方电话
  16189. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16190. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16191. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16192. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16193. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16194. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16195. marks.Add("PayItemContent", itemStr);//详细信息
  16196. marks.Add("Total", allPrice.ToString("F2"));//合计
  16197. #endregion
  16198. foreach (var item in marks.Keys)
  16199. {
  16200. if (doc.Range.Bookmarks[item] != null)
  16201. {
  16202. Bookmark mark = doc.Range.Bookmarks[item];
  16203. mark.Text = marks[item];
  16204. }
  16205. }
  16206. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16207. doc.Save(savePaht);
  16208. var jw = new JsonView();
  16209. jw.Msg = "生成成功!";
  16210. jw.Code = 200;
  16211. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16212. return Ok(jw);
  16213. }
  16214. /// <summary>
  16215. /// 详细报价费用Excel下载
  16216. /// </summary>
  16217. /// <param name="dto"></param>
  16218. /// <returns></returns>
  16219. [HttpPost]
  16220. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16221. {
  16222. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16223. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16224. if (di == null)
  16225. {
  16226. return Ok(JsonView(false, "团组不存在!"));
  16227. }
  16228. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16229. if (mainPrice == null || mainPrice.IsShare == 0)
  16230. {
  16231. return Ok(JsonView(false, "团组成本不存在!"));
  16232. }
  16233. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16234. .FirstAsync(x=>x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16235. if (costTypeHotelNumbers == null)
  16236. {
  16237. return Ok(JsonView(false, "团组成本不存在!"));
  16238. }
  16239. WorkbookDesigner designer = new WorkbookDesigner();
  16240. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16241. List<int> hideRowsList = new List<int>();
  16242. int conterStartIndex = 3;
  16243. int rowIndex = conterStartIndex;
  16244. designer.SetDataSource("GroupName", di.TeamName);
  16245. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16246. {
  16247. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16248. ("BXRS", "BXCB", "BXXS", "bx"),
  16249. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16250. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16251. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16252. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16253. ("CPRS", "CPCB", "CPXS", "cp") ,
  16254. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16255. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16256. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16257. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16258. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16259. ("DJRS", "DJCB", "DJXS", "dj") ,
  16260. ("GWRS", "GWCB", "GWXS", "gw") ,
  16261. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16262. };
  16263. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16264. var rightSum = 0.00M;
  16265. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16266. {
  16267. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16268. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16269. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16270. if (prefix == "tbr")
  16271. {
  16272. rsValue *= 2;
  16273. cbValue /= 2;
  16274. }
  16275. if (OtherCostPropertyBJ.Contains(prefix))
  16276. {
  16277. rightSum += cbValue * xsValue;
  16278. }
  16279. if (rsValue == 0)
  16280. {
  16281. hideRowsList.Add(rowIndex);
  16282. }
  16283. else
  16284. {
  16285. designer.SetDataSource($"{prefix}rs", rsValue);
  16286. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16287. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16288. }
  16289. rowIndex += 2;
  16290. }
  16291. var hotelRooms = new Dictionary<string, int>
  16292. {
  16293. { "SGR", costTypeHotelNumbers.SGR },
  16294. { "TBR", costTypeHotelNumbers.TBR },
  16295. { "JSES", costTypeHotelNumbers.JSES },
  16296. { "SUITE", costTypeHotelNumbers.SUITE }
  16297. };
  16298. var flights = new Dictionary<string, int>
  16299. {
  16300. { "经济舱", mainPrice.JJCRS },
  16301. { "公务舱", mainPrice.GWCRS },
  16302. { "头等舱", mainPrice.TDCRS }
  16303. };
  16304. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16305. {
  16306. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16307. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16308. { "头等舱", new[] { "SUITE", "JSES" } }
  16309. };
  16310. var result = new Dictionary<string, int>();
  16311. foreach (var flight in flights.Keys)
  16312. {
  16313. // 获取当前舱位的匹配规则
  16314. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16315. {
  16316. MatchRooms(ref hotelRooms,ref flights, roomTypes, flight,ref result);
  16317. }
  16318. }
  16319. var allPrice = 0.00M;
  16320. #region right计算
  16321. int airRowIndex = 35;
  16322. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16323. {
  16324. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16325. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16326. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16327. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16328. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16329. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16330. }
  16331. else
  16332. {
  16333. hideRowsList.Add(airRowIndex);
  16334. }
  16335. airRowIndex += 2;
  16336. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16337. {
  16338. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16339. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16340. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16341. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16342. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16343. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16344. }
  16345. else
  16346. {
  16347. hideRowsList.Add(airRowIndex);
  16348. }
  16349. airRowIndex += 2;
  16350. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16351. {
  16352. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16353. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16354. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16355. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16356. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16357. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16358. }
  16359. else
  16360. {
  16361. hideRowsList.Add(airRowIndex);
  16362. }
  16363. airRowIndex += 2;
  16364. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16365. {
  16366. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16367. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16368. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16369. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16370. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16371. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16372. }
  16373. else
  16374. {
  16375. hideRowsList.Add(airRowIndex);
  16376. }
  16377. airRowIndex += 2;
  16378. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16379. {
  16380. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16381. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16382. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16383. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16384. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16385. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16386. }
  16387. else
  16388. {
  16389. hideRowsList.Add(airRowIndex);
  16390. }
  16391. airRowIndex += 2;
  16392. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16393. {
  16394. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16395. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16396. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16397. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16398. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16399. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16400. }
  16401. else
  16402. {
  16403. hideRowsList.Add(airRowIndex);
  16404. }
  16405. airRowIndex += 2;
  16406. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16407. {
  16408. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16409. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16410. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16411. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16412. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16413. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16414. }
  16415. else
  16416. {
  16417. hideRowsList.Add(airRowIndex);
  16418. }
  16419. airRowIndex += 2;
  16420. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16421. {
  16422. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16423. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16424. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16425. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16426. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16427. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16428. }
  16429. else
  16430. {
  16431. hideRowsList.Add(airRowIndex);
  16432. }
  16433. airRowIndex += 2;
  16434. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16435. {
  16436. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16437. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16438. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16439. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16440. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16441. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16442. }
  16443. else
  16444. {
  16445. hideRowsList.Add(airRowIndex);
  16446. }
  16447. #endregion
  16448. designer.SetDataSource("AllPrice","总金额:" + allPrice.ToString("#0.00"));
  16449. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName +"_详细报批费用.xls";
  16450. var ws = designer.Workbook.Worksheets[0];
  16451. foreach (var Rowindex in hideRowsList)
  16452. {
  16453. ws.Cells.HideRows(Rowindex, 2);
  16454. }
  16455. designer.Process();
  16456. designer.Workbook.Save(savePaht);
  16457. return Ok(JsonView(true, "生成成功!", new
  16458. {
  16459. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16460. }));
  16461. }
  16462. private void MatchRooms(ref Dictionary<string, int> hotelRooms,ref Dictionary<string, int> flights, string[] roomTypes, string flightType,ref Dictionary<string, int> result)
  16463. {
  16464. foreach (var roomType in roomTypes)
  16465. {
  16466. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16467. {
  16468. hotelRooms[roomType]--;
  16469. flights[flightType]--;
  16470. if (roomType == "TBR")
  16471. {
  16472. flights[flightType]--; // 双人间在减少1
  16473. }
  16474. string key = flightType + roomType;
  16475. if (result.Keys.Contains(key))
  16476. {
  16477. result[key]++;
  16478. }
  16479. else
  16480. {
  16481. result.Add(key, 1);
  16482. }
  16483. }
  16484. }
  16485. }
  16486. private class AirHotelPrice
  16487. {
  16488. public string Name { get; set; }
  16489. public decimal Price { get; set; }
  16490. public int Count { get; set; }
  16491. }
  16492. #endregion
  16493. #region 酒店预订 新 雷怡 2023-12-28 17:45
  16494. /// <summary>
  16495. /// 酒店预订
  16496. /// 酒店费用列表 根据团组Id查询
  16497. /// </summary>
  16498. /// <param name="_dto"></param>
  16499. /// <returns></returns>
  16500. [HttpPost]
  16501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16502. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16503. {
  16504. #region 参数验证
  16505. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16506. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16507. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16508. #region 团组操作权限验证 76 酒店预定模块
  16509. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16510. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16511. #endregion
  16512. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16513. #region 页面操作权限验证
  16514. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16515. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16516. #endregion
  16517. #endregion
  16518. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  16519. }
  16520. /// <summary>
  16521. /// 酒店预订
  16522. /// 基础数据
  16523. /// </summary>
  16524. /// <param name="_dto"></param>
  16525. /// <returns></returns>
  16526. [HttpPost]
  16527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16528. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16529. {
  16530. #region 参数验证
  16531. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16532. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16533. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16534. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16535. #region 页面操作权限验证
  16536. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16537. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16538. #endregion
  16539. #region 团组操作权限验证 76 酒店预定模块
  16540. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16541. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16542. #endregion
  16543. #endregion
  16544. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  16545. }
  16546. /// <summary>
  16547. /// 酒店预订
  16548. /// 创建 入住卷号码
  16549. /// </summary>
  16550. /// <param name="_dto"></param>
  16551. /// <returns></returns>
  16552. [HttpPost]
  16553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16554. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16555. {
  16556. #region 参数验证
  16557. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16558. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16559. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16560. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16561. #region 页面操作权限验证
  16562. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16563. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16564. #endregion
  16565. #region 团组操作权限验证 76 酒店预定模块
  16566. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16567. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16568. #endregion
  16569. #endregion
  16570. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  16571. if (data.Code != 0)
  16572. {
  16573. return Ok(JsonView(false, data.Msg));
  16574. }
  16575. return Ok(JsonView(true, data.Msg, data.Data));
  16576. }
  16577. /// <summary>
  16578. /// 酒店预订
  16579. /// 详情
  16580. /// </summary>
  16581. /// <param name="_dto"></param>
  16582. /// <returns></returns>
  16583. [HttpPost]
  16584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16585. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16586. {
  16587. #region 参数验证
  16588. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16589. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16590. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16591. #region 团组操作权限验证 76 酒店预定模块
  16592. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16593. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16594. #endregion
  16595. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16596. #region 页面操作权限验证
  16597. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16598. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16599. #endregion
  16600. #endregion
  16601. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  16602. }
  16603. /// <summary>
  16604. /// 酒店预订
  16605. /// Add Or Edit
  16606. /// </summary>
  16607. /// <param name="_dto"></param>
  16608. /// <returns></returns>
  16609. [HttpPost]
  16610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16611. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16612. {
  16613. #region 参数验证
  16614. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16615. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16616. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16617. #region 团组操作权限验证 76 酒店预定模块
  16618. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16619. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16620. #endregion
  16621. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16622. #region 页面操作权限验证
  16623. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16624. if (_dto.Id == 0) // Add
  16625. {
  16626. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16627. }
  16628. else if (_dto.Id > 1) // Edit
  16629. {
  16630. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16631. }
  16632. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16633. #endregion
  16634. #endregion
  16635. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  16636. if (_view.Code != 200)
  16637. {
  16638. return Ok(_view);
  16639. }
  16640. #region 成本无酒店价格数据进入超支
  16641. _sqlSugar.BeginTran();
  16642. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  16643. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  16644. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  16645. for (int i = 0; i < groupCost.Count; i++)
  16646. {
  16647. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  16648. {
  16649. groupCost[i].Date = groupCost[i - 1].Date;
  16650. }
  16651. }
  16652. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  16653. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  16654. List<Fin_GroupExtraCostDto_OP>();
  16655. if (start_Bool && end_Bool)
  16656. {
  16657. while (start_Time < end_Time)
  16658. {
  16659. foreach (var item in groupCost_Grp)
  16660. {
  16661. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  16662. {
  16663. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  16664. {
  16665. extraCostList.Add(new
  16666. Fin_GroupExtraCostDto_OP
  16667. {
  16668. Area = _dto.AreaId,
  16669. coefficient = 1.5M,
  16670. createUser = _dto.UserId,
  16671. currency = _dto.CardPriceCurrency,
  16672. diId = _dto.DiId,
  16673. ManagerConfirm = 0,
  16674. SupervisorConfirm = 0,
  16675. SYsupervisorConfirm = 0,
  16676. editType = 1,
  16677. PortType = 1,
  16678. price = _dto.CardPrice,
  16679. PriceCount = 1,
  16680. priceType = 1027,
  16681. priceDetailType = 1044,
  16682. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  16683. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  16684. });
  16685. }
  16686. }
  16687. }
  16688. start_Time = start_Time.AddDays(1);
  16689. }
  16690. }
  16691. if (extraCostList.Any())
  16692. {
  16693. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  16694. }
  16695. _sqlSugar.CommitTran();
  16696. #endregion
  16697. #region 应用推送
  16698. try
  16699. {
  16700. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16701. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16702. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16703. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16704. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16705. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16706. var diId = _dto.DiId;
  16707. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16708. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16709. #region 操作记录
  16710. var opInfo = new Crm_TableOperationRecord()
  16711. {
  16712. TableName = "Grp_HotelReservations",
  16713. PortType = _dto.PortType,
  16714. DataId = hotelId,
  16715. CreateUserId = _dto.UserId
  16716. };
  16717. //var opStatus = OperationEnum.NoOperation;
  16718. if (_dto.Id < 1) //添加操作
  16719. {
  16720. opInfo.OperationItem = OperationEnum.Add;
  16721. }
  16722. else if (_dto.Id > 0)
  16723. {
  16724. opInfo.OperationItem = OperationEnum.Edit;
  16725. }
  16726. string opRemark = string.Empty;
  16727. if (ccpInfo != null)
  16728. {
  16729. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  16730. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  16731. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  16732. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  16733. }
  16734. opInfo.Remark = opRemark;
  16735. await _tableorRep.AddAsync(opInfo);
  16736. #endregion
  16737. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  16738. //2024-10-21 新增LZ UID
  16739. var userIds = new List<int>() { 21 };
  16740. string title = $"费用审核";
  16741. string content = "";
  16742. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16743. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16744. try
  16745. {
  16746. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  16747. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  16748. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  16749. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  16750. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  16751. }
  16752. catch (Exception ex)
  16753. {
  16754. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  16755. }
  16756. }
  16757. catch (Exception ex)
  16758. {
  16759. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  16760. }
  16761. try
  16762. {
  16763. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16764. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16765. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16766. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16767. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16768. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16769. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16770. //自动审核
  16771. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  16772. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  16773. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  16774. //2024-10-21 新增LZ UID
  16775. var userIds = new List<int>() { 21 };
  16776. string title = $"系统通知";
  16777. var diId = _dto.DiId;
  16778. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16779. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16780. string content = "";
  16781. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16782. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16783. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16784. }
  16785. catch (Exception ex)
  16786. {
  16787. }
  16788. #endregion
  16789. return Ok(_view);
  16790. }
  16791. /// <summary>
  16792. /// 酒店自动审核测试
  16793. /// Add Or Edit
  16794. /// </summary>
  16795. /// <param name="diid"></param>
  16796. /// <param name="dataId"></param>
  16797. /// <returns></returns>
  16798. [HttpPost]
  16799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16800. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  16801. {
  16802. #region 应用推送
  16803. try
  16804. {
  16805. //自动审核
  16806. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  16807. }
  16808. catch (Exception ex)
  16809. {
  16810. return Ok(JsonView(false, "操作失败"));
  16811. }
  16812. #endregion
  16813. return Ok(JsonView(false, "操作成功"));
  16814. }
  16815. /// <summary>
  16816. /// 酒店预订
  16817. /// Del
  16818. /// </summary>
  16819. /// <param name="_dto"></param>
  16820. /// <returns></returns>
  16821. [HttpPost]
  16822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16823. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  16824. {
  16825. #region 参数验证
  16826. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16827. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16828. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16829. #region 团组操作权限验证 76 酒店预定模块
  16830. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16831. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16832. #endregion
  16833. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16834. #region 页面操作权限验证
  16835. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16836. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16837. #endregion
  16838. #endregion
  16839. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  16840. #region 操作记录
  16841. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  16842. {
  16843. TableName = "Grp_HotelReservations",
  16844. PortType = _dto.PortType,
  16845. OperationItem = OperationEnum.Del,
  16846. DataId = _dto.Id,
  16847. CreateUserId = _dto.UserId
  16848. });
  16849. #endregion
  16850. return Ok(data);
  16851. }
  16852. /// <summary>
  16853. /// 酒店预订
  16854. /// 生成VOUCHER
  16855. /// 2024.05.06 之前版本
  16856. /// </summary>
  16857. /// <param name="_dto"></param>
  16858. /// <returns></returns>
  16859. [HttpPost]
  16860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16861. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  16862. {
  16863. try
  16864. {
  16865. #region 参数验证
  16866. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16867. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16868. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16869. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  16870. #region 团组操作权限验证 76 酒店预定模块
  16871. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16872. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16873. #endregion
  16874. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16875. #region 页面操作权限验证
  16876. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16877. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16878. #endregion
  16879. #endregion
  16880. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  16881. //判断数据是否完整
  16882. if (hr != null)
  16883. {
  16884. if (!string.IsNullOrEmpty(hr.DetermineNo))
  16885. {
  16886. string strFileName = "HotelStatement/";
  16887. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16888. if (dele != null)
  16889. strFileName += dele.TourCode;
  16890. //载入模板
  16891. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  16892. Document doc = new Document(sss);
  16893. DocumentBuilder builder = new DocumentBuilder(doc);
  16894. #region 替换Word模板书签内容
  16895. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  16896. //入住卷预定号码
  16897. if (doc.Range.Bookmarks["VNO"] != null)
  16898. {
  16899. Bookmark mark = doc.Range.Bookmarks["VNO"];
  16900. mark.Text = hr.CheckNumber;
  16901. }
  16902. //酒店时间
  16903. if (doc.Range.Bookmarks["Date"] != null)
  16904. {
  16905. Bookmark mark = doc.Range.Bookmarks["Date"];
  16906. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16907. }
  16908. //团号
  16909. if (doc.Range.Bookmarks["TNo"] != null)
  16910. {
  16911. Bookmark mark = doc.Range.Bookmarks["TNo"];
  16912. mark.Text = dele.TourCode;
  16913. }
  16914. //预定号码
  16915. if (doc.Range.Bookmarks["BookingId"] != null)
  16916. {
  16917. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  16918. mark.Text = hr.ReservationsNo;
  16919. }
  16920. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  16921. {
  16922. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  16923. mark.Text = hr.DetermineNo;
  16924. }
  16925. //酒店城市
  16926. if (doc.Range.Bookmarks["City"] != null)
  16927. {
  16928. Bookmark mark = doc.Range.Bookmarks["City"];
  16929. mark.Text = hr.City;
  16930. }
  16931. //酒店名称
  16932. if (doc.Range.Bookmarks["HName"] != null)
  16933. {
  16934. Bookmark mark = doc.Range.Bookmarks["HName"];
  16935. mark.Text = hr.HotelName;
  16936. }
  16937. //酒店地址
  16938. if (doc.Range.Bookmarks["Address"] != null)
  16939. {
  16940. Bookmark mark = doc.Range.Bookmarks["Address"];
  16941. mark.Text = hr.HotelAddress;
  16942. }
  16943. //酒店电话
  16944. if (doc.Range.Bookmarks["Tel"] != null)
  16945. {
  16946. Bookmark mark = doc.Range.Bookmarks["Tel"];
  16947. mark.Text = hr.HotelTel;
  16948. }
  16949. //酒店传真
  16950. if (doc.Range.Bookmarks["Fax"] != null)
  16951. {
  16952. Bookmark mark = doc.Range.Bookmarks["Fax"];
  16953. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  16954. {
  16955. mark.Text = hr.HotelFax;
  16956. }
  16957. }
  16958. //入住时间
  16959. if (doc.Range.Bookmarks["CIn"] != null)
  16960. {
  16961. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16962. Bookmark mark = doc.Range.Bookmarks["CIn"];
  16963. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  16964. }
  16965. //退房时间
  16966. if (doc.Range.Bookmarks["COut"] != null)
  16967. {
  16968. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16969. Bookmark mark = doc.Range.Bookmarks["COut"];
  16970. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16971. }
  16972. //客户名称
  16973. if (doc.Range.Bookmarks["GName"] != null)
  16974. {
  16975. string guestName = "";
  16976. string[] clients = new string[] { };
  16977. if (hr.GuestName.Contains(","))
  16978. {
  16979. clients = hr.GuestName.Split(",");
  16980. }
  16981. else
  16982. {
  16983. clients = new string[] { hr.GuestName };
  16984. }
  16985. List<int> clientIds_int = new List<int>();
  16986. if (clients.Length > 0)
  16987. {
  16988. foreach (var item in clients)
  16989. {
  16990. if (item.IsNumeric())
  16991. {
  16992. clientIds_int.Add(int.Parse(item));
  16993. }
  16994. }
  16995. }
  16996. if (clientIds_int.Count > 0)
  16997. {
  16998. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  16999. foreach (var client in _clientDatas)
  17000. {
  17001. //男
  17002. if (client.Sex == 0) guestName += $"Mr.";
  17003. //女
  17004. else if (client.Sex == 1) guestName += $"Ms.";
  17005. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17006. {
  17007. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17008. }
  17009. //guestName += $"{client.Pinyin},";
  17010. }
  17011. if (guestName.Length > 0)
  17012. {
  17013. guestName = guestName.Substring(0, guestName.Length - 1);
  17014. }
  17015. }
  17016. else
  17017. {
  17018. guestName = hr.GuestName;
  17019. }
  17020. Bookmark mark = doc.Range.Bookmarks["GName"];
  17021. mark.Text = guestName;
  17022. }
  17023. //房间介绍
  17024. if (doc.Range.Bookmarks["ROOM"] != null)
  17025. {
  17026. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17027. mark.Text = hr.RoomExplanation;
  17028. }
  17029. //报价描述
  17030. if (doc.Range.Bookmarks["NOTE"] != null)
  17031. {
  17032. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17033. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17034. if (ss != null)
  17035. mark.Text = ss.Name;
  17036. }
  17037. //入住时间
  17038. if (doc.Range.Bookmarks["CheckIn"] != null)
  17039. {
  17040. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17041. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17042. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17043. }
  17044. //退房时间
  17045. if (doc.Range.Bookmarks["CheckOut"] != null)
  17046. {
  17047. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17048. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17049. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17050. }
  17051. //日期
  17052. if (doc.Range.Bookmarks["DT"] != null)
  17053. {
  17054. Bookmark mark = doc.Range.Bookmarks["DT"];
  17055. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17056. }
  17057. //名称
  17058. if (doc.Range.Bookmarks["VName"] != null)
  17059. {
  17060. Bookmark mark = doc.Range.Bookmarks["VName"];
  17061. mark.Text = hr.HotelName;
  17062. }
  17063. //号码
  17064. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17065. {
  17066. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17067. mark.Text = hr.CheckNumber;
  17068. }
  17069. #endregion
  17070. strFileName += "VOUCHER.doc";
  17071. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17072. doc.Save(fileDir);
  17073. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17074. return Ok(JsonView(true, "操作成功!", Url));
  17075. }
  17076. else
  17077. {
  17078. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17079. }
  17080. }
  17081. else
  17082. {
  17083. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17084. }
  17085. }
  17086. catch (Exception ex)
  17087. {
  17088. return Ok(JsonView(false, ex.Message));
  17089. }
  17090. }
  17091. /// <summary>
  17092. /// 酒店预订
  17093. /// 生成VOUCHER
  17094. /// 2024.05.06 之后版本
  17095. /// </summary>
  17096. /// <param name="_dto"></param>
  17097. /// <returns></returns>
  17098. [HttpPost]
  17099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17100. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17101. {
  17102. #region 参数验证
  17103. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17104. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17105. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17106. #region 团组操作权限验证 76 酒店预定模块
  17107. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17108. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17109. #endregion
  17110. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17111. #region 页面操作权限验证
  17112. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17113. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17114. #endregion
  17115. #endregion
  17116. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17117. //判断数据是否完整
  17118. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17119. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17120. string strFileName = "HotelStatement/";
  17121. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17122. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17123. #region 数据处理
  17124. List<int> guestIds = new List<int>();
  17125. //int index = 0;
  17126. foreach (var item in hrDtas)
  17127. {
  17128. if (item.GuestName.Contains(","))
  17129. {
  17130. string[] guestIdArr = item.GuestName.Split(',');
  17131. foreach (var guestIdStr in guestIdArr)
  17132. {
  17133. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17134. if (guestBool)
  17135. {
  17136. guestIds.Add(guestId);
  17137. }
  17138. }
  17139. }
  17140. else guestNames += item.GuestName;
  17141. var voucherInfo = new HotelVoucherInfoView()
  17142. {
  17143. HotelName = item.HotelName,
  17144. CheckInDate = item.CheckInDate,
  17145. CheckOutDate = item.CheckOutDate,
  17146. ConfirmationNumber = item.DetermineNo.Trim(),
  17147. RoomType = item.RoomExplanation
  17148. };
  17149. vouchers.Add(voucherInfo);
  17150. }
  17151. if (guestIds.Count > 0)
  17152. {
  17153. guestIds = guestIds.Distinct().ToList();
  17154. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17155. if (guestDatas.Count > 0)
  17156. {
  17157. guestNames = "";
  17158. foreach (var guest in guestDatas)
  17159. {
  17160. string guestName = "";
  17161. if (guest.Sex == 0) guestName += @"MR.";
  17162. else if (guest.Sex == 1) guestName += @"MS.";
  17163. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17164. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17165. guestNames += @$"{guestName.Trim()}、";
  17166. }
  17167. if (guestNames.Length > 0)
  17168. {
  17169. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17170. }
  17171. }
  17172. }
  17173. #endregion
  17174. //载入模板
  17175. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17176. Document doc = new Document(sss);
  17177. DocumentBuilder builder = new DocumentBuilder(doc);
  17178. if (doc.Range.Bookmarks["GuestName"] != null)
  17179. {
  17180. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17181. mark.Text = guestNames;
  17182. }
  17183. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17184. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17185. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17186. for (int i = 1; i <= vouchers.Count; i++)
  17187. {
  17188. HotelVoucherInfoView hviv = vouchers[i - 1];
  17189. builder.MoveToCell(0, i, 0, 0);
  17190. builder.Write(hviv.HotelName);
  17191. builder.MoveToCell(0, i, 1, 0);
  17192. builder.Write(hviv.CheckInDate);
  17193. builder.MoveToCell(0, i, 2, 0);
  17194. builder.Write(hviv.CheckOutDate);
  17195. builder.MoveToCell(0, i, 3, 0);
  17196. builder.Write(hviv.RoomType);
  17197. builder.MoveToCell(0, i, 4, 0);
  17198. builder.Write(hviv.ConfirmationNumber);
  17199. }
  17200. //删除多余行
  17201. int currRowIndex = vouchers.Count + 1;
  17202. int delRows = 21 - currRowIndex;
  17203. if (delRows > 0)
  17204. {
  17205. for (int i = 0; i < delRows; i++)
  17206. {
  17207. table.Rows.RemoveAt(currRowIndex);
  17208. //cultivateRowIndex++;
  17209. }
  17210. }
  17211. strFileName += "VOUCHER.docx";
  17212. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17213. doc.Save(fileDir);
  17214. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17215. return Ok(JsonView(true, "操作成功!", Url));
  17216. }
  17217. /// <summary>
  17218. /// 酒店预订
  17219. /// 生成VOUCHER 批量生成
  17220. /// New
  17221. /// </summary>
  17222. /// <param name="_dto"></param>
  17223. /// <returns></returns>
  17224. [HttpPost]
  17225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17226. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17227. {
  17228. #region 参数验证
  17229. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17230. if (_dto.PageId < 1) _dto.PageId = 28;
  17231. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17232. #region 团组操作权限验证 76 酒店预定模块
  17233. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17234. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17235. #endregion
  17236. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17237. #region 页面操作权限验证
  17238. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17239. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17240. #endregion
  17241. #endregion
  17242. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17243. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17244. .OrderBy(x => x.CheckInDate)
  17245. .ToListAsync();
  17246. //判断数据是否完整
  17247. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17248. string strFileName = "HotelStatement/";
  17249. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17250. if (dele != null)
  17251. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17252. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17253. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17254. .Where(it => it.IsDel == 0)
  17255. .ToListAsync();
  17256. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17257. for (int i = 0; i < hrDtas.Count; i++)
  17258. {
  17259. string guestNames = string.Empty;
  17260. List<int> guestIds = new List<int>();
  17261. var item = hrDtas[i];
  17262. //处理客户姓名
  17263. if (item.GuestName.Contains(","))
  17264. {
  17265. string[] guestIdArr = item.GuestName.Split(',');
  17266. foreach (var guestIdStr in guestIdArr)
  17267. if (int.TryParse(guestIdStr, out int guestId))
  17268. guestIds.Add(guestId);
  17269. }
  17270. else
  17271. {
  17272. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17273. if (guestIdBool)
  17274. {
  17275. guestIds.Add(guestId);
  17276. }
  17277. //NaN
  17278. if (item.GuestName.Contains("NaN"))
  17279. {
  17280. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17281. }
  17282. }
  17283. if (guestIds.Count > 0)
  17284. {
  17285. guestIds = guestIds.Distinct().ToList();
  17286. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17287. if (guestDatas1.Count > 0)
  17288. {
  17289. guestNames = "";
  17290. foreach (var guest in guestDatas1)
  17291. {
  17292. string guestName = "";
  17293. if (guest.Sex == 0) guestName += @"MR.";
  17294. else if (guest.Sex == 1) guestName += @"MS.";
  17295. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17296. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17297. guestNames += @$"{guestName.Trim()}、";
  17298. }
  17299. if (guestNames.Length > 0)
  17300. {
  17301. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17302. }
  17303. }
  17304. }
  17305. //if (!string.IsNullOrEmpty(guestNames))
  17306. //{
  17307. hrDtas[i].GuestName = guestNames;
  17308. //}
  17309. }
  17310. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17311. Document doc = new Document();
  17312. DocumentBuilder builder = new DocumentBuilder(doc);
  17313. try
  17314. {
  17315. builder.MoveToDocumentStart();
  17316. foreach (var item in hrDtas)
  17317. {
  17318. //标题
  17319. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17320. builder.ParagraphFormat.LineSpacing = 1;
  17321. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17322. builder.ParagraphFormat.Style.Font.Size = 9;
  17323. builder.ParagraphFormat.Style.Font.Bold = true;
  17324. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17325. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17326. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17327. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17328. builder.ParagraphFormat.LineSpacing = 1;
  17329. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17330. builder.ParagraphFormat.Style.Font.Size = 9;
  17331. builder.ParagraphFormat.Style.Font.Bold = true;
  17332. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17333. builder.StartTable();
  17334. // 设置边框颜色
  17335. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17336. //设置边框样式
  17337. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17338. //表格
  17339. #region 第一行
  17340. builder.InsertCell();
  17341. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17342. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17343. //builder.CellFormat.AllowAutoFit = false;
  17344. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17345. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17346. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17347. builder.CellFormat.WrapText = true; //自动换行
  17348. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17349. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17350. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17351. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17352. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17353. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17354. builder.Write("TOUR NO:");
  17355. builder.InsertCell();
  17356. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17357. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17358. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17359. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17360. builder.ParagraphFormat.Style.Font.Bold = false;
  17361. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17362. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17363. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17364. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17365. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17366. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17367. builder.Write($"{dele?.TourCode ?? "-"}");
  17368. builder.InsertCell();
  17369. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17370. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17371. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17372. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17373. builder.ParagraphFormat.Style.Font.Bold = false;
  17374. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17375. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17376. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17377. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17378. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17379. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17380. builder.Write($"CITY:");
  17381. builder.InsertCell();
  17382. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17383. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17384. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17385. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17386. builder.ParagraphFormat.Style.Font.Bold = false;
  17387. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17388. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17389. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17390. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17391. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17392. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17393. builder.Write($"{item.City}");
  17394. builder.EndRow();
  17395. #endregion
  17396. #region 第二行
  17397. builder.InsertCell();
  17398. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17399. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17400. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17401. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17402. builder.ParagraphFormat.Style.Font.Bold = false;
  17403. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17404. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17405. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17406. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17407. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17408. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17409. builder.Write("CONFIRMATION NO:");
  17410. builder.InsertCell();
  17411. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17412. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17413. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17414. builder.ParagraphFormat.Style.Font.Bold = false;
  17415. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17416. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17417. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17418. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17419. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17420. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17421. builder.CellFormat.VerticalMerge = CellMerge.None;
  17422. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17423. builder.Write($"{item.DetermineNo}");
  17424. builder.InsertCell();
  17425. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17426. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17427. builder.InsertCell();
  17428. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17429. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17430. builder.EndRow();
  17431. #endregion
  17432. #region 第三行
  17433. builder.InsertCell();
  17434. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17435. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17436. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17437. builder.ParagraphFormat.Style.Font.Bold = false;
  17438. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17439. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17440. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17441. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17442. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17443. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17444. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17445. builder.Write($"HOTEL NAME:");
  17446. builder.InsertCell();
  17447. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17448. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17449. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17450. builder.ParagraphFormat.Style.Font.Bold = false;
  17451. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17452. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17453. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17454. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17455. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17456. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17457. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17458. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17459. builder.Write($"{item.HotelName}");
  17460. builder.InsertCell();
  17461. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17462. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17463. builder.InsertCell();
  17464. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17465. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17466. builder.EndRow();
  17467. #endregion
  17468. #region 第四行
  17469. builder.InsertCell();
  17470. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17471. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17472. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17473. builder.ParagraphFormat.Style.Font.Bold = false;
  17474. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17475. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17476. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17477. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17478. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17479. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17480. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17481. builder.Write($"HOTEL ADDRESS:");
  17482. builder.InsertCell();
  17483. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17484. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17485. builder.ParagraphFormat.Style.Font.Size = 8;
  17486. builder.ParagraphFormat.Style.Font.Bold = false;
  17487. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17488. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17489. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17490. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17491. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17492. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17493. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17494. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17495. builder.Write($"{item.HotelAddress}");
  17496. builder.InsertCell();
  17497. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17498. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17499. builder.InsertCell();
  17500. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17501. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17502. builder.EndRow();
  17503. #endregion
  17504. #region 第五行
  17505. builder.InsertCell();
  17506. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17507. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17508. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17509. builder.ParagraphFormat.Style.Font.Bold = false;
  17510. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17511. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17512. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17513. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17514. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17515. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17516. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17517. builder.Write("TEL:");
  17518. builder.InsertCell();
  17519. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17520. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17521. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17522. builder.ParagraphFormat.Style.Font.Bold = false;
  17523. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17524. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17525. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17526. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17527. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17528. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17529. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17530. builder.Write($"{item.HotelTel}");
  17531. builder.InsertCell();
  17532. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17533. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17534. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17535. builder.ParagraphFormat.Style.Font.Bold = false;
  17536. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17537. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17538. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17539. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17540. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17541. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17542. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17543. builder.Write($"FAX:");
  17544. builder.InsertCell();
  17545. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17546. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17547. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17548. builder.ParagraphFormat.Style.Font.Bold = false;
  17549. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17550. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17551. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17552. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17553. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17554. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17555. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17556. builder.Write($"{item.HotelFax}");
  17557. builder.EndRow();
  17558. #endregion
  17559. #region 第六行
  17560. builder.InsertCell();
  17561. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17562. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17563. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17564. builder.ParagraphFormat.Style.Font.Bold = false;
  17565. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17566. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17567. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17568. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17569. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17570. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17571. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17572. builder.Write("CHECK IN:");
  17573. builder.InsertCell();
  17574. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17575. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17576. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17577. builder.ParagraphFormat.Style.Font.Bold = false;
  17578. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17579. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17580. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17581. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17582. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17583. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17584. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17585. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17586. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17587. builder.Write($"{checkInStr}");
  17588. builder.InsertCell();
  17589. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17590. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17591. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17592. builder.ParagraphFormat.Style.Font.Bold = false;
  17593. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17594. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17595. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17596. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17597. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17598. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17599. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17600. builder.Write($"CHECK OUT:");
  17601. builder.InsertCell();
  17602. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17603. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17604. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17605. builder.ParagraphFormat.Style.Font.Bold = false;
  17606. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17607. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17608. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17609. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17610. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17611. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17612. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17613. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17614. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17615. builder.Write($"{checkOutStr}");
  17616. builder.EndRow();
  17617. #endregion
  17618. #region 第七行
  17619. builder.InsertCell();
  17620. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17621. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17622. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17623. builder.ParagraphFormat.Style.Font.Bold = false;
  17624. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17625. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17626. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17627. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17628. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17629. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17630. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17631. builder.Write($"GUEST NAME:");
  17632. builder.InsertCell();
  17633. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17634. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17635. builder.ParagraphFormat.Style.Font.Size = 8;
  17636. builder.ParagraphFormat.Style.Font.Bold = false;
  17637. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17638. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17639. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17640. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17641. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17642. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17643. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17644. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17645. builder.Write($"{item.GuestName}");
  17646. builder.InsertCell();
  17647. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17648. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17649. builder.InsertCell();
  17650. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17651. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17652. builder.EndRow();
  17653. #endregion
  17654. #region 第八行
  17655. builder.InsertCell();
  17656. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17657. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17658. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17659. builder.ParagraphFormat.Style.Font.Bold = false;
  17660. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17661. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17662. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17663. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17664. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17665. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17666. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17667. builder.Write($"ROOM TYPE:");
  17668. builder.InsertCell();
  17669. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17670. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17671. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17672. builder.ParagraphFormat.Style.Font.Bold = false;
  17673. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17674. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17675. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17676. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17677. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17678. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17679. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17680. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17681. builder.Write($"{item.RoomExplanation}");
  17682. builder.InsertCell();
  17683. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17684. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17685. builder.InsertCell();
  17686. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17687. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17688. builder.EndRow();
  17689. #endregion
  17690. #region 第九行
  17691. builder.InsertCell();
  17692. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17693. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17694. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17695. builder.ParagraphFormat.Style.Font.Bold = false;
  17696. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17697. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17698. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17699. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17700. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17701. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17702. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17703. builder.Write($"NOTE:");
  17704. builder.InsertCell();
  17705. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17706. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17707. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17708. builder.ParagraphFormat.Style.Font.Bold = false;
  17709. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17710. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17711. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17712. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17713. 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.");
  17714. builder.InsertCell();
  17715. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17716. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17717. builder.InsertCell();
  17718. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17719. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17720. builder.EndRow();
  17721. #endregion
  17722. builder.EndTable();
  17723. //换行
  17724. builder.Writeln("");
  17725. builder.Writeln("");
  17726. }
  17727. #region 获取文档中的所有表格 设置文字自适应
  17728. // 获取文档中的所有表格。
  17729. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17730. {
  17731. // 遍历表格中的所有行。
  17732. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17733. {
  17734. foreach (Cell cell in row.Cells)
  17735. {
  17736. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  17737. cellFormat.Width = 0;
  17738. }
  17739. }
  17740. }
  17741. #endregion
  17742. #region 设置页眉
  17743. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  17744. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  17745. if (System.IO.File.Exists(voucherHeaderPath))
  17746. {
  17747. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  17748. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  17749. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  17750. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  17751. // 调整图片位置
  17752. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  17753. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  17754. shape.Top = 50; // 将图片距离页眉上边缘的距离
  17755. shape.Left = 0; // 将图片距离页面左边缘的距离
  17756. shape.Width = 81; // 设置图片宽度
  17757. shape.Height = 36; // 设置图片高度
  17758. }
  17759. //靠右
  17760. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17761. //// 设置页脚上下边距
  17762. //builder.PageSetup.HeaderDistance = 42;
  17763. // 添加页眉线
  17764. Aspose.Words.Border borderHeader = null;
  17765. try
  17766. {
  17767. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  17768. }
  17769. catch (Exception e)
  17770. {
  17771. // TODO Auto-generated catch block
  17772. //e.printStackTrace();
  17773. }
  17774. borderHeader.Shadow = true;
  17775. borderHeader.DistanceFromText = 2;
  17776. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  17777. #endregion
  17778. }
  17779. catch (Exception ex)
  17780. {
  17781. }
  17782. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17783. doc.Save(fileDir);
  17784. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17785. return Ok(JsonView(true, "操作成功!", Url));
  17786. }
  17787. /// <summary>
  17788. /// 酒店预订
  17789. /// 生成 预定成本 Excel
  17790. /// </summary>
  17791. /// <param name="_dto"></param>
  17792. /// <returns></returns>
  17793. [HttpPost]
  17794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17795. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  17796. {
  17797. #region 参数验证
  17798. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  17799. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  17800. if (!vadalitorRes.IsValid)
  17801. {
  17802. var errors = new StringBuilder();
  17803. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  17804. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  17805. }
  17806. #region 团组操作权限验证 76 酒店预定模块
  17807. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17808. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17809. #endregion
  17810. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17811. #region 页面操作权限验证
  17812. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17813. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17814. #endregion
  17815. #endregion
  17816. decimal _rate = 1.00M;
  17817. string _currency = string.Empty;
  17818. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  17819. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17820. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  17821. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  17822. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  17823. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  17824. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  17825. if (_GroupCostParameter == null)
  17826. {
  17827. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  17828. bool isIntType = int.TryParse(_currency, out int currId);
  17829. if (isIntType)
  17830. {
  17831. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17832. }
  17833. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17834. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17835. if (currInfo == null)
  17836. {
  17837. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17838. }
  17839. else _rate = currInfo.Rate;
  17840. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  17841. {
  17842. _rate = _GroupCostParameter.Rate;
  17843. }
  17844. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17845. //string strFileName = "HotelStatement/";
  17846. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17847. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17848. var rateDatas = new List<dynamic>();
  17849. #region 数据处理
  17850. foreach (var item in hrDtas)
  17851. {
  17852. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17853. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17854. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17855. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17856. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17857. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  17858. {
  17859. continue;
  17860. }
  17861. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17862. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  17863. string singleRoomFeeStr = string.Empty,
  17864. doubleRoomFeeStr = string.Empty,
  17865. suiteRoomFeeStr = string.Empty,
  17866. otherRoomFeeStr = string.Empty,
  17867. payMoneyStr = string.Empty,
  17868. cardPriceStr = string.Empty;
  17869. if (roomCurr.Equals("CNY"))
  17870. {
  17871. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  17872. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17873. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17874. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17875. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17876. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  17877. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  17878. }
  17879. else
  17880. {
  17881. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17882. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17883. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17884. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17885. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17886. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17887. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17888. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17889. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17890. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17891. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  17892. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  17893. if (ccpPaymentCurrency.Equals("CNY"))
  17894. {
  17895. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  17896. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17897. }
  17898. else
  17899. {
  17900. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  17901. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  17902. }
  17903. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  17904. if (hotelcardPriceCurrency.Equals("CNY"))
  17905. {
  17906. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17907. }
  17908. else
  17909. {
  17910. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  17911. }
  17912. }
  17913. string breakfastPriceStr = string.Empty,
  17914. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17915. governmentRentStr = string.Empty,
  17916. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17917. cityTaxStr = string.Empty,
  17918. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17919. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  17920. if (!string.IsNullOrEmpty(breakfastCurrency1))
  17921. {
  17922. if (breakfastCurrency1.Equals("CNY"))
  17923. {
  17924. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17925. }
  17926. else
  17927. {
  17928. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  17929. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  17930. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  17931. }
  17932. }
  17933. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17934. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  17935. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  17936. {
  17937. if (governmentRentCurrency.Equals("CNY"))
  17938. {
  17939. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17940. }
  17941. else
  17942. {
  17943. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  17944. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  17945. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  17946. }
  17947. }
  17948. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17949. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  17950. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  17951. {
  17952. if (cityTaxStrCurrency1.Equals("CNY"))
  17953. {
  17954. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17955. }
  17956. else
  17957. {
  17958. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  17959. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  17960. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  17961. }
  17962. }
  17963. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17964. int payDId = roomInfo?.PayDId ?? 0;
  17965. pcfds.Add(new HotelReservations_PCFD_View()
  17966. {
  17967. City = item.City,
  17968. HotelName = item.HotelName,
  17969. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17970. // SingleRoomCount = item.SingleRoomCount,
  17971. SingleRoomPrice = singleRoomFeeStr,
  17972. // DoubleRoomCount = item.DoubleRoomCount,
  17973. DoubleRoomPrice = doubleRoomFeeStr,
  17974. //SuiteRoomCount = item.SuiteRoomCount,
  17975. SuiteRoomPrice = suiteRoomFeeStr,
  17976. OtherRoomPrice = otherRoomFeeStr,
  17977. //OtherRoomCount = item.OtherRoomCount,
  17978. BreakfastPrice = breakfastPriceStr,
  17979. GovernmentRent = governmentRentStr,
  17980. CityTax = cityTaxStr,
  17981. RoomExplanation = item.RoomExplanation,
  17982. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17983. PayTime = roomInfo?.ConsumptionDate,
  17984. BankNo = roomInfo?.BankNo,
  17985. PayMoney = payMoneyStr,
  17986. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17987. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17988. CardPrice = cardPriceStr,
  17989. Remark = ccpInfo.Remark
  17990. });
  17991. }
  17992. #endregion
  17993. //载入模板
  17994. WorkbookDesigner designer = new WorkbookDesigner();
  17995. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17996. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17997. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17998. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17999. var rateDatas1 = rateDatas.Distinct();
  18000. var rateStr = string.Empty;
  18001. foreach (var item in rateDatas1)
  18002. {
  18003. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18004. }
  18005. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18006. designer.SetDataSource("Opertor", userInfo.CnName);
  18007. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18008. dt.TableName = "ViewMyHotelReservations";
  18009. designer.SetDataSource(dt);
  18010. designer.Process();
  18011. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18012. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18013. designer.Workbook.Save(serverPath);
  18014. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18015. #region 删除指定行
  18016. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18017. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18018. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18019. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18020. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18021. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18022. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18023. cssIndex = dt.Columns["CityTax"].Ordinal,
  18024. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18025. remarkIndex = dt.Columns["Remark"].Ordinal;
  18026. //删除指定列
  18027. foreach (DataRow item in dt.Rows)
  18028. {
  18029. string singleStr = item["SingleRoomPrice"].ToString();
  18030. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18031. if (containsDigitButNotZero1) singleDel = false;
  18032. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18033. string doubleStr = item["DoubleRoomPrice"].ToString();
  18034. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18035. if (containsDigitButNotZero2) doubleDel = false;
  18036. string suiteStr = item["SuiteRoomPrice"].ToString();
  18037. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18038. if (containsDigitButNotZero3) suiteDel = false;
  18039. string otherStr = item["OtherRoomPrice"].ToString();
  18040. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18041. if (containsDigitButNotZero4) otherDel = false;
  18042. string zcStr = item["BreakfastPrice"].ToString();
  18043. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18044. if (containsDigitButNotZero5) zcDel = false;
  18045. string dsStr = item["GovernmentRent"].ToString();
  18046. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18047. if (containsDigitButNotZero6) dsDel = false;
  18048. string cssStr = item["CityTax"].ToString();
  18049. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18050. if (containsDigitButNotZero7) cssDel = false;
  18051. string cpStr = item["ConsumptionPatterns"].ToString();
  18052. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18053. string remarkStr = item["Remark"].ToString();
  18054. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18055. }
  18056. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18057. DeleteColumn(serverPath, cpIndex, cpDel);
  18058. DeleteColumn(serverPath, dsIndex, dsDel);
  18059. DeleteColumn(serverPath, cssIndex, cssDel);
  18060. DeleteColumn(serverPath, zcIndex, zcDel);
  18061. DeleteColumn(serverPath, otherIndex, otherDel);
  18062. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18063. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18064. DeleteColumn(serverPath, singleIndex, singleDel);
  18065. #endregion
  18066. //只保留第一个表格
  18067. DeleteSheet(serverPath);
  18068. return Ok(JsonView(true, "操作成功", url = rst));
  18069. }
  18070. else
  18071. {
  18072. _currency = _GroupCostParameter.Currency;
  18073. bool isIntType = int.TryParse(_currency, out int currId);
  18074. if (isIntType)
  18075. {
  18076. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18077. }
  18078. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18079. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18080. if (currInfo == null)
  18081. {
  18082. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18083. }
  18084. if (!_currency.ToUpper().Equals("CNY"))
  18085. {
  18086. _rate = _GroupCostParameter.Rate;
  18087. }
  18088. _rate = currInfo.Rate;
  18089. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18090. //string strFileName = "HotelStatement/";
  18091. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18092. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18093. #region 数据处理
  18094. foreach (var item in hrDtas)
  18095. {
  18096. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18097. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18098. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18099. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18100. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18101. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18102. string singleRoomFeeStr = string.Empty,
  18103. doubleRoomFeeStr = string.Empty,
  18104. suiteRoomFeeStr = string.Empty,
  18105. otherRoomFeeStr = string.Empty,
  18106. payMoneyStr = string.Empty,
  18107. cardPriceStr = string.Empty;
  18108. if (roomCurr.Equals(_currency))
  18109. {
  18110. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18111. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18112. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18113. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18114. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18115. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18116. }
  18117. else
  18118. {
  18119. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18120. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18121. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18122. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18123. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18124. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18125. }
  18126. string breakfastPriceStr = string.Empty,
  18127. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18128. governmentRentStr = string.Empty,
  18129. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18130. cityTaxStrStr = string.Empty,
  18131. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18132. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18133. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18134. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18135. int payDId = roomInfo?.PayDId ?? 0;
  18136. pcfds.Add(new HotelReservations_PCFD_View()
  18137. {
  18138. City = item.City,
  18139. HotelName = item.HotelName,
  18140. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18141. // SingleRoomCount = item.SingleRoomCount,
  18142. SingleRoomPrice = singleRoomFeeStr,
  18143. // DoubleRoomCount = item.DoubleRoomCount,
  18144. DoubleRoomPrice = doubleRoomFeeStr,
  18145. //SuiteRoomCount = item.SuiteRoomCount,
  18146. SuiteRoomPrice = suiteRoomFeeStr,
  18147. OtherRoomPrice = otherRoomFeeStr,
  18148. //OtherRoomCount = item.OtherRoomCount,
  18149. BreakfastPrice = breakfastPriceStr,
  18150. GovernmentRent = governmentRentStr,
  18151. CityTax = cityTaxStrStr,
  18152. RoomExplanation = item.RoomExplanation,
  18153. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18154. PayTime = roomInfo?.ConsumptionDate,
  18155. BankNo = roomInfo?.BankNo,
  18156. PayMoney = payMoneyStr,
  18157. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18158. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18159. CardPrice = cardPriceStr,
  18160. Remark = ccpInfo.Remark
  18161. });
  18162. }
  18163. #endregion
  18164. //载入模板
  18165. WorkbookDesigner designer = new WorkbookDesigner();
  18166. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18167. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18168. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18169. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18170. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18171. designer.SetDataSource("Opertor", userInfo.CnName);
  18172. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18173. dt.TableName = "ViewMyHotelReservations";
  18174. designer.SetDataSource(dt);
  18175. designer.Process();
  18176. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18177. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18178. designer.Workbook.Save(serverPath);
  18179. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18180. #region 删除指定行
  18181. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18182. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18183. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18184. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18185. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18186. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18187. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18188. cssIndex = dt.Columns["CityTax"].Ordinal,
  18189. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18190. remarkIndex = dt.Columns["Remark"].Ordinal;
  18191. //删除指定列
  18192. foreach (DataRow item in dt.Rows)
  18193. {
  18194. string singleStr = item["SingleRoomPrice"].ToString();
  18195. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18196. if (containsDigitButNotZero1) singleDel = false;
  18197. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18198. string doubleStr = item["DoubleRoomPrice"].ToString();
  18199. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18200. if (containsDigitButNotZero2) doubleDel = false;
  18201. string suiteStr = item["SuiteRoomPrice"].ToString();
  18202. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18203. if (containsDigitButNotZero3) suiteDel = false;
  18204. string otherStr = item["OtherRoomPrice"].ToString();
  18205. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18206. if (containsDigitButNotZero4) otherDel = false;
  18207. string zcStr = item["BreakfastPrice"].ToString();
  18208. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18209. if (containsDigitButNotZero5) zcDel = false;
  18210. string dsStr = item["GovernmentRent"].ToString();
  18211. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18212. if (containsDigitButNotZero6) dsDel = false;
  18213. string cssStr = item["CityTax"].ToString();
  18214. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18215. if (containsDigitButNotZero7) cssDel = false;
  18216. string cpStr = item["ConsumptionPatterns"].ToString();
  18217. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18218. string remarkStr = item["Remark"].ToString();
  18219. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18220. }
  18221. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18222. DeleteColumn(serverPath, cpIndex, cpDel);
  18223. DeleteColumn(serverPath, dsIndex, dsDel);
  18224. DeleteColumn(serverPath, cssIndex, cssDel);
  18225. DeleteColumn(serverPath, zcIndex, zcDel);
  18226. DeleteColumn(serverPath, otherIndex, otherDel);
  18227. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18228. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18229. DeleteColumn(serverPath, singleIndex, singleDel);
  18230. #endregion
  18231. //只保留第一个表格
  18232. DeleteSheet(serverPath);
  18233. return Ok(JsonView(true, "操作成功", url = rst));
  18234. }
  18235. //return Ok(JsonView(false));
  18236. }
  18237. /// <summary>
  18238. /// 删除指定列
  18239. /// </summary>
  18240. /// <param name="file"></param>
  18241. /// <param name="columnIndex"></param>
  18242. /// <param name="isDel"></param>
  18243. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18244. {
  18245. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18246. //wb.Save(file);
  18247. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18248. if (sheet1 != null)
  18249. {
  18250. if (isDel)
  18251. {
  18252. Cells cells = sheet1.Cells;
  18253. cells.DeleteColumn(columnIndex);
  18254. }
  18255. }
  18256. wb.Save(file);
  18257. }
  18258. /// <summary>
  18259. /// 删除sheet
  18260. /// </summary>
  18261. /// <param name="file"></param>
  18262. /// <param name="sheetName"></param>
  18263. private void DeleteSheet(string file, string sheetName = "")
  18264. {
  18265. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18266. //wb.Save(file);
  18267. List<string> sheets = new List<string>();
  18268. foreach (var item in wb.Worksheets)
  18269. {
  18270. sheets.Add(item.Name);
  18271. }
  18272. if (sheets.Count > 0)
  18273. {
  18274. sheets.RemoveAt(0);//不删除第一个sheet
  18275. foreach (var item in sheets)
  18276. {
  18277. wb.Worksheets.RemoveAt(item);
  18278. }
  18279. }
  18280. wb.Save(file);
  18281. }
  18282. /// <summary>
  18283. /// 酒店预订
  18284. /// 确认单
  18285. /// </summary>
  18286. /// <param name="_dto"></param>
  18287. /// <returns></returns>
  18288. [HttpPost]
  18289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18290. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18291. {
  18292. try
  18293. {
  18294. #region 参数验证
  18295. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18296. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18297. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18298. #region 团组操作权限验证 76 酒店预定模块
  18299. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18300. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18301. #endregion
  18302. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18303. #region 页面操作权限验证
  18304. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18305. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18306. #endregion
  18307. #endregion
  18308. //团组信息
  18309. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18310. //酒店数据
  18311. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18312. if (listhoteldata.Count < 0)
  18313. {
  18314. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18315. }
  18316. //利datatable存储
  18317. DataTable dt = new DataTable();
  18318. dt.Columns.Add("CheckInDate", typeof(string));
  18319. dt.Columns.Add("City", typeof(string));
  18320. dt.Columns.Add("Hotel", typeof(string));
  18321. dt.Columns.Add("Room", typeof(string));
  18322. for (int i = 0; i < listhoteldata.Count; i++)
  18323. {
  18324. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18325. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18326. while (dayStart < dayEnd)
  18327. {
  18328. string temp = "";
  18329. DataRow row = dt.NewRow();
  18330. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18331. row["City"] = listhoteldata[i].City;
  18332. row["Hotel"] = listhoteldata[i].HotelName;
  18333. if (listhoteldata[i].SingleRoomCount > 0)
  18334. {
  18335. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18336. }
  18337. if (listhoteldata[i].DoubleRoomCount > 0)
  18338. {
  18339. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18340. }
  18341. if (listhoteldata[i].SuiteRoomCount > 0)
  18342. {
  18343. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18344. }
  18345. if (listhoteldata[i].OtherRoomCount > 0)
  18346. {
  18347. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18348. }
  18349. row["Room"] = temp;
  18350. dt.Rows.Add(row);
  18351. dayStart = dayStart.AddDays(1);
  18352. }
  18353. }
  18354. Dictionary<string, string> dic = new Dictionary<string, string>();
  18355. dic.Add("Dele", di.TeamName);
  18356. dic.Add("City", di.VisitCountry);
  18357. //模板路径
  18358. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18359. //载入模板
  18360. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18361. DocumentBuilder builder = new DocumentBuilder(doc);
  18362. foreach (var key in dic.Keys)
  18363. {
  18364. builder.MoveToBookmark(key);
  18365. builder.Write(dic[key]);
  18366. }
  18367. //获取word里所有表格
  18368. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18369. //获取所填表格的序数
  18370. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18371. var rowStart = tableOne.Rows[0]; //获取第1行
  18372. //循环赋值
  18373. for (int i = 0; i < dt.Rows.Count; i++)
  18374. {
  18375. builder.MoveToCell(0, i + 1, 0, 0);
  18376. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18377. builder.MoveToCell(0, i + 1, 1, 0);
  18378. builder.Write(dt.Rows[i]["City"].ToString());
  18379. builder.MoveToCell(0, i + 1, 2, 0);
  18380. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18381. builder.MoveToCell(0, i + 1, 3, 0);
  18382. builder.Write(dt.Rows[i]["Room"].ToString());
  18383. }
  18384. //删除多余行
  18385. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18386. {
  18387. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18388. }
  18389. string strFileName = di.TeamName + "酒店确认单.doc";
  18390. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18391. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18392. return Ok(JsonView(true, "成功", url));
  18393. }
  18394. catch (Exception ex)
  18395. {
  18396. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18397. }
  18398. }
  18399. #endregion
  18400. #region 团组状态
  18401. /// <summary>
  18402. /// 团组状态列表 Page
  18403. /// </summary>
  18404. /// <param name="dto">团组列表请求dto</param>
  18405. /// <returns></returns>
  18406. [HttpPost]
  18407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18408. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18409. {
  18410. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18411. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18412. {
  18413. string sqlWhere = string.Empty;
  18414. if (dto.IsSure == 0) //未完成
  18415. {
  18416. sqlWhere += string.Format(@" And IsSure = 0");
  18417. }
  18418. else if (dto.IsSure == 1) //已完成
  18419. {
  18420. sqlWhere += string.Format(@" And IsSure = 1");
  18421. }
  18422. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18423. {
  18424. string tj = dto.SearchCriteria;
  18425. 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}%')",
  18426. tj, tj, tj, tj, tj);
  18427. }
  18428. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18429. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18430. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18431. From (
  18432. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18433. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18434. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18435. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18436. From Grp_DelegationInfo gdi
  18437. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18438. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18439. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18440. Where gdi.IsDel = 0 {0}
  18441. ) temp ", sqlWhere);
  18442. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18443. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18444. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18445. }
  18446. else
  18447. {
  18448. return Ok(JsonView(false, "查询失败"));
  18449. }
  18450. }
  18451. /// <summary>
  18452. /// 团组状态
  18453. /// 设置操作完成
  18454. /// </summary>
  18455. /// <param name="dto">团组列表请求dto</param>
  18456. /// <returns></returns>
  18457. [HttpPost]
  18458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18459. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18460. {
  18461. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18462. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18463. {
  18464. Id = dto.Id,
  18465. IsSure = 1
  18466. };
  18467. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18468. .UpdateColumns(it => new { it.IsSure })
  18469. .WhereColumns(it => new { it.Id })
  18470. .ExecuteCommandAsync();
  18471. if (result > 0)
  18472. {
  18473. return Ok(JsonView(true, "操作完成!"));
  18474. }
  18475. return Ok(JsonView(false, "操作失败!"));
  18476. }
  18477. #endregion
  18478. #region 保险费用录入
  18479. /// <summary>
  18480. /// 根据团组Id查询保险费用列表
  18481. /// </summary>
  18482. /// <param name="dto"></param>
  18483. /// <returns></returns>
  18484. [HttpPost]
  18485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18486. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18487. {
  18488. Result groupData = await _customersRep.CustomersByDiId(dto);
  18489. if (groupData.Code != 0)
  18490. {
  18491. return Ok(JsonView(false, groupData.Msg));
  18492. }
  18493. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18494. }
  18495. /// <summary>
  18496. /// 根据保险费用Id查询保险费用详细
  18497. /// </summary>
  18498. /// <param name="dto"></param>
  18499. /// <returns></returns>
  18500. [HttpPost]
  18501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18502. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18503. {
  18504. try
  18505. {
  18506. Result groupData = await _customersRep.CustomersById(dto);
  18507. if (groupData.Code != 0)
  18508. {
  18509. return Ok(JsonView(false, groupData.Msg));
  18510. }
  18511. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18512. }
  18513. catch (Exception ex)
  18514. {
  18515. return Ok(JsonView(false, ex.Message));
  18516. }
  18517. }
  18518. /// <summary>
  18519. /// 保险费用录入页面初始化绑定
  18520. /// </summary>
  18521. /// <param name="dto"></param>
  18522. /// <returns></returns>
  18523. [HttpPost]
  18524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18525. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18526. {
  18527. try
  18528. {
  18529. Result groupData = await _customersRep.CustomersInitialize(dto);
  18530. if (groupData.Code != 0)
  18531. {
  18532. return Ok(JsonView(false, groupData.Msg));
  18533. }
  18534. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18535. }
  18536. catch (Exception ex)
  18537. {
  18538. return Ok(JsonView(false, ex.Message));
  18539. }
  18540. }
  18541. /// <summary>
  18542. /// 保险费用操作(Status:1.新增,2.修改)
  18543. /// </summary>
  18544. /// <param name="dto"></param>
  18545. /// <returns></returns>
  18546. [HttpPost]
  18547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18548. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18549. {
  18550. Result groupData = await _customersRep.OpCustomers(dto);
  18551. if (groupData.Code != 0)
  18552. {
  18553. return Ok(JsonView(false, groupData.Msg));
  18554. }
  18555. #region 应用推送
  18556. try
  18557. {
  18558. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18559. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18560. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18561. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18562. //自动审核
  18563. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18564. //2024-10-21 新增LZ UID
  18565. var userIds = new List<int>() { 21 };
  18566. string title = $"系统通知";
  18567. var diId = dto.DiId;
  18568. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18569. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18570. string content = "";
  18571. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18572. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18573. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18574. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18575. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18576. }
  18577. catch (Exception ex)
  18578. {
  18579. }
  18580. #endregion
  18581. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18582. }
  18583. /// <summary>
  18584. /// 保险文件上传
  18585. /// </summary>
  18586. /// <param name="file"></param>
  18587. /// <returns></returns>
  18588. [HttpPost]
  18589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18590. public async Task<IActionResult> UploadCus(IFormFile file)
  18591. {
  18592. try
  18593. {
  18594. if (file != null)
  18595. {
  18596. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18597. //文件名称
  18598. string projectFileName = file.FileName;
  18599. //上传的文件的路径
  18600. string filePath = "";
  18601. if (!Directory.Exists(fileDir))
  18602. {
  18603. Directory.CreateDirectory(fileDir);
  18604. }
  18605. //上传的文件的路径
  18606. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18607. using (FileStream fs = System.IO.File.Create(filePath))
  18608. {
  18609. file.CopyTo(fs);
  18610. fs.Flush();
  18611. }
  18612. return Ok(JsonView(true, "上传成功!", projectFileName));
  18613. }
  18614. else
  18615. {
  18616. return Ok(JsonView(false, "上传失败!"));
  18617. }
  18618. }
  18619. catch (Exception ex)
  18620. {
  18621. return Ok(JsonView(false, "程序错误!"));
  18622. throw;
  18623. }
  18624. }
  18625. /// <summary>
  18626. /// 保险删除指定文件
  18627. /// </summary>
  18628. /// <param name="dto"></param>
  18629. /// <returns></returns>
  18630. [HttpPost]
  18631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18632. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18633. {
  18634. try
  18635. {
  18636. string filePath = "";
  18637. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18638. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  18639. //int id = 0;
  18640. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  18641. // 删除该文件
  18642. try
  18643. {
  18644. System.IO.File.Delete(filePath);
  18645. 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()
  18646. {
  18647. Attachment = "",
  18648. }).ExecuteCommandAsync();
  18649. if (result != 0)
  18650. {
  18651. return Ok(JsonView(true, "成功!"));
  18652. }
  18653. else
  18654. {
  18655. return Ok(JsonView(false, "失败!"));
  18656. }
  18657. }
  18658. catch (Exception)
  18659. {
  18660. 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()
  18661. {
  18662. Attachment = "",
  18663. }).ExecuteCommandAsync();
  18664. if (result != 0)
  18665. {
  18666. return Ok(JsonView(true, "成功!"));
  18667. }
  18668. else
  18669. {
  18670. return Ok(JsonView(false, "失败!"));
  18671. }
  18672. }
  18673. }
  18674. catch (Exception ex)
  18675. {
  18676. return Ok(JsonView(false, "程序错误!"));
  18677. throw;
  18678. }
  18679. }
  18680. /// <summary>
  18681. /// 保险费用操作(删除)
  18682. /// </summary>
  18683. /// <param name="dto"></param>
  18684. /// <returns></returns>
  18685. [HttpPost]
  18686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18687. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  18688. {
  18689. try
  18690. {
  18691. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  18692. if (!res)
  18693. {
  18694. return Ok(JsonView(false, "删除失败"));
  18695. }
  18696. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  18697. {
  18698. IsDel = 1,
  18699. DeleteUserId = dto.DeleteUserId,
  18700. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  18701. }).ExecuteCommandAsync();
  18702. return Ok(JsonView(true, "删除成功!"));
  18703. }
  18704. catch (Exception ex)
  18705. {
  18706. return Ok(JsonView(false, "程序错误!"));
  18707. throw;
  18708. }
  18709. }
  18710. #endregion
  18711. #region 接团客户名单 PageId 104
  18712. /// <summary>
  18713. /// 接团客户名单
  18714. /// 迁移数据(慎用!)
  18715. /// </summary>
  18716. /// <returns></returns>
  18717. [HttpPost]
  18718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18719. public async Task<IActionResult> PostTourClientListChange()
  18720. {
  18721. try
  18722. {
  18723. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  18724. //var groupClinetData1
  18725. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  18726. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  18727. int updateCount = 0;
  18728. if (oldOAClientList.Count > 0)
  18729. {
  18730. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  18731. _sqlSugar.BeginTran();
  18732. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  18733. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  18734. foreach (var item in oldOAClientList)
  18735. {
  18736. int comId = 0;
  18737. string format = "yyyy-MM-dd HH:mm:ss";
  18738. string data11 = "1990-01-01 00:00";
  18739. var data1 = IsValidDate(item.OPdate, format);
  18740. if (data1) data11 = item.OPdate;
  18741. //客户公司验证
  18742. if (!string.IsNullOrEmpty(item.Company))
  18743. {
  18744. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  18745. if (clientComInfo == null) // add
  18746. {
  18747. var addInfo = new Crm_CustomerCompany()
  18748. {
  18749. CompanyAbbreviation = "",
  18750. CompanyFullName = item.Company,
  18751. Address = "",
  18752. PostCodes = "",
  18753. LastedOpUserId = item.OPer,
  18754. LastedOpDt = Convert.ToDateTime(data11),
  18755. CreateUserId = item.OPer,
  18756. CreateTime = Convert.ToDateTime(data11),
  18757. IsDel = 0
  18758. };
  18759. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  18760. if (comId1 > 0) comId = comId1;
  18761. }
  18762. else comId = clientComInfo.Id;
  18763. }
  18764. //客户人员验证
  18765. int clientId = 0;
  18766. string name = item.LastName + item.Name;
  18767. if (!string.IsNullOrEmpty(name))
  18768. {
  18769. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  18770. if (clientInfo == null)
  18771. {
  18772. DateTime? dateTime = null;
  18773. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  18774. if (isDt) dateTime = birthDayDt;
  18775. var addInfo1 = new Crm_DeleClient()
  18776. {
  18777. CrmCompanyId = comId,
  18778. DiId = -1,
  18779. LastName = item.LastName,
  18780. FirstName = item.Name,
  18781. OldName = "",
  18782. Pinyin = item.Pinyin,
  18783. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  18784. Marriage = 0,
  18785. Phone = item.Phone,
  18786. Job = item.Job,
  18787. BirthDay = dateTime
  18788. };
  18789. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  18790. if (clientId1 > 0) clientId = clientId1;
  18791. }
  18792. else clientId = clientInfo.Id;
  18793. }
  18794. if (clientId < 1)
  18795. {
  18796. continue;
  18797. }
  18798. int airType = 0;
  18799. if (item.AirType == "超经舱") airType = 459;
  18800. else if (item.AirType == "公务舱") airType = 458;
  18801. else if (item.AirType == "经济舱") airType = 460;
  18802. else if (item.AirType == "其他") airType = 565;
  18803. else if (item.AirType == "头等舱") airType = 457;
  18804. var _TourClientListEntity = new Grp_TourClientList()
  18805. {
  18806. DiId = item.Diid,
  18807. ClientId = clientId,
  18808. CreateUserId = item.OPer,
  18809. CreateTime = Convert.ToDateTime(data11),
  18810. Remark = item.Remark,
  18811. IsDel = item.Isdel,
  18812. ShippingSpaceTypeId = airType,
  18813. ShippingSpaceSpecialNeeds = item.AirRemark,
  18814. HotelSpecialNeeds = item.RoomType
  18815. };
  18816. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  18817. if (_TourClientList > 0)
  18818. {
  18819. updateCount++;
  18820. }
  18821. }
  18822. _sqlSugar.CommitTran();
  18823. }
  18824. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  18825. }
  18826. catch (Exception ex)
  18827. {
  18828. _sqlSugar.RollbackTran();
  18829. return Ok(JsonView(false, ex.Message));
  18830. }
  18831. //return Ok(JsonView(true));
  18832. }
  18833. private bool IsValidDate(string dateString, string format)
  18834. {
  18835. DateTime dateValue;
  18836. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  18837. return valid;
  18838. }
  18839. /// <summary>
  18840. /// 接团客户名单
  18841. /// 根据团组Id查询List
  18842. /// </summary>
  18843. /// <param name="_dto"></param>
  18844. /// <returns></returns>
  18845. [HttpPost]
  18846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18847. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  18848. {
  18849. #region 参数验证
  18850. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  18851. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  18852. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  18853. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18854. #region 页面操作权限验证
  18855. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18856. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18857. #endregion
  18858. #endregion
  18859. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  18860. if (viewData.Code != 0)
  18861. {
  18862. return Ok(JsonView(false, viewData.Msg));
  18863. }
  18864. return Ok(JsonView(viewData.Data));
  18865. }
  18866. /// <summary>
  18867. /// 接团客户名单
  18868. /// 基础数据 Init
  18869. /// </summary>
  18870. /// <param name="_dto"></param>
  18871. /// <returns></returns>
  18872. [HttpPost]
  18873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18874. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  18875. {
  18876. #region 参数验证
  18877. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18878. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18879. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18880. #region 页面操作权限验证
  18881. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18882. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18883. #endregion
  18884. #endregion
  18885. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  18886. }
  18887. /// <summary>
  18888. /// 接团客户名单
  18889. /// 根据 Id查询 Details
  18890. /// </summary>
  18891. /// <param name="_dto"></param>
  18892. /// <returns></returns>
  18893. [HttpPost]
  18894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18895. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  18896. {
  18897. #region 参数验证
  18898. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18899. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18900. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18901. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18902. #region 页面操作权限验证
  18903. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18904. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18905. #endregion
  18906. #endregion
  18907. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  18908. if (viewData.Code != 0)
  18909. {
  18910. return Ok(JsonView(false, viewData.Msg));
  18911. }
  18912. return Ok(JsonView(viewData.Data));
  18913. }
  18914. /// <summary>
  18915. /// 接团客户名单
  18916. /// Add Or Edit
  18917. /// </summary>
  18918. /// <param name="_dto"></param>
  18919. /// <returns></returns>
  18920. [HttpPost]
  18921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18922. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  18923. {
  18924. #region 参数验证
  18925. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18926. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18927. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18928. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18929. #region 页面操作权限验证
  18930. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18931. if (_dto.Id == 0) //添加
  18932. {
  18933. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18934. }
  18935. else if (_dto.Id >= 0) //修改
  18936. {
  18937. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18938. }
  18939. #endregion
  18940. #endregion
  18941. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  18942. if (viewData.Code != 0)
  18943. {
  18944. return Ok(JsonView(false, viewData.Msg));
  18945. }
  18946. return Ok(JsonView(true));
  18947. }
  18948. /// <summary>
  18949. /// 接团客户名单
  18950. /// json字符串 AddMultiple(添加多个)
  18951. /// </summary>
  18952. /// <param name="_dto"></param>
  18953. /// <returns></returns>
  18954. [HttpPost]
  18955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18956. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  18957. {
  18958. #region 参数验证
  18959. string jsonLabel = _dto.JsonLabel;
  18960. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18961. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18962. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18963. #region 页面操作权限验证
  18964. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18965. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18966. #endregion
  18967. #endregion
  18968. var request = new TourClientListAddMultipleDto();
  18969. request.DiId = _dto.DiId;
  18970. request.UserId = _dto.UserId;
  18971. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  18972. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  18973. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  18974. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  18975. var infos = new List<TourClientListInfo>();
  18976. foreach (var data in datas)
  18977. {
  18978. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  18979. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  18980. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  18981. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  18982. {
  18983. continue;
  18984. }
  18985. infos.Add(new TourClientListInfo()
  18986. {
  18987. IsAccompany = 1,
  18988. LastName = lastName,
  18989. FirstName = firstName,
  18990. Pinyin = lastNameEn + @"/" + firstNameEn,
  18991. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  18992. CompanyFullName = data.CompanyFullName,
  18993. Job = data.Job
  18994. });
  18995. }
  18996. if (infos.Any())
  18997. {
  18998. var viewData = await _tourClientListRep._AddMultiple(request);
  18999. if (viewData.Code != 0)
  19000. {
  19001. return Ok(JsonView(false, viewData.Msg));
  19002. }
  19003. return Ok(JsonView(true));
  19004. }
  19005. return Ok(JsonView(false));
  19006. }
  19007. /// <summary>
  19008. /// 接团客户名单
  19009. /// AddMultiple(添加多个)
  19010. /// </summary>
  19011. /// <param name="_dto"></param>
  19012. /// <returns></returns>
  19013. [HttpPost]
  19014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19015. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19016. {
  19017. #region 参数验证
  19018. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19019. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19020. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19021. #region 页面操作权限验证
  19022. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19023. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19024. #endregion
  19025. #endregion
  19026. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19027. if (viewData.Code != 0)
  19028. {
  19029. return Ok(JsonView(false, viewData.Msg));
  19030. }
  19031. return Ok(JsonView(true));
  19032. }
  19033. /// <summary>
  19034. /// 接团客户名单
  19035. /// Del
  19036. /// </summary>
  19037. /// <param name="_dto"></param>
  19038. /// <returns></returns>
  19039. [HttpPost]
  19040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19041. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19042. {
  19043. #region 参数验证
  19044. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19045. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19046. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19047. #region 页面操作权限验证
  19048. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19049. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19050. #endregion
  19051. #endregion
  19052. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19053. if (viewData.Code != 0)
  19054. {
  19055. return Ok(JsonView(false, viewData.Msg));
  19056. }
  19057. return Ok(JsonView(true));
  19058. }
  19059. /// <summary>
  19060. /// 接团客户名单
  19061. /// 文件下载 客户名单
  19062. /// </summary>
  19063. /// <param name="_dto"></param>
  19064. /// <returns></returns>
  19065. [HttpPost]
  19066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19067. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19068. {
  19069. #region 参数验证
  19070. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19071. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19072. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19073. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19074. #region 页面操作权限验证
  19075. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19076. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19077. #endregion
  19078. #endregion
  19079. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19080. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19081. From Grp_TourClientList tcl
  19082. Left Join
  19083. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19084. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19085. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19086. From Crm_DeleClient dc
  19087. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19088. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19089. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19090. Where dc.IsDel = 0) temp
  19091. On temp.DcId =tcl.ClientId
  19092. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19093. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19094. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19095. //载入模板
  19096. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19097. if (_dto.Language == 1)
  19098. {
  19099. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19100. }
  19101. //载入模板
  19102. var doc = new Document(tempPath);
  19103. DocumentBuilder builder = new DocumentBuilder(doc);
  19104. //获取word里所有表格
  19105. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19106. //获取所填表格的序数
  19107. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19108. var rowStart = tableOne.Rows[0]; //获取第1行
  19109. if (_dto.Language == 0)
  19110. {
  19111. //循环赋值
  19112. for (int i = 0; i < DcList.Count; i++)
  19113. {
  19114. EncryptionProcessor.DecryptProperties(DcList[i]);
  19115. builder.MoveToCell(0, i + 1, 0, 0);
  19116. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19117. builder.MoveToCell(0, i + 1, 1, 0);
  19118. int sex = DcList[i].Sex;
  19119. string sexStr = string.Empty;
  19120. if (sex == 0) sexStr = "男";
  19121. else if (sex == 1) sexStr = "女";
  19122. else sexStr = "未设置";
  19123. builder.Write(sexStr);
  19124. builder.MoveToCell(0, i + 1, 2, 0);
  19125. string birthDay = DcList[i].BirthDay;
  19126. string birthDayStr = string.Empty;
  19127. if (!string.IsNullOrEmpty(birthDay))
  19128. {
  19129. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19130. }
  19131. builder.Write(birthDayStr);
  19132. builder.MoveToCell(0, i + 1, 3, 0);
  19133. string company = "";
  19134. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19135. {
  19136. company = DcList[i].CompanyFullName.ToString();
  19137. }
  19138. builder.Write(company);
  19139. builder.MoveToCell(0, i + 1, 4, 0);
  19140. builder.Write(DcList[i].Job);
  19141. }
  19142. }
  19143. else if (_dto.Language == 1)
  19144. {
  19145. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19146. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19147. List<string> transArrayStr = new List<string>();
  19148. string transStrRes1 = "";
  19149. for (int i = 0; i < DcList.Count; i++)
  19150. {
  19151. var dc = DcList[i];
  19152. EncryptionProcessor.DecryptProperties(dc);
  19153. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19154. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19155. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19156. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19157. else transStrRes1 += $"{str1}|";
  19158. }
  19159. #region AI转英文
  19160. string jsonValue = JsonConvert.SerializeObject(DcList);
  19161. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19162. List<SeedMessages> messages = new List<SeedMessages>()
  19163. {
  19164. new SeedMessages
  19165. {
  19166. Role = KimiRole.user,
  19167. Content = jsonValue + text
  19168. }
  19169. };
  19170. KiMiApiClient client = new KiMiApiClient();
  19171. var kimiApiResult = await client.SeedMessage(messages);
  19172. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19173. string clients = kimiApiResult_JObject["content"].ToString();
  19174. string startStr = "```json", endStr = "```";
  19175. // 判断并清除开头部分
  19176. if (clients.StartsWith(startStr))
  19177. {
  19178. clients = clients.Remove(0, startStr.Length);
  19179. }
  19180. // 判断并清除结尾部分
  19181. if (clients.EndsWith(endStr))
  19182. {
  19183. clients = clients.Remove(clients.Length - endStr.Length);
  19184. }
  19185. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19186. //循环赋值
  19187. for (int i = 0; i < en_Json.Count; i++)
  19188. {
  19189. var dc = en_Json[i];
  19190. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19191. string PYName = dc.FirstName + " " + dc.LastName;
  19192. builder.MoveToCell(0, i + 1, 0, 0);
  19193. builder.Write(PYName);
  19194. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19195. builder.MoveToCell(0, i + 1, 1, 0);
  19196. builder.Write(sex);
  19197. DateTime birthDt;
  19198. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19199. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19200. builder.MoveToCell(0, i + 1, 2, 0);
  19201. builder.Write(birthday);
  19202. string company = string.Empty, job = string.Empty;
  19203. company = dc.CompanyFullName;
  19204. job = dc.Job;
  19205. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName) )
  19206. {
  19207. //查询对照表
  19208. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19209. if (tempCec != null)
  19210. {
  19211. company = tempCec.enName;
  19212. }
  19213. }
  19214. builder.MoveToCell(0, i + 1, 3, 0);
  19215. builder.Write(company);
  19216. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19217. {
  19218. //查询对照表
  19219. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19220. if (tempPec != null)
  19221. {
  19222. job = tempPec.enName;
  19223. }
  19224. }
  19225. builder.MoveToCell(0, i + 1, 4, 0);
  19226. builder.Write(job);
  19227. }
  19228. #endregion
  19229. #region 旧翻译英文处理
  19230. ////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";
  19231. //string transStrRes = "";
  19232. //if (transStrRes1.Length > 0)
  19233. //{
  19234. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19235. //}
  19236. ////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
  19237. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19238. ////List<string> transArray = new List<string> { };
  19239. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19240. //if (transStrRes.Contains("|"))
  19241. //{
  19242. // string[] transArray1 = transStrRes.Split('|');
  19243. // if (transArray1.Length > 0)
  19244. // {
  19245. // foreach (var item in transArray1)
  19246. // {
  19247. // if (item.Contains("&"))
  19248. // {
  19249. // string[] transArray2 = item.Split('&');
  19250. // int index = 0;
  19251. // string companyName = "", job = "";
  19252. // if (transArray2.Length > 0)
  19253. // {
  19254. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19255. // if (1 < transArray2.Length) companyName = transArray2[1];
  19256. // if (2 < transArray2.Length) job = transArray2[2];
  19257. // }
  19258. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19259. // }
  19260. // }
  19261. // }
  19262. //}
  19263. ////循环赋值
  19264. //for (int i = 0; i < DcList.Count; i++)
  19265. //{
  19266. // string PYName = "";
  19267. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19268. // {
  19269. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19270. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19271. // PYName = PY_First + " " + PY_Last;
  19272. // }
  19273. // else
  19274. // {
  19275. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19276. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19277. // PYName = PY_First + " " + PY_Last;
  19278. // }
  19279. // builder.MoveToCell(0, i + 1, 0, 0);
  19280. // builder.Write(PYName);
  19281. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19282. // builder.MoveToCell(0, i + 1, 1, 0);
  19283. // builder.Write(sex);
  19284. // DateTime birthDt;
  19285. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19286. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19287. // builder.MoveToCell(0, i + 1, 2, 0);
  19288. // builder.Write(birthday);
  19289. // string company = string.Empty, job = string.Empty;
  19290. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19291. // if (dcTransInfo != null)
  19292. // {
  19293. // company = dcTransInfo.CompanyName;
  19294. // job = dcTransInfo.Job;
  19295. // }
  19296. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19297. // {
  19298. // //查询对照表
  19299. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19300. // if (tempCec != null)
  19301. // {
  19302. // company = tempCec.enName;
  19303. // }
  19304. // //翻译
  19305. // else
  19306. // {
  19307. // }
  19308. // }
  19309. // builder.MoveToCell(0, i + 1, 3, 0);
  19310. // builder.Write(company);
  19311. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19312. // {
  19313. // //查询对照表
  19314. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19315. // if (tempPec != null)
  19316. // {
  19317. // job = tempPec.enName;
  19318. // }
  19319. // //翻译
  19320. // else
  19321. // {
  19322. // }
  19323. // }
  19324. // builder.MoveToCell(0, i + 1, 4, 0);
  19325. // builder.Write(job);
  19326. //}
  19327. #endregion
  19328. }
  19329. //删除多余行
  19330. while (tableOne.Rows.Count > DcList.Count + 1)
  19331. {
  19332. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19333. }
  19334. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19335. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19336. doc.Save(fileDir);
  19337. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19338. return Ok(JsonView(true, "操作成功!", Url));
  19339. }
  19340. private class TranslateInfo
  19341. {
  19342. public int Index { get; set; }
  19343. public string CompanyName { get; set; }
  19344. public string Job { get; set; }
  19345. }
  19346. [HttpPost]
  19347. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19348. {
  19349. if (files.Count == 0)
  19350. {
  19351. return Ok(JsonView(false, "文件为空"));
  19352. }
  19353. KiMiApiClient KiMiApi = new KiMiApiClient();
  19354. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19355. if (seedConter.Count == 0)
  19356. {
  19357. return Ok(JsonView(false, "上传结果为空!"));
  19358. }
  19359. var messages = new List<SeedMessages>
  19360. {
  19361. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19362. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19363. };
  19364. messages.InsertRange(1, seedConter);
  19365. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19366. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19367. string clients = kimiApiResult_JObject["content"].ToString();
  19368. string startStr = "```json", endStr = "```";
  19369. // 判断并清除开头部分
  19370. if (clients.StartsWith(startStr))
  19371. {
  19372. clients = clients.Remove(0, startStr.Length);
  19373. }
  19374. // 判断并清除结尾部分
  19375. if (clients.EndsWith(endStr))
  19376. {
  19377. clients = clients.Remove(clients.Length - endStr.Length);
  19378. }
  19379. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19380. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19381. {
  19382. {"姓", "LastName" },
  19383. {"名", "FirstName" },
  19384. {"姓名拼音", "Pinyin" },
  19385. {"性别", "Sex" },
  19386. {"单位", "CompanyFullName" },
  19387. {"职务", "Job" },
  19388. {"出生日期", "Birthday" },
  19389. };
  19390. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19391. foreach (var item in clients_JObject)
  19392. {
  19393. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19394. foreach (var field in clientFieldMap.Keys)
  19395. {
  19396. if (item.TryGetValue(field, out JToken value))
  19397. {
  19398. var getValue = value.ToString();
  19399. System.Type type = cdc.GetType();
  19400. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19401. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19402. propertyInfo.SetValue(cdc, propertyValue);
  19403. }
  19404. }
  19405. crmClients.Add(cdc);
  19406. }
  19407. return Ok(JsonView(new
  19408. {
  19409. fileCount = files.Count,
  19410. UploadCount = seedConter.Count,
  19411. ApiResult = clients,
  19412. CrmClients = crmClients
  19413. }));
  19414. }
  19415. #endregion
  19416. #region 团组倒推表
  19417. /// <summary>
  19418. /// 倒推表基础数据
  19419. /// Init
  19420. /// </summary>
  19421. /// <returns></returns>
  19422. [HttpPost]
  19423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19424. public async Task<IActionResult> PostInvertedListInit()
  19425. {
  19426. var viewData = await _invertedListRep._Init();
  19427. if (viewData.Code != 0)
  19428. {
  19429. return Ok(JsonView(false, viewData.Msg));
  19430. }
  19431. return Ok(JsonView(viewData.Data));
  19432. }
  19433. /// <summary>
  19434. /// 倒推表
  19435. /// Info
  19436. /// </summary>
  19437. /// <param name="dto"></param>
  19438. /// <returns></returns>
  19439. [HttpPost]
  19440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19441. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19442. {
  19443. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19444. if (viewData.Code != 0)
  19445. {
  19446. return Ok(JsonView(false, viewData.Msg));
  19447. }
  19448. return Ok(JsonView(viewData.Data));
  19449. }
  19450. /// <summary>
  19451. /// 倒推表
  19452. /// Create
  19453. /// </summary>
  19454. /// <param name="dto"></param>
  19455. /// <returns></returns>
  19456. [HttpPost]
  19457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19458. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19459. {
  19460. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19461. if (viewData.Code != 0)
  19462. {
  19463. return Ok(JsonView(false, viewData.Msg));
  19464. }
  19465. return Ok(JsonView(viewData.Data));
  19466. }
  19467. /// <summary>
  19468. /// 倒推表
  19469. /// Update
  19470. /// </summary>
  19471. /// <param name="dto"></param>
  19472. /// <returns></returns>
  19473. [HttpPost]
  19474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19475. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19476. {
  19477. var viewData = await _invertedListRep._Update(dto);
  19478. if (viewData.Code != 0)
  19479. {
  19480. return Ok(JsonView(false, viewData.Msg));
  19481. }
  19482. return Ok(JsonView(viewData.Data));
  19483. }
  19484. /// <summary>
  19485. /// 倒推表
  19486. /// File Download
  19487. /// </summary>
  19488. /// <param name="dto"></param>
  19489. /// <returns></returns>
  19490. [HttpPost]
  19491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19492. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19493. {
  19494. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19495. if (info2.Code != 0)
  19496. {
  19497. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19498. }
  19499. var info1 = info2.Data as InvertedListInfoView;
  19500. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19501. string teamName = "";
  19502. if (info != null) teamName = info.TeamName;
  19503. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19504. var doc = new Document();
  19505. var builder = new DocumentBuilder(doc);
  19506. #region old insert
  19507. ////载入模板
  19508. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19509. //Document doc = new Document(tempPath);
  19510. //DocumentBuilder builder = new DocumentBuilder(doc);
  19511. //利用键值对存放数据
  19512. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19513. //dic.Add("TeamName", teamName);
  19514. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19515. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19516. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19517. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19518. //dic.Add("SQRemark", info1.ApprovalRemark);
  19519. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19520. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19521. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19522. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19523. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19524. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19525. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19526. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19527. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19528. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19529. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19530. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19531. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19532. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19533. //#region 填充word模板书签内容
  19534. //foreach (var key in dic.Keys)
  19535. //{
  19536. // builder.MoveToBookmark(key);
  19537. // builder.Write(dic[key]);
  19538. //}
  19539. //#endregion
  19540. #endregion
  19541. #region New Insert
  19542. string titleFont = $"仿宋",
  19543. contentFont = $"仿宋";
  19544. var fontColor = Color.FromArgb(64, 64, 64);
  19545. //设置标题 团组名称
  19546. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19547. builder.Font.Name = titleFont;
  19548. builder.Font.Color = fontColor;
  19549. builder.Font.Size = 12;
  19550. builder.Font.Bold = true;
  19551. builder.Writeln(teamName);
  19552. //设置副标题 团组出访时间
  19553. builder.Font.Size = 12;
  19554. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19555. builder.Writeln();
  19556. var backgroundColor = Color.FromArgb(199, 199, 199);
  19557. var table = builder.StartTable();
  19558. builder.InsertCell();
  19559. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19560. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19561. builder.CellFormat.Borders.LineWidth = 1;
  19562. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19563. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19564. builder.RowFormat.Height = 40;
  19565. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19566. builder.Font.Name = contentFont;
  19567. builder.Font.Size = 12;
  19568. builder.Font.Bold = true;
  19569. builder.Font.Color = fontColor;
  19570. builder.Write("时间");
  19571. builder.InsertCell();
  19572. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19573. builder.Write("流程");
  19574. builder.InsertCell();
  19575. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19576. builder.Write("说明");
  19577. builder.EndRow();
  19578. //报批资料准备
  19579. if (info1.IsSelectedAirportd)
  19580. {
  19581. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19582. }
  19583. //报批/提供送签资料
  19584. if (info1.IsSelectedApprovalData)
  19585. {
  19586. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19587. }
  19588. //出批件护照办理
  19589. if (info1.IsSelectedIssueApproval)
  19590. {
  19591. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19592. }
  19593. //签证资料准备
  19594. if (info1.IsSelectedVisaInfo)
  19595. {
  19596. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19597. }
  19598. //送签
  19599. if (info1.IsSelectedSendVisa)
  19600. {
  19601. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19602. }
  19603. //出签
  19604. if (info1.IsSelectedIssueVisa)
  19605. {
  19606. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19607. }
  19608. //机票
  19609. if (info1.IsSelectedAirTicket)
  19610. {
  19611. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19612. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19613. }
  19614. //酒店
  19615. if (info1.IsSelectedHotel)
  19616. {
  19617. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19618. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19619. }
  19620. //开行前会
  19621. if (info1.IsSelectedPreTripMeeting)
  19622. {
  19623. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19624. }
  19625. //送机
  19626. if (info1.IsSelectedAirportdDropOff)
  19627. {
  19628. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19629. }
  19630. builder.EndTable();
  19631. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19632. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19633. for (int i = 0; i < table.Rows.Count; i++)
  19634. {
  19635. var row = table.Rows[i];
  19636. //设置宽度
  19637. row.Cells[0].CellFormat.Width = 20.00;
  19638. row.Cells[1].CellFormat.Width = 30.00;
  19639. row.Cells[2].CellFormat.Width = 50.00;
  19640. if (i != 0)
  19641. {
  19642. //边框设置
  19643. InvertedListFileDownloadSetBorders(row.Cells, 0);
  19644. InvertedListFileDownloadSetBorders(row.Cells, 1);
  19645. InvertedListFileDownloadSetBorders(row.Cells, 2);
  19646. }
  19647. }
  19648. #region 页脚插入图片
  19649. // 创建页脚
  19650. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  19651. doc.FirstSection.HeadersFooters.Add(footer);
  19652. Paragraph para = new Paragraph(doc);
  19653. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  19654. footer.AppendChild(para);
  19655. builder.MoveTo(para);
  19656. string imagePath = "./Images/FMGJ_Log.png";
  19657. builder.InsertImage(imagePath);
  19658. #endregion
  19659. #endregion
  19660. var fileDir = AppSettingsHelper.Get("WordBasePath");
  19661. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  19662. string filePath = fileDir + $@"InvertedList/{fileName}";
  19663. doc.Save(filePath);
  19664. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  19665. return Ok(JsonView(true, "操作成功!", Url));
  19666. }
  19667. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  19668. {
  19669. var fontColor = Color.FromArgb(64, 64, 64);
  19670. builder.InsertCell();
  19671. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  19672. builder.RowFormat.Height = 40;
  19673. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19674. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19675. builder.Font.Name = fontName;
  19676. builder.Font.Size = 8;
  19677. builder.Font.Bold = true;
  19678. builder.Font.Color = fontColor;
  19679. builder.Write(dateTime);
  19680. builder.InsertCell();
  19681. builder.Font.Size = 9;
  19682. builder.Font.Bold = true;
  19683. builder.Font.Color = fontColor;
  19684. builder.Write(content);
  19685. builder.InsertCell();
  19686. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19687. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19688. builder.Font.Size = 9;
  19689. builder.Font.Bold = false;
  19690. builder.Font.Color = fontColor;
  19691. builder.Write(reamrk);
  19692. builder.EndRow();
  19693. }
  19694. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  19695. {
  19696. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  19697. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  19698. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  19699. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  19700. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  19701. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  19702. }
  19703. #endregion
  19704. #region 会务倒推表
  19705. /// <summary>
  19706. /// 会务倒推表
  19707. /// Init
  19708. /// </summary>
  19709. /// <returns></returns>
  19710. [HttpPost]
  19711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19712. public async Task<IActionResult> InforRetrogressTableInit()
  19713. {
  19714. var groupData = await _groupRepository.PostShareGroupInfos(1);
  19715. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  19716. return Ok(JsonView(false, groupData.Msg));
  19717. }
  19718. /// <summary>
  19719. /// 会务倒推表
  19720. /// ExcelDownload
  19721. /// </summary>
  19722. /// <param name="dto"></param>
  19723. /// <returns></returns>
  19724. [HttpPost]
  19725. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  19726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19727. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  19728. {
  19729. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  19730. var validatorRes = await validator.ValidateAsync(dto);
  19731. if (!validatorRes.IsValid)
  19732. {
  19733. StringBuilder sb = new StringBuilder();
  19734. foreach (var item in validatorRes.Errors)
  19735. {
  19736. sb.AppendLine(item.ErrorMessage);
  19737. }
  19738. return Ok(JsonView(false, sb.ToString()));
  19739. }
  19740. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  19741. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  19742. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  19743. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  19744. #region Excel
  19745. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  19746. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  19747. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  19748. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  19749. var fileNamePrefix = string.Empty;
  19750. if (days >= 30)
  19751. {
  19752. tempPath += $"会务工作倒推进度表(30天).xlsx";
  19753. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  19754. }
  19755. else if (days < 30 && days > 7)
  19756. {
  19757. tempPath += $"会务工作倒推进度表(15天).xlsx";
  19758. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  19759. }
  19760. else if (days <= 7)
  19761. {
  19762. tempPath += $"会务工作倒推进度表(7天).xlsx";
  19763. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  19764. }
  19765. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  19766. fileName = CommonFun.ValidFileName(fileName);
  19767. //载入模板
  19768. WorkbookDesigner designer = new WorkbookDesigner();
  19769. designer.Workbook = new Workbook(tempPath);
  19770. designer.Process();
  19771. if (!Directory.Exists(savePath))
  19772. {
  19773. Directory.CreateDirectory(savePath);
  19774. }
  19775. string serverPath = $"{savePath}{fileName}";
  19776. designer.Workbook.Save(serverPath);
  19777. string rst = $"{servicePath}{ftpPath}{fileName}";
  19778. #endregion
  19779. return Ok(JsonView(new { url = rst }));
  19780. }
  19781. #endregion
  19782. #region 三公签证费用(签证费、代办费)
  19783. /// <summary>
  19784. /// 三公签证费用(签证费、代办费)
  19785. /// List
  19786. /// </summary>
  19787. /// <returns></returns>
  19788. [HttpPost]
  19789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19790. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  19791. {
  19792. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  19793. if (_view.Code != 0)
  19794. {
  19795. return Ok(JsonView(false, _view.Msg));
  19796. }
  19797. return Ok(JsonView(true, "操作成功!", _view.Data));
  19798. }
  19799. /// <summary>
  19800. /// 三公签证费用(签证费、代办费)
  19801. /// Add Or Update
  19802. /// </summary>
  19803. /// <returns></returns>
  19804. [HttpPost]
  19805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19806. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  19807. {
  19808. var _view = await _visaFeeInfoRep._Update(_dto);
  19809. if (_view.Code != 0)
  19810. {
  19811. return Ok(JsonView(false, _view.Msg));
  19812. }
  19813. return Ok(JsonView(true, _view.Msg));
  19814. }
  19815. #endregion
  19816. #region 酒店询价
  19817. /// <summary>
  19818. /// 酒店询价
  19819. /// Init
  19820. /// </summary>
  19821. /// <returns></returns>
  19822. [HttpPost]
  19823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19824. public async Task<IActionResult> PostHotelInquiryInit()
  19825. {
  19826. var res = await _hotelInquiryRep._Init();
  19827. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19828. return Ok(JsonView(true, res.Msg, res.Data));
  19829. }
  19830. /// <summary>
  19831. /// 酒店询价
  19832. /// page Item
  19833. /// </summary>
  19834. /// <param name="_dto"></param>
  19835. /// <returns></returns>
  19836. [HttpPost]
  19837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19838. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  19839. {
  19840. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  19841. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19842. var view = res.Data as PageDataViewBase;
  19843. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  19844. }
  19845. /// <summary>
  19846. /// 酒店询价
  19847. /// info
  19848. /// </summary>
  19849. /// <param name="_dto"></param>
  19850. /// <returns></returns>
  19851. [HttpPost]
  19852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19853. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  19854. {
  19855. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  19856. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19857. return Ok(JsonView(true, res.Msg, res.Data));
  19858. }
  19859. /// <summary>
  19860. /// 酒店询价
  19861. /// Add Or Edit
  19862. /// </summary>
  19863. /// <param name="_dto"></param>
  19864. /// <returns></returns>
  19865. [HttpPost]
  19866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19867. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  19868. {
  19869. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  19870. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19871. return Ok(JsonView(true, res.Msg, res.Data));
  19872. }
  19873. /// <summary>
  19874. /// 酒店询价
  19875. /// Del
  19876. /// </summary>
  19877. /// <param name="_dto"></param>
  19878. /// <returns></returns>
  19879. [HttpPost]
  19880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19881. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  19882. {
  19883. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  19884. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  19885. return Ok(JsonView(true, res.Msg, res.Data));
  19886. }
  19887. #endregion
  19888. #region 下载匹配op行程单
  19889. /// <summary>
  19890. /// 匹配op行程单
  19891. /// Init
  19892. /// </summary>
  19893. /// <param name="dto">团组列表请求dto</param>
  19894. /// <returns></returns>
  19895. [HttpPost]
  19896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19897. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  19898. {
  19899. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19900. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19901. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  19902. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  19903. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  19904. .Where(it => it.IsDel == 0)
  19905. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  19906. .OrderByDescending(it => it.VisitStartDate)
  19907. .ToList();
  19908. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  19909. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  19910. var diids = groupInfos.Select(it => it.Id).ToList();
  19911. List<string> countrys = new List<string>();
  19912. foreach (var item in country)
  19913. {
  19914. var data = _groupRepository.FormartTeamName(item);
  19915. var dataArray = _groupRepository.GroupSplitCountry(data);
  19916. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  19917. }
  19918. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  19919. List<string> areaArray = new List<string>(); //GetGroupCityLine
  19920. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  19921. foreach (var item in areaItem)
  19922. {
  19923. string areaStr = item.Value;
  19924. if (!string.IsNullOrEmpty(areaStr))
  19925. {
  19926. string[] str1 = areaStr.Split("-");
  19927. if (str1.Length > 0)
  19928. {
  19929. areaArray.AddRange(str1);
  19930. }
  19931. }
  19932. }
  19933. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  19934. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  19935. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  19936. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  19937. .ToList();
  19938. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  19939. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  19940. .Where(it => countriesIds.Contains(it.Id))
  19941. .Select(it => new { it.Id, Name = it.Name_CN })
  19942. .ToList();
  19943. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  19944. .Select(it => it.TeamName).ToList();
  19945. stopwatch.Stop();
  19946. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  19947. }
  19948. ///// <summary>
  19949. ///// 匹配op行程单
  19950. ///// Init 查询区域数据
  19951. ///// </summary>
  19952. ///// <param name="dto">团组列表请求dto</param>
  19953. ///// <returns></returns>
  19954. //[HttpPost]
  19955. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19956. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  19957. //{
  19958. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19959. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  19960. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  19961. // if (string.IsNullOrEmpty(countriesDataStr))
  19962. // {
  19963. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  19964. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  19965. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  19966. // }
  19967. // else
  19968. // {
  19969. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  19970. // }
  19971. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  19972. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  19973. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  19974. // List<dynamic> childList = new List<dynamic>();
  19975. // int parentId = dto.CountriesId;
  19976. // if (provinceData.Count > 1)
  19977. // {
  19978. // foreach (var item1 in provinceData)
  19979. // {
  19980. // List<dynamic> childList1 = new List<dynamic>();
  19981. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  19982. // foreach (var item2 in citiesData1)
  19983. // {
  19984. // List<dynamic> childList2 = new List<dynamic>();
  19985. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19986. // foreach (var item3 in countiesData1)
  19987. // {
  19988. // childList2.Add(new
  19989. // {
  19990. // id = item3.Id,
  19991. // parentId = item2.Id,
  19992. // level = "district",
  19993. // name = item3.Name_CN,
  19994. // });
  19995. // }
  19996. // childList1.Add(new
  19997. // {
  19998. // id = item2.Id,
  19999. // parentId = item1.Id,
  20000. // level = "city",
  20001. // name = item2.Name_CN,
  20002. // childList = childList2
  20003. // });
  20004. // }
  20005. // childList.Add(new
  20006. // {
  20007. // id = item1.Id,
  20008. // parentId = parentId,
  20009. // level = "province",
  20010. // name = item1.Name_CN,
  20011. // childList = childList1
  20012. // });
  20013. // }
  20014. // //城市
  20015. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20016. // foreach (var item2 in citiesData2)
  20017. // {
  20018. // List<dynamic> childList22 = new List<dynamic>();
  20019. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20020. // foreach (var item3 in countiesData1)
  20021. // {
  20022. // childList22.Add(new
  20023. // {
  20024. // id = item3.Id,
  20025. // parentId = item2.Id,
  20026. // level = "district",
  20027. // name = item3.Name_CN,
  20028. // });
  20029. // }
  20030. // childList.Add(new
  20031. // {
  20032. // id = item2.Id,
  20033. // parentId = parentId,
  20034. // level = "city",
  20035. // name = item2.Name_CN,
  20036. // childList = childList22
  20037. // });
  20038. // }
  20039. // }
  20040. // else
  20041. // {
  20042. // foreach (var item2 in citiesData)
  20043. // {
  20044. // string cname = item2.Name_CN;
  20045. // List<dynamic> childList1 = new List<dynamic>();
  20046. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20047. // foreach (var item3 in countiesData1)
  20048. // {
  20049. // childList1.Add(new
  20050. // {
  20051. // Id = item3.Id,
  20052. // parentId = item2.Id,
  20053. // level = "district",
  20054. // name = item3.Name_CN
  20055. // });
  20056. // }
  20057. // childList.Add(new
  20058. // {
  20059. // id = item2.Id,
  20060. // parentId = parentId,
  20061. // level = "city",
  20062. // name = item2.Name_CN,
  20063. // childList = childList1
  20064. // });
  20065. // }
  20066. // }
  20067. // stopwatch.Stop();
  20068. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20069. //}
  20070. /// <summary>
  20071. /// 匹配op行程单
  20072. /// 接团信息列表 Page
  20073. /// </summary>
  20074. /// <param name="dto">团组列表请求dto</param>
  20075. /// <returns></returns>
  20076. [HttpPost]
  20077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20078. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20079. {
  20080. var swatch = new Stopwatch();
  20081. swatch.Start();
  20082. #region 参数验证
  20083. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20084. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20085. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20086. #region 页面操作权限验证
  20087. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20088. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20089. #endregion
  20090. #endregion
  20091. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20092. {
  20093. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20094. //string sqlWhere = "";
  20095. if (!string.IsNullOrEmpty(dto.Country))
  20096. {
  20097. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20098. }
  20099. if (!string.IsNullOrEmpty(dto.Area))
  20100. {
  20101. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20102. }
  20103. if (!string.IsNullOrEmpty(dto.TeamName))
  20104. {
  20105. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20106. }
  20107. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20108. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20109. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20110. swatch.Stop();
  20111. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20112. }
  20113. else
  20114. {
  20115. return Ok(JsonView(false, "查询失败"));
  20116. }
  20117. }
  20118. /// <summary>
  20119. /// 匹配op行程单
  20120. /// 行程单下载
  20121. /// </summary>
  20122. /// <param name="dto">团组列表请求dto</param>
  20123. /// <returns></returns>
  20124. [HttpPost]
  20125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20126. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20127. {
  20128. #region 参数验证
  20129. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20130. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20131. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20132. #region 页面操作权限验证
  20133. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20134. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20135. #endregion
  20136. #endregion
  20137. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20138. {
  20139. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20140. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20141. }
  20142. else
  20143. {
  20144. return Ok(JsonView(false, "下载失败!"));
  20145. }
  20146. }
  20147. #endregion
  20148. #region 国家信息 数据 注释
  20149. //[HttpPost]
  20150. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20151. //{
  20152. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20153. // foreach (var item in dto)
  20154. // {
  20155. // infos.Add(new Grp_GroupsTaskAssignment()
  20156. // {
  20157. // DIId = item,
  20158. // CTId = 82,
  20159. // UId = 248,
  20160. // IsEnable = 1,
  20161. // CreateUserId = 233,
  20162. // CreateTime = DateTime.Now,
  20163. // IsDel = 0
  20164. // });
  20165. // infos.Add(new Grp_GroupsTaskAssignment()
  20166. // {
  20167. // DIId = item,
  20168. // CTId = 82,
  20169. // UId = 286,
  20170. // IsEnable = 1,
  20171. // CreateUserId = 233,
  20172. // CreateTime = DateTime.Now,
  20173. // IsDel = 0
  20174. // });
  20175. // }
  20176. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20177. // return Ok("操作成功");
  20178. //}
  20179. //public class paramJsonDto
  20180. //{
  20181. // public List<CountriesInfo> str { get; set; }
  20182. //}
  20183. //[HttpPost]
  20184. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20185. //{
  20186. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20187. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20188. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20189. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20190. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20191. // _sqlSugar.BeginTran();
  20192. // int countitiesIndex = 0;
  20193. // foreach (var item in dto.str)
  20194. // {
  20195. // dynamic data = item.c;
  20196. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20197. // if (data != null)
  20198. // {
  20199. // countitiesIndex++;
  20200. // foreach (var item1 in data)
  20201. // {
  20202. // string cnname = item1.cn;
  20203. // string enname = item1.en;
  20204. // Sys_Cities provinceInfo = new Sys_Cities()
  20205. // {
  20206. // CountriesId = countriesId,
  20207. // Name_CN = cnname,
  20208. // Name_EN = enname,
  20209. // ParentId = 0,
  20210. // IsCapital = 1,
  20211. // CreateUserId = 208,
  20212. // CreateTime = DateTime.Now,
  20213. // IsDel = 0
  20214. // };
  20215. // if (item1.lv == "province") //省份
  20216. // {
  20217. // provinceInfo.Level = 1;
  20218. // int provinceId = 0;
  20219. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20220. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20221. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20222. // var data1 = item1.c;
  20223. // foreach (var item2 in data1)
  20224. // {
  20225. // if (item2.lv == "city")
  20226. // {
  20227. // string citycnname = item2.cn;
  20228. // string cityenname = item2.en;
  20229. // Sys_Cities cityInfo = new Sys_Cities()
  20230. // {
  20231. // CountriesId = countriesId,
  20232. // ParentId = provinceId,
  20233. // Level = 2,
  20234. // Name_CN = citycnname,
  20235. // Name_EN = cityenname,
  20236. // IsCapital = 1,
  20237. // CreateUserId = 208,
  20238. // CreateTime = DateTime.Now,
  20239. // IsDel = 0
  20240. // };
  20241. // if (item2.c != null)
  20242. // {
  20243. // int cityId = 0;
  20244. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20245. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20246. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20247. // foreach (var item3 in item2.c)
  20248. // {
  20249. // if (item3.lv == "district")
  20250. // {
  20251. // var districtInfo = new Sys_Cities()
  20252. // {
  20253. // CountriesId = countriesId,
  20254. // Name_CN = item3.cn,
  20255. // Name_EN = item3.en,
  20256. // Level = 3,
  20257. // ParentId = cityId,
  20258. // IsCapital = 1,
  20259. // CreateUserId = 208,
  20260. // CreateTime = DateTime.Now,
  20261. // IsDel = 0
  20262. // };
  20263. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20264. // //{
  20265. // districts.Add(districtInfo);
  20266. // //}
  20267. // }
  20268. // }
  20269. // }
  20270. // else
  20271. // {
  20272. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20273. // //{
  20274. // cities.Add(cityInfo);
  20275. // //}
  20276. // }
  20277. // }
  20278. // }
  20279. // }
  20280. // else if (item1.lv == "city")//城市
  20281. // {
  20282. // provinceInfo.Level = 2;
  20283. // if (item1.c != null)
  20284. // {
  20285. // int cityId = 0;
  20286. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20287. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20288. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20289. // foreach (var item3 in item1.c)
  20290. // {
  20291. // if (item3.lv == "district")
  20292. // {
  20293. // var districtInfo = new Sys_Cities()
  20294. // {
  20295. // CountriesId = countriesId,
  20296. // Name_CN = item3.cn,
  20297. // Name_EN = item3.en,
  20298. // Level = 3,
  20299. // ParentId = cityId,
  20300. // IsCapital = 1,
  20301. // CreateUserId = 208,
  20302. // CreateTime = DateTime.Now,
  20303. // IsDel = 0
  20304. // };
  20305. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20306. // //{
  20307. // districts.Add(districtInfo);
  20308. // //}
  20309. // }
  20310. // }
  20311. // }
  20312. // else
  20313. // {
  20314. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20315. // //{
  20316. // cities.Add(provinceInfo);
  20317. // //}
  20318. // }
  20319. // }
  20320. // }
  20321. // }
  20322. // }
  20323. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20324. // cities = cities.Distinct().ToList();
  20325. // districts = districts.Distinct().ToList();
  20326. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20327. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20328. // cities.AddRange(districts);
  20329. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20330. // //_sqlSugar.RollbackTran();
  20331. // _sqlSugar.CommitTran();
  20332. // return Ok(JsonView(false, "操作成功!"));
  20333. //}
  20334. //[HttpPost]
  20335. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20336. //{
  20337. // List<CountitiesInfo> infos = dto.MyProperty;
  20338. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20339. // _sqlSugar.BeginTran();
  20340. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20341. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20342. // foreach (var item in infos)
  20343. // {
  20344. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20345. // if (countryInfo != null)
  20346. // {
  20347. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20348. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20349. // if (cityInfo1 != null)
  20350. // {
  20351. // cityInfo1.IsCapital = 0;
  20352. // cityInfos.Add(cityInfo1);
  20353. // }
  20354. // }
  20355. // }
  20356. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20357. // .UpdateColumns(it => it.IsCapital)
  20358. // .WhereColumns(it => it.Id)
  20359. // .ExecuteCommand();
  20360. // //_sqlSugar.RollbackTran();
  20361. // _sqlSugar.CommitTran();
  20362. // return Ok(JsonView(false, "操作成功!"));
  20363. //}
  20364. //public class CounrtiesDto
  20365. //{
  20366. // public List<CountitiesInfo> MyProperty { get; set; }
  20367. //}
  20368. //public class CountitiesInfo
  20369. //{
  20370. // /// <summary>
  20371. // /// 圣约翰
  20372. // /// </summary>
  20373. // public string capital_name_chinese { get; set; }
  20374. // /// <summary>
  20375. // ///
  20376. // /// </summary>
  20377. // public string capital_name { get; set; }
  20378. // /// <summary>
  20379. // ///
  20380. // /// </summary>
  20381. // public string country_type { get; set; }
  20382. // /// <summary>
  20383. // /// 安提瓜和巴布达
  20384. // /// </summary>
  20385. // public string country_name_chinese { get; set; }
  20386. // /// <summary>
  20387. // /// 安提瓜和巴布达
  20388. // /// </summary>
  20389. // public string country_name_chinese_short { get; set; }
  20390. // /// <summary>
  20391. // /// 安提瓜和巴布达
  20392. // /// </summary>
  20393. // public string country_name_chinese_UN { get; set; }
  20394. // /// <summary>
  20395. // ///
  20396. // /// </summary>
  20397. // public string country_name_english_abbreviation { get; set; }
  20398. // /// <summary>
  20399. // ///
  20400. // /// </summary>
  20401. // public string country_name_english_formal { get; set; }
  20402. // /// <summary>
  20403. // ///
  20404. // /// </summary>
  20405. // public string country_name_english_UN { get; set; }
  20406. // /// <summary>
  20407. // ///
  20408. // /// </summary>
  20409. // public string continent_name { get; set; }
  20410. // /// <summary>
  20411. // ///
  20412. // /// </summary>
  20413. // public string subregion_name { get; set; }
  20414. // /// <summary>
  20415. // ///
  20416. // /// </summary>
  20417. // public string country_code2 { get; set; }
  20418. // /// <summary>
  20419. // ///
  20420. // /// </summary>
  20421. // public string country_code3 { get; set; }
  20422. // /// <summary>
  20423. // ///
  20424. // /// </summary>
  20425. // public string phone_code { get; set; }
  20426. //}
  20427. //public class CountriesInfo : BasicInfo
  20428. //{
  20429. // public List<CitiesInfo> c { get; set; }
  20430. //}
  20431. //public class CitiesInfo : BasicInfo
  20432. //{
  20433. // public List<AreaInfo> c { get; set; }
  20434. //}
  20435. //public class AreaInfo : BasicInfo
  20436. //{
  20437. // public List<AreaInfo> c { get; set; }
  20438. //}
  20439. //public class BasicInfo
  20440. //{
  20441. // public string code { get; set; }
  20442. // public string cn { get; set; }
  20443. // public string lv { get; set; }
  20444. // public string en { get; set; }
  20445. //}
  20446. #endregion
  20447. #region 查看邀请方
  20448. /// <summary>
  20449. /// 查看邀请方
  20450. /// 邀请方信息 Init
  20451. /// </summary>
  20452. /// <param name="dto"></param>
  20453. /// <returns></returns>
  20454. [HttpPost]
  20455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20456. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20457. {
  20458. string sqlWhere = string.Empty;
  20459. if (!string.IsNullOrEmpty(dto.Search))
  20460. {
  20461. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20462. }
  20463. string sql = string.Format($@"Select
  20464. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20465. Id,
  20466. UnitName
  20467. From Res_InvitationOfficialActivityData
  20468. Where IsDel = 0
  20469. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20470. RefAsync<int> total = 0;
  20471. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20472. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20473. }
  20474. /// <summary>
  20475. /// 查看邀请方
  20476. /// 国家信息 Init
  20477. /// </summary>
  20478. /// <param name="dto"></param>
  20479. /// <returns></returns>
  20480. [HttpPost]
  20481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20482. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20483. {
  20484. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20485. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20486. var diids = groupInfos.Select(it => it.Id).ToList();
  20487. List<string> countrys = new List<string>();
  20488. foreach (var item in country)
  20489. {
  20490. var data = _groupRepository.FormartTeamName(item);
  20491. var dataArray = _groupRepository.GroupSplitCountry(data);
  20492. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20493. }
  20494. countrys = countrys.Distinct().ToList();
  20495. for (int i = 0; i < countrys.Count; i++)
  20496. {
  20497. string item = countrys[i];
  20498. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20499. {
  20500. countrys.Remove(item);
  20501. i--;
  20502. }
  20503. }
  20504. RefAsync<int> total = 0;
  20505. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20506. .Where(it => countrys.Contains(it.Name_CN))
  20507. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20508. .Select(it => new { id = it.Id, name = it.Name_CN })
  20509. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20510. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20511. }
  20512. /// <summary>
  20513. /// 查看邀请方
  20514. /// 城市信息 Init
  20515. /// </summary>
  20516. /// <param name="dto"></param>
  20517. /// <returns></returns>
  20518. [HttpPost]
  20519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20520. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20521. {
  20522. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20523. RefAsync<int> total = 0;
  20524. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20525. .Where(it => it.CountriesId == dto.CountiesId)
  20526. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20527. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20528. .Select(it => new { id = it.Id, name = it.Name_CN })
  20529. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20530. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20531. }
  20532. /// <summary>
  20533. /// 查看邀请方
  20534. /// 团组名称 Init
  20535. /// </summary>
  20536. /// <param name="dto"></param>
  20537. /// <returns></returns>
  20538. [HttpPost]
  20539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20540. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20541. {
  20542. var watch = new Stopwatch();
  20543. watch.Start();
  20544. RefAsync<int> total = 0;
  20545. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20546. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20547. .Where((oa, di) => oa.IsDel == 0)
  20548. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20549. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20550. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20551. .Distinct()
  20552. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20553. watch.Stop();
  20554. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20555. }
  20556. /// <summary>
  20557. /// 查看邀请方
  20558. /// 团组 & 邀请方信息
  20559. /// </summary>
  20560. /// <param name="dto"></param>
  20561. /// <returns></returns>
  20562. [HttpPost]
  20563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20564. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20565. {
  20566. var watch = new Stopwatch();
  20567. watch.Start();
  20568. RefAsync<int> total = 0;
  20569. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20570. .AS("Grp_DelegationInfo")
  20571. .Includes(x => x.InvitingInfos)
  20572. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20573. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20574. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20575. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20576. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20577. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20578. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20579. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20580. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20581. infos.ForEach(x =>
  20582. {
  20583. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20584. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20585. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20586. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20587. });
  20588. watch.Stop();
  20589. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20590. }
  20591. #endregion
  20592. #region 报批行程
  20593. /// <summary>
  20594. /// 报批行程初始化
  20595. /// </summary>
  20596. /// <param name="dto"></param>
  20597. /// <returns></returns>
  20598. [HttpPost]
  20599. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20600. {
  20601. const int chiNumber = 5;
  20602. var jw = JsonView(false);
  20603. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20604. var group = groupList.First();
  20605. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20606. group = groupList.First(x => x.Id == diid);
  20607. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20608. .Where(x => x.DiId == diid && x.IsDel == 0)
  20609. .ToArray();
  20610. var count = 1;
  20611. foreach (var item in blackCodeList)
  20612. {
  20613. if (string.IsNullOrWhiteSpace(item.Title))
  20614. {
  20615. item.Title = "未设置名称数据" + count;
  20616. }
  20617. count++;
  20618. };
  20619. if (group == null)
  20620. {
  20621. jw.Msg = "暂无团组!";
  20622. return Ok(jw);
  20623. }
  20624. var data = new
  20625. {
  20626. groupList = groupList.Select(x => new
  20627. {
  20628. x.TeamName,
  20629. x.Id
  20630. }),
  20631. content = new ArrayList(),
  20632. groupInfo = new
  20633. {
  20634. group.VisitDays,
  20635. group.TourCode,
  20636. group.VisitPNumber,
  20637. group.TeamName,
  20638. group.Id,
  20639. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  20640. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  20641. },
  20642. blackCodeList = blackCodeList.Select(x => new
  20643. {
  20644. x.Title,
  20645. x.Id
  20646. }),
  20647. FileTempList = new ArrayList()
  20648. {
  20649. new { Index = 1,FileName = "旧模板" },
  20650. new { Index = 2,FileName = "省外办" },
  20651. new { Index = 3,FileName = "市外办" },
  20652. }
  20653. };
  20654. var resultArr = new ArrayList();
  20655. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  20656. #region 默认不生成行程
  20657. //if (content.Count == 0)
  20658. //{
  20659. // var stay = "-";
  20660. // var cityPath = "-";
  20661. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20662. // .Where(x => x.DiId == diid && x.IsDel == 0)
  20663. // .ToList();
  20664. // //添加城市路径以及住宿地
  20665. // //黑屏代码数据
  20666. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  20667. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20668. // {
  20669. // jw = JsonView(true, "黑屏代码有误!", data);
  20670. // return Ok(jw);
  20671. // }
  20672. // data = data with
  20673. // {
  20674. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  20675. // {
  20676. // x.Title,
  20677. // x.Id,
  20678. // }).ToArray())
  20679. // };
  20680. // foreach (DataRow row in dtBlack.Rows)
  20681. // {
  20682. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20683. // {
  20684. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  20685. // return Ok(jw);
  20686. // }
  20687. // }
  20688. // //黑屏代码获取时间区间
  20689. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20690. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20691. // _sqlSugar.BeginTran();
  20692. // for (int i = 0; i < timeArr.Count; i++)
  20693. // {
  20694. // stay = "-";
  20695. // cityPath = "-";
  20696. // DateTime NewData = DateTime.Parse(timeArr[i]);
  20697. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20698. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20699. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20700. // if (tbSelect.Length > 0)
  20701. // {
  20702. // List<string> threeCodeStr = new List<string>();
  20703. // foreach (var item in tbSelect)
  20704. // {
  20705. // var threeCode = item["Three"].ToString() ?? "";
  20706. // if (threeCode.Length == 6)
  20707. // {
  20708. // var start = threeCode.Substring(0, 3);
  20709. // var end = threeCode.Substring(3, 3);
  20710. // if (threeCodeStr.Count == 0)
  20711. // {
  20712. // threeCodeStr.Add(start);
  20713. // threeCodeStr.Add(end);
  20714. // }
  20715. // else
  20716. // {
  20717. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20718. // {
  20719. // threeCodeStr.Add(end);
  20720. // }
  20721. // else
  20722. // {
  20723. // threeCodeStr.Add(start);
  20724. // threeCodeStr.Add(end);
  20725. // }
  20726. // }
  20727. // }
  20728. // }
  20729. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20730. // var last = threeCodeStr.Last();
  20731. // foreach (var item in threeCodeStr)
  20732. // {
  20733. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20734. // if (item.Equals(last))
  20735. // {
  20736. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20737. // }
  20738. // }
  20739. // cityPath = cityPath.Trim('-');
  20740. // }
  20741. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  20742. // appro.Diid = diid ?? -1;
  20743. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20744. // appro.Id = thisId;
  20745. // appro.CreateUserId = dto.UserId;
  20746. // appro.CreateTime = DateTime.Now;
  20747. // content.Add(appro);
  20748. // }
  20749. // _sqlSugar.CommitTran();
  20750. //}
  20751. #endregion
  20752. foreach (var x in content)
  20753. {
  20754. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  20755. if (chiList.Count < chiNumber)
  20756. {
  20757. for (int i = chiList.Count; i < chiNumber; i++)
  20758. {
  20759. chiList.Add(new Grp_ApprovalTravelDetails());
  20760. }
  20761. }
  20762. resultArr.Add(new
  20763. {
  20764. x.Id,
  20765. x.Date,
  20766. x.Diid,
  20767. chiList = chiList.Select(x1 => new
  20768. {
  20769. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  20770. x1.Details,
  20771. x1.ParentId,
  20772. x1.Id
  20773. })
  20774. });
  20775. }
  20776. data = data with
  20777. {
  20778. content = resultArr,
  20779. };
  20780. jw = JsonView(true, "获取成功!", data);
  20781. return Ok(jw);
  20782. }
  20783. /// <summary>
  20784. /// 报批行程删除
  20785. /// </summary>
  20786. /// <param name="dto"></param>
  20787. /// <returns></returns>
  20788. [HttpPost]
  20789. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  20790. {
  20791. var jw = JsonView(false);
  20792. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20793. if (group == null)
  20794. {
  20795. jw.Msg = "团组参数有误!";
  20796. return Ok(jw);
  20797. }
  20798. try
  20799. {
  20800. _sqlSugar.BeginTran();
  20801. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  20802. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  20803. {
  20804. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20805. DeleteUserId = dto.uesrId,
  20806. IsDel = 1
  20807. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  20808. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  20809. {
  20810. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20811. DeleteUserId = dto.uesrId,
  20812. IsDel = 1
  20813. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  20814. _sqlSugar.CommitTran();
  20815. jw = JsonView(true, "删除成功");
  20816. }
  20817. catch (Exception ex)
  20818. {
  20819. jw = JsonView(false, ex.Message);
  20820. }
  20821. return Ok(jw);
  20822. }
  20823. /// <summary>
  20824. /// 报批行程保存
  20825. /// </summary>
  20826. /// <param name="dto"></param>
  20827. /// <returns></returns>
  20828. [HttpPost]
  20829. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  20830. {
  20831. var jw = JsonView(false);
  20832. var Find = dto.Arr.Find(x => x.id == 0);
  20833. if (Find != null)
  20834. {
  20835. jw.Msg = "生成的ID为0!";
  20836. return Ok(jw);
  20837. }
  20838. foreach (var item in dto.Arr)
  20839. {
  20840. foreach (var chi in item.chiList)
  20841. {
  20842. if (chi.parentId == 0)
  20843. {
  20844. chi.parentId = item.id;
  20845. }
  20846. }
  20847. }
  20848. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  20849. _sqlSugar.BeginTran();
  20850. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  20851. {
  20852. var parentIds = dto.Arr.Select(x => x.id).ToList();
  20853. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  20854. {
  20855. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  20856. DeleteUserId = dto.UserId,
  20857. IsDel = 1
  20858. }).ExecuteCommand();
  20859. }
  20860. try
  20861. {
  20862. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  20863. {
  20864. CreateTime = DateTime.Now,
  20865. CreateUserId = dto.UserId,
  20866. Details = x.details,
  20867. ParentId = x.parentId,
  20868. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20869. Remark = "",
  20870. IsDel = 0
  20871. }).ToList()).ExecuteCommand();
  20872. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  20873. {
  20874. Id = x.id,
  20875. Details = x.details,
  20876. ParentId = x.parentId,
  20877. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  20878. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  20879. {
  20880. Details = x.Details,
  20881. ParentId = x.ParentId,
  20882. Time = x.Time
  20883. }).ExecuteCommand();
  20884. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  20885. {
  20886. Id = x.id,
  20887. Date = x.date,
  20888. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  20889. {
  20890. Date = x.Date
  20891. }).ExecuteCommand();
  20892. _sqlSugar.CommitTran();
  20893. jw = JsonView(true, "保存成功!");
  20894. }
  20895. catch (Exception ex)
  20896. {
  20897. _sqlSugar.RollbackTran();
  20898. jw = JsonView(false, "保存失败!" + ex.Message);
  20899. }
  20900. return Ok(jw);
  20901. }
  20902. /// <summary>
  20903. /// 报批行程生成
  20904. /// </summary>
  20905. /// <param name="dto"></param>
  20906. /// <returns></returns>
  20907. [HttpPost]
  20908. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  20909. {
  20910. var jw = JsonView(false);
  20911. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20912. if (group == null)
  20913. {
  20914. jw.Msg = "暂无该团组!";
  20915. return Ok(jw);
  20916. }
  20917. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  20918. //黑屏代码数据
  20919. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  20920. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20921. {
  20922. jw.Msg = "黑屏代码有误!";
  20923. return Ok(jw);
  20924. }
  20925. foreach (DataRow row in dtBlack.Rows)
  20926. {
  20927. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20928. {
  20929. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  20930. return Ok(jw);
  20931. }
  20932. }
  20933. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  20934. var resultArr = new ArrayList();
  20935. //if (officialActivitiesArr.Count == 0)
  20936. //{
  20937. // jw.Msg = "暂无公务出访信息!";
  20938. // return Ok(jw);
  20939. //}
  20940. try
  20941. {
  20942. _sqlSugar.BeginTran();
  20943. DeleteApprovalJourney(new
  20944. Domain.Dtos.Groups.DeleteApprovalJourney
  20945. {
  20946. Diid = dto.Diid,
  20947. uesrId = dto.Userid
  20948. });
  20949. var stay = "-";
  20950. var cityPath = "-";
  20951. var arriveCountry = string.Empty;
  20952. //添加城市路径以及住宿地
  20953. //黑屏代码获取时间区间
  20954. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20955. var empty = "【未收入该三字码!请机票同事录入】";
  20956. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20957. #region 配置公务活动时间
  20958. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  20959. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  20960. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  20961. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  20962. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  20963. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  20964. {
  20965. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,6,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  20966. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,8,30,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  20967. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  20968. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  20969. };
  20970. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  20971. {
  20972. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,7,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  20973. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,9,0,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  20974. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  20975. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  20976. };
  20977. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  20978. {
  20979. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,18,0,0), new List<string>{"9:00-10:30","11:00-12:00", "14:00-15:30","16:00-17:00" }),
  20980. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,15,30,0), new List<string>{"9:00-10:30", "11:00-12:00", "14:00-15:00","15:00-16:00"}),
  20981. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  20982. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  20983. };
  20984. #endregion
  20985. var nextDayNum = 0;
  20986. for (int i = 0; i < timeArr.Count; i++)
  20987. {
  20988. stay = "-";
  20989. cityPath = "-";
  20990. var chiarr = new List<Grp_ApprovalTravelDetails>();
  20991. DateTime NewData = DateTime.Parse(timeArr[i]);
  20992. //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();
  20993. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20994. if (nextDayNum > 0)
  20995. {
  20996. nextDayNum--;
  20997. }
  20998. if (tbSelect.Length > 0)
  20999. {
  21000. List<string> threeCodeStr = new List<string>();
  21001. bool isTrade = false;
  21002. string trip = string.Empty;
  21003. foreach (var item in tbSelect)
  21004. {
  21005. if (nextDayNum == 0)
  21006. {
  21007. nextDayNum = Convert.ToInt32(item["Sign"]);
  21008. }
  21009. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21010. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21011. var takeOffTime = DateTime.Parse(timeArr[i]);
  21012. var fallToTime = DateTime.Parse(timeArr[i]);
  21013. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21014. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21015. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21016. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21017. if (nextDayNum > 0)
  21018. {
  21019. fallToTime = fallToTime.AddDays(nextDayNum);
  21020. }
  21021. trip = string.Empty;
  21022. var start = string.Empty;
  21023. var end = string.Empty;
  21024. var threeCode = item["Three"].ToString() ?? "";
  21025. if (threeCode.Length == 6)
  21026. {
  21027. start = threeCode.Substring(0, 3);
  21028. end = threeCode.Substring(3, 3);
  21029. if (threeCodeStr.Count == 0)
  21030. {
  21031. threeCodeStr.Add(start);
  21032. threeCodeStr.Add(end);
  21033. }
  21034. else
  21035. {
  21036. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21037. {
  21038. threeCodeStr.Add(end);
  21039. }
  21040. else
  21041. {
  21042. threeCodeStr.Add(start);
  21043. threeCodeStr.Add(end);
  21044. }
  21045. }
  21046. }
  21047. //处理机票信息
  21048. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21049. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21050. if (start_Object == null)
  21051. {
  21052. start_Object = new Res_ThreeCode()
  21053. {
  21054. AirPort = empty,
  21055. AirPort_En = empty,
  21056. City = empty,
  21057. Country = empty,
  21058. Four = empty,
  21059. Three = empty,
  21060. };
  21061. }
  21062. if (end_Object == null)
  21063. {
  21064. end_Object = new Res_ThreeCode()
  21065. {
  21066. AirPort = empty,
  21067. AirPort_En = empty,
  21068. City = empty,
  21069. Country = empty,
  21070. Four = empty,
  21071. Three = empty,
  21072. };
  21073. }
  21074. //机型判断
  21075. string airModel = item["AirModel"].ToString();
  21076. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21077. string flightTime = item["FlightTime"].ToString();
  21078. flightTime = ParseBlackTime(flightTime);
  21079. //航班号
  21080. string flightcode = item["Fliagtcode"].ToString();
  21081. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21082. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21083. if (aircompany == null)
  21084. {
  21085. aircompany = new Res_AirCompany
  21086. {
  21087. CnName = hsEmpty,
  21088. EnName = hsEmpty,
  21089. ShortCode = hsEmpty,
  21090. };
  21091. }
  21092. //航班前公务安排
  21093. if (tbSelect.First().Equals(item) && i != 0)
  21094. {
  21095. foreach (var takeoff in takeoffTimes)
  21096. {
  21097. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21098. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21099. {
  21100. foreach (var addTime in takeoff.Item2)
  21101. {
  21102. chiarr.Add(new Grp_ApprovalTravelDetails
  21103. {
  21104. Time = addTime,
  21105. CreateTime = DateTime.Now,
  21106. CreateUserId = dto.Userid,
  21107. ParentId = 0,
  21108. Details = "公务活动"
  21109. });
  21110. }
  21111. break;
  21112. }
  21113. }
  21114. }
  21115. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21116. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21117. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21118. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21119. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21120. if (isTrade)
  21121. {
  21122. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21123. trip += "(转机不出机场)。";
  21124. }
  21125. //else
  21126. //{
  21127. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21128. //}
  21129. chiarr.Add(new Grp_ApprovalTravelDetails
  21130. {
  21131. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21132. CreateTime = DateTime.Now,
  21133. CreateUserId = dto.Userid,
  21134. ParentId = 0,
  21135. Details = trip
  21136. });
  21137. //最后一条到达的时间安排公务
  21138. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21139. {
  21140. bool isCheckCountry = false;
  21141. if (end_Object.Country != arriveCountry)
  21142. {
  21143. arriveCountry = end_Object.Country;
  21144. isCheckCountry = true;
  21145. }
  21146. if (nextDayNum == 0)
  21147. {
  21148. //需要入境的情况
  21149. if (isCheckCountry)
  21150. {
  21151. foreach (var fallTime in fallTimesCheckCountry)
  21152. {
  21153. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21154. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21155. {
  21156. foreach (var addTime in fallTime.Item2)
  21157. {
  21158. chiarr.Add(new Grp_ApprovalTravelDetails
  21159. {
  21160. Time = addTime,
  21161. CreateTime = DateTime.Now,
  21162. CreateUserId = dto.Userid,
  21163. ParentId = 0,
  21164. Details = "公务活动"
  21165. });
  21166. }
  21167. break;
  21168. }
  21169. }
  21170. }
  21171. else
  21172. {
  21173. foreach (var fallTime in fallTimesNotCheckCountry)
  21174. {
  21175. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21176. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21177. {
  21178. foreach (var addTime in fallTime.Item2)
  21179. {
  21180. chiarr.Add(new Grp_ApprovalTravelDetails
  21181. {
  21182. Time = addTime,
  21183. CreateTime = DateTime.Now,
  21184. CreateUserId = dto.Userid,
  21185. ParentId = 0,
  21186. Details = "公务活动"
  21187. });
  21188. }
  21189. break;
  21190. }
  21191. }
  21192. }
  21193. }
  21194. }
  21195. }
  21196. //添加乘车语句
  21197. //chiarr.Add(new Grp_ApprovalTravelDetails
  21198. //{
  21199. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21200. // CreateTime = DateTime.Now,
  21201. // CreateUserId = dto.Userid,
  21202. // ParentId = 0,
  21203. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21204. //});
  21205. //if (i != timeArr.Count - 1)
  21206. //{
  21207. // fallToTime = fallToTime.AddHours(2.5);
  21208. // foreach (var item in Times)
  21209. // {
  21210. // //排列公务时间
  21211. // if (fallToTime.Hour < item.Item1)
  21212. // {
  21213. // chiarr.Add(new Grp_ApprovalTravelDetails
  21214. // {
  21215. // Time = $"{item.Item2} - {item.Item3}",
  21216. // CreateTime = DateTime.Now,
  21217. // CreateUserId = dto.Userid,
  21218. // ParentId = 0,
  21219. // Details = "公务活动"
  21220. // });
  21221. // }
  21222. // }
  21223. //}
  21224. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21225. var last = threeCodeStr.Last();
  21226. foreach (var item in threeCodeStr)
  21227. {
  21228. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21229. if (item.Equals(last))
  21230. {
  21231. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21232. }
  21233. }
  21234. cityPath = cityPath.Trim('-');
  21235. }
  21236. else
  21237. {
  21238. foreach (var item in Times)
  21239. {
  21240. chiarr.Add(new Grp_ApprovalTravelDetails
  21241. {
  21242. Time = $"{item.Item2} - {item.Item3}",
  21243. CreateTime = DateTime.Now,
  21244. CreateUserId = dto.Userid,
  21245. ParentId = 0,
  21246. Details = "公务活动"
  21247. });
  21248. }
  21249. }
  21250. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21251. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21252. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21253. appro.Diid = dto.Diid;
  21254. appro.CreateUserId = dto.Userid;
  21255. appro.CreateTime = DateTime.Now;
  21256. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21257. appro.Id = thisId;
  21258. //foreach (var item in gwinfo)
  21259. //{
  21260. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21261. // chi.Details = "拜访" + item.Client;
  21262. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21263. // {
  21264. // chi.Details += "," + item.ReqSample;
  21265. // }
  21266. // chi.ParentId = thisId;
  21267. // chi.Time = item.Time;
  21268. // chiarr.Add(chi);
  21269. //}
  21270. if (chiarr.Count < 6)
  21271. {
  21272. for (int j = chiarr.Count; j < 6; j++)
  21273. {
  21274. chiarr.Add(new
  21275. Grp_ApprovalTravelDetails());
  21276. }
  21277. }
  21278. resultArr.Add(new
  21279. {
  21280. appro.Id,
  21281. appro.Date,
  21282. appro.Diid,
  21283. chiList = chiarr.Select(x1 => new
  21284. {
  21285. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21286. x1.Details,
  21287. x1.ParentId,
  21288. x1.Id
  21289. })
  21290. });
  21291. }
  21292. _sqlSugar.CommitTran();
  21293. jw = JsonView(true, "生成成功!", resultArr);
  21294. }
  21295. catch (Exception ex)
  21296. {
  21297. jw.Code = 400;
  21298. jw.Msg = "生成失败!" + ex.Message;
  21299. }
  21300. return Ok(jw);
  21301. }
  21302. /// <summary>
  21303. /// 报批行程word导出
  21304. /// </summary>
  21305. /// <param name="dto"></param>
  21306. /// <returns></returns>
  21307. [HttpPost]
  21308. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21309. {
  21310. var jw = JsonView(false);
  21311. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21312. if (group == null)
  21313. {
  21314. jw.Msg = "暂无该团组!";
  21315. return Ok(jw);
  21316. }
  21317. //模板路径
  21318. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21319. var fileName = string.Empty;
  21320. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21321. bool bold = false;
  21322. if (dto.FileIndex == 1)
  21323. {
  21324. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21325. }
  21326. else if (dto.FileIndex == 2)
  21327. {
  21328. fileName = "省外办-报批.docx";
  21329. bold = false;
  21330. titleFont = "方正黑体简体";
  21331. timeFont = "Times New Roman";
  21332. contentFont = "方正仿宋_GBK";
  21333. }
  21334. else if (dto.FileIndex == 3)
  21335. {
  21336. fileName = "市外办-报批.docx";
  21337. titleFont = "方正黑体简体";
  21338. timeFont = "Times New Roman";
  21339. contentFont = "方正仿宋简体";
  21340. }
  21341. tempPath = tempPath + fileName;
  21342. //载入模板
  21343. Document doc = new Document(tempPath);
  21344. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21345. //获取所填表格的序数
  21346. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21347. Aspose.Words.Tables.Row titleRowClone = null;
  21348. Aspose.Words.Tables.Row CenterRowClone = null;
  21349. int index = 0;
  21350. int indexChi = 0;
  21351. int SetIndex = 0;
  21352. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21353. //获取数据,放到datatable
  21354. foreach (var item in ApprovalTravelArr)
  21355. {
  21356. if (index > 0)
  21357. {
  21358. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21359. tableOne.AppendChild(titleRowClone);
  21360. }
  21361. var textTime = item.Date;
  21362. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21363. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21364. SetIndex++;
  21365. if (ChiRep.Count > 0)
  21366. {
  21367. foreach (var itemChi in ChiRep)
  21368. {
  21369. var txtTime = itemChi.Time;
  21370. var txtDetail = itemChi.Details;
  21371. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21372. {
  21373. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21374. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21375. //indexChi++;
  21376. //SetIndex++;
  21377. break;
  21378. }
  21379. if (indexChi > 0)
  21380. {
  21381. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21382. tableOne.AppendChild(CenterRowClone);
  21383. }
  21384. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21385. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21386. indexChi++;
  21387. SetIndex++;
  21388. }
  21389. }
  21390. //else
  21391. //{
  21392. // if (indexChi > 0)
  21393. // {
  21394. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21395. // tableOne.AppendChild(CenterRowClone);
  21396. // }
  21397. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21398. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21399. // indexChi++;
  21400. // SetIndex++;
  21401. //}
  21402. index++;
  21403. }
  21404. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21405. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21406. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21407. jw.Code = 200;
  21408. jw.Msg = "";
  21409. return Ok(jw);
  21410. }
  21411. private string ParseBlackTime(string time)
  21412. {
  21413. // 匹配可能只有分钟的情况
  21414. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21415. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21416. if (match.Success)
  21417. {
  21418. string hours = match.Groups[1].Value;
  21419. string minutes = match.Groups[2].Value;
  21420. // 如果小时部分为空,则只显示分钟
  21421. if (string.IsNullOrEmpty(hours))
  21422. {
  21423. return $"{minutes}分钟";
  21424. }
  21425. // 如果分钟部分为空,则只显示小时
  21426. else if (string.IsNullOrEmpty(minutes))
  21427. {
  21428. return $"{hours}小时";
  21429. }
  21430. // 否则显示完整格式
  21431. else
  21432. {
  21433. return $"{hours}小时{minutes}分钟";
  21434. }
  21435. }
  21436. else
  21437. {
  21438. return "未知时长";
  21439. }
  21440. }
  21441. private string intToString(int numberVal)
  21442. {
  21443. string numberval = numberVal.ToString();
  21444. Dictionary<char, string> Number = new Dictionary<char, string>();
  21445. Number.Add('1', "一");
  21446. Number.Add('2', "二");
  21447. Number.Add('3', "三");
  21448. Number.Add('4', "四");
  21449. Number.Add('5', "五");
  21450. Number.Add('6', "六");
  21451. Number.Add('7', "七");
  21452. Number.Add('8', "八");
  21453. Number.Add('9', "九");
  21454. string stringNumberVal = string.Empty;
  21455. for (int i = 0; i < numberval.Length; i++)
  21456. {
  21457. if (i == 0)
  21458. {
  21459. stringNumberVal += Number[numberval[i]];
  21460. }
  21461. else if (i >= 1)
  21462. {
  21463. if (numberval[i] == '0')
  21464. {
  21465. stringNumberVal = "十";
  21466. }
  21467. else
  21468. {
  21469. stringNumberVal += "十" + Number[numberval[i]];
  21470. }
  21471. }
  21472. }
  21473. return stringNumberVal;
  21474. }
  21475. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21476. {
  21477. //获取table中的某个单元格,从0开始
  21478. Cell lshCell = table.Rows[rows].Cells[cells];
  21479. //将单元格中段落移除
  21480. foreach (Paragraph item in lshCell.Paragraphs)
  21481. {
  21482. lshCell.Paragraphs.Remove(item);
  21483. }
  21484. if (val.Contains("\r\n"))
  21485. {
  21486. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21487. foreach (var item in spArr)
  21488. {
  21489. //新建一个段落
  21490. Paragraph p = new Paragraph(doc);
  21491. var r = new Run(doc, item);
  21492. //设置字体
  21493. if (!string.IsNullOrEmpty(font))
  21494. {
  21495. r.Font.Name = font;
  21496. }
  21497. r.Font.Bold = bold;
  21498. //把设置的值赋给之前新建的段落
  21499. p.AppendChild(r);
  21500. //将此段落加到单元格内
  21501. lshCell.AppendChild(p);
  21502. }
  21503. }
  21504. else
  21505. {
  21506. //新建一个段落
  21507. Paragraph p = new Paragraph(doc);
  21508. var r = new Run(doc, val);
  21509. //设置字体
  21510. if (!string.IsNullOrEmpty(font))
  21511. {
  21512. r.Font.Name = font;
  21513. }
  21514. r.Font.Bold = bold;
  21515. //把设置的值赋给之前新建的段落
  21516. p.AppendChild(r);
  21517. //将此段落加到单元格内
  21518. lshCell.AppendChild(p);
  21519. }
  21520. }
  21521. //[HttpPost]
  21522. //public async Task<IActionResult> ServerHttp(string paramStr)
  21523. //{
  21524. // paramStr = paramStr.TrimEnd('\'');
  21525. // paramStr = paramStr.TrimStart('\'');
  21526. // JsonView jw = JsonView(false);
  21527. // JObject param = JObject.Parse(paramStr);
  21528. // if (!param.ContainsKey("url"))
  21529. // {
  21530. // jw.Msg = "url null";
  21531. // return Ok(jw);
  21532. // }
  21533. // string url = param["url"]!.ToString();
  21534. // var methon = "get";
  21535. // Dictionary<string, string> headValues = null;
  21536. // string bodyStr = string.Empty;
  21537. // if (param.ContainsKey("methon"))
  21538. // {
  21539. // methon = param["methon"]!.ToString().ToLower();
  21540. // }
  21541. // if (param.ContainsKey("header"))
  21542. // {
  21543. // var header = param["header"]!.ToString();
  21544. // JObject headerJobject = JObject.Parse(header);
  21545. // headValues = new Dictionary<string, string>();
  21546. // foreach (JProperty item in headerJobject.Properties())
  21547. // {
  21548. // var value = item.Value.ToString();
  21549. // var head = item.Path;
  21550. // headValues.Add(head, value);
  21551. // }
  21552. // }
  21553. // HttpClient client = new HttpClient();
  21554. // string responseString = string.Empty;
  21555. // StringContent content = null;
  21556. // if (headValues != null)
  21557. // {
  21558. // foreach (var item in headValues.Keys)
  21559. // {
  21560. // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  21561. // {
  21562. // if (param.ContainsKey("body"))
  21563. // {
  21564. // bodyStr = param["body"]!.ToString();
  21565. // }
  21566. // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  21567. // }
  21568. // else
  21569. // {
  21570. // client.DefaultRequestHeaders.Add(item, headValues[item]);
  21571. // }
  21572. // }
  21573. // }
  21574. // try
  21575. // {
  21576. // if (methon == "get")
  21577. // {
  21578. // responseString = await client.GetStringAsync(url);
  21579. // }
  21580. // else if (methon == "post")
  21581. // {
  21582. // var request = new HttpRequestMessage(HttpMethod.Post, url)
  21583. // {
  21584. // Content = content
  21585. // };
  21586. // var response = await client.SendAsync(request);
  21587. // try
  21588. // {
  21589. // Stream responseStream = await response.Content.ReadAsStreamAsync();
  21590. // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  21591. // {
  21592. // using (StreamReader reader = new StreamReader(gzipStream))
  21593. // {
  21594. // responseString = await reader.ReadToEndAsync();
  21595. // }
  21596. // }
  21597. // }
  21598. // catch (Exception)
  21599. // {
  21600. // responseString = await response.Content.ReadAsStringAsync();
  21601. // }
  21602. // }
  21603. // else
  21604. // {
  21605. // responseString = "methon error";
  21606. // }
  21607. // jw = JsonView(true, "success", responseString);
  21608. // }
  21609. // catch (Exception ex)
  21610. // {
  21611. // jw.Msg = "error " + ex.Message;
  21612. // jw.Data = ex.StackTrace;
  21613. // }
  21614. // finally
  21615. // {
  21616. // client.Dispose();
  21617. // }
  21618. // return Ok(jw);
  21619. //}
  21620. #endregion
  21621. #region 团组接待意见调查
  21622. /// <summary>
  21623. /// 团组接待意见调查 - 信息管理
  21624. /// 基础数据(团组)
  21625. /// </summary>
  21626. /// <returns></returns>
  21627. [HttpGet]
  21628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21629. public async Task<IActionResult> OpinionaireInit()
  21630. {
  21631. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21632. .Select(x => new
  21633. {
  21634. x.Id,
  21635. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21636. })
  21637. .OrderByDescending(x => x.Id)
  21638. .ToListAsync();
  21639. return Ok(JsonView(groupData, groupData.Count));
  21640. }
  21641. /// <summary>
  21642. /// 团组接待意见调查 - 信息管理
  21643. /// 列表
  21644. /// </summary>
  21645. /// <param name="groupId"></param>
  21646. /// <returns></returns>
  21647. [HttpGet("{groupId}")]
  21648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21649. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21650. {
  21651. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21652. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21653. .Select(x => new
  21654. {
  21655. x.Id,
  21656. x.TourGuideName,
  21657. x.CityName,
  21658. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21659. x.CreateTime
  21660. })
  21661. .OrderBy(x => x.Id)
  21662. .ToListAsync();
  21663. return Ok(JsonView(data));
  21664. }
  21665. /// <summary>
  21666. /// 团组接待意见调查 - 信息管理
  21667. /// 保存
  21668. /// </summary>
  21669. /// <param name="dto"></param>
  21670. /// <returns></returns>
  21671. [HttpPost]
  21672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21673. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21674. {
  21675. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21676. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21677. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21678. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21679. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21680. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21681. _opinionaireRep.BeginTran();
  21682. if (addData != null && addData.Count > 0)
  21683. {
  21684. foreach (var item in addData)
  21685. {
  21686. item.CreateUserId = currUserInfo.UserId;
  21687. item.DiId = dto.DiId;
  21688. }
  21689. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21690. }
  21691. if (updData != null && updData.Count > 0)
  21692. {
  21693. var upd = await _opinionaireRep._sqlSugar
  21694. .Updateable(updData)
  21695. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21696. .WhereColumns(x => new { x.Id })
  21697. .ExecuteCommandAsync();
  21698. }
  21699. _opinionaireRep.CommitTran();
  21700. return Ok(JsonView("操作成功!"));
  21701. }
  21702. /// <summary>
  21703. /// 团组接待意见调查 - 信息管理
  21704. /// 删除
  21705. /// </summary>
  21706. /// <param name="id"></param>
  21707. /// <returns></returns>
  21708. [HttpDelete("{id}")]
  21709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21710. public async Task<IActionResult> OpinionaireManageDel(int id)
  21711. {
  21712. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21713. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21714. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  21715. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  21716. if (!del) return Ok(JsonView("操作失败!"));
  21717. return Ok(JsonView("操作成功!"));
  21718. }
  21719. /// <summary>
  21720. /// 团组接待意见调查 - 用户
  21721. /// 列表
  21722. /// </summary>
  21723. /// <param name="diId"></param>
  21724. /// <returns></returns>
  21725. [HttpGet("{diId}")]
  21726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21727. public async Task<IActionResult> OpinionaireUserList(int diId)
  21728. {
  21729. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21730. var sql = string.Format(@"
  21731. SELECT
  21732. o.Id,
  21733. o.DiId,
  21734. di.TeamName AS 'GroupName',
  21735. di.VisitPNumber AS 'PeopleNumber',
  21736. di.ClientName AS 'LeadGroup',
  21737. di.VisitCountry AS 'Travel',
  21738. di.VisitDays AS 'Days',
  21739. o.CityName,
  21740. o.TourGuideName,
  21741. o.Catering,
  21742. o.CateringReason,
  21743. o.Stay,
  21744. o.StayReason,
  21745. o.[Route],
  21746. o.RouteReason,
  21747. o.OfficialActivity,
  21748. o.OfficialActivityReason,
  21749. o.TourGuide,
  21750. o.TourGuideReason,
  21751. o.[Translate],
  21752. o.TranslateReason,
  21753. o.Trip,
  21754. o.TripReason,
  21755. o.ESFileName,
  21756. o.SignatureDate,
  21757. o.Remark
  21758. FROM
  21759. Grp_Opinionaire o
  21760. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  21761. WHERE
  21762. o.IsDel = 0
  21763. AND o.DiId = {0}
  21764. ORDER BY
  21765. o.Id ASC", diId);
  21766. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  21767. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  21768. return Ok(JsonView(data));
  21769. }
  21770. /// <summary>
  21771. /// 团组接待意见调查 - 用户
  21772. /// 保存
  21773. /// </summary>
  21774. /// <param name="dto"></param>
  21775. /// <returns></returns>
  21776. [HttpPost]
  21777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21778. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  21779. {
  21780. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  21781. foreach (var item in dto)
  21782. {
  21783. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  21784. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  21785. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  21786. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  21787. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  21788. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  21789. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  21790. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  21791. }
  21792. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  21793. if (!Directory.Exists(filePathBase))
  21794. {
  21795. Directory.CreateDirectory(filePathBase);
  21796. }
  21797. #region 上传文件
  21798. var filePaths = new List<string>();
  21799. foreach (var item in dto)
  21800. {
  21801. var file = item.File;
  21802. // 将文件保存到指定位置
  21803. var filePath = Path.Combine(filePathBase, file.FileName);
  21804. using (var stream = new FileStream(filePath, FileMode.Create))
  21805. {
  21806. await file.CopyToAsync(stream);
  21807. }
  21808. //验证文件是否上传成功
  21809. if (!System.IO.File.Exists(filePath))
  21810. {
  21811. foreach (var filePathStr in filePaths)
  21812. {
  21813. System.IO.File.Delete(filePathStr);
  21814. }
  21815. return Ok(JsonView(false, "文件上传失败!"));
  21816. }
  21817. item.ESFileName = file.FileName;
  21818. }
  21819. #endregion
  21820. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  21821. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  21822. .UpdateColumns(x => new
  21823. {
  21824. x.Catering,
  21825. x.CateringReason,
  21826. x.Stay,
  21827. x.StayReason,
  21828. x.Route,
  21829. x.RouteReason,
  21830. x.OfficialActivity,
  21831. x.OfficialActivityReason,
  21832. x.TourGuide,
  21833. x.TourGuideReason,
  21834. x.Translate,
  21835. x.TranslateReason,
  21836. x.Trip,
  21837. x.TripReason,
  21838. x.ESFileName,
  21839. x.SignatureDate,
  21840. x.Remark
  21841. })
  21842. .WhereColumns(x => new { x.Id })
  21843. .ExecuteCommandAsync();
  21844. if (upd < 1)
  21845. {
  21846. foreach (var filePathStr in filePaths)
  21847. {
  21848. System.IO.File.Delete(filePathStr);
  21849. }
  21850. return Ok(JsonView(false));
  21851. }
  21852. return Ok(JsonView(true));
  21853. }
  21854. #endregion
  21855. #region 团组餐厅相关信息
  21856. /// <summary>
  21857. /// 团组相关餐厅信息
  21858. /// 基础数据(团组)
  21859. /// </summary>
  21860. /// <returns></returns>
  21861. [HttpGet]
  21862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21863. public async Task<IActionResult> RestaurantInit()
  21864. {
  21865. return Ok(await _restaurantRep.InitAsync());
  21866. }
  21867. /// <summary>
  21868. /// 团组相关餐厅信息
  21869. /// Item
  21870. /// </summary>
  21871. /// <param name="dto"></param>
  21872. /// <returns></returns>
  21873. [HttpPost]
  21874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21875. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  21876. {
  21877. int portType = dto.PortType,
  21878. groupId = dto.GroupId;
  21879. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21880. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21881. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  21882. }
  21883. /// <summary>
  21884. /// 团组相关餐厅信息
  21885. /// List
  21886. /// </summary>
  21887. /// <param name="dto"></param>
  21888. /// <returns></returns>
  21889. [HttpPost]
  21890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21891. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  21892. {
  21893. int portType = dto.PortType,
  21894. groupId = dto.GroupId;
  21895. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21896. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21897. var sql = string.Format(@" SELECT
  21898. ri.Id,
  21899. ri.GroupId,
  21900. ri.Date,
  21901. ri.StartTime,
  21902. ri.EndTime,
  21903. CASE WHEN ri.Type = 1 THEN '早餐'
  21904. WHEN ri.Type = 2 THEN '午餐'
  21905. WHEN ri.Type = 3 THEN '晚餐'
  21906. ELSE '其他'
  21907. END AS 'Type',
  21908. ri.Name,
  21909. ri.Address,
  21910. ri.Tel,
  21911. ri.Remark,
  21912. ri.CreateTime,
  21913. u.CnName AS CreateUserName
  21914. FROM
  21915. Grp_RestaurantInfo ri
  21916. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  21917. WHERE
  21918. ri.IsDel = 0
  21919. AND ri.GroupId = {0}
  21920. ORDER BY
  21921. ri.Date ASC
  21922. ", groupId);
  21923. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  21924. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  21925. return Ok(JsonView(infos));
  21926. }
  21927. /// <summary>
  21928. /// 团组相关餐厅信息
  21929. /// Info
  21930. /// </summary>
  21931. /// <param name="dto"></param>
  21932. /// <returns></returns>
  21933. [HttpPost]
  21934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21935. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  21936. {
  21937. int portType = dto.PortType,
  21938. id = dto.Id;
  21939. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  21940. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  21941. return Ok(await _restaurantRep.InfoAsync(portType, id));
  21942. }
  21943. /// <summary>
  21944. /// 团组相关餐厅信息
  21945. /// Op
  21946. /// </summary>
  21947. /// <param name="dto"></param>
  21948. /// <returns></returns>
  21949. [HttpPost]
  21950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21951. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  21952. {
  21953. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21954. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21955. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  21956. return Ok(await _restaurantRep.OpAsync(dto));
  21957. }
  21958. /// <summary>
  21959. /// 团组相关餐厅信息
  21960. /// Del
  21961. /// </summary>
  21962. /// <param name="dto"></param>
  21963. /// <returns></returns>
  21964. [HttpPost]
  21965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21966. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  21967. {
  21968. int userId = dto.DeleteUserId;
  21969. var id = dto.Id;
  21970. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21971. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  21972. return Ok(await _restaurantRep.DelAsync(dto));
  21973. }
  21974. #endregion
  21975. // /// <summary>
  21976. // ///
  21977. // /// </summary>
  21978. // /// <param name="_dto"></param>
  21979. // /// <returns></returns>
  21980. // [HttpPost]
  21981. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21982. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  21983. // {
  21984. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  21985. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  21986. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  21987. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  21988. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  21989. // dic_psg.Add("客人", 974);
  21990. // dic_psg.Add("司机", 975);
  21991. // dic_psg.Add("导游", 976);
  21992. // dic_psg.Add("公司内部人员", 977);
  21993. // dic_psg.Add("司机/导游/公司内部人员", 978);
  21994. // foreach (var item in list_visa)
  21995. // {
  21996. // Grp_VisaInfo temp = new Grp_VisaInfo();
  21997. // temp.Id = item.Id;
  21998. // temp.DIId = item.DIId;
  21999. // temp.VisaClient = item.VisaClient;
  22000. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  22001. // temp.VisaCurrency = item.VisaCurrency;
  22002. // temp.IsThird = item.IsThird;
  22003. // if (dic_psg.ContainsKey(item.PassengerType))
  22004. // {
  22005. // temp.PassengerType = dic_psg[item.PassengerType];
  22006. // }
  22007. // else {
  22008. // temp.PassengerType = -1;
  22009. // }
  22010. // temp.VisaNumber = item.VisaNumber;
  22011. // temp.VisaFreeNumber = item.VisaFreeNumber;
  22012. // temp.CreateUserId = item.Operators;
  22013. // DateTime dt_ct;
  22014. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  22015. // if (b_ct)
  22016. // {
  22017. // temp.CreateTime = dt_ct;
  22018. // }
  22019. // else
  22020. // {
  22021. // temp.CreateTime = DateTime.Now;
  22022. // }
  22023. // temp.DeleteTime = "";
  22024. // temp.DeleteUserId = 0;
  22025. // temp.Remark = item.Remark;
  22026. // if (string.IsNullOrEmpty(temp.Remark)) {
  22027. // temp.Remark = "";
  22028. // }
  22029. // temp.IsDel = item.IsDel;
  22030. // temp.VisaDescription = item.VisaAttachment;
  22031. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  22032. //([Id]
  22033. // ,[DIId]
  22034. // ,[VisaClient]
  22035. // ,[VisaPrice]
  22036. // ,[VisaCurrency]
  22037. // ,[IsThird]
  22038. // ,[PassengerType]
  22039. // ,[VisaNumber]
  22040. // ,[VisaFreeNumber]
  22041. // ,[CreateUserId]
  22042. // ,[CreateTime]
  22043. // ,[DeleteTime]
  22044. // ,[DeleteUserId]
  22045. // ,[Remark]
  22046. // ,[IsDel]
  22047. // ,[visaDescription])
  22048. // VALUES
  22049. // ({0},{1},'{2}',{3},{4}
  22050. //,{5},{6},{7},{8},{9}
  22051. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  22052. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  22053. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  22054. //);
  22055. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  22056. // }
  22057. // return Ok(JsonView(true, "操作成功!"));
  22058. // }
  22059. /// <summary>
  22060. /// 123132123
  22061. /// </summary>
  22062. /// <param name="_dto"></param>
  22063. /// <returns></returns>
  22064. [HttpPost]
  22065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22066. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22067. {
  22068. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22069. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22070. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22071. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22072. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22073. dicDetail.Add(789, 1034);
  22074. dicDetail.Add(790, 1035);
  22075. dicDetail.Add(791, 1036);
  22076. dicDetail.Add(792, 1037);
  22077. dicDetail.Add(793, 1038);
  22078. dicDetail.Add(794, 1039);
  22079. dicDetail.Add(795, 1040);
  22080. dicDetail.Add(796, 1041);
  22081. dicDetail.Add(797, 1042);
  22082. dicDetail.Add(798, 1043);
  22083. dicDetail.Add(801, 1044);
  22084. dicDetail.Add(802, 1045);
  22085. dicDetail.Add(803, 1046);
  22086. Dictionary<int, int> dic = new Dictionary<int, int>();
  22087. dic.Add(806, 1027);
  22088. dic.Add(807, 1028);
  22089. dic.Add(808, 1029);
  22090. dic.Add(809, 1030);
  22091. dic.Add(810, 1031);
  22092. dic.Add(811, 1032);
  22093. dic.Add(812, 1033);
  22094. foreach (var item in list_visa)
  22095. {
  22096. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22097. temp.Coefficient = item.coefficient;
  22098. DateTime dtCrt;
  22099. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22100. if (b1)
  22101. {
  22102. temp.CreateTime = dtCrt;
  22103. }
  22104. else
  22105. {
  22106. temp.CreateTime = DateTime.Now;
  22107. }
  22108. temp.CreateUserId = item.Operators;
  22109. temp.DeleteTime = "";
  22110. temp.DeleteUserId = 0;
  22111. temp.DiId = int.Parse(item.DIID);
  22112. temp.FilePath = item.FilePath;
  22113. temp.IsDel = item.IsDel;
  22114. temp.Price = item.Price;
  22115. temp.PriceCount = 1;
  22116. temp.PriceCurrency = item.Currency;
  22117. int detailId = 0;
  22118. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22119. {
  22120. detailId = dicDetail[item.PriceTypeDetail];
  22121. }
  22122. temp.PriceDetailType = detailId;
  22123. temp.PriceDt = DateTime.Now;
  22124. temp.PriceName = item.PriceName;
  22125. temp.PriceSum = item.Price;
  22126. int tid = 0;
  22127. if (dic.ContainsKey(item.PriceType))
  22128. {
  22129. tid = dic[item.PriceType];
  22130. }
  22131. temp.PriceType = tid;
  22132. temp.Remark = item.Remark;
  22133. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22134. }
  22135. return Ok(JsonView(true, "操作成功!"));
  22136. }
  22137. [HttpPost]
  22138. public IActionResult TimeTest()
  22139. {
  22140. var jw = JsonView(false, "error");
  22141. _sqlSugar.BeginTran();
  22142. try
  22143. {
  22144. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22145. .Select(x => new Crm_NewClientData
  22146. {
  22147. Id = x.Id,
  22148. Client = x.Client,
  22149. Contact = x.Contact,
  22150. Location = x.Location,
  22151. })
  22152. .ToList();
  22153. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22154. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22155. Stopwatch stopwatch = new Stopwatch();
  22156. // 开始计时
  22157. stopwatch.Start();
  22158. foreach (var item in clientList)
  22159. {
  22160. EncryptionProcessor.DecryptProperties(item);
  22161. }
  22162. stopwatch.Stop();
  22163. jw.Code = 200;
  22164. jw.Data = stopwatch.ElapsedMilliseconds;
  22165. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22166. }
  22167. catch (Exception ex)
  22168. {
  22169. jw.Code = 400;
  22170. jw.Msg = ex.Message;
  22171. }
  22172. return Ok(jw);
  22173. }
  22174. }
  22175. }