GroupsController.cs 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using NPOI.SS.UserModel;
  8. using NPOI.SS.Util;
  9. using NPOI.XSSF.UserModel;
  10. using OASystem.API.Middlewares;
  11. using OASystem.API.OAMethodLib;
  12. using OASystem.API.OAMethodLib.APNs;
  13. using OASystem.API.OAMethodLib.File;
  14. using OASystem.API.OAMethodLib.Hub.HubClients;
  15. using OASystem.API.OAMethodLib.Hub.Hubs;
  16. using OASystem.API.OAMethodLib.JuHeAPI;
  17. using OASystem.API.OAMethodLib.KiMiApi;
  18. using OASystem.API.OAMethodLib.Logging;
  19. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  20. using OASystem.Domain.AesEncryption;
  21. using OASystem.Domain.Attributes;
  22. using OASystem.Domain.Dtos.CRM;
  23. using OASystem.Domain.Dtos.FileDto;
  24. using OASystem.Domain.Dtos.Financial;
  25. using OASystem.Domain.Dtos.Groups;
  26. using OASystem.Domain.Entities.Customer;
  27. using OASystem.Domain.Entities.Financial;
  28. using OASystem.Domain.Entities.Groups;
  29. using OASystem.Domain.ViewModels.CRM;
  30. using OASystem.Domain.ViewModels.Financial;
  31. using OASystem.Domain.ViewModels.Groups;
  32. using OASystem.Domain.ViewModels.OCR;
  33. using OASystem.Infrastructure.Repositories.CRM;
  34. using OASystem.Infrastructure.Repositories.Financial;
  35. using OASystem.Infrastructure.Repositories.Groups;
  36. using Quartz.Util;
  37. using SqlSugar.Extensions;
  38. using System.Collections;
  39. using System.ComponentModel.DataAnnotations;
  40. using System.Data;
  41. using System.Diagnostics;
  42. using System.Globalization;
  43. using System.IO;
  44. using System.IO.Compression;
  45. using System.Text.Json;
  46. using System.Text.RegularExpressions;
  47. using System.Web;
  48. using static OASystem.API.OAMethodLib.JWTHelper;
  49. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  50. using Bookmark = Aspose.Words.Bookmark;
  51. using Cell = Aspose.Words.Tables.Cell;
  52. using Table = Aspose.Words.Tables.Table;
  53. namespace OASystem.API.Controllers
  54. {
  55. /// <summary>
  56. /// 团组相关
  57. /// </summary>
  58. //[Authorize]
  59. [Route("api/[controller]/[action]")]
  60. public class GroupsController : ControllerBase
  61. {
  62. private readonly ILogger<GroupsController> _logger;
  63. private readonly ITextFileLogger _eec_textLogger;
  64. private readonly GrpScheduleRepository _grpScheduleRep;
  65. private readonly IMapper _mapper;
  66. private readonly DelegationInfoRepository _groupRepository;
  67. private readonly TaskAssignmentRepository _taskAssignmentRep;
  68. private readonly AirTicketResRepository _airTicketResRep;
  69. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  70. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  71. private readonly DelegationEnDataRepository _delegationEnDataRep;
  72. private readonly DelegationVisaRepository _delegationVisaRep;
  73. private readonly VisaPriceRepository _visaPriceRep;
  74. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  75. private readonly HotelPriceRepository _hotelPriceRep;
  76. private readonly CustomersRepository _customersRep;
  77. private readonly MessageRepository _message;
  78. private readonly SqlSugarClient _sqlSugar;
  79. private readonly TourClientListRepository _tourClientListRep;
  80. private readonly TeamRateRepository _teamRateRep;
  81. #region 成本相关
  82. private readonly CheckBoxsRepository _checkBoxs;
  83. private readonly GroupCostRepository _GroupCostRepository;
  84. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  85. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  86. #endregion
  87. private readonly SetDataRepository _setDataRep;
  88. private string url;
  89. private string path;
  90. private readonly EnterExitCostRepository _enterExitCostRep;
  91. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  92. private readonly UsersRepository _usersRep;
  93. private readonly IJuHeApiService _juHeApi;
  94. private readonly InvertedListRepository _invertedListRep;
  95. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  96. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  97. private readonly ThreeCodeRepository _threeCodeRepository;
  98. private readonly HotelInquiryRepository _hotelInquiryRep;
  99. private readonly FeeAuditRepository _feeAuditRep;
  100. private readonly VisaCommissionRepository _visaCommissionRep;
  101. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  102. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  103. private readonly List<CurrencyInfo> _currencyInit;
  104. private readonly List<int> _portTypeData;
  105. private readonly TableOperationRecordRepository _tableorRep;
  106. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  107. private readonly RestaurantRepository _restaurantRep;
  108. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  109. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  110. /// <summary>
  111. /// 构造函数
  112. /// </summary>
  113. /// <param name="logger"></param>
  114. /// <param name="eec_textLogger"></param>
  115. /// <param name="mapper"></param>
  116. /// <param name="hubContext"></param>
  117. /// <param name="sqlSugar"></param>
  118. /// <param name="grpScheduleRep"></param>
  119. /// <param name="groupRepository"></param>
  120. /// <param name="taskAssignmentRep"></param>
  121. /// <param name="airTicketResRep"></param>
  122. /// <param name="decreasePaymentsRep"></param>
  123. /// <param name="InvitationOfficialActivitiesRep"></param>
  124. /// <param name="delegationEnDataRep"></param>
  125. /// <param name="enterExitCostRep"></param>
  126. /// <param name="delegationVisaRep"></param>
  127. /// <param name="message"></param>
  128. /// <param name="visaPriceRep"></param>
  129. /// <param name="carTouristGuideGroundRep"></param>
  130. /// <param name="checkBoxs"></param>
  131. /// <param name="GroupCostRepository"></param>
  132. /// <param name="CostTypeHotelNumberRepository"></param>
  133. /// <param name="GroupCostParameterRepository"></param>
  134. /// <param name="hotelPriceRep"></param>
  135. /// <param name="customersRep"></param>
  136. /// <param name="setDataRep"></param>
  137. /// <param name="tourClientListRep"></param>
  138. /// <param name="teamRateRep"></param>
  139. /// <param name="usersRep"></param>
  140. /// <param name="juHeApi"></param>
  141. /// <param name="invertedListRep"></param>
  142. /// <param name="visaFeeInfoRep"></param>
  143. /// <param name="ticketBlackCodeRep"></param>
  144. /// <param name="hotelInquiryRep"></param>
  145. /// <param name="threeCodeRepository"></param>
  146. /// <param name="feeAuditRep"></param>
  147. /// <param name="visaCommissionRep"></param>
  148. /// <param name="ffrRep"></param>
  149. /// <param name="opinionaireRep"></param>
  150. /// <param name="tableorRep"></param>
  151. /// <param name="enterExitCostDraftRep"></param>
  152. /// <param name="restaurantRep"></param>
  153. /// <param name="enterExitCostQuoteRep"></param>
  154. /// <param name="grpOrderPreInfoRep"></param>
  155. public GroupsController(
  156. ILogger<GroupsController> logger,
  157. ITextFileLogger eec_textLogger,
  158. IMapper mapper,
  159. IHubContext<ChatHub, IChatClient> hubContext,
  160. SqlSugarClient sqlSugar,
  161. GrpScheduleRepository grpScheduleRep,
  162. DelegationInfoRepository groupRepository,
  163. TaskAssignmentRepository taskAssignmentRep,
  164. AirTicketResRepository airTicketResRep,
  165. DecreasePaymentsRepository decreasePaymentsRep,
  166. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  167. DelegationEnDataRepository delegationEnDataRep,
  168. EnterExitCostRepository enterExitCostRep,
  169. DelegationVisaRepository delegationVisaRep,
  170. MessageRepository message,
  171. VisaPriceRepository visaPriceRep,
  172. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  173. CheckBoxsRepository checkBoxs,
  174. GroupCostRepository GroupCostRepository,
  175. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  176. GroupCostParameterRepository GroupCostParameterRepository,
  177. HotelPriceRepository hotelPriceRep,
  178. CustomersRepository customersRep,
  179. SetDataRepository setDataRep,
  180. TourClientListRepository tourClientListRep,
  181. TeamRateRepository teamRateRep,
  182. UsersRepository usersRep,
  183. IJuHeApiService juHeApi,
  184. InvertedListRepository invertedListRep,
  185. VisaFeeInfoRepository visaFeeInfoRep,
  186. TicketBlackCodeRepository ticketBlackCodeRep,
  187. HotelInquiryRepository hotelInquiryRep,
  188. ThreeCodeRepository threeCodeRepository,
  189. FeeAuditRepository feeAuditRep,
  190. VisaCommissionRepository visaCommissionRep,
  191. ForeignReceivablesRepository ffrRep,
  192. OpinionaireRepository opinionaireRep,
  193. TableOperationRecordRepository tableorRep,
  194. EnterExitCostDraftRepository enterExitCostDraftRep,
  195. RestaurantRepository restaurantRep,
  196. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  197. GroupOrderPreInfoRepository grpOrderPreInfoRep
  198. )
  199. {
  200. _logger = logger;
  201. _eec_textLogger = eec_textLogger;
  202. _mapper = mapper;
  203. _grpScheduleRep = grpScheduleRep;
  204. _groupRepository = groupRepository;
  205. _taskAssignmentRep = taskAssignmentRep;
  206. _airTicketResRep = airTicketResRep;
  207. _sqlSugar = sqlSugar;
  208. url = AppSettingsHelper.Get("ExcelBaseUrl");
  209. path = AppSettingsHelper.Get("ExcelBasePath");
  210. if (!System.IO.Directory.Exists(path))
  211. {
  212. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  213. }
  214. _decreasePaymentsRep = decreasePaymentsRep;
  215. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  216. _delegationEnDataRep = delegationEnDataRep;
  217. _enterExitCostRep = enterExitCostRep;
  218. _delegationVisaRep = delegationVisaRep;
  219. _message = message;
  220. _visaPriceRep = visaPriceRep;
  221. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  222. _checkBoxs = checkBoxs;
  223. _GroupCostRepository = GroupCostRepository;
  224. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  225. _GroupCostParameterRepository = GroupCostParameterRepository;
  226. _hotelPriceRep = hotelPriceRep;
  227. _customersRep = customersRep;
  228. _setDataRep = setDataRep;
  229. _tourClientListRep = tourClientListRep;
  230. _teamRateRep = teamRateRep;
  231. _hubContext = hubContext;
  232. _usersRep = usersRep;
  233. _juHeApi = juHeApi;
  234. _invertedListRep = invertedListRep;
  235. _visaFeeInfoRep = visaFeeInfoRep;
  236. _ticketBlackCodeRep = ticketBlackCodeRep;
  237. _hotelInquiryRep = hotelInquiryRep;
  238. _threeCodeRepository = threeCodeRepository;
  239. _feeAuditRep = feeAuditRep;
  240. _visaCommissionRep = visaCommissionRep;
  241. _ffrRep = ffrRep;
  242. _opinionaireRep = opinionaireRep;
  243. _currencyInit = new List<CurrencyInfo>()
  244. {
  245. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  246. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  247. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  248. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  249. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  250. };
  251. _portTypeData = new List<int>() { 2, 3 };
  252. _tableorRep = tableorRep;
  253. _enterExitCostDraftRep = enterExitCostDraftRep;
  254. _restaurantRep = restaurantRep;
  255. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  256. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  257. }
  258. #region 流程管控
  259. /// <summary>
  260. /// 获取团组流程管控信息
  261. /// </summary>
  262. /// <param name="_jsonDto">查询参数</param>
  263. /// <returns></returns>
  264. [HttpPost]
  265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  266. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  267. {
  268. if (string.IsNullOrEmpty(_jsonDto.Paras))
  269. {
  270. return Ok(JsonView(false, "参数为空"));
  271. }
  272. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  273. if (_ScheduleDto != null)
  274. {
  275. if (_ScheduleDto.SearchType == 2)//获取列表
  276. {
  277. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  278. return Ok(JsonView(_grpScheduleViewList));
  279. }
  280. else//获取对象
  281. {
  282. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  283. if (_grpScheduleView != null)
  284. {
  285. return Ok(JsonView(_grpScheduleView));
  286. }
  287. }
  288. }
  289. else
  290. {
  291. return Ok(JsonView(false, "参数反序列化失败"));
  292. }
  293. return Ok(JsonView(false, "暂无数据!"));
  294. }
  295. /// <summary>
  296. /// 修改团组流程管控详细表数据
  297. /// </summary>
  298. /// <param name="dto"></param>
  299. /// <returns></returns>
  300. [HttpPost]
  301. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  302. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  303. {
  304. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  305. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  306. .SetColumns(it => it.Duty == _detail.Duty)
  307. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  308. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  309. .SetColumns(it => it.JobContent == _detail.JobContent)
  310. .SetColumns(it => it.Remark == _detail.Remark)
  311. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  312. .Where(s => s.Id == dto.Id)
  313. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  314. .ExecuteCommandAsync();
  315. if (result > 0)
  316. {
  317. return Ok(JsonView(true, "保存成功!"));
  318. }
  319. return Ok(JsonView(false, "保存失败!"));
  320. }
  321. /// <summary>
  322. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  323. /// </summary>
  324. /// <param name="dto"></param>
  325. /// <returns></returns>
  326. [HttpPost]
  327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  328. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  329. {
  330. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  331. _detail.IsDel = 1;
  332. _detail.DeleteUserId = dto.Duty;
  333. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  334. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  335. .SetColumns(it => it.IsDel == _detail.IsDel)
  336. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  337. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  338. .Where(it => it.Id == dto.Id)
  339. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  340. //.WhereColumns(s => s.Id == dto.Id)
  341. .ExecuteCommandAsync();
  342. if (result > 0)
  343. {
  344. return Ok(JsonView(true, "删除成功!"));
  345. }
  346. return Ok(JsonView(false, "删除失败!"));
  347. }
  348. /// <summary>
  349. /// 增加团组流程管控详细表数据
  350. /// </summary>
  351. /// <param name="dto"></param>
  352. /// <returns></returns>
  353. [HttpPost]
  354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  355. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  356. {
  357. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  358. if (DateTime.Now < _detail.ExpectBeginDt)
  359. {
  360. _detail.StepStatus = 0;
  361. }
  362. else
  363. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  364. _detail.StepStatus = 1;
  365. }
  366. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  367. if (result > 0)
  368. {
  369. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  370. return Ok(JsonView(true, "添加成功!", _result));
  371. }
  372. return Ok(JsonView(false, "添加失败!"));
  373. }
  374. #endregion
  375. #region 团组前期信息
  376. /// <summary>
  377. /// 团组前期信息H5-URL(员工对应地址)
  378. /// </summary>
  379. /// <param name="name">用户名称</param>
  380. /// <returns></returns>
  381. [HttpGet]
  382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  383. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  384. {
  385. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  386. .Where(x => x.IsDel == 0)
  387. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  388. .OrderBy(x => x.Id)
  389. .Select(x => new
  390. {
  391. name = x.CnName,
  392. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  393. })
  394. .ToListAsync();
  395. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  396. }
  397. /// <summary>
  398. /// 团组前期信息 List
  399. /// </summary>
  400. /// <returns></returns>
  401. [HttpPost]
  402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  403. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  404. {
  405. var search = dto.Search;
  406. int[] nameTempIds = new int[] { 1, 12, 28 },
  407. countryTempIds = new int[] { 2, 13, 29 },
  408. daysTempIds = new int[] { 4, 15, 31 },
  409. ppNumTempIds = new int[] { 6 };
  410. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  411. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  412. .Where((opi, u) => opi.IsDel == 0)
  413. .OrderByDescending((opi, u) => opi.CreateTime)
  414. .Select((opi, u) => new GroupOrderPreInfoListView()
  415. {
  416. Id = opi.Id,
  417. Name = opi.Name,
  418. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  419. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  420. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  421. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  422. Operator = u.CnName,
  423. OperationTime = opi.CreateTime
  424. })
  425. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  426. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  427. .ToListAsync();
  428. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  429. int total = list.Count;
  430. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  431. var listPageData1 = listPageData
  432. .Skip((dto.PageIndex - 1) * dto.PageSize)
  433. .Take(dto.PageSize)
  434. .ToList();
  435. var infoIds = listPageData1.Select(x => x.Id).ToList();
  436. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  437. .Where(x => x.IsDel == 0 && x.STid == 109)
  438. .ToArrayAsync();
  439. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  440. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  441. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  442. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  443. .ToListAsync();
  444. foreach (var item in listPageData1)
  445. {
  446. var typeDatas1 = typeDatas.Select(x => new
  447. {
  448. x.Id,
  449. x.Name,
  450. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  451. }).ToArray();
  452. item.VersionDetails = typeDatas1;
  453. }
  454. return Ok(JsonView(listPageData1, listPageData1.Count));
  455. }
  456. /// <summary>
  457. /// 团组前期信息 Init
  458. /// </summary>
  459. /// <returns></returns>
  460. [HttpGet("{userId}")]
  461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  462. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  463. {
  464. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  465. }
  466. /// <summary>
  467. /// 国家数据源
  468. /// </summary>
  469. /// <param name="pageIndex">当前页码</param>
  470. /// <param name="pageSize">每页条数</param>
  471. /// <param name="search">查询条件</param>
  472. /// <returns></returns>
  473. [HttpGet]
  474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  475. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  476. {
  477. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  478. if (pageIndex == 0 && pageSize == 0)
  479. {
  480. //所有数据
  481. return Ok(JsonView(countrys, countrys.Count));
  482. }
  483. //分页
  484. int skip = (pageIndex - 1) * pageSize;
  485. int take = pageSize;
  486. if (!string.IsNullOrEmpty(search))
  487. {
  488. IEnumerable<char> charSequence = search.Select(c => c);
  489. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  490. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  491. return Ok(JsonView(pageData, pageResult1.Count));
  492. }
  493. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  494. return Ok(JsonView(pageResult2, countrys.Count));
  495. }
  496. /// <summary>
  497. /// 城市数据源
  498. /// </summary>
  499. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  500. /// <param name="pageIndex">当前页码</param>
  501. /// <param name="pageSize">每页条数</param>
  502. /// <param name="search">查询条件</param>
  503. /// <returns></returns>
  504. [HttpGet("{countryLabel}")]
  505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  506. public async Task<IActionResult> CityByCountry(
  507. string countryLabel,
  508. [FromQuery] int pageIndex,
  509. [FromQuery] int pageSize,
  510. [FromQuery] string search)
  511. {
  512. countryLabel = HttpUtility.UrlDecode(countryLabel);
  513. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  514. var citys = Array.Empty<string?>();
  515. if (countryList.Any())
  516. {
  517. var cityDatas = await _sqlSugar
  518. .Queryable<Grp_NationalTravelFee>()
  519. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  520. .ToArrayAsync();
  521. foreach (var item in cityDatas)
  522. {
  523. if (item.City.Contains("城市"))
  524. {
  525. item.City = item.Country + "-所有城市";
  526. }
  527. }
  528. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  529. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  530. }
  531. if (pageIndex == 0 && pageSize == 0)
  532. {
  533. //所有数据
  534. return Ok(JsonView(citys, citys?.Length ?? 0));
  535. }
  536. //分页
  537. int skip = (pageIndex - 1) * pageSize;
  538. int take = pageSize;
  539. if (!string.IsNullOrEmpty(search))
  540. {
  541. IEnumerable<char> charSequence = search.Select(c => c);
  542. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  543. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  544. return Ok(JsonView(pageData, pageResult1.Count));
  545. }
  546. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  547. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  548. }
  549. /// <summary>
  550. /// 团组前期信息 Info
  551. /// </summary>
  552. /// <param name="dto">Id</param>
  553. /// <returns></returns>
  554. [HttpGet("{Id}/{TempId}")]
  555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  556. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  557. {
  558. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  559. }
  560. /// <summary>
  561. /// 团组前期信息 移动端 Info
  562. /// </summary>
  563. /// <param name="dto">Id</param>
  564. /// <returns></returns>
  565. [HttpGet("{Id}/{TempId}")]
  566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  567. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  568. {
  569. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  570. }
  571. /// <summary>
  572. /// 团组前期信息 Save
  573. /// </summary>
  574. /// <param name="dto">Id</param>
  575. /// <returns></returns>
  576. [HttpPost]
  577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  578. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  579. {
  580. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  581. }
  582. /// <summary>
  583. /// 团组前期信息 Del
  584. /// </summary>
  585. /// <param name="dto">Id</param>
  586. /// <returns></returns>
  587. [HttpPost]
  588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  589. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  590. {
  591. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  592. }
  593. /// <summary>
  594. /// 团组前期信息 文件下载
  595. /// </summary>
  596. /// <param name="dto">Id</param>
  597. /// <returns></returns>
  598. [HttpGet("{Id}/{TempId}")]
  599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  600. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  601. {
  602. int id = dto.Id, tempId = dto.TempId;
  603. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  604. var data = view.Data as GrpOrderPreInfoView;
  605. #region Excel
  606. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  607. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  608. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  609. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  610. var fileNamePrefix = string.Empty;
  611. if (tempId == 1405)
  612. {
  613. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  614. fileNamePrefix = $"{data.Name}_无商邀版";
  615. }
  616. else if (tempId == 1406)
  617. {
  618. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  619. fileNamePrefix = $"{data.Name}_有商邀版";
  620. }
  621. else
  622. {
  623. //tempId == 1404 默认下载
  624. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  625. fileNamePrefix = $"{data.Name}_单接送机";
  626. }
  627. foreach (var item in data.Items)
  628. {
  629. var obj = item.NewValue;
  630. if (obj == null) item.OriginVal = "";
  631. else if (obj.Equals("有") || obj.Equals("无"))
  632. {
  633. item.OriginVal = obj.ToString();
  634. }
  635. else if (obj is object[] objArray)
  636. {
  637. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  638. item.OriginVal = string.Join("、", stringArray);
  639. }
  640. else if (obj is string[] stringArray)
  641. {
  642. item.OriginVal = string.Join("、", stringArray);
  643. }
  644. else if (obj.Equals("-"))
  645. {
  646. item.OriginVal = "";
  647. }
  648. }
  649. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  650. fileName = CommonFun.ValidFileName(fileName);
  651. //载入模板
  652. var designer = new WorkbookDesigner
  653. {
  654. Workbook = new Workbook(tempPath)
  655. };
  656. if (tempId == 1406)
  657. {
  658. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  659. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  660. for (int i = 1; i <= view2.Length; i++)
  661. {
  662. view2[i - 1].Index = i;
  663. }
  664. designer.SetDataSource("View1", view1);
  665. designer.SetDataSource("View2", view2);
  666. }
  667. else
  668. {
  669. designer.SetDataSource("View", data.Items);
  670. }
  671. designer.Process();
  672. if (!Directory.Exists(savePath))
  673. {
  674. Directory.CreateDirectory(savePath);
  675. }
  676. string serverPath = $"{savePath}{fileName}";
  677. designer.Workbook.Save(serverPath);
  678. string rst = $"{servicePath}{ftpPath}{fileName}";
  679. #endregion
  680. return Ok(JsonView(new { url = rst }));
  681. }
  682. #endregion
  683. #region 团组基本信息
  684. /// <summary>
  685. /// 接团信息列表
  686. /// </summary>
  687. /// <param name="dto">团组列表请求dto</param>
  688. /// <returns></returns>
  689. [HttpPost]
  690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  691. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  692. {
  693. var groupData = await _groupRepository.GetGroupList(dto);
  694. if (groupData.Code != 0)
  695. {
  696. return Ok(JsonView(false, groupData.Msg));
  697. }
  698. return Ok(JsonView(groupData.Data));
  699. }
  700. /// <summary>
  701. /// 分页查询团组列表
  702. /// </summary>
  703. /// <param name="dto"></param>
  704. /// <returns></returns>
  705. [HttpPost]
  706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  707. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  708. {
  709. var watch = new Stopwatch();
  710. watch.Start();
  711. RefAsync<int> total = 0;
  712. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  713. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  714. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  715. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  716. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  717. .Distinct()
  718. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  719. watch.Stop();
  720. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  721. }
  722. /// <summary>
  723. /// 接团信息列表 Page Init
  724. /// </summary>
  725. /// <returns></returns>
  726. [HttpPost]
  727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  728. public async Task<IActionResult> PostGroupPageListInit()
  729. {
  730. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  731. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  732. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  733. var _view = new
  734. {
  735. depData = depDatas,
  736. rankData = rankDatas
  737. };
  738. return Ok(JsonView(true, "查询成功!", _view));
  739. }
  740. /// <summary>
  741. /// 接团信息列表 Page
  742. /// </summary>
  743. /// <param name="dto">团组列表请求dto</param>
  744. /// <returns></returns>
  745. [HttpPost]
  746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  747. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  748. {
  749. #region 参数验证
  750. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  751. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  752. #region 页面操作权限验证
  753. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  754. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  755. #endregion
  756. #endregion
  757. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  758. {
  759. string sqlWhere = string.Empty;
  760. if (dto.IsSure == 0) //未完成
  761. {
  762. sqlWhere += string.Format(@" And IsSure = 0");
  763. }
  764. else if (dto.IsSure == 1) //已完成
  765. {
  766. sqlWhere += string.Format(@" And IsSure = 1");
  767. }
  768. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  769. {
  770. string tj = dto.SearchCriteria;
  771. 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}%')",
  772. tj, tj, tj, tj, tj);
  773. }
  774. if (int.TryParse(dto.Rank, out int rankId))
  775. {
  776. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  777. }
  778. string sqlWhere1 = string.Empty;
  779. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  780. {
  781. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  782. }
  783. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  784. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  785. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  786. JietuanOperator,IsSure,CreateTime,IsBid
  787. From (
  788. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  789. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  790. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  791. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  792. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  793. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  794. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  795. From Grp_DelegationInfo gdi
  796. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  797. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  798. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  799. Where gdi.IsDel = 0 {0}
  800. ) temp {1}", sqlWhere, sqlWhere1);
  801. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  802. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  803. //处理 团组模块实际操作人
  804. _DelegationList.ForEach(async x =>
  805. {
  806. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  807. var operatorNames = new StringBuilder();
  808. //operatorNames.AppendLine("各模块实际操作人:");
  809. if (operators.Any())
  810. {
  811. operators.ForEach(y =>
  812. {
  813. string label = string.Empty;
  814. if (y.OperationUsers.Any())
  815. {
  816. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  817. label = string.Join('、', users);
  818. }
  819. else label = "暂未指定";
  820. operatorNames.AppendLine($"{y.CTableName}:{label}");
  821. operatorNames.AppendLine();
  822. });
  823. }
  824. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  825. });
  826. var _view = new
  827. {
  828. PageFuncAuth = pageFunAuthView,
  829. Data = _DelegationList
  830. };
  831. return Ok(JsonView(true, "查询成功!", _view, total));
  832. }
  833. else
  834. {
  835. return Ok(JsonView(false, "查询失败"));
  836. }
  837. }
  838. /// <summary>
  839. /// 团组列表
  840. /// </summary>
  841. /// <returns></returns>
  842. [HttpPost]
  843. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  844. {
  845. #region 参数验证
  846. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  847. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  848. #region 页面操作权限验证
  849. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  850. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  851. #endregion
  852. #endregion
  853. if (dto.PortType != 1 && dto.PortType != 2)
  854. {
  855. return Ok(JsonView(false, "查询失败!"));
  856. }
  857. string orderbyStr = "order by gdi.CreateTime Desc";
  858. string sqlWhere = string.Empty;
  859. if (dto.IsSure == 0) //未完成
  860. {
  861. sqlWhere += string.Format(@" And IsSure = 0");
  862. }
  863. else if (dto.IsSure == 1) //已完成
  864. {
  865. sqlWhere += string.Format(@" And IsSure = 1");
  866. }
  867. //团组类型
  868. if (dto.TeamDid > 0)
  869. {
  870. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  871. }
  872. //团组名称
  873. if (!string.IsNullOrEmpty(dto.TeamName))
  874. {
  875. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  876. }
  877. //客户名称
  878. if (!string.IsNullOrEmpty(dto.ClientName))
  879. {
  880. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  881. }
  882. //客户单位
  883. if (!string.IsNullOrEmpty(dto.ClientUnit))
  884. {
  885. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  886. }
  887. //出访时间
  888. if (!string.IsNullOrEmpty(dto.visitDataTime))
  889. {
  890. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  891. orderbyStr = "order by gdi.VisitDate";
  892. }
  893. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  894. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  895. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  896. JietuanOperator,IsSure,CreateTime
  897. From (
  898. Select row_number() over({0}) as Row_Number,
  899. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  900. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  901. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  902. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  903. From Grp_DelegationInfo gdi
  904. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  905. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  906. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  907. Where gdi.IsDel = 0 {1}
  908. ) temp ", orderbyStr, sqlWhere);
  909. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  910. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  911. #region 处理所属部门
  912. /*
  913. * 1.sq 和 gyy 等显示 市场部
  914. * 2.王鸽和主管及张总还有管理员号统一国交部
  915. * 2-1. 4 管理员 ,21 张海麟
  916. */
  917. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  918. var userIds1 = new List<int>() { 4, 21 };
  919. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  920. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  921. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  922. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  923. .ToList();
  924. foreach (var item in _DelegationList)
  925. {
  926. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  927. }
  928. #endregion
  929. var _view = new
  930. {
  931. PageFuncAuth = pageFunAuthView,
  932. Data = _DelegationList
  933. };
  934. return Ok(JsonView(true, "查询成功!", _view, total));
  935. }
  936. /// <summary>
  937. /// 接团信息详情
  938. /// </summary>
  939. /// <param name="dto">团组info请求dto</param>
  940. /// <returns></returns>
  941. [HttpPost]
  942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  943. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  944. {
  945. var groupData = await _groupRepository.GetGroupInfo(dto);
  946. if (groupData.Code != 0)
  947. {
  948. return Ok(JsonView(false, groupData.Msg));
  949. }
  950. return Ok(JsonView(groupData.Data));
  951. }
  952. /// <summary>
  953. /// 接团信息 编辑添加
  954. /// 基础信息数据源
  955. /// </summary>
  956. /// <param name="dto"></param>
  957. /// <returns></returns>
  958. [HttpPost]
  959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  960. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  961. {
  962. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  963. if (groupData.Code != 0)
  964. {
  965. return Ok(JsonView(false, groupData.Msg));
  966. }
  967. return Ok(JsonView(groupData.Data));
  968. }
  969. /// <summary>
  970. /// 成本修改团组信息
  971. /// </summary>
  972. /// <param name="dto"></param>
  973. /// <returns></returns>
  974. [HttpPost]
  975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  976. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  977. {
  978. var jw = JsonView(false, "操作失败");
  979. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  980. if (di == null)
  981. {
  982. jw.Msg = "参数有误!";
  983. return Ok(jw);
  984. }
  985. #region 添加出访起止时间
  986. var startTime = new DateTime();
  987. var endTime = new DateTime();
  988. if (DateTime.TryParse(dto.VisitDate, out startTime))
  989. {
  990. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  991. }
  992. else
  993. {
  994. jw.Msg = "参数有误!";
  995. return Ok(jw);
  996. }
  997. #endregion
  998. di.VisitDate = startTime;
  999. di.VisitPNumber = dto.VisitPNumber;
  1000. di.VisitDays = dto.VisitDays;
  1001. di.VisitStartDate = startTime;
  1002. di.VisitEndDate = endTime;
  1003. var count = _sqlSugar.Updateable(di)
  1004. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1005. .ExecuteCommand();
  1006. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1007. }
  1008. /// <summary>
  1009. /// 接团信息 编辑添加
  1010. /// 省份-城市 基础信息数据源
  1011. /// </summary>
  1012. /// <param name="dto"></param>
  1013. /// <returns></returns>
  1014. [HttpPost]
  1015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1016. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1017. {
  1018. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1019. string search = dto.Search;
  1020. var data = await _groupRepository.CityBasicSource();
  1021. int total = data.Length;
  1022. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1023. .Skip((pageIndex - 1) * pageSize)
  1024. .Take(pageSize)
  1025. .ToArray();
  1026. return Ok(JsonView(data, total));
  1027. }
  1028. /// <summary>
  1029. /// 接团信息 操作(增改)
  1030. /// </summary>
  1031. /// <param name="dto"></param>
  1032. /// <returns></returns>
  1033. [HttpPost]
  1034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1035. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1036. {
  1037. // 创建 Stopwatch 实例
  1038. Stopwatch stopwatch = Stopwatch.StartNew();
  1039. decimal ffrPrice = 0.00M;
  1040. DateTime? visitDt = null;
  1041. if (dto.Status == 2)
  1042. {
  1043. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1044. if (groupInfo != null)
  1045. {
  1046. ffrPrice = groupInfo.PaymentMoney;
  1047. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1048. }
  1049. }
  1050. var groupData = await _groupRepository.GroupOperation(dto);
  1051. if (groupData.Code != 0)
  1052. {
  1053. return Ok(JsonView(false, groupData.Msg));
  1054. }
  1055. int diId = 0;
  1056. try
  1057. {
  1058. //添加时 默认加入团组汇率
  1059. if (dto.Status == 1) //添加
  1060. {
  1061. diId = groupData.Data;
  1062. //添加默认币种
  1063. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1064. //默认分配权限
  1065. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1066. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1067. var _managerIds = new List<int>() { 22, 32, 21 };
  1068. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1069. if (userIds.Count > 0)
  1070. {
  1071. userIds.Add(208);
  1072. //创建团组管控
  1073. GroupStepForDelegation.CreateWorkStep(diId);
  1074. //发送消息
  1075. string groupName = dto.TeamName;
  1076. string createGroupUser = string.Empty;
  1077. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1078. if (userInfo != null) createGroupUser = userInfo.CnName;
  1079. string title = $"系统通知";
  1080. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1081. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1082. }
  1083. //默认创建倒推表
  1084. await _invertedListRep._Create(dto.UserId, diId);
  1085. }
  1086. else if (dto.Status == 2)
  1087. {
  1088. diId = dto.Id;
  1089. }
  1090. #region 签证人员团组时间通知
  1091. #region 计算出访起止时间
  1092. var startTime = new DateTime();
  1093. var endTime = new DateTime();
  1094. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1095. {
  1096. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1097. }
  1098. #endregion
  1099. #endregion
  1100. #region 团组操作默认添加/修改收款账单
  1101. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1102. {
  1103. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1104. .Where(x => x.IsDel == 0 &&
  1105. x.Diid == diId &&
  1106. x.Remark.Equals("预付款")
  1107. )
  1108. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1109. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1110. .FirstAsync();
  1111. ffrInfo = new Fin_ForeignReceivables()
  1112. {
  1113. Diid = diId,
  1114. PriceName = dto.ClientUnit,
  1115. Price = dto.PaymentMoney,
  1116. Count = 1,
  1117. Unit = $"元",
  1118. ItemSumPrice = dto.PaymentMoney,
  1119. Rate = 1.0000M,
  1120. Currency = 836,
  1121. AddingWay = 0,
  1122. CreateUserId = dto.UserId,
  1123. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1124. Remark = $"预付款"
  1125. };
  1126. if (ffrInfo == null) //Add
  1127. {
  1128. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1129. }
  1130. else //修改
  1131. {
  1132. await _sqlSugar.Updateable(ffrInfo)
  1133. .UpdateColumns(x => new
  1134. {
  1135. x.PriceName,
  1136. x.Price,
  1137. x.ItemSumPrice,
  1138. x.CreateTime,
  1139. x.CreateUserId
  1140. })
  1141. .WhereColumns(x => x.Id)
  1142. .ExecuteCommandAsync();
  1143. }
  1144. }
  1145. #endregion
  1146. if (diId > 0)
  1147. {
  1148. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1149. }
  1150. // 停止计时
  1151. stopwatch.Stop();
  1152. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1153. }
  1154. catch (Exception ex)
  1155. {
  1156. // 停止计时
  1157. stopwatch.Stop();
  1158. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1159. Logs(ex.Message);
  1160. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1161. }
  1162. // 停止计时
  1163. stopwatch.Stop();
  1164. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1165. }
  1166. /// <summary>
  1167. /// 接团流程操作(增改)
  1168. /// 安卓端使用 建团时添加客户名单
  1169. /// </summary>
  1170. /// <param name="dto"></param>
  1171. /// <returns></returns>
  1172. [HttpPost]
  1173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1174. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1175. {
  1176. #region 参数验证
  1177. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1178. #region 页面操作权限验证
  1179. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1180. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1181. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1182. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1183. #endregion
  1184. #endregion
  1185. try
  1186. {
  1187. //_sqlSugar.BeginTran();
  1188. decimal ffrPrice = 0.00M;
  1189. DateTime? visitDt = null;
  1190. if (dto.Status == 2)
  1191. {
  1192. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1193. if (groupInfo != null)
  1194. {
  1195. ffrPrice = groupInfo.PaymentMoney;
  1196. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1197. }
  1198. }
  1199. var _dto = new GroupOperationDto();
  1200. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1201. var groupData = await _groupRepository.GroupOperation(_dto);
  1202. if (groupData.Code != 0)
  1203. {
  1204. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1205. }
  1206. int diId = 0;
  1207. //添加时 默认加入团组汇率
  1208. if (dto.Status == 1) //添加
  1209. {
  1210. diId = groupData.Data;
  1211. //添加默认币种
  1212. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1213. //默认分配权限
  1214. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1215. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1216. var _managerIds = new List<int>() { 21, 22, 32 };
  1217. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1218. if (userIds.Count > 0)
  1219. {
  1220. userIds.Add(208);
  1221. //创建团组管控
  1222. GroupStepForDelegation.CreateWorkStep(diId);
  1223. //发送消息
  1224. string groupName = dto.TeamName;
  1225. string createGroupUser = string.Empty;
  1226. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1227. if (userInfo != null) createGroupUser = userInfo.CnName;
  1228. string title = $"系统通知";
  1229. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1230. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1231. }
  1232. #region 应用推送
  1233. try
  1234. {
  1235. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1236. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1237. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1238. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1239. {
  1240. var userList = new List<string>() { users.QiyeChatUserId };
  1241. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1242. }
  1243. }
  1244. catch (Exception ex)
  1245. {
  1246. }
  1247. #endregion
  1248. //默认创建倒推表
  1249. await _invertedListRep._Create(dto.UserId, diId);
  1250. }
  1251. if (dto.Status == 2)
  1252. {
  1253. diId = dto.Id;
  1254. if (diId == 0)
  1255. {
  1256. //_sqlSugar.RollbackTran();
  1257. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1258. }
  1259. }
  1260. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1261. if (viewData.Code != 0)
  1262. {
  1263. //_sqlSugar.RollbackTran();
  1264. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1265. }
  1266. #region 团组操作默认添加/修改收款账单
  1267. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1268. {
  1269. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1270. .Where(x => x.IsDel == 0 &&
  1271. x.Diid == diId &&
  1272. x.Remark.Equals("预付款")
  1273. )
  1274. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1275. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1276. .FirstAsync();
  1277. ffrInfo = new Fin_ForeignReceivables()
  1278. {
  1279. Diid = diId,
  1280. PriceName = dto.ClientUnit,
  1281. Price = dto.PaymentMoney,
  1282. Count = 1,
  1283. Unit = $"元",
  1284. ItemSumPrice = dto.PaymentMoney,
  1285. Rate = 1.0000M,
  1286. Currency = 836,
  1287. AddingWay = 0,
  1288. CreateUserId = dto.UserId,
  1289. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1290. Remark = $"预付款"
  1291. };
  1292. if (ffrInfo == null) //Add
  1293. {
  1294. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1295. }
  1296. else //修改
  1297. {
  1298. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1299. .UpdateColumns(x => new
  1300. {
  1301. x.PriceName,
  1302. x.Price,
  1303. x.ItemSumPrice,
  1304. x.CreateTime,
  1305. x.CreateUserId
  1306. })
  1307. .WhereColumns(x => x.Id)
  1308. .ExecuteCommandAsync();
  1309. }
  1310. }
  1311. #endregion
  1312. #region 签证人员团组时间通知
  1313. #region 计算出访起止时间
  1314. var startTime = new DateTime();
  1315. var endTime = new DateTime();
  1316. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1317. {
  1318. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1319. }
  1320. #endregion
  1321. if (diId > 0)
  1322. {
  1323. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1324. }
  1325. #endregion
  1326. //_sqlSugar.CommitTran();
  1327. return Ok(JsonView(true, "添加成功"));
  1328. }
  1329. catch (Exception ex)
  1330. {
  1331. _sqlSugar.RollbackTran();
  1332. return Ok(JsonView(false, ex.Message));
  1333. }
  1334. }
  1335. /// <summary>
  1336. /// 接团流程操作(增改)
  1337. /// 安卓端使用 建团时添加客户名单
  1338. /// </summary>
  1339. /// <param name="dto"></param>
  1340. /// <returns></returns>
  1341. [HttpPost]
  1342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1343. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1344. {
  1345. #region 参数验证
  1346. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1347. #region 页面操作权限验证
  1348. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1349. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1350. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1351. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1352. #endregion
  1353. #endregion
  1354. _sqlSugar.BeginTran();
  1355. decimal ffrPrice = 0.00M;
  1356. DateTime? visitDt = null;
  1357. if (dto.Status == 2)
  1358. {
  1359. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1360. if (groupInfo != null)
  1361. {
  1362. ffrPrice = groupInfo.PaymentMoney;
  1363. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1364. }
  1365. }
  1366. var _dto = new GroupOperationDto();
  1367. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1368. var groupData = await _groupRepository.GroupOperation(_dto);
  1369. if (groupData.Code != 0)
  1370. {
  1371. _sqlSugar.RollbackTran();
  1372. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1373. }
  1374. try
  1375. {
  1376. int diId = 0;
  1377. //添加时 默认加入团组汇率
  1378. if (dto.Status == 1) //添加
  1379. {
  1380. diId = groupData.Data;
  1381. //添加默认币种
  1382. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1383. //默认分配权限
  1384. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1385. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1386. var _managerIds = new List<int>() { 21, 22, 32 };
  1387. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1388. if (userIds.Count > 0)
  1389. {
  1390. userIds.Add(208);
  1391. //创建团组管控
  1392. GroupStepForDelegation.CreateWorkStep(diId);
  1393. //发送消息
  1394. string groupName = dto.TeamName;
  1395. string createGroupUser = string.Empty;
  1396. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1397. if (userInfo != null) createGroupUser = userInfo.CnName;
  1398. string title = $"系统通知";
  1399. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1400. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1401. }
  1402. #region 应用推送
  1403. try
  1404. {
  1405. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1406. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1407. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1408. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1409. {
  1410. var userList = new List<string>() { users.QiyeChatUserId };
  1411. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1412. }
  1413. }
  1414. catch (Exception ex)
  1415. {
  1416. _sqlSugar.CommitTran();
  1417. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1418. }
  1419. #endregion
  1420. //默认创建倒推表
  1421. await _invertedListRep._Create(dto.UserId, diId);
  1422. }
  1423. else if (dto.Status == 2)
  1424. {
  1425. diId = dto.Id;
  1426. if (diId == 0)
  1427. {
  1428. _sqlSugar.RollbackTran();
  1429. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1430. }
  1431. }
  1432. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1433. if (viewData.Code != 0)
  1434. {
  1435. _sqlSugar.RollbackTran();
  1436. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1437. }
  1438. #region 团组操作默认添加/修改收款账单
  1439. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1440. {
  1441. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1442. .Where(x => x.IsDel == 0 &&
  1443. x.Diid == diId &&
  1444. x.Remark.Equals("预付款")
  1445. )
  1446. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1447. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1448. .FirstAsync();
  1449. ffrInfo = new Fin_ForeignReceivables()
  1450. {
  1451. Diid = diId,
  1452. PriceName = dto.ClientUnit,
  1453. Price = dto.PaymentMoney,
  1454. Count = 1,
  1455. Unit = $"元",
  1456. ItemSumPrice = dto.PaymentMoney,
  1457. Rate = 1.0000M,
  1458. Currency = 836,
  1459. AddingWay = 0,
  1460. CreateUserId = dto.UserId,
  1461. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1462. Remark = $"预付款"
  1463. };
  1464. if (ffrInfo == null) //Add
  1465. {
  1466. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1467. }
  1468. else //修改
  1469. {
  1470. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1471. .UpdateColumns(x => new
  1472. {
  1473. x.PriceName,
  1474. x.Price,
  1475. x.ItemSumPrice,
  1476. x.CreateTime,
  1477. x.CreateUserId
  1478. })
  1479. .WhereColumns(x => x.Id)
  1480. .ExecuteCommandAsync();
  1481. }
  1482. }
  1483. #endregion
  1484. #region 签证人员团组时间通知
  1485. #region 计算出访起止时间
  1486. var startTime = new DateTime();
  1487. var endTime = new DateTime();
  1488. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1489. {
  1490. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1491. }
  1492. #endregion
  1493. if (diId > 0)
  1494. {
  1495. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1496. }
  1497. #endregion
  1498. _sqlSugar.CommitTran();
  1499. return Ok(JsonView(true));
  1500. }
  1501. catch (Exception ex)
  1502. {
  1503. _sqlSugar.RollbackTran();
  1504. return Ok(JsonView(false, ex.Message));
  1505. }
  1506. }
  1507. /// <summary>
  1508. /// 接团信息 操作(删除)
  1509. /// </summary>
  1510. /// <param name="dto"></param>
  1511. /// <returns></returns>
  1512. [HttpPost]
  1513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1514. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1515. {
  1516. var diId = dto.Id;
  1517. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1518. #region 删除 验证
  1519. /*
  1520. * 1、收款账单数据:0 条
  1521. * 2、收款退还数据:0 条
  1522. * 3、机票费用数据:0 条
  1523. * 4、签证费用数据:0 条
  1524. * 5、保险费用数据:0 条
  1525. * 6、酒店费用数据:0 条
  1526. * 7、公务出访数据:1 条
  1527. * 8、邀请公务活动费用数据:1 条
  1528. * 9、OP费用数据:5 条
  1529. * 10、其他费用数据:0 条
  1530. * 11、团组日付报销费用数据:0 条
  1531. *
  1532. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1533. */
  1534. //收款账单
  1535. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1536. //收款退还
  1537. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1538. //机票费用
  1539. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1540. //签证费用
  1541. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1542. //保险费用
  1543. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1544. //酒店费用
  1545. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1546. //公务出访
  1547. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1548. //邀请公务活动费用
  1549. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1550. //OP费用
  1551. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1552. //其他费用
  1553. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1554. //团组日付报销费用
  1555. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1556. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1557. if (feeCount > 0)
  1558. {
  1559. var delMsgTips = new StringBuilder();
  1560. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1561. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1562. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1563. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1564. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1565. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1566. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1567. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1568. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1569. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1570. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1571. delMsgTips.AppendLine($"");
  1572. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1573. return Ok(JsonView(false, delMsgTips.ToString()));
  1574. }
  1575. #endregion
  1576. var groupData = await _groupRepository.GroupDel(dto);
  1577. if (groupData.Code != 0)
  1578. {
  1579. return Ok(JsonView(false, groupData.Msg));
  1580. }
  1581. return Ok(JsonView(true));
  1582. }
  1583. /// <summary>
  1584. /// 获取团组销售报价号
  1585. /// 团组添加时 使用
  1586. /// </summary>
  1587. /// <returns></returns>
  1588. [HttpPost]
  1589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1590. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1591. {
  1592. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1593. if (groupData.Code != 0)
  1594. {
  1595. return Ok(JsonView(false, groupData.Msg));
  1596. }
  1597. object salesQuoteNo = new
  1598. {
  1599. SalesQuoteNo = groupData.Data
  1600. };
  1601. return Ok(JsonView(salesQuoteNo));
  1602. }
  1603. /// <summary>
  1604. /// 设置确认出团
  1605. /// </summary>
  1606. /// <param name="dto"></param>
  1607. /// <returns></returns>
  1608. [HttpPost]
  1609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1610. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1611. {
  1612. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1613. if (groupData.Code != 0)
  1614. {
  1615. return Ok(JsonView(false, groupData.Msg));
  1616. }
  1617. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1618. #region OA消息推送
  1619. try
  1620. {
  1621. string groupName = groupInfo.TeamName;
  1622. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1623. string title = $"系统通知";
  1624. string content = $"团组[{groupName}]已确认出团!";
  1625. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1626. }
  1627. catch (Exception ex)
  1628. {
  1629. }
  1630. #endregion
  1631. #region 应用推送
  1632. try
  1633. {
  1634. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1635. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1636. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1637. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1638. {
  1639. var userList = new List<string>() { users.QiyeChatUserId };
  1640. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1641. }
  1642. }
  1643. catch (Exception ex)
  1644. {
  1645. }
  1646. #endregion
  1647. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1648. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1649. }
  1650. /// <summary>
  1651. /// 获取团组名称data And 签证国别Data
  1652. /// </summary>
  1653. /// <param name="dto"></param>
  1654. /// <returns></returns>
  1655. [HttpPost]
  1656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1657. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1658. {
  1659. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1660. if (groupData.Code != 0)
  1661. {
  1662. return Ok(JsonView(false, groupData.Msg));
  1663. }
  1664. return Ok(JsonView(groupData.Data));
  1665. }
  1666. /// <summary>
  1667. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1668. /// </summary>
  1669. /// <returns></returns>
  1670. [HttpPost]
  1671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1672. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1673. {
  1674. try
  1675. {
  1676. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1677. if (groupData.Code != 0)
  1678. {
  1679. return Ok(JsonView(false, groupData.Msg));
  1680. }
  1681. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1682. }
  1683. catch (Exception ex)
  1684. {
  1685. return Ok(JsonView(false, ex.Message));
  1686. throw;
  1687. }
  1688. }
  1689. /// <summary>
  1690. /// 团组清单 Excel
  1691. /// </summary>
  1692. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1693. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1694. /// <returns></returns>
  1695. [HttpGet]
  1696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1697. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1698. {
  1699. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1700. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1701. if (!beginBool && !endBool)
  1702. {
  1703. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1704. }
  1705. string sql = string.Format(@"
  1706. SELECT
  1707. ROW_NUMBER,
  1708. Id,
  1709. SalesQuoteNo,
  1710. TourCode,
  1711. TeamTypeId,
  1712. TeamType,
  1713. TeamLevId,
  1714. TeamLev,
  1715. TeamName,
  1716. ClientName,
  1717. ClientUnit,
  1718. VisitDate,
  1719. VisitDays,
  1720. VisitPNumber,
  1721. JietuanOperatorId,
  1722. JietuanOperator,
  1723. IsSure,
  1724. CreateUserName,
  1725. IsBid
  1726. FROM
  1727. (
  1728. SELECT
  1729. ROW_NUMBER() OVER(
  1730. ORDER BY
  1731. gdi.VisitDate Desc
  1732. ) AS ROW_NUMBER,
  1733. gdi.Id,
  1734. SalesQuoteNo,
  1735. TourCode,
  1736. ssd.Id TeamTypeId,
  1737. ssd.Name TeamType,
  1738. ssd1.Id TeamLevId,
  1739. ssd1.Name TeamLev,
  1740. TeamName,
  1741. ClientName,
  1742. ClientUnit,
  1743. VisitDate,
  1744. VisitDays,
  1745. VisitPNumber,
  1746. JietuanOperator JietuanOperatorId,
  1747. su.CnName JietuanOperator,
  1748. IsSure,
  1749. gdi.CreateTime,
  1750. su1.CnName As CreateUserName,
  1751. gdi.IsBid
  1752. FROM
  1753. Grp_DelegationInfo gdi
  1754. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1755. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1756. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1757. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1758. WHERE
  1759. gdi.IsDel = 0
  1760. AND gdi.IsBid = 0
  1761. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1762. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1763. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1764. #region 处理所属部门
  1765. /*
  1766. * 1.sq 和 gyy 等显示 市场部
  1767. * 2.王鸽和主管及张总还有管理员号统一国交部
  1768. * 2-1. 4 管理员 ,21 张海麟
  1769. */
  1770. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1771. var userIds1 = new List<int>() { 4, 21 };
  1772. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1773. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1774. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1775. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1776. .ToListAsync();
  1777. var droupIds = groupList.Select(it => it.Id).ToList();
  1778. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1779. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1780. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1781. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1782. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1783. {
  1784. DiId = tcl.DiId,
  1785. LastName = dc.LastName,
  1786. FirstName = dc.FirstName,
  1787. Sex = dc.Sex,
  1788. Birthday = dc.BirthDay,
  1789. Company = cc.CompanyFullName,
  1790. Job = dc.Job,
  1791. CreateTime = tcl.CreateTime,
  1792. })
  1793. .ToList();
  1794. foreach (var item in groupList)
  1795. {
  1796. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1797. string groupFirstName = "";
  1798. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1799. if (currDatas.Any())
  1800. {
  1801. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1802. }
  1803. item.GroupFirst = groupFirstName;
  1804. }
  1805. #endregion
  1806. #region Excel
  1807. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1808. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1809. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1810. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1811. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1812. //载入模板
  1813. var designer = new WorkbookDesigner
  1814. {
  1815. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1816. };
  1817. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1818. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1819. dt.TableName = "GroupList";
  1820. designer.SetDataSource(dt);
  1821. designer.Process();
  1822. if (!Directory.Exists(savePath))
  1823. {
  1824. Directory.CreateDirectory(savePath);
  1825. }
  1826. string serverPath = $"{savePath}{fileName}";
  1827. designer.Workbook.Save(serverPath);
  1828. string rst = $"{servicePath}{ftpPath}{fileName}";
  1829. #endregion
  1830. return Ok(JsonView(true, "操作成功!", rst));
  1831. }
  1832. /// <summary>
  1833. /// 团组合同下载(1.付款80% 2.付全款)
  1834. /// </summary>
  1835. /// <param name="dto"></param>
  1836. /// <returns></returns>
  1837. /// <exception cref="Exception"></exception>
  1838. [HttpPost]
  1839. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1840. {
  1841. var jw = JsonView(false);
  1842. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1843. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1844. if (di == null)
  1845. {
  1846. jw.Msg = "团组Id有误!";
  1847. return Ok(jw);
  1848. }
  1849. #region 权限校验
  1850. var allDownFile = new List<int>() { 21 };
  1851. try
  1852. {
  1853. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1854. .First(x => x.Id == 1418 && x.IsDel == 0);
  1855. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1856. }
  1857. catch (Exception)
  1858. { }
  1859. var guojiaoDownFile = new List<int>() { 330,383};
  1860. var shichangDownFile = new List<int>() { 95 };
  1861. if (allDownFile.Contains(dto.UserId))
  1862. {
  1863. }
  1864. else if (guojiaoDownFile.Contains(dto.UserId))
  1865. {
  1866. var guojiaobuDi = new List<int>() { 4, 21 };
  1867. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1868. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1869. .Where((d, u) => u.Id == di.JietuanOperator)
  1870. .Select((d, u) => d.DepName)
  1871. .First();
  1872. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1873. {
  1874. jw.Msg = "暂无下载权限!";
  1875. return Ok(jw);
  1876. }
  1877. }
  1878. else if (shichangDownFile.Contains(dto.UserId))
  1879. {
  1880. var dic = new Dictionary<int, int[]>()
  1881. {
  1882. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1883. };
  1884. try
  1885. {
  1886. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1887. if (sqSetting != null)
  1888. {
  1889. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1890. foreach (var item in result.Keys)
  1891. {
  1892. if (dic.ContainsKey(item))
  1893. {
  1894. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1895. Array.Copy(dic[item], dilatation, dic[item].Length);
  1896. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1897. dic[item] = dilatation;
  1898. }
  1899. else
  1900. {
  1901. dic.Add(item, result[item]);
  1902. }
  1903. }
  1904. }
  1905. if (!dic[95].Contains(di.CreateUserId))
  1906. {
  1907. jw.Msg = "暂无下载权限!";
  1908. return Ok(jw);
  1909. }
  1910. }
  1911. catch (Exception)
  1912. { }
  1913. }
  1914. else if (dto.UserId == di.CreateUserId)
  1915. {
  1916. }
  1917. else
  1918. {
  1919. jw.Msg = "暂无下载权限!";
  1920. return Ok(jw);
  1921. }
  1922. #endregion
  1923. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1924. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1925. .ToListAsync();
  1926. if (!blackCodeList.Any())
  1927. {
  1928. jw.Msg = "该团无机票行程代码!";
  1929. return Ok(jw);
  1930. }
  1931. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1932. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1933. if (groupEnterExitCost == null)
  1934. {
  1935. jw.Msg = "暂无三公费用信息!";
  1936. return Ok(jw);
  1937. }
  1938. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1939. rateList ??= new List<CurrencyInfo>();
  1940. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1941. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1942. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1943. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1944. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1945. .Select((x, a, b) => new
  1946. {
  1947. x.Index,
  1948. itemName = a.Name,
  1949. CurrencyStr = b.Name,
  1950. x.Cost,
  1951. x.SubTotal,
  1952. x.Remark
  1953. })
  1954. .OrderBy((x) => x.Index)
  1955. .ToList();
  1956. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1957. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1958. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1959. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1960. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1961. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1962. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1963. decimal subJJC = 0.00M,
  1964. subGWC = 0.00M,
  1965. subTDC = 0.00M;
  1966. //经济舱
  1967. if (groupEnterExitCost.SumJJC == 1)
  1968. {
  1969. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1970. }
  1971. //公务舱
  1972. if (groupEnterExitCost.SumGWC == 1)
  1973. {
  1974. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1975. }
  1976. //头等舱
  1977. if (groupEnterExitCost.SumTDC == 1)
  1978. {
  1979. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1980. }
  1981. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1982. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1983. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1984. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1985. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1986. .Select((x, s, dc, cc) => new GroupClints
  1987. {
  1988. Id = x.Id,
  1989. Name = s.Name,
  1990. IsAccompany = x.IsAccompany,
  1991. CompanyFullName = cc.CompanyFullName
  1992. })
  1993. .ToListAsync();
  1994. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1995. //获取舱位人数
  1996. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1997. .GroupBy(x => x.Name)
  1998. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1999. .ToList();
  2000. string cityPath = string.Empty;
  2001. string startCity = string.Empty;
  2002. string endCity = string.Empty;
  2003. foreach (var item in blackCodeList)
  2004. {
  2005. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2006. cityPath += city + "\r\n";
  2007. if (item.Equals(blackCodeList.First()))
  2008. {
  2009. var sp = city.Split('-');
  2010. startCity = sp[0];
  2011. endCity = sp[^1];
  2012. }
  2013. }
  2014. var bookMarkDic = new Dictionary<string, string>
  2015. {
  2016. { "ClientUnit", di.ClientUnit },
  2017. { "VisitCountry", di.VisitCountry },
  2018. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2019. { "VisitPNumber", di.VisitPNumber.ToString() },
  2020. { "CityPath", cityPath },
  2021. { "StartCity", startCity },
  2022. { "EndCity", endCity },
  2023. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2024. };
  2025. Document doc = null;
  2026. var percentage = 0.8M;
  2027. var fileNameadd = "预付";
  2028. if (dto.FileType == 1)
  2029. {
  2030. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2031. }
  2032. else if (dto.FileType == 2)
  2033. {
  2034. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2035. percentage = 1;
  2036. fileNameadd = "全款";
  2037. }
  2038. else
  2039. {
  2040. throw new Exception("FileType有误!");
  2041. }
  2042. var builder = new DocumentBuilder(doc);
  2043. decimal totalPrice = 0.00M;
  2044. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2045. if (firstTable != null)
  2046. {
  2047. // 遍历表格的行和单元格
  2048. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2049. {
  2050. for (int i = 0; i < row.Cells.Count; i++)
  2051. {
  2052. var cell = row.Cells[i];
  2053. // 读取单元格内容
  2054. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2055. if (cellTextFirst.Contains("舱位"))
  2056. {
  2057. break;
  2058. }
  2059. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2060. {
  2061. if (i == 2)
  2062. {
  2063. if (cellTextFirst == "经济舱")
  2064. {
  2065. // 设置单元格内容
  2066. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2067. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2068. }
  2069. else
  2070. {
  2071. // 设置单元格内容
  2072. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2073. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2074. }
  2075. }
  2076. if (i == 3)
  2077. {
  2078. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2079. if (count != null)
  2080. {
  2081. // 设置单元格内容
  2082. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2083. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2084. }
  2085. }
  2086. if (i == 4)
  2087. {
  2088. var rowPrice = 0.00M;
  2089. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2090. count ??= 0;
  2091. if (cellTextFirst == "经济舱")
  2092. {
  2093. rowPrice = subJJC * (int)count;
  2094. }
  2095. else
  2096. {
  2097. rowPrice = subGWC * (int)count;
  2098. }
  2099. totalPrice += rowPrice;
  2100. // 设置单元格内容
  2101. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2102. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2103. }
  2104. }
  2105. }
  2106. }
  2107. }
  2108. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2109. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2110. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2111. //--合同表格部分
  2112. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2113. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2114. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2115. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2116. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2117. bookMarkDic.Add("CityPath1", cityPath);
  2118. bookMarkDic.Add("CityPath2", cityPath);
  2119. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2120. if (contractTable != null)
  2121. {
  2122. //数据源
  2123. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2124. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2125. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2126. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2127. .Select((it, y, s) => new
  2128. {
  2129. it.Cost,
  2130. it.SubTotal,
  2131. it.Type,
  2132. y.Id,
  2133. y.City,
  2134. s.Name,
  2135. CurrencyCodeCn = s.Remark
  2136. })
  2137. .ToList()
  2138. .Select(x => new
  2139. {
  2140. CurrencyCode = x.Name,
  2141. CityId = x.Id,
  2142. x.City,
  2143. di.VisitPNumber,
  2144. x.Type,
  2145. x.Cost,
  2146. x.SubTotal,
  2147. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2148. x.CurrencyCodeCn,
  2149. });
  2150. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2151. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2152. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2153. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2154. var tableSettings = new List<tableSetting>()
  2155. {
  2156. new(){ Index = 1 , Property = "City"},
  2157. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2158. new(){ Index = 3 , Property = "Cost"},
  2159. new(){ Index = 4 , Property = "VisitPNumber"},
  2160. //new tableSetting{ Index = 5 , Property = ""},
  2161. //new tableSetting{ Index = 6 , Property = ""},
  2162. new(){ Index = 7 , Property = "Rate"},
  2163. //new tableSetting{ Index = 8 , Property = ""},
  2164. };
  2165. //1.住宿费
  2166. int cloneRow = 8;
  2167. int startDayPrice = 8; //写入index
  2168. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2169. foreach (var dac in dac1)
  2170. {
  2171. var first = dac.First();
  2172. var dayCount = dac.Count();
  2173. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2174. for (int i = 1; i < row.Cells.Count; i++)
  2175. {
  2176. var cell = row.Cells[i];
  2177. var findProperty = tableSettings.Find(x => x.Index == i);
  2178. if (findProperty != null)
  2179. {
  2180. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2181. // 设置单元格内容
  2182. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2183. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2184. }
  2185. else
  2186. {
  2187. switch (i)
  2188. {
  2189. case 5:
  2190. cell.FirstParagraph.Runs.Clear();
  2191. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2192. break;
  2193. case 6:
  2194. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2195. cell.FirstParagraph.Runs.Clear();
  2196. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2197. break;
  2198. case 8:
  2199. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2200. cell.FirstParagraph.Runs.Clear();
  2201. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2202. ZSPriceSum += xiaojiRMB;
  2203. break;
  2204. default:
  2205. break;
  2206. }
  2207. }
  2208. }
  2209. startDayPrice++;
  2210. if (!dac1.Last().Equals(dac))
  2211. {
  2212. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2213. // 将克隆的行追加到原行后面
  2214. contractTable.Rows.Insert(startDayPrice, newRow);
  2215. }
  2216. else
  2217. {
  2218. cloneRow += dac1.Count + 1;
  2219. startDayPrice = cloneRow;
  2220. }
  2221. }
  2222. //2.伙食费
  2223. foreach (var dac in dac2)
  2224. {
  2225. var first = dac.First();
  2226. var dayCount = dac.Count();
  2227. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2228. for (int i = 1; i < row.Cells.Count; i++)
  2229. {
  2230. var cell = row.Cells[i];
  2231. var findProperty = tableSettings.Find(x => x.Index == i);
  2232. if (findProperty != null)
  2233. {
  2234. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2235. // 设置单元格内容
  2236. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2237. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2238. }
  2239. else
  2240. {
  2241. switch (i)
  2242. {
  2243. case 5:
  2244. cell.FirstParagraph.Runs.Clear();
  2245. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2246. break;
  2247. case 6:
  2248. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2249. cell.FirstParagraph.Runs.Clear();
  2250. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2251. break;
  2252. case 8:
  2253. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2254. cell.FirstParagraph.Runs.Clear();
  2255. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2256. HSPriceSum += xiaojiRMB;
  2257. break;
  2258. default:
  2259. break;
  2260. }
  2261. }
  2262. }
  2263. startDayPrice++;
  2264. if (!dac2.Last().Equals(dac))
  2265. {
  2266. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2267. // 将克隆的行追加到原行后面
  2268. contractTable.Rows.Insert(startDayPrice, newRow);
  2269. }
  2270. else
  2271. {
  2272. cloneRow += dac2.Count + 1;
  2273. startDayPrice = cloneRow;
  2274. }
  2275. }
  2276. //3.公杂费
  2277. foreach (var dac in dac3)
  2278. {
  2279. var first = dac.First();
  2280. var dayCount = dac.Count();
  2281. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2282. for (int i = 1; i < row.Cells.Count; i++)
  2283. {
  2284. var cell = row.Cells[i];
  2285. var findProperty = tableSettings.Find(x => x.Index == i);
  2286. if (findProperty != null)
  2287. {
  2288. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2289. // 设置单元格内容
  2290. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2291. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2292. }
  2293. else
  2294. {
  2295. switch (i)
  2296. {
  2297. case 5:
  2298. cell.FirstParagraph.Runs.Clear();
  2299. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2300. break;
  2301. case 6:
  2302. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2303. cell.FirstParagraph.Runs.Clear();
  2304. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2305. break;
  2306. case 8:
  2307. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2308. cell.FirstParagraph.Runs.Clear();
  2309. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2310. GZPriceSum += xiaojiRMB;
  2311. break;
  2312. default:
  2313. break;
  2314. }
  2315. }
  2316. }
  2317. startDayPrice++;
  2318. if (!dac3.Last().Equals(dac))
  2319. {
  2320. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2321. // 将克隆的行追加到原行后面
  2322. contractTable.Rows.Insert(startDayPrice, newRow);
  2323. }
  2324. else
  2325. {
  2326. cloneRow += dac3.Count + 1;
  2327. startDayPrice = cloneRow;
  2328. }
  2329. }
  2330. //合并单元格
  2331. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2332. {
  2333. var currentRow = contractTable.Rows[i];
  2334. var nextRow = contractTable.Rows[i + 1];
  2335. // 获取当前行和下一行的第一个单元格
  2336. Cell currentCell = currentRow.Cells[0];
  2337. Cell nextCell = nextRow.Cells[0];
  2338. // 检查单元格内容是否一致(去除尾部的换行符)
  2339. string currentText = currentCell.GetText().Trim();
  2340. string nextText = nextCell.GetText().Trim();
  2341. if (currentText == nextText)
  2342. {
  2343. // 如果当前单元格已经被合并,找到合并的起始单元格
  2344. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2345. {
  2346. // 找到合并的起始单元格
  2347. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2348. // 将下一行的单元格设置为合并的后续单元格
  2349. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2350. }
  2351. else
  2352. {
  2353. // 如果当前单元格是合并的起始单元格
  2354. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2355. // 将下一行的单元格设置为合并的后续单元格
  2356. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2357. }
  2358. }
  2359. else
  2360. {
  2361. // 如果内容不一致,重置当前单元格的合并属性
  2362. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2363. {
  2364. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2365. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2366. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2367. }
  2368. else
  2369. {
  2370. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2371. }
  2372. }
  2373. }
  2374. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2375. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2376. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2377. }
  2378. foreach (var bookmarkName in bookMarkDic.Keys)
  2379. {
  2380. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2381. if (bookmark != null)
  2382. {
  2383. if (bookmarkName == "ClientUnit")
  2384. {
  2385. // 移动到书签位置
  2386. builder.MoveTo(bookmark.BookmarkStart);
  2387. // 设置字体样式为下划线
  2388. builder.Font.Underline = Aspose.Words.Underline.Single;
  2389. // 插入书签值
  2390. builder.Write(bookMarkDic[bookmarkName]);
  2391. // 清除字体格式,避免影响后续文本
  2392. builder.Font.ClearFormatting();
  2393. }
  2394. else
  2395. {
  2396. builder.MoveToBookmark(bookmarkName);
  2397. builder.Write(bookMarkDic[bookmarkName]);
  2398. }
  2399. }
  2400. }
  2401. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2402. doc.Save(savePaht);
  2403. jw.Msg = "生成成功!";
  2404. jw.Code = 200;
  2405. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2406. return Ok(jw);
  2407. }
  2408. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2409. {
  2410. int index = rowIndex;
  2411. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2412. {
  2413. index--;
  2414. }
  2415. return index;
  2416. }
  2417. #endregion
  2418. #region 团组&签证
  2419. #region 团组&签证 New
  2420. /// <summary>
  2421. /// 团组&签证 New
  2422. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2423. /// </summary>
  2424. /// <param name="file">请求dto</param>
  2425. /// <returns></returns>
  2426. [HttpPost]
  2427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2428. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile file, int fileTypeId)
  2429. {
  2430. //文件验证
  2431. if (file.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2432. //var visaFiles = new VisaUploadFileTypeView();
  2433. var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2434. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2435. //服务器存储文件
  2436. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2437. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2438. var filePath = Path.Combine(fileServerPath, file.FileName);
  2439. using (var stream = new FileStream(filePath, FileMode.Create))
  2440. {
  2441. await file.CopyToAsync(stream);
  2442. }
  2443. //日志记录-上传文件
  2444. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, file.FileName);
  2445. //kimi AI 识别文档返回json结果
  2446. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2447. var KiMiApi = new KiMiApiClient();
  2448. var files = new List<IFormFile>() { file };
  2449. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2450. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2451. var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2452. var messages = new List<SeedMessages>
  2453. {
  2454. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2455. new() { Role = KimiRole.user, Content = seedMessage }
  2456. };
  2457. messages.InsertRange(1, seedConter);
  2458. string jsonString = string.Empty;
  2459. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2460. while (!isJson)
  2461. {
  2462. kimiAI_API_Index++;
  2463. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2464. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2465. jsonString += kimiApiResult_JObject["content"].ToString();
  2466. string startStr = "```json", endStr = "```";
  2467. // 判断并清除开头部分
  2468. if (jsonString.StartsWith(startStr))
  2469. {
  2470. jsonString = jsonString.Replace(startStr, "");
  2471. }
  2472. // 判断并清除结尾部分
  2473. if (jsonString.EndsWith(endStr))
  2474. {
  2475. jsonString = jsonString.Replace(endStr, "");
  2476. }
  2477. //验证json格式是否正确
  2478. try
  2479. {
  2480. JsonDocument.Parse(jsonString);
  2481. isJson = true; // 如果解析成功,则是json格式
  2482. }
  2483. catch (Exception)
  2484. {
  2485. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2486. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2487. }
  2488. }
  2489. var clientInfo = new Crm_DeleClient(); //客户资料表
  2490. var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2491. var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2492. var clientCert = new Crm_CustomerCert(); //客户证件表
  2493. var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2494. //按照表格类型分别进行参数处理
  2495. switch (fileTypeId)
  2496. {
  2497. //澳新签证个人申请表
  2498. case 1:
  2499. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2500. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2501. break;
  2502. default:
  2503. break;
  2504. }
  2505. return Ok(JsonView(true, jsonString));
  2506. }
  2507. #endregion
  2508. /// <summary>
  2509. /// 根据团组Id获取签证客户信息List
  2510. /// </summary>
  2511. /// <param name="dto">请求dto</param>
  2512. /// <returns></returns>
  2513. [HttpPost]
  2514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2515. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2516. {
  2517. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2518. if (groupData.Code != 0)
  2519. {
  2520. return Ok(JsonView(false, groupData.Msg));
  2521. }
  2522. return Ok(JsonView(groupData.Data));
  2523. }
  2524. /// <summary>
  2525. /// IOS获取团组签证拍照上传进度01(团组列表)
  2526. /// </summary>
  2527. /// <param name="dto">请求dto</param>
  2528. /// <returns></returns>
  2529. [HttpPost]
  2530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2531. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2532. {
  2533. if (dto == null)
  2534. {
  2535. return Ok(JsonView(false, "参数为空"));
  2536. }
  2537. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2538. return Ok(JsonView(visaList));
  2539. }
  2540. /// <summary>
  2541. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2542. /// </summary>
  2543. /// <returns></returns>
  2544. [HttpPost]
  2545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2546. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2547. {
  2548. if (dto == null)
  2549. {
  2550. return Ok(JsonView(false, "请求错误:"));
  2551. }
  2552. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2553. return Ok(JsonView(list));
  2554. }
  2555. /// <summary>
  2556. /// IOS获取团组签证拍照上传进度03(相册)
  2557. /// </summary>
  2558. /// <returns></returns>
  2559. [HttpPost]
  2560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2561. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2562. {
  2563. if (dto == null)
  2564. {
  2565. return Ok(JsonView(false, "请求错误:"));
  2566. }
  2567. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2568. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2569. list.ForEach(s => s.url = url);
  2570. return Ok(JsonView(list));
  2571. }
  2572. /// <summary>
  2573. /// IOS获取团组签证拍照上传进度04(图片上传)
  2574. /// </summary>
  2575. /// <param name="dto"></param>
  2576. /// <returns></returns>
  2577. [HttpPost]
  2578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2579. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2580. {
  2581. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2582. //if (!string.IsNullOrEmpty(result))
  2583. //{
  2584. //}
  2585. //else {
  2586. // return Ok(JsonView(false, "上传失败"));
  2587. //}
  2588. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2589. int sucNum = 0;
  2590. try
  2591. {
  2592. foreach (var item in dto.base64DataList)
  2593. {
  2594. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2595. string result = DecodeBase64ToImage(item, imageName);
  2596. if (!string.IsNullOrEmpty(result))
  2597. {
  2598. var pic = new Grp_VisaProgressCustomerPicture
  2599. {
  2600. CreateUserId = dto.CreateUserId,
  2601. PicName = imageName,
  2602. PicPath = result,
  2603. VisaProgressCustomerId = dto.visaProgressCustomerId
  2604. };
  2605. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2606. if (insertResult > 0)
  2607. {
  2608. sucNum++;
  2609. }
  2610. }
  2611. }
  2612. }
  2613. catch (Exception ex)
  2614. {
  2615. return Ok(JsonView(false, ex.Message));
  2616. }
  2617. string msg = string.Format(@"成功上传{0}张", sucNum);
  2618. return Ok(JsonView(true, msg));
  2619. }
  2620. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2621. {
  2622. string filename = "";//声明一个string类型的相对路径
  2623. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2624. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2625. try//会有异常抛出,try,catch一下
  2626. {
  2627. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2628. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2629. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2630. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2631. //文件名称
  2632. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2633. //上传的文件的路径
  2634. string filePath = "";
  2635. if (!Directory.Exists(fileDir))
  2636. {
  2637. Directory.CreateDirectory(fileDir);
  2638. }
  2639. //上传的文件的路径
  2640. filePath = fileDir + filename;
  2641. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2642. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2643. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2644. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2645. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2646. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2647. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2648. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2649. bitmap.Dispose();
  2650. }
  2651. catch (Exception e)
  2652. {
  2653. string massage = e.Message;
  2654. Logs("IOS图片上传Error:" + massage);
  2655. //filename = e.Message;
  2656. }
  2657. return filename;//返回相对路径
  2658. }
  2659. /// <summary>
  2660. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2661. /// </summary>
  2662. /// <param name="dto"></param>
  2663. /// <returns></returns>
  2664. [HttpPost]
  2665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2666. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2667. {
  2668. if (dto == null)
  2669. {
  2670. return Ok(JsonView(false, "请求错误:"));
  2671. }
  2672. string msg = "参数错误";
  2673. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2674. {
  2675. try
  2676. {
  2677. //_delegationVisaRep.BeginTran();
  2678. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2679. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2680. .Where(s => s.Id == dto.visaProgressCustomerId)
  2681. .ExecuteCommandAsync();
  2682. if (updCount > 0 && dto.publishCode == 1)
  2683. {
  2684. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2685. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2686. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2687. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2688. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2689. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2690. if (groupData == null)
  2691. {
  2692. _delegationVisaRep.RollbackTran();
  2693. }
  2694. string title = string.Format(@"[签证进度更新]");
  2695. string content = string.Format(@"测试文本");
  2696. bool rst = await _message.AddMsg(new MessageDto()
  2697. {
  2698. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2699. IssuerId = dto.publisher,
  2700. Title = title,
  2701. Content = content,
  2702. ReleaseTime = DateTime.Now,
  2703. UIdList = new List<int> {
  2704. 234
  2705. }
  2706. });
  2707. if (rst)
  2708. {
  2709. return Ok(JsonView(true, "发送通知成功"));
  2710. }
  2711. }
  2712. //_delegationVisaRep.CommitTran();
  2713. }
  2714. catch (Exception)
  2715. {
  2716. //_delegationVisaRep.RollbackTran();
  2717. }
  2718. }
  2719. return Ok(JsonView(true, msg));
  2720. }
  2721. #endregion
  2722. #region 团组任务分配
  2723. /// <summary>
  2724. /// 团组任务分配初始化
  2725. /// </summary>
  2726. /// <returns></returns>
  2727. [HttpPost]
  2728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2729. public async Task<IActionResult> GetTaskAssignmen()
  2730. {
  2731. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2732. if (groupData.Code != 0)
  2733. {
  2734. return Ok(JsonView(false, groupData.Msg));
  2735. }
  2736. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2737. }
  2738. /// <summary>
  2739. /// 团组任务分配查询
  2740. /// </summary>
  2741. /// <param name="dto"></param>
  2742. /// <returns></returns>
  2743. [HttpPost]
  2744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2745. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2746. {
  2747. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2748. if (groupData.Code != 0)
  2749. {
  2750. return Ok(JsonView(false, groupData.Msg));
  2751. }
  2752. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2753. }
  2754. /// <summary>
  2755. /// 团组任务分配操作
  2756. /// </summary>
  2757. /// <param name="dto"></param>
  2758. /// <returns></returns>
  2759. [HttpPost]
  2760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2761. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2762. {
  2763. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2764. if (groupData.Code != 0)
  2765. {
  2766. return Ok(JsonView(false, groupData.Msg));
  2767. }
  2768. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2769. }
  2770. /// <summary>
  2771. /// 团组任务分配
  2772. /// 批量分配
  2773. /// 查询团组
  2774. /// </summary>
  2775. /// <param name="dto"></param>
  2776. /// <returns></returns>
  2777. [HttpPost]
  2778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2779. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2780. {
  2781. //参数验证
  2782. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2783. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2784. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2785. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2786. }
  2787. /// <summary>
  2788. /// 团组任务分配
  2789. /// 批量分配
  2790. /// </summary>
  2791. /// <param name="dto"></param>
  2792. /// <returns></returns>
  2793. [HttpPost]
  2794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2795. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2796. {
  2797. //参数验证
  2798. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2799. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2800. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2801. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2802. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2803. }
  2804. #endregion
  2805. #region 团组费用审核
  2806. /// <summary>
  2807. /// 费用审核
  2808. /// 团组列表 Page
  2809. /// </summary>
  2810. /// <param name="_dto">团组列表请求dto</param>
  2811. /// <returns></returns>
  2812. [HttpPost]
  2813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2814. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2815. {
  2816. #region 参数验证
  2817. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2818. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2819. #region 页面操作权限验证
  2820. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2821. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2822. #endregion
  2823. #endregion
  2824. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2825. {
  2826. string sqlWhere = string.Empty;
  2827. if (_dto.IsSure == 0) //未完成
  2828. {
  2829. sqlWhere += string.Format(@" And IsSure = 0");
  2830. }
  2831. else if (_dto.IsSure == 1) //已完成
  2832. {
  2833. sqlWhere += string.Format(@" And IsSure = 1");
  2834. }
  2835. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2836. {
  2837. string tj = _dto.SearchCriteria;
  2838. 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}%')",
  2839. tj, tj, tj, tj, tj);
  2840. }
  2841. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2842. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2843. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2844. From (
  2845. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2846. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2847. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2848. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2849. From Grp_DelegationInfo gdi
  2850. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2851. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2852. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2853. Where gdi.IsDel = 0 {0}
  2854. ) temp ", sqlWhere);
  2855. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2856. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2857. var _view = new
  2858. {
  2859. PageFuncAuth = pageFunAuthView,
  2860. Data = _DelegationList
  2861. };
  2862. return Ok(JsonView(true, "查询成功!", _view, total));
  2863. }
  2864. else
  2865. {
  2866. return Ok(JsonView(false, "查询失败"));
  2867. }
  2868. }
  2869. /// <summary>
  2870. /// 获取团组费用审核
  2871. /// </summary>
  2872. /// <param name="_dto"></param>
  2873. /// <returns></returns>
  2874. [HttpPost]
  2875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2876. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2877. {
  2878. try
  2879. {
  2880. #region 参数验证
  2881. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2882. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2883. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2884. #region 页面操作权限验证
  2885. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2886. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2887. #endregion
  2888. #endregion
  2889. var _view = new Grp_CreditCardPaymentView();
  2890. var clientNameList = GetSimplClientList(_dto.DiId);
  2891. #region 费用清单
  2892. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2893. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2894. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2895. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2896. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2897. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2898. /*
  2899. * 76://酒店预订
  2900. */
  2901. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2902. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2903. /*
  2904. * 79://车/导游地接
  2905. */
  2906. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2907. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2908. /*
  2909. * 80: //签证
  2910. */
  2911. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2912. /*
  2913. *81: //邀请/公务活动
  2914. */
  2915. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2916. /*
  2917. * 82: //团组客户保险
  2918. */
  2919. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2920. /*
  2921. * Lable = 85 机票预订
  2922. */
  2923. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2924. /*
  2925. * 85 机票预定
  2926. */
  2927. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2928. /*
  2929. * 98 其他款项
  2930. */
  2931. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2932. /*
  2933. * 285:收款退还
  2934. */
  2935. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2936. /*
  2937. * 1015: //超支费用
  2938. */
  2939. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2940. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2941. /*
  2942. * 币种信息
  2943. */
  2944. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2945. /*
  2946. * 车/导游地接 费用类型
  2947. */
  2948. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2949. /*
  2950. * 车/导游地接 费用类型
  2951. */
  2952. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2953. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2954. /*
  2955. * 用户信息
  2956. */
  2957. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2958. /*
  2959. * 费用模块
  2960. */
  2961. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2962. string priceModule = string.Empty;
  2963. if (sdPriceName != null)
  2964. {
  2965. priceModule = sdPriceName.Name;
  2966. }
  2967. /*
  2968. * 成本信息
  2969. */
  2970. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2971. decimal _groupRate = 0.0000M;
  2972. string _groupCurrencyCode = "-";
  2973. if (groupCost != null)
  2974. {
  2975. _groupRate = groupCost.Rate;
  2976. if (int.TryParse(groupCost.Currency, out int _currency))
  2977. {
  2978. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2979. }
  2980. else _groupCurrencyCode = groupCost.Currency;
  2981. }
  2982. string costContentSql = $"Select * From Grp_GroupCost";
  2983. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2984. //处理日期为空的天数
  2985. for (int i = 0; i < groupCostDetails.Count; i++)
  2986. if (i != 0)
  2987. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2988. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2989. /*
  2990. * 处理详情数据
  2991. */
  2992. foreach (var entity in entityList)
  2993. {
  2994. var _detail = new Grp_CreditCardPaymentDetailView
  2995. {
  2996. Id = entity.Id,
  2997. PriceName = priceModule,
  2998. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  2999. };
  3000. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3001. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3002. //处理金额
  3003. if (entity.CTable == 1015)
  3004. {
  3005. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3006. if (czInfo != null)
  3007. {
  3008. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3009. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3010. }
  3011. }
  3012. /*
  3013. * 应付款金额
  3014. */
  3015. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3016. string PaymentCurrency_WaitPay = "Unknown";
  3017. string hotelCurrncyCode = "Unknown";
  3018. string hotelCurrncyName = "Unknown";
  3019. if (sdPaymentCurrency_WaitPay != null)
  3020. {
  3021. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3022. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3023. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3024. if (hotelCurrncyCode.Equals("CNY"))
  3025. {
  3026. entity.DayRate = 1.0000M;
  3027. }
  3028. }
  3029. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3030. /*
  3031. * 此次付款金额
  3032. */
  3033. decimal CurrPayStr = 0.00M,
  3034. OriginalCurrPay = 0.00M;
  3035. if (entity.PayPercentage == 0)
  3036. {
  3037. if (entity.PayThenMoney != 0)
  3038. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3039. }
  3040. else
  3041. {
  3042. if (entity.PayMoney != 0)
  3043. {
  3044. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3045. }
  3046. }
  3047. //if (_dto.Label == 79)
  3048. //{
  3049. // string original = string.Empty;
  3050. // if (hotelCurrncyCode.Equals("CNY"))
  3051. // {
  3052. // OriginalCurrPay = CurrPayStr;
  3053. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3054. // }
  3055. // else
  3056. // {
  3057. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3058. // //760 EUR(7600.00 CNY)
  3059. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3060. // }
  3061. //}
  3062. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3063. string original = string.Empty;
  3064. if (hotelCurrncyCode.Equals("CNY"))
  3065. {
  3066. OriginalCurrPay = CurrPayStr;
  3067. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3068. }
  3069. else
  3070. {
  3071. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3072. //760 EUR(7600.00 CNY)
  3073. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3074. }
  3075. /*
  3076. * 剩余尾款
  3077. */
  3078. decimal BalanceStr = 0;
  3079. if (CurrPayStr != 0)
  3080. {
  3081. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3082. BalanceStr = 0;
  3083. else
  3084. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3085. }
  3086. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3087. /*
  3088. * Bus名称
  3089. */
  3090. _detail.BusName = "待增加";
  3091. /*
  3092. *费用所属
  3093. */
  3094. switch (entity.CTable)
  3095. {
  3096. case 76://酒店预订
  3097. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3098. if (hotelReservations != null)
  3099. {
  3100. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3101. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3102. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3103. string roomFeeStr = "", roomFeestr1 = "";
  3104. //是否比较房型价格
  3105. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3106. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3107. roomFeeStr += $"<br/>";
  3108. var roomTotal = 0.00M;
  3109. if (hotelReservations.SingleRoomPrice > 0)
  3110. {
  3111. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3112. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3113. //__isSingle = true;
  3114. roomTotal += fee;
  3115. }
  3116. if (hotelReservations.DoubleRoomPrice > 0)
  3117. {
  3118. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3119. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3120. // __isDouble = true;
  3121. roomTotal += fee;
  3122. }
  3123. if (hotelReservations.SuiteRoomPrice > 0)
  3124. {
  3125. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3126. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3127. //__isSuite = true;
  3128. roomTotal += fee;
  3129. }
  3130. if (hotelReservations.OtherRoomPrice > 0)
  3131. {
  3132. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3133. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3134. //__isOther = true;
  3135. roomTotal += fee;
  3136. }
  3137. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3138. else roomFeeStr += " 0.00 * 0";
  3139. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3140. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3141. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3142. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3143. /*
  3144. * 费用类型
  3145. * 1:房费
  3146. * 2:早餐
  3147. * 3:地税
  3148. * 4:城市税
  3149. * </summary>
  3150. */
  3151. //地税
  3152. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3153. if (governmentRentData != null)
  3154. {
  3155. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3156. governmentRentFee = governmentRentData.Price;
  3157. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3158. if (governmentRentCurrData != null)
  3159. {
  3160. governmentRentCode = governmentRentCurrData.Name;
  3161. governmentRentName = $"({governmentRentCurrData.Remark})";
  3162. }
  3163. }
  3164. //城市税
  3165. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3166. if (cityTaxData != null)
  3167. {
  3168. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3169. cityTaxFee = cityTaxData.Price;
  3170. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3171. if (cityTaxCurrData != null)
  3172. {
  3173. cityTaxCode = cityTaxCurrData.Name;
  3174. cityTaxName = $"({cityTaxCurrData.Remark})";
  3175. }
  3176. }
  3177. //酒店早餐
  3178. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3179. if (breakfastData != null)
  3180. {
  3181. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3182. breakfastFee = breakfastData.Price;
  3183. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3184. if (breakfastCurrData != null)
  3185. {
  3186. breakfastCode = breakfastCurrData.Name;
  3187. breakfastName = $"({breakfastCurrData.Remark})";
  3188. }
  3189. }
  3190. //房间费用
  3191. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3192. if (roomData != null)
  3193. {
  3194. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3195. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3196. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3197. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3198. roomFee = roomData.Price;
  3199. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3200. if (roomCurrData != null)
  3201. {
  3202. roomCode = roomCurrData.Name;
  3203. roomName = $"({roomCurrData.Remark})";
  3204. }
  3205. }
  3206. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3207. string hotelCostStr = "";
  3208. decimal hotelCsotTotal = 0.00M;
  3209. if (groupCost != null)
  3210. {
  3211. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3212. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3213. }
  3214. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3215. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3216. string hotelCost_day = "";
  3217. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3218. foreach (var item in hotelCostDetails1)
  3219. {
  3220. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3221. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3222. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3223. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3224. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3225. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3226. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3227. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3228. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3229. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3230. hotelCost_day += @$"<br/>";
  3231. }
  3232. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3233. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3234. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3235. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3236. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3237. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3238. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3239. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3240. $"房间说明: {hotelReservations.Remark} <br/>" +
  3241. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3242. $"{hotelBreakfastStr}" +
  3243. $"{hotelGovernmentRentStr}" +
  3244. $"{hotelCityTaxStr}";
  3245. _detail.PriceNameContent = hotelReservations.HotelName;
  3246. }
  3247. break;
  3248. case 79://车/导游地接
  3249. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3250. if (touristGuideGroundReservations != null)
  3251. {
  3252. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3253. {
  3254. _detail.BusName = touristGuideGroundReservations.BusName;
  3255. }
  3256. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3257. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3258. //if (isInt)
  3259. //{
  3260. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3261. // if (cityInfo != null)
  3262. // {
  3263. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3264. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3265. // if (carFeeItem != null)
  3266. // {
  3267. // nameContent += $@"({carFeeItem.Name})";
  3268. // }
  3269. // _detail.PriceNameContent = nameContent;
  3270. // }
  3271. //}
  3272. //else
  3273. //{
  3274. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3275. //}
  3276. var touristGuideGroundReservationsContents =
  3277. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3278. var opContent_sb = new StringBuilder();
  3279. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3280. opContent_sb.AppendLine(contetTitle);
  3281. foreach (var item in touristGuideGroundReservationsContents)
  3282. {
  3283. string typeName = "Unknown";
  3284. string carCurrencyCode = "Unknown";
  3285. string carCurrencyName = "Unknown";
  3286. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3287. if (carTypeData != null) typeName = carTypeData.Name;
  3288. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3289. if (currencyData != null)
  3290. {
  3291. carCurrencyCode = currencyData.Name;
  3292. carCurrencyName = currencyData.Remark;
  3293. }
  3294. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3295. bool IsCurrencyAgreement = false;
  3296. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3297. string opCostStr = string.Empty;
  3298. decimal opCostTypePrice = 0.00M;
  3299. #region 处理成本各项费用
  3300. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3301. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3302. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3303. costOPFeeCNY = 0.00M, //团组成本 op费用
  3304. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3305. if (opCost.Count > 0)
  3306. {
  3307. switch (item.SId)
  3308. {
  3309. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3310. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3311. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3312. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3313. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3314. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3315. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3316. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3317. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3318. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3319. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3320. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3321. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3322. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3323. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3324. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3325. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3326. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3327. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3328. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3329. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3330. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3331. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3332. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3333. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3334. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3335. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3336. }
  3337. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3338. costOPFeeCNY = opCostTypePrice * _groupRate;
  3339. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3340. }
  3341. #endregion
  3342. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3343. aduitOPFeeCNY = item.Price * entity.DayRate;
  3344. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3345. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3346. $"{opTypeStr} {opCostStr}<br/>" +
  3347. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3348. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3349. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3350. {
  3351. if (IsCurrencyAgreement)
  3352. {
  3353. if (item.Price > opCostTypePrice)
  3354. {
  3355. opContent_sb.Append("<span style='color:red;'>");
  3356. opContent_sb.Append(opContent);
  3357. opContent_sb.Append("</span>");
  3358. opContent_sb.AppendLine();
  3359. }
  3360. else
  3361. {
  3362. opContent_sb.Append(opContent);
  3363. opContent_sb.AppendLine();
  3364. }
  3365. }
  3366. else
  3367. {
  3368. //验证是否超成本 按付款比例计算
  3369. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3370. {
  3371. opContent_sb.Append("<span style='color:red;'>");
  3372. opContent_sb.Append(opContent);
  3373. opContent_sb.Append("</span>");
  3374. opContent_sb.AppendLine();
  3375. }
  3376. else
  3377. {
  3378. opContent_sb.Append(opContent);
  3379. opContent_sb.AppendLine();
  3380. }
  3381. }
  3382. }
  3383. else
  3384. {
  3385. opContent_sb.Append(opContent);
  3386. opContent_sb.AppendLine();
  3387. }
  3388. }
  3389. _detail.PriceMsgContent = opContent_sb.ToString();
  3390. }
  3391. break;
  3392. case 80: //签证
  3393. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3394. if (visaInfo != null)
  3395. {
  3396. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3397. _detail.PriceNameContent = visaInfo.VisaDescription;
  3398. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3399. }
  3400. break;
  3401. case 81: //邀请/公务活动
  3402. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3403. if (_ioa != null)
  3404. {
  3405. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3406. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3407. sendCurrName = "Unknown", //快递费用币种 Name
  3408. sendCurrCode = "Unknown", //快递费用币种 Code
  3409. eventsCurrName = "Unknown", //公务活动费币种 Name
  3410. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3411. translateCurrName = "Unknown", //公务翻译费 Name
  3412. translateCurrCode = "Unknown"; //公务翻译费 Code
  3413. #region 处理费用币种
  3414. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3415. if (inviteCurrData != null)
  3416. {
  3417. inviteCurrName = inviteCurrData.Remark;
  3418. inviteCurrCode = inviteCurrData.Name;
  3419. }
  3420. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3421. if (sendCurrData != null)
  3422. {
  3423. sendCurrName = sendCurrData.Remark;
  3424. sendCurrCode = sendCurrData.Name;
  3425. }
  3426. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3427. if (eventsCurrData != null)
  3428. {
  3429. eventsCurrName = eventsCurrData.Remark;
  3430. eventsCurrCode = eventsCurrData.Name;
  3431. }
  3432. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3433. if (translateCurrData != null)
  3434. {
  3435. translateCurrName = translateCurrData.Remark;
  3436. translateCurrCode = translateCurrData.Name;
  3437. }
  3438. #endregion
  3439. _detail.PriceNameContent = _ioa.InviterArea;
  3440. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3441. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3442. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3443. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3444. $@"备注:" + _ioa.Remark + "<br/>";
  3445. }
  3446. break;
  3447. case 82: //团组客户保险
  3448. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3449. if (customers != null)
  3450. {
  3451. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3452. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3453. }
  3454. break;
  3455. case 85: //机票预订
  3456. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3457. if (jpRes != null)
  3458. {
  3459. string FlightsDescription = jpRes.FlightsDescription;
  3460. string PriceDescription = jpRes.PriceDescription;
  3461. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3462. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3463. }
  3464. break;
  3465. case 98://其他款项
  3466. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3467. if (gdpRes != null)
  3468. {
  3469. //var urlBase = $"http://132.232.92.186:24/Office/GrpFile/http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  3470. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  3471. //{
  3472. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  3473. //}
  3474. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3475. _detail.PriceNameContent = gdpRes.PriceName;
  3476. }
  3477. break;
  3478. case 285://收款退还
  3479. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3480. if (refundAndOtherMoney != null)
  3481. {
  3482. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3483. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3484. }
  3485. break;
  3486. case 751://酒店早餐
  3487. break;
  3488. case 1015://超支费用
  3489. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3490. if (groupExtraCost != null)
  3491. {
  3492. _detail.PriceNameContent = groupExtraCost.PriceName;
  3493. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3494. }
  3495. break;
  3496. default:
  3497. break;
  3498. }
  3499. /*
  3500. * 申请人
  3501. */
  3502. string operatorName = " - ";
  3503. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3504. if (_opUser != null)
  3505. {
  3506. operatorName = _opUser.CnName;
  3507. }
  3508. _detail.OperatorName = operatorName;
  3509. /*
  3510. * 审核人
  3511. */
  3512. string auditOperatorName = " - ";
  3513. if (entity.IsAuditGM != 0)
  3514. {
  3515. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3516. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3517. else
  3518. {
  3519. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3520. if (_adUser != null)
  3521. {
  3522. auditOperatorName = _adUser.CnName;
  3523. }
  3524. }
  3525. }
  3526. _detail.AuditOperatorName = auditOperatorName;
  3527. /*
  3528. * 超预算比例
  3529. */
  3530. string overBudgetStr = "";
  3531. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3532. else if (entity.ExceedBudget == 0)
  3533. {
  3534. if (entity.CTable == 76 || entity.CTable == 79)
  3535. {
  3536. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3537. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3538. }
  3539. else
  3540. {
  3541. overBudgetStr = "未超预算";
  3542. }
  3543. }
  3544. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3545. _detail.OverBudget = overBudgetStr;
  3546. decimal auditFee = 0.00M; //已审核金额 人名币
  3547. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3548. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3549. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3550. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3551. {
  3552. auditedFeeOriginal = entity.PayMoney;
  3553. auditFee = CurrPayStr;
  3554. }
  3555. else if (entity.IsAuditGM == 0)
  3556. {
  3557. unAuditFeeCNY = CurrPayStr;
  3558. unAuditFeeOriginal = OriginalCurrPay;
  3559. OriginalCurrPay = 0.00M;
  3560. }
  3561. /*
  3562. * 费用总计
  3563. */
  3564. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3565. {
  3566. CurrencyId = entity.PaymentCurrency,
  3567. CurrencyName = PaymentCurrency_WaitPay,
  3568. AmountPayable = entity.PayMoney,
  3569. ThisPayment = OriginalCurrPay,
  3570. BalancePayment = BalanceStr,
  3571. AuditedFunds = auditFee,
  3572. AuditedFundsOriginal = auditedFeeOriginal,
  3573. UnAuditFundsCNY = unAuditFeeCNY,
  3574. UnAuditFundsOriginal = unAuditFeeOriginal
  3575. });
  3576. _detail.IsAuditGM = entity.IsAuditGM;
  3577. detailList.Add(_detail);
  3578. }
  3579. #endregion
  3580. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3581. /*
  3582. * 下方描述处理
  3583. */
  3584. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3585. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3586. if (ccpCurrencyPrice != null)
  3587. {
  3588. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3589. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3590. }
  3591. else
  3592. {
  3593. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3594. }
  3595. string amountPayableStr = string.Format(@"应付款总金额: ");
  3596. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3597. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3598. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3599. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3600. foreach (var item in nonDuplicat)
  3601. {
  3602. var currencyName = item.CurrencyName;
  3603. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3604. if (strs.Count > 0)
  3605. {
  3606. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3607. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3608. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3609. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3610. //单独处理此次付款金额
  3611. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3612. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3613. //单独处理已审核费用
  3614. //if (item.CurrencyId == 836) //人民币
  3615. //{
  3616. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3617. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3618. //}
  3619. //else
  3620. //{
  3621. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3622. //}
  3623. if (currencyName.Equals("CNY"))
  3624. {
  3625. //已审核费用
  3626. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3627. //未审核费用
  3628. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3629. }
  3630. else
  3631. {
  3632. //已审核费用
  3633. 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"));
  3634. //未审核费用
  3635. 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"));
  3636. }
  3637. }
  3638. }
  3639. _view.TotalStr1 = amountPayableStr[..^1];
  3640. _view.TotalStr2 = thisPaymentStr[..^1];
  3641. _view.TotalStr3 = balancePaymentStr[..^1];
  3642. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3643. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3644. var _view1 = new
  3645. {
  3646. PageFuncAuth = pageFunAuthView,
  3647. Data = _view
  3648. };
  3649. return Ok(JsonView(_view1));
  3650. }
  3651. catch (Exception ex)
  3652. {
  3653. return Ok(JsonView(false, ex.Message));
  3654. }
  3655. }
  3656. /// <summary>
  3657. /// 费用审核
  3658. /// 修改团组费用审核状态
  3659. /// </summary>
  3660. /// <param name="_dto">参数Json字符串</param>
  3661. /// <returns></returns>
  3662. [HttpPost]
  3663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3664. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3665. {
  3666. #region 参数验证
  3667. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3668. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3669. #endregion
  3670. #region 页面操作权限验证
  3671. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3672. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3673. #endregion
  3674. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3675. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3676. DateTime dtNow = DateTime.Now;
  3677. _groupRepository.BeginTran();
  3678. int rst = 0;
  3679. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3680. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3681. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3682. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3683. var msgDatas = new List<dynamic>();
  3684. var dic_ccp_user = new Dictionary<int, int>() { };
  3685. foreach (var item in idList)
  3686. {
  3687. int CreditId = int.Parse(item);
  3688. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3689. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3690. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3691. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3692. .Where(s => s.Id == CreditId)
  3693. .ExecuteCommandAsync();
  3694. if (result < 1)
  3695. {
  3696. rst = -1;
  3697. _groupRepository.RollbackTran();
  3698. return Ok(JsonView(false, "操作失败并回滚!"));
  3699. }
  3700. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3701. if (creditData != null)
  3702. {
  3703. #region 应用通知配置
  3704. try
  3705. {
  3706. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3707. }
  3708. catch (Exception ex)
  3709. {
  3710. }
  3711. #endregion
  3712. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3713. string groupNameStr = string.Empty;
  3714. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3715. if (groupData != null) groupNameStr = groupData.TeamName;
  3716. string creditTypeStr = string.Empty;
  3717. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3718. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3719. string creditCurrency = string.Empty;
  3720. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3721. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3722. if (creditCurrency.Equals("CNY"))
  3723. {
  3724. creditData.DayRate = 1.0000M;
  3725. }
  3726. if (creditData.PayPercentage == 0.00M)
  3727. {
  3728. creditData.PayPercentage = 100M;
  3729. }
  3730. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3731. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3732. string msgContent = "";
  3733. if (creditCurrency.Equals("CNY"))
  3734. {
  3735. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3736. }
  3737. else
  3738. {
  3739. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3740. }
  3741. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3742. }
  3743. }
  3744. if (rst == 0)
  3745. {
  3746. _groupRepository.CommitTran();
  3747. foreach (var item in msgDatas)
  3748. {
  3749. //发送消息
  3750. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3751. }
  3752. #region 应用推送
  3753. try
  3754. {
  3755. foreach (var ccpId in dic_ccp_user.Keys)
  3756. {
  3757. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3758. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3759. }
  3760. }
  3761. catch (Exception)
  3762. {
  3763. }
  3764. #endregion
  3765. return Ok(JsonView(true, "操作成功!"));
  3766. }
  3767. return Ok(JsonView(false, "操作失败!"));
  3768. }
  3769. /// <summary>
  3770. /// 费用审核
  3771. /// 其他款项 文件下载
  3772. /// </summary>
  3773. /// <param name="id">其他款项 主键编号</param>
  3774. /// <returns></returns>
  3775. [HttpGet("{id}")]
  3776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3777. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1,int.MaxValue,ErrorMessage ="请传入有效的ID")]int id)
  3778. {
  3779. //网站域名
  3780. const string baseUrl = "http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  3781. var otherInfo = await _decreasePaymentsRep._sqlSugar
  3782. .Queryable<Grp_DecreasePayments>()
  3783. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  3784. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  3785. .Select((x, y) => new
  3786. {
  3787. x.Id,
  3788. x.FilePath
  3789. })
  3790. .FirstAsync();
  3791. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  3792. {
  3793. var url = $"{baseUrl}{otherInfo.FilePath}";
  3794. return Ok(JsonView(true, "操作成功!", url));
  3795. }
  3796. return Ok(JsonView(false, "暂无附件"));
  3797. }
  3798. #endregion
  3799. #region 机票费用录入
  3800. /// <summary>
  3801. /// 机票录入当前登录人可操作团组
  3802. /// </summary>
  3803. /// <param name="dto"></param>
  3804. /// <returns></returns>
  3805. [HttpPost]
  3806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3807. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3808. {
  3809. try
  3810. {
  3811. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3812. if (groupData.Code != 0)
  3813. {
  3814. return Ok(JsonView(false, groupData.Msg));
  3815. }
  3816. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3817. }
  3818. catch (Exception ex)
  3819. {
  3820. return Ok(JsonView(false, ex.Message));
  3821. }
  3822. }
  3823. /// <summary>
  3824. /// 机票费用录入列表
  3825. /// </summary>
  3826. /// <param name="dto"></param>
  3827. /// <returns></returns>
  3828. [HttpPost]
  3829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3830. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3831. {
  3832. try
  3833. {
  3834. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3835. if (groupData.Code != 0)
  3836. {
  3837. return Ok(JsonView(false, groupData.Msg));
  3838. }
  3839. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3840. }
  3841. catch (Exception ex)
  3842. {
  3843. return Ok(JsonView(false, ex.Message));
  3844. throw;
  3845. }
  3846. }
  3847. /// <summary>
  3848. /// 根据id查询费用录入信息
  3849. /// </summary>
  3850. /// <param name="dto"></param>
  3851. /// <returns></returns>
  3852. [HttpPost]
  3853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3854. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3855. {
  3856. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3857. if (groupData.Code != 0)
  3858. {
  3859. return Ok(JsonView(false, groupData.Msg));
  3860. }
  3861. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3862. }
  3863. /// <summary>
  3864. /// 机票费用录入操作(Status:1.新增,2.修改)
  3865. /// </summary>
  3866. /// <param name="dto"></param>
  3867. /// <returns></returns>
  3868. [HttpPost]
  3869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3870. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3871. {
  3872. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3873. if (groupData.Code != 0)
  3874. {
  3875. return Ok(JsonView(false, groupData.Msg));
  3876. }
  3877. #region 应用推送
  3878. try
  3879. {
  3880. var diId = dto.AirTicketResOpData.DiId;
  3881. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3882. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3883. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3884. //自动审核
  3885. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3886. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3887. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3888. $"GroupId:{diId};airId:{dataId};",
  3889. status,
  3890. auditMsg);
  3891. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3892. //2024-10-21 新增LZ UID
  3893. var userIds = new List<int>() { 21 };
  3894. string title = $"系统通知";
  3895. string content = "";
  3896. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3897. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3898. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3899. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3900. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3901. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3902. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3903. }
  3904. catch (Exception ex)
  3905. {
  3906. }
  3907. #endregion
  3908. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3909. }
  3910. /// <summary>
  3911. /// 机票费用自动审核 AI识别方式
  3912. /// </summary>
  3913. /// <returns></returns>
  3914. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3915. {
  3916. var ecoTypeIds = new List<int>() {
  3917. 459, //超经舱
  3918. 460, //经济舱
  3919. 1430, //公务舱(实际经济舱)
  3920. 1432, //头等舱(实际经济舱)
  3921. };
  3922. var bizTypeIds = new List<int>() {
  3923. 457, //头等舱
  3924. 458, //公务舱
  3925. 1431, //头等舱(实际公务舱)
  3926. };
  3927. var auditFeeTypeIds = new List<int>() { };
  3928. auditFeeTypeIds.AddRange(ecoTypeIds);
  3929. auditFeeTypeIds.AddRange(bizTypeIds);
  3930. int currModule = 85;
  3931. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3932. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3933. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3934. .Select((x, y) => new
  3935. {
  3936. x.Id,
  3937. CcpId = y.Id,
  3938. x.FlightsDate,
  3939. x.PrePrice,
  3940. x.CType,
  3941. x.ClientNum,
  3942. x.DIId
  3943. })
  3944. .FirstAsync();
  3945. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3946. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3947. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3948. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3949. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3950. var groupCostContents = await _sqlSugar
  3951. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3952. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3953. .ToListAsync();
  3954. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3955. //处理 成本详细信息日期为空 填装费用信息
  3956. var airFeeLabel = new StringBuilder();
  3957. airFeeLabel.AppendLine("费用成本:");
  3958. for (int i = 0; i < groupCostContents.Count; i++)
  3959. {
  3960. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3961. {
  3962. int index = i - 1;
  3963. if (index >= 0)
  3964. {
  3965. groupCostContents[i].Date = groupCostContents[index].Date;
  3966. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3967. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3968. }
  3969. }
  3970. else
  3971. {
  3972. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3973. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3974. }
  3975. var item = groupCostContents[i];
  3976. airFeeLabel.AppendLine($"{item.Date}");
  3977. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3978. }
  3979. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3980. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3981. //访问Kimi AI 返回价格结果
  3982. var msgs = new List<SeedMessages>()
  3983. {
  3984. new ()
  3985. {
  3986. Role = KimiRole.user,
  3987. Content = airFeeLabel.ToString()
  3988. }
  3989. };
  3990. var client = new KiMiApiClient();
  3991. var kimiApiResult = await client.SeedMessage(msgs);
  3992. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3993. string clients = kimiApiResult_JObject["content"].ToString();
  3994. decimal ecoPri_kimiAI = 0.00M,
  3995. bizPri_kimiAI = 0.00M;
  3996. //单个价格: 经济舱价格
  3997. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3998. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3999. if (clients.Contains('/'))
  4000. {
  4001. var priArray = clients.Split('/');
  4002. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4003. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4004. }
  4005. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4006. var isAutoAudit = false;
  4007. //价格验证处理
  4008. //经济舱
  4009. if (ecoTypeIds.Contains(airInfo.CType))
  4010. {
  4011. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4012. }
  4013. //公务舱
  4014. else if (bizTypeIds.Contains(airInfo.CType))
  4015. {
  4016. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4017. }
  4018. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4019. //是否执行自动审核
  4020. if (isAutoAudit)
  4021. {
  4022. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4023. .SetColumns(x => x.IsAuditGM == 3)
  4024. .SetColumns(x => x.AuditGMOperate == 4)
  4025. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4026. .Where(x => x.Id == airInfo.CcpId)
  4027. .ExecuteCommandAsync();
  4028. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4029. }
  4030. return (false, "当前费用超过成本费用,不可自动审核!");
  4031. }
  4032. /// <summary>
  4033. /// 机票费用录入
  4034. /// 自动审核测试 - AI 识别
  4035. /// </summary>
  4036. /// <param name="groupId"></param>
  4037. /// <param name="Id"></param>
  4038. /// <returns></returns>
  4039. [HttpPost]
  4040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4041. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4042. {
  4043. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4044. return Ok(JsonView(status, msg));
  4045. }
  4046. /// <summary>
  4047. /// 根据舱位类型查询接团客户名单信息
  4048. /// </summary>
  4049. /// <param name="dto"></param>
  4050. /// <returns></returns>
  4051. [HttpPost]
  4052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4053. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4054. {
  4055. try
  4056. {
  4057. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4058. if (crm_Groups.Count != 0)
  4059. {
  4060. var Customer = new List<dynamic>();
  4061. foreach (var item in crm_Groups)
  4062. {
  4063. var data = new
  4064. {
  4065. item.Id,
  4066. item.Pinyin,
  4067. Name = item.LastName + item.FirstName
  4068. };
  4069. Customer.Add(data);
  4070. }
  4071. return Ok(JsonView(true, "查询成功!", Customer));
  4072. }
  4073. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4074. }
  4075. catch (Exception ex)
  4076. {
  4077. return Ok(JsonView(false, "程序错误!"));
  4078. throw;
  4079. }
  4080. }
  4081. /// <summary>
  4082. /// 根据团号获取客户信息
  4083. /// </summary>
  4084. /// <param name="dto"></param>
  4085. /// <returns></returns>
  4086. [HttpPost]
  4087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4088. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4089. {
  4090. var jw = JsonView(false);
  4091. if (dto.DIID < 1)
  4092. {
  4093. jw.Msg += "请输入正确的diid";
  4094. return Ok(jw);
  4095. }
  4096. var arr = GetSimplClientList(dto.DIID);
  4097. jw = JsonView(true, "获取成功!", arr);
  4098. return Ok(jw);
  4099. }
  4100. private List<SimplClientInfo> GetSimplClientList(int diId)
  4101. {
  4102. 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);
  4103. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4104. foreach (var item in arr)
  4105. {
  4106. EncryptionProcessor.DecryptProperties(item);
  4107. }
  4108. return arr;
  4109. }
  4110. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4111. {
  4112. string result = origin;
  4113. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4114. {
  4115. string[] temparr = origin.Split(',');
  4116. string fistrStr = temparr[0];
  4117. int count = temparr.Length;
  4118. bool success = int.TryParse(fistrStr, out int tempId);
  4119. if (success)
  4120. {
  4121. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4122. if (tempInfo != null)
  4123. {
  4124. if (count > 1)
  4125. {
  4126. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4127. }
  4128. else
  4129. {
  4130. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4131. }
  4132. }
  4133. }
  4134. }
  4135. return result;
  4136. }
  4137. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4138. {
  4139. string result = origin;
  4140. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4141. {
  4142. string[] temparr = origin.Split(',');
  4143. result = "";
  4144. foreach (var item in temparr)
  4145. {
  4146. bool success = int.TryParse(item, out int tempId);
  4147. if (success)
  4148. {
  4149. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4150. if (tempInfo != null)
  4151. {
  4152. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4153. }
  4154. }
  4155. }
  4156. }
  4157. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4158. return result;
  4159. }
  4160. /// <summary>
  4161. /// 机票费用录入,删除
  4162. /// </summary>
  4163. /// <param name="dto"></param>
  4164. /// <returns></returns>
  4165. [HttpPost]
  4166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4167. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4168. {
  4169. try
  4170. {
  4171. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4172. if (res)
  4173. {
  4174. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4175. {
  4176. IsDel = 1,
  4177. DeleteUserId = dto.DeleteUserId,
  4178. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4179. }).ExecuteCommandAsync();
  4180. return Ok(JsonView(true, "删除成功!"));
  4181. }
  4182. return Ok(JsonView(false, "删除失败!"));
  4183. }
  4184. catch (Exception ex)
  4185. {
  4186. return Ok(JsonView(false, "程序错误!"));
  4187. throw;
  4188. }
  4189. }
  4190. /// <summary>
  4191. /// 导出机票录入报表
  4192. /// </summary>
  4193. /// <param name="dto"></param>
  4194. /// <returns></returns>
  4195. [HttpPost]
  4196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4197. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4198. {
  4199. try
  4200. {
  4201. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4202. if (groupData.Code != 0)
  4203. {
  4204. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4205. }
  4206. else
  4207. {
  4208. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4209. if (AirTicketReservations.Count != 0)
  4210. {
  4211. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4212. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4213. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4214. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4215. var designer = new WorkbookDesigner
  4216. {
  4217. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4218. };
  4219. decimal countCost = 0;
  4220. foreach (var item in AirTicketReservations)
  4221. {
  4222. #region 处理客人姓名
  4223. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4224. item.ClientName = clientNames;
  4225. #endregion
  4226. if (item.BankType == "其他")
  4227. {
  4228. item.BankNo = "--";
  4229. }
  4230. else
  4231. {
  4232. if (!string.IsNullOrEmpty(item.BankType))
  4233. {
  4234. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  4235. }
  4236. }
  4237. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4238. item.Price = System.Decimal.Round(item.Price, 2);
  4239. countCost += Convert.ToDecimal(item.Price);
  4240. }
  4241. designer.SetDataSource("Export", AirTicketReservations);
  4242. designer.SetDataSource("ExportDiCode", diCode);
  4243. designer.SetDataSource("ExportDiName", diName);
  4244. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4245. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4246. designer.Process();
  4247. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4248. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4249. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4250. return Ok(JsonView(true, "成功", url = rst));
  4251. }
  4252. else
  4253. {
  4254. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4255. }
  4256. }
  4257. }
  4258. catch (Exception ex)
  4259. {
  4260. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4261. throw;
  4262. }
  4263. }
  4264. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  4265. /// <summary>
  4266. /// 行程单导出
  4267. /// </summary>
  4268. /// <param name="dto"></param>
  4269. /// <returns></returns>
  4270. [HttpPost]
  4271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4272. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4273. {
  4274. try
  4275. {
  4276. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4277. if (groupData.Code != 0)
  4278. {
  4279. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4280. }
  4281. else
  4282. {
  4283. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4284. if (dto.Language == "CN")
  4285. {
  4286. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4287. var builder = new DocumentBuilder(doc);
  4288. int tableIndex = 0;//表格索引
  4289. //得到文档中的第一个表格
  4290. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4291. foreach (var item in _AirTicketReservations)
  4292. {
  4293. #region 处理固定数据
  4294. string[] FlightsCode = item.FlightsCode.Split('/');
  4295. if (FlightsCode.Length != 0)
  4296. {
  4297. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4298. if (_AirCompany != null)
  4299. {
  4300. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4301. }
  4302. else
  4303. {
  4304. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4305. }
  4306. }
  4307. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4308. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4309. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4310. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4311. string name = "";
  4312. foreach (string clientName in nameArray)
  4313. {
  4314. if (!name.Contains(clientName))
  4315. {
  4316. name += clientName + ",";
  4317. }
  4318. }
  4319. if (!string.IsNullOrWhiteSpace(name))
  4320. {
  4321. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4322. }
  4323. else
  4324. {
  4325. table.Range.Bookmarks["ClientName"].Text = "--";
  4326. }
  4327. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4328. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4329. table.Range.Bookmarks["JointTicket"].Text = "--";
  4330. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4331. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4332. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4333. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4334. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4335. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4336. #endregion
  4337. #region 循环数据处理
  4338. var airs = new List<AirInfo>();
  4339. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4340. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4341. for (int i = 0; i < FlightsCode.Length; i++)
  4342. {
  4343. var air = new AirInfo();
  4344. string[] tempstr = DayArray[i]
  4345. .Replace("\r\n", string.Empty)
  4346. .Replace("\\r\\n", string.Empty)
  4347. .TrimStart().TrimEnd()
  4348. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4349. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4350. string starCity = "";
  4351. if (star_Three != null)
  4352. {
  4353. starCity = star_Three.AirPort;
  4354. }
  4355. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4356. string EndCity = "";
  4357. if (End_Three != null)
  4358. {
  4359. EndCity = End_Three.AirPort;
  4360. }
  4361. air.Destination = starCity + "/" + EndCity;
  4362. air.Flight = FlightsCode[i];
  4363. air.SeatingClass = item.CTypeName;
  4364. string dateTime = tempstr[2];
  4365. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4366. air.FlightDate = DateTemp;
  4367. air.DepartureTime = tempstr[5];
  4368. air.LandingTime = tempstr[6];
  4369. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4370. air.TicketStatus = "--";
  4371. air.Luggage = "--";
  4372. air.DepartureTerminal = "--";
  4373. air.LandingTerminal = "--";
  4374. airs.Add(air);
  4375. }
  4376. int row = 13;
  4377. for (int i = 0; i < airs.Count; i++)
  4378. {
  4379. if (airs.Count > 2)
  4380. {
  4381. for (int j = 0; j < airs.Count - 2; j++)
  4382. {
  4383. var CopyRow = table.Rows[12].Clone(true);
  4384. table.Rows.Add(CopyRow);
  4385. }
  4386. }
  4387. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4388. int index = 0;
  4389. foreach (PropertyInfo property in properties)
  4390. {
  4391. string value = property.GetValue(airs[i]).ToString();
  4392. Cell ishcel0 = table.Rows[row].Cells[index];
  4393. var p = new Paragraph(doc);
  4394. string s = value;
  4395. p.AppendChild(new Run(doc, s));
  4396. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4397. ishcel0.AppendChild(p);
  4398. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4399. index++;
  4400. }
  4401. row++;
  4402. }
  4403. #endregion
  4404. var lastParagraph = new Paragraph(doc);
  4405. //第一个表格末尾加段落
  4406. table.ParentNode.InsertAfter(lastParagraph, table);
  4407. //复制第一个表格
  4408. Table cloneTable = (Table)table.Clone(true);
  4409. //在文档末尾段落后面加入复制的表格
  4410. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4411. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4412. {
  4413. int rownewsIndex = 13;
  4414. for (int i = 0; i < 2; i++)
  4415. {
  4416. var CopyRow = table.Rows[12].Clone(true);
  4417. table.Rows.RemoveAt(13);
  4418. table.Rows.Add(CopyRow);
  4419. rownewsIndex++;
  4420. }
  4421. }
  4422. else
  4423. {
  4424. table.Rows.RemoveAt(12);
  4425. }
  4426. cloneTable.Rows.RemoveAt(12);
  4427. }
  4428. if (_AirTicketReservations.Count != 0)
  4429. {
  4430. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4431. if (FlightsCode.Length != 0)
  4432. {
  4433. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4434. if (_AirCompany != null)
  4435. {
  4436. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4437. }
  4438. else
  4439. {
  4440. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4441. }
  4442. }
  4443. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4444. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4445. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4446. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4447. string name = "";
  4448. foreach (string clientName in nameArray)
  4449. {
  4450. if (!name.Contains(clientName))
  4451. {
  4452. name += clientName + ",";
  4453. }
  4454. }
  4455. if (!string.IsNullOrWhiteSpace(name))
  4456. {
  4457. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4458. }
  4459. else
  4460. {
  4461. table.Range.Bookmarks["ClientName"].Text = "--";
  4462. }
  4463. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4464. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4465. table.Range.Bookmarks["JointTicket"].Text = "--";
  4466. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4467. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4468. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4469. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4470. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4471. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4472. }
  4473. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4474. //保存合并后的文档
  4475. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4476. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4477. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4478. return Ok(JsonView(true, "成功!", rst));
  4479. }
  4480. else
  4481. {
  4482. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4483. var builder = new DocumentBuilder(doc);
  4484. int tableIndex = 0;//表格索引
  4485. //得到文档中的第一个表格
  4486. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4487. var texts = new List<string>();
  4488. foreach (var item in _AirTicketReservations)
  4489. {
  4490. string[] FlightsCode = item.FlightsCode.Split('/');
  4491. if (FlightsCode.Length != 0)
  4492. {
  4493. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4494. if (_AirCompany != null)
  4495. {
  4496. if (!transDic.ContainsKey(_AirCompany.CnName))
  4497. {
  4498. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4499. }
  4500. }
  4501. else
  4502. {
  4503. if (!transDic.ContainsKey("--"))
  4504. {
  4505. transDic.Add("--", "--");
  4506. }
  4507. }
  4508. }
  4509. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4510. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4511. string name = "";
  4512. foreach (string clientName in nameArray)
  4513. {
  4514. name += clientName + ",";
  4515. }
  4516. if (!texts.Contains(name))
  4517. {
  4518. texts.Add(name);
  4519. }
  4520. var airs = new List<AirInfo>();
  4521. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4522. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4523. for (int i = 0; i < FlightsCode.Length; i++)
  4524. {
  4525. var air = new AirInfo();
  4526. string[] tempstr = DayArray[i]
  4527. .Replace("\r\n", string.Empty)
  4528. .Replace("\\r\\n", string.Empty)
  4529. .TrimStart().TrimEnd()
  4530. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4531. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4532. if (star_Three != null)
  4533. {
  4534. if (!transDic.ContainsKey(star_Three.AirPort))
  4535. {
  4536. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4537. }
  4538. }
  4539. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4540. if (End_Three != null)
  4541. {
  4542. if (!transDic.ContainsKey(End_Three.AirPort))
  4543. {
  4544. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4545. }
  4546. }
  4547. if (!texts.Contains(item.CTypeName))
  4548. {
  4549. texts.Add(item.CTypeName);
  4550. }
  4551. }
  4552. }
  4553. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4554. if (transData.Count > 0)
  4555. {
  4556. foreach (TranslateResult item in transData)
  4557. {
  4558. if (!transDic.ContainsKey(item.Query))
  4559. {
  4560. transDic.Add(item.Query, item.Translation);
  4561. }
  4562. }
  4563. }
  4564. foreach (var item in _AirTicketReservations)
  4565. {
  4566. #region 处理固定数据
  4567. string[] FlightsCode = item.FlightsCode.Split('/');
  4568. if (FlightsCode.Length != 0)
  4569. {
  4570. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4571. if (_AirCompany != null)
  4572. {
  4573. string str = "--";
  4574. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4575. if (!string.IsNullOrEmpty(translateResult))
  4576. {
  4577. str = translateResult;
  4578. str = _airTicketResRep.Processing(str);
  4579. }
  4580. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4581. }
  4582. else
  4583. {
  4584. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4585. }
  4586. }
  4587. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4588. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4589. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4590. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4591. string names = "";
  4592. foreach (string clientName in nameArray)
  4593. {
  4594. names += clientName + ",";
  4595. }
  4596. if (!string.IsNullOrWhiteSpace(names))
  4597. {
  4598. string str = "--";
  4599. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4600. if (!string.IsNullOrEmpty(translateResult))
  4601. {
  4602. str = translateResult;
  4603. str = _airTicketResRep.Processing(str);
  4604. }
  4605. table.Range.Bookmarks["ClientName"].Text = str;
  4606. }
  4607. else
  4608. {
  4609. table.Range.Bookmarks["ClientName"].Text = "--";
  4610. }
  4611. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4612. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4613. table.Range.Bookmarks["JointTicket"].Text = "--";
  4614. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4615. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4616. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4617. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4618. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4619. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4620. #endregion
  4621. #region 循环数据处理
  4622. var airs = new List<AirInfo>();
  4623. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4624. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4625. for (int i = 0; i < FlightsCode.Length; i++)
  4626. {
  4627. var air = new AirInfo();
  4628. string[] tempstr = DayArray[i]
  4629. .Replace("\r\n", string.Empty)
  4630. .Replace("\\r\\n", string.Empty)
  4631. .TrimStart().TrimEnd()
  4632. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4633. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4634. string starCity = "";
  4635. if (star_Three != null)
  4636. {
  4637. string str2 = "--";
  4638. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4639. if (!string.IsNullOrEmpty(translateResult2))
  4640. {
  4641. str2 = translateResult2;
  4642. str2 = _airTicketResRep.Processing(str2);
  4643. }
  4644. starCity = str2;
  4645. }
  4646. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4647. string EndCity = "";
  4648. if (End_Three != null)
  4649. {
  4650. string str1 = "--";
  4651. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4652. if (!string.IsNullOrEmpty(translateResult1))
  4653. {
  4654. str1 = translateResult1;
  4655. str1 = _airTicketResRep.Processing(str1);
  4656. }
  4657. EndCity = str1;
  4658. }
  4659. air.Destination = starCity + "/" + EndCity;
  4660. air.Flight = FlightsCode[i];
  4661. string str = "--";
  4662. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4663. if (!string.IsNullOrEmpty(translateResult))
  4664. {
  4665. str = translateResult;
  4666. str = _airTicketResRep.Processing(str);
  4667. }
  4668. air.SeatingClass = str;
  4669. string dateTime = tempstr[2];
  4670. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4671. air.FlightDate = DateTemp;
  4672. air.DepartureTime = tempstr[5];
  4673. air.LandingTime = tempstr[6];
  4674. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4675. air.TicketStatus = "--";
  4676. air.Luggage = "--";
  4677. air.DepartureTerminal = "--";
  4678. air.LandingTerminal = "--";
  4679. airs.Add(air);
  4680. }
  4681. int row = 13;
  4682. for (int i = 0; i < airs.Count; i++)
  4683. {
  4684. if (airs.Count > 2)
  4685. {
  4686. for (int j = 0; j < airs.Count - 2; j++)
  4687. {
  4688. var CopyRow = table.Rows[12].Clone(true);
  4689. table.Rows.Add(CopyRow);
  4690. }
  4691. }
  4692. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4693. int index = 0;
  4694. foreach (PropertyInfo property in properties)
  4695. {
  4696. string value = property.GetValue(airs[i]).ToString();
  4697. Cell ishcel0 = table.Rows[row].Cells[index];
  4698. var p = new Paragraph(doc);
  4699. string s = value;
  4700. p.AppendChild(new Run(doc, s));
  4701. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4702. ishcel0.AppendChild(p);
  4703. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4704. //ishcel0.CellFormat.VerticalAlignment=
  4705. index++;
  4706. }
  4707. row++;
  4708. }
  4709. #endregion
  4710. var lastParagraph = new Paragraph(doc);
  4711. //第一个表格末尾加段落
  4712. table.ParentNode.InsertAfter(lastParagraph, table);
  4713. //复制第一个表格
  4714. Table cloneTable = (Table)table.Clone(true);
  4715. //在文档末尾段落后面加入复制的表格
  4716. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4717. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4718. {
  4719. int rownewsIndex = 13;
  4720. for (int i = 0; i < 2; i++)
  4721. {
  4722. var CopyRow = table.Rows[12].Clone(true);
  4723. table.Rows.RemoveAt(13);
  4724. table.Rows.Add(CopyRow);
  4725. rownewsIndex++;
  4726. }
  4727. }
  4728. else
  4729. {
  4730. table.Rows.RemoveAt(12);
  4731. }
  4732. cloneTable.Rows.RemoveAt(12);
  4733. }
  4734. if (_AirTicketReservations.Count != 0)
  4735. {
  4736. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4737. if (FlightsCode.Length != 0)
  4738. {
  4739. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4740. if (_AirCompany != null)
  4741. {
  4742. string str = "--";
  4743. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4744. if (!string.IsNullOrEmpty(translateResult))
  4745. {
  4746. str = translateResult;
  4747. str = _airTicketResRep.Processing(str);
  4748. }
  4749. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4750. }
  4751. else
  4752. {
  4753. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4754. }
  4755. }
  4756. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4757. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4758. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4759. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4760. string names = "";
  4761. foreach (string clientName in nameArray)
  4762. {
  4763. names += clientName + ",";
  4764. }
  4765. if (!string.IsNullOrWhiteSpace(names))
  4766. {
  4767. string str = "--";
  4768. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4769. if (!string.IsNullOrEmpty(translateResult))
  4770. {
  4771. str = translateResult;
  4772. str = _airTicketResRep.Processing(str);
  4773. }
  4774. table.Range.Bookmarks["ClientName"].Text = str;
  4775. }
  4776. else
  4777. {
  4778. table.Range.Bookmarks["ClientName"].Text = "--";
  4779. }
  4780. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4781. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4782. table.Range.Bookmarks["JointTicket"].Text = "--";
  4783. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4784. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4785. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4786. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4787. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4788. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4789. }
  4790. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4791. //保存合并后的文档
  4792. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4793. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4794. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4795. return Ok(JsonView(true, "成功!", rst));
  4796. }
  4797. }
  4798. }
  4799. catch (Exception ex)
  4800. {
  4801. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4802. throw;
  4803. }
  4804. }
  4805. #endregion
  4806. #region 团组增减款项 --> 其他款项
  4807. /// <summary>
  4808. /// 团组增减款项下拉框绑定
  4809. /// </summary>
  4810. /// <param name="dto"></param>
  4811. /// <returns></returns>
  4812. [HttpPost]
  4813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4814. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4815. {
  4816. #region 参数验证
  4817. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4818. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4819. #endregion
  4820. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4821. }
  4822. /// <summary>
  4823. /// 根据团组Id查询团组增减款项
  4824. /// </summary>
  4825. /// <param name="dto"></param>
  4826. /// <returns></returns>
  4827. [HttpPost]
  4828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4829. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4830. {
  4831. #region 参数验证
  4832. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4833. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4834. #endregion
  4835. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4836. }
  4837. /// <summary>
  4838. /// 团组增减款项操作(Status:1.新增,2.修改)
  4839. /// </summary>
  4840. /// <param name="dto"></param>
  4841. /// <returns></returns>
  4842. [HttpPost]
  4843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4844. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4845. {
  4846. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4847. if (groupData.Code != 200)
  4848. {
  4849. return Ok(JsonView(false, groupData.Msg));
  4850. }
  4851. #region 应用推送
  4852. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4853. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4854. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4855. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4856. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4857. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4858. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  4859. if (recheck)
  4860. {
  4861. //自动审核
  4862. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4863. }
  4864. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4865. //2024-10-21 新增LZ UID
  4866. var userIds = new List<int>() { 21 };
  4867. string title = $"系统通知";
  4868. string content = "";
  4869. var diId = dto.DiId;
  4870. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4871. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4872. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4873. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4874. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4875. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4876. #endregion
  4877. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4878. }
  4879. /// <summary>
  4880. /// 团组增减款项操作 删除
  4881. /// </summary>
  4882. /// <param name="dto"></param>
  4883. /// <returns></returns>
  4884. [HttpPost]
  4885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4886. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4887. {
  4888. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4889. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4890. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4891. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4892. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4893. }
  4894. /// <summary>
  4895. /// 根据团组增减款项Id查询
  4896. /// </summary>
  4897. /// <param name="dto"></param>
  4898. /// <returns></returns>
  4899. [HttpPost]
  4900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4901. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4902. {
  4903. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4904. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4905. }
  4906. /// <summary>
  4907. /// 查询供应商名称
  4908. /// </summary>
  4909. /// <param name="dto"></param>
  4910. /// <returns></returns>
  4911. [HttpPost]
  4912. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4913. {
  4914. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4915. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4916. ?? new List<Grp_DecreasePayments>();
  4917. dbResult = dbResult.Distinct(new
  4918. ProductComparer()).ToList();
  4919. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4920. {
  4921. x.Id,
  4922. x.SupplierAddress,
  4923. x.SupplierArea,
  4924. x.SupplierContact,
  4925. x.SupplierContactNumber,
  4926. x.SupplierEmail,
  4927. x.SupplierName,
  4928. x.SupplierSocialAccount,
  4929. x.SupplierTypeId,
  4930. }).ToList());
  4931. return Ok(jw);
  4932. }
  4933. /// <summary>
  4934. /// 团组增减款项 OTA匹配
  4935. /// </summary>
  4936. /// <param name="file"></param>
  4937. /// <returns></returns>
  4938. [HttpPost]
  4939. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4940. {
  4941. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4942. string fileName = file.FileName;
  4943. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4944. {
  4945. return Ok(JsonView(false, "请上传Excel文件!"));
  4946. }
  4947. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4948. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4949. if (!Directory.Exists(path))
  4950. {
  4951. Directory.CreateDirectory(path);
  4952. }
  4953. var filePath = @$"{path}/{fileName}";
  4954. //保存文件
  4955. using (FileStream fs = System.IO.File.Create(filePath))
  4956. {
  4957. file.CopyTo(fs);
  4958. fs.Flush();
  4959. }
  4960. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4961. //读取ExcelFile
  4962. DataTable dt = ConvertExcelToDataTable(filePath);
  4963. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4964. dt.TableName = "TB";
  4965. //修改table列名
  4966. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4967. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4968. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4969. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4970. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4971. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4972. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4973. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4974. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4975. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4976. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4977. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4978. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4979. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4980. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4981. var otaOrderNos = new List<string>();
  4982. foreach (DataRow item in dt.Rows)
  4983. {
  4984. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4985. }
  4986. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4987. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4988. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4989. .Select((dp, di) => new
  4990. {
  4991. dp.PriceName,
  4992. dp.OTAOrderNo,
  4993. dp.FeeTotal,
  4994. di.TeamName,
  4995. })
  4996. .ToListAsync();
  4997. foreach (DataRow item in dt.Rows)
  4998. {
  4999. var otaOrderNo = item["OTAOrderNo"].ToString();
  5000. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5001. if (oaData == null) continue;
  5002. item["GroupName"] = oaData.TeamName;
  5003. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5004. }
  5005. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5006. var pairs = new Dictionary<string, object>();
  5007. var datas = new List<DataTable>
  5008. {
  5009. dt
  5010. };
  5011. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5012. return Ok(JsonView(true, "操作成功", new { url }));
  5013. }
  5014. #region
  5015. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5016. {
  5017. // 创建Workbook对象
  5018. var workbook = new Workbook(excelFilePath);
  5019. // 获取第一个工作表
  5020. var worksheet = workbook.Worksheets[0];
  5021. // 将工作表转换为DataTable
  5022. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5023. return dataTable;
  5024. }
  5025. #endregion
  5026. /// <summary>
  5027. /// 世运会数据
  5028. /// </summary>
  5029. /// <returns></returns>
  5030. [HttpGet]
  5031. public IActionResult WorldGamesData()
  5032. {
  5033. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5034. var groupMenu = setData.GroupBy(x => x.T0);
  5035. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5036. foreach (var item in groupMenu)
  5037. {
  5038. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5039. {
  5040. Data = new SetDataView
  5041. {
  5042. Name = item.Key
  5043. },
  5044. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5045. });
  5046. }
  5047. return Ok(JsonView(true, "success", resultArr));
  5048. }
  5049. #endregion
  5050. #region 文件上传、删除
  5051. /// <summary>
  5052. /// region 文件上传 可以带参数
  5053. /// </summary>
  5054. /// <param name="file"></param>
  5055. /// <returns></returns>
  5056. [HttpPost]
  5057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5058. public async Task<IActionResult> UploadProject(IFormFile file)
  5059. {
  5060. //var TypeName = Request.Headers["TypeName"].ToString();
  5061. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5062. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5063. ////文件名称
  5064. //string projectFileName = file.FileName;
  5065. ////上传的文件的路径
  5066. //string filePath = $"{fileDir}/{projectFileName}";
  5067. //if (TypeName == "A")//A代表团组增减款项
  5068. //{
  5069. // filePath = fileDir + $@"\团组增减款项相关文件";
  5070. // if (!Directory.Exists(filePath))
  5071. // {
  5072. // Directory.CreateDirectory(filePath);
  5073. // }
  5074. // //上传的文件的路径
  5075. // filePath += $@"\{projectFileName}";
  5076. //}
  5077. //else if (TypeName == "B")//B代表商邀相关文件
  5078. //{
  5079. // //上传的文件的路径
  5080. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5081. // if (!Directory.Exists(filePath))
  5082. // {
  5083. // Directory.CreateDirectory(filePath);
  5084. // }
  5085. // //上传的文件的路径
  5086. // filePath = $@"\{projectFileName}";
  5087. //}
  5088. //try
  5089. //{
  5090. // using (FileStream fs = System.IO.File.Create(filePath))
  5091. // {
  5092. // file.CopyTo(fs);
  5093. // fs.Flush();
  5094. // }
  5095. //}
  5096. //catch (Exception ex)
  5097. //{
  5098. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5099. //}
  5100. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5101. try
  5102. {
  5103. var TypeName = Request.Headers["TypeName"].ToString();
  5104. if (file != null)
  5105. {
  5106. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5107. //文件名称
  5108. string projectFileName = file.FileName;
  5109. //上传的文件的路径
  5110. string filePath = $"{fileDir}/{projectFileName}";
  5111. if (TypeName == "A")//A代表团组增减款项
  5112. {
  5113. if (!Directory.Exists(fileDir))
  5114. {
  5115. Directory.CreateDirectory(fileDir);
  5116. }
  5117. //上传的文件的路径
  5118. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5119. }
  5120. else if (TypeName == "B")//B代表商邀相关文件
  5121. {
  5122. if (!Directory.Exists(fileDir))
  5123. {
  5124. Directory.CreateDirectory(fileDir);
  5125. }
  5126. //上传的文件的路径
  5127. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5128. }
  5129. using (FileStream fs = System.IO.File.Create(filePath))
  5130. {
  5131. file.CopyTo(fs);
  5132. fs.Flush();
  5133. }
  5134. return Ok(JsonView(true, "上传成功!", projectFileName));
  5135. }
  5136. else
  5137. {
  5138. return Ok(JsonView(false, "上传失败!"));
  5139. }
  5140. }
  5141. catch (Exception ex)
  5142. {
  5143. return Ok(JsonView(false, ex.Message));
  5144. }
  5145. }
  5146. /// <summary>
  5147. /// 删除指定文件
  5148. /// </summary>
  5149. /// <param name="dto"></param>
  5150. /// <returns></returns>
  5151. [HttpPost]
  5152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5153. public async Task<IActionResult> DelFile(DelFileDto dto)
  5154. {
  5155. try
  5156. {
  5157. var TypeName = Request.Headers["TypeName"].ToString();
  5158. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5159. string filePath = "";
  5160. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5161. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5162. int id = 0;
  5163. if (TypeName == "A")
  5164. {
  5165. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5166. // 删除该文件
  5167. System.IO.File.Delete(filePath);
  5168. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5169. .Where(a => a.Id == dto.Id)
  5170. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5171. .ExecuteCommandAsync();
  5172. }
  5173. else if (TypeName == "B")
  5174. {
  5175. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5176. // 删除该文件
  5177. System.IO.File.Delete(filePath);
  5178. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5179. if (info != null)
  5180. {
  5181. string[] files = Array.Empty<string>();
  5182. if (!string.IsNullOrEmpty(info.Attachment))
  5183. {
  5184. try
  5185. {
  5186. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5187. }
  5188. catch (Exception)
  5189. {
  5190. files = new List<string>() { info.Attachment }.ToArray();
  5191. }
  5192. }
  5193. if (files.Length > 0)
  5194. {
  5195. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5196. string filePath2 = string.Empty;
  5197. if (files1.Length > 0)
  5198. {
  5199. filePath2 = JsonConvert.SerializeObject(files1);
  5200. }
  5201. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5202. .Where(a => a.Id == dto.Id)
  5203. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5204. .ExecuteCommandAsync();
  5205. }
  5206. }
  5207. }
  5208. if (id != 0)
  5209. {
  5210. return Ok(JsonView(true, "成功!"));
  5211. }
  5212. else
  5213. {
  5214. return Ok(JsonView(false, "失败!"));
  5215. }
  5216. }
  5217. catch (Exception ex)
  5218. {
  5219. return Ok(JsonView(false, "程序错误!"));
  5220. throw;
  5221. }
  5222. }
  5223. /// <summary>
  5224. /// 文件上传多个文件 可以带参数
  5225. /// </summary>
  5226. /// <param name="files"></param>
  5227. /// <returns></returns>
  5228. [HttpPost]
  5229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5230. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5231. {
  5232. try
  5233. {
  5234. var TypeName = Request.Headers["TypeName"].ToString();
  5235. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5236. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5237. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5238. var filePahts = new List<string>();
  5239. foreach (var file in files)
  5240. {
  5241. //文件名称
  5242. string projectFileName = file.FileName;
  5243. //上传的文件的路径
  5244. string filePath = $"{fileDir}/{projectFileName}";
  5245. if (TypeName == "A")//A代表团组增减款项
  5246. {
  5247. if (!Directory.Exists(fileDir))
  5248. {
  5249. Directory.CreateDirectory(fileDir);
  5250. }
  5251. //上传的文件的路径
  5252. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5253. }
  5254. else if (TypeName == "B")//B代表商邀相关文件
  5255. {
  5256. if (!Directory.Exists(fileDir))
  5257. {
  5258. Directory.CreateDirectory(fileDir);
  5259. }
  5260. //上传的文件的路径
  5261. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5262. }
  5263. using (FileStream fs = System.IO.File.Create(filePath))
  5264. {
  5265. file.CopyTo(fs);
  5266. fs.Flush();
  5267. }
  5268. filePahts.Add(projectFileName);
  5269. }
  5270. return Ok(JsonView(true, "上传成功!", filePahts));
  5271. }
  5272. catch (Exception ex)
  5273. {
  5274. return Ok(JsonView(false, ex.Message));
  5275. }
  5276. }
  5277. #endregion
  5278. #region 商邀费用录入
  5279. /// <summary>
  5280. /// 根据团组Id查询商邀费用列表
  5281. /// </summary>
  5282. /// <param name="dto"></param>
  5283. /// <returns></returns>
  5284. [HttpPost]
  5285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5286. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5287. {
  5288. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5289. if (groupData.Code != 0)
  5290. {
  5291. return Ok(JsonView(false, groupData.Msg));
  5292. }
  5293. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5294. }
  5295. /// <summary>
  5296. /// 商邀费用列表
  5297. /// 下载文件
  5298. /// </summary>
  5299. /// <param name="id"></param>
  5300. /// <returns></returns>
  5301. [HttpGet("{id}")]
  5302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5303. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5304. {
  5305. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5306. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5307. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5308. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5309. var filePaths = new List<string>();
  5310. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5311. try
  5312. {
  5313. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5314. }
  5315. catch (Exception ex)
  5316. {
  5317. filePaths.Add(info.Attachment);
  5318. }
  5319. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5320. for (int i = 0; i < filePaths.Count; i++)
  5321. {
  5322. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5323. }
  5324. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5325. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5326. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5327. {
  5328. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5329. {
  5330. foreach (string filePath in filePaths)
  5331. {
  5332. if (System.IO.File.Exists(filePath))
  5333. {
  5334. // 获取文件名
  5335. string fileName = Path.GetFileName(filePath);
  5336. // 将文件添加到ZIP归档中
  5337. zipArchive.CreateEntryFromFile(filePath, fileName);
  5338. }
  5339. }
  5340. }
  5341. }
  5342. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5343. }
  5344. /// <summary>
  5345. /// 商邀费用 Info Page 基础数据源
  5346. /// </summary>
  5347. /// <returns></returns>
  5348. [HttpPost]
  5349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5350. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5351. {
  5352. try
  5353. {
  5354. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5355. if (groupData.Code != 0)
  5356. {
  5357. return Ok(JsonView(false, groupData.Msg));
  5358. }
  5359. return Ok(JsonView(true, "操作成功", groupData.Data));
  5360. }
  5361. catch (Exception ex)
  5362. {
  5363. return Ok(JsonView(false, ex.Message));
  5364. throw;
  5365. }
  5366. }
  5367. /// <summary>
  5368. /// 根据商邀费用ID查询C表和商邀费用数据
  5369. /// </summary>
  5370. /// <param name="dto"></param>
  5371. /// <returns></returns>
  5372. [HttpPost]
  5373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5374. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5375. {
  5376. try
  5377. {
  5378. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5379. if (groupData.Code != 0)
  5380. {
  5381. return Ok(JsonView(false, groupData.Msg));
  5382. }
  5383. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5384. }
  5385. catch (Exception ex)
  5386. {
  5387. return Ok(JsonView(false, ex.Message));
  5388. throw;
  5389. }
  5390. }
  5391. /// <summary>
  5392. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5393. /// </summary>
  5394. /// <param name="dto"></param>
  5395. /// <returns></returns>
  5396. [HttpPost]
  5397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5398. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5399. {
  5400. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5401. if (groupData.Code != 0)
  5402. {
  5403. return Ok(JsonView(false, groupData.Msg));
  5404. }
  5405. #region 应用推送
  5406. try
  5407. {
  5408. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5409. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5410. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5411. //2024-10-21 新增LZ UID
  5412. var userIds = new List<int>() { 21 };
  5413. string title = $"系统通知";
  5414. string content = "";
  5415. var diId = dto.DiId;
  5416. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5417. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5418. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5419. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5420. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5421. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5422. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5423. }
  5424. catch (Exception ex)
  5425. {
  5426. }
  5427. #endregion
  5428. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5429. }
  5430. /// <summary>
  5431. /// 商邀删除
  5432. /// </summary>
  5433. /// <param name="dto"></param>
  5434. /// <returns></returns>
  5435. [HttpPost]
  5436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5437. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5438. {
  5439. try
  5440. {
  5441. _sqlSugar.BeginTran();
  5442. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5443. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5444. {
  5445. IsDel = 1,
  5446. DeleteUserId = dto.DeleteUserId,
  5447. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5448. })
  5449. .Where(it => it.Id == dto.Id)
  5450. .ExecuteCommand();
  5451. if (res1 > 0)
  5452. {
  5453. int _diId = 0;
  5454. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5455. if (_ioaInfo != null)
  5456. {
  5457. _diId = _ioaInfo.DiId;
  5458. }
  5459. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5460. .SetColumns(a => new Grp_CreditCardPayment()
  5461. {
  5462. IsDel = 1,
  5463. DeleteUserId = dto.DeleteUserId,
  5464. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5465. })
  5466. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5467. .ExecuteCommand();
  5468. if (res2 > 0)
  5469. {
  5470. _sqlSugar.CommitTran();
  5471. return Ok(JsonView(true, "删除成功!"));
  5472. }
  5473. }
  5474. _sqlSugar.RollbackTran();
  5475. return Ok(JsonView(false, "删除失败"));
  5476. }
  5477. catch (Exception ex)
  5478. {
  5479. _sqlSugar.RollbackTran();
  5480. return Ok(JsonView(false, ex.Message));
  5481. }
  5482. }
  5483. #endregion
  5484. #region 票据上传
  5485. /// <summary>
  5486. /// 团组模块文件上传
  5487. /// </summary>
  5488. /// <param name="dto"></param>
  5489. /// <returns></returns>
  5490. [HttpPost]
  5491. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5492. {
  5493. var jw = JsonView(false);
  5494. long M = 1024 * 1024;
  5495. if (dto.Files == null || dto.Files.Count == 0)
  5496. {
  5497. jw.Msg = "无文件信息!";
  5498. return Ok(jw);
  5499. }
  5500. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5501. {
  5502. jw.Msg = "文件大小超过20M!";
  5503. return Ok(jw);
  5504. }
  5505. //var nameSp = dto.File.FileName.Split(".");
  5506. //if (nameSp.Length < 2)
  5507. //{
  5508. // jw.Msg = "拓展名称有误!";
  5509. // return Ok(jw);
  5510. //}
  5511. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5512. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5513. //{
  5514. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5515. // return Ok(jw);
  5516. //}
  5517. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5518. if (Ctable == null)
  5519. {
  5520. jw.Msg = "Ctable指向有误!";
  5521. return Ok(jw);
  5522. }
  5523. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5524. if (groupInfo == null)
  5525. {
  5526. jw.Msg = "团组信息不存在!";
  5527. return Ok(jw);
  5528. }
  5529. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5530. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5531. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5532. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5533. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5534. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5535. try
  5536. {
  5537. if (!Directory.Exists(fileBase))
  5538. {
  5539. Directory.CreateDirectory(fileBase);
  5540. }
  5541. var saveArr = new List<Grp_GroupModelFile>();
  5542. foreach (var fileStream in dto.Files)
  5543. {
  5544. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5545. var file = new Grp_GroupModelFile()
  5546. {
  5547. Cid = dto.Cid,
  5548. CreateTime = DateTime.Now,
  5549. CreateUserId = dto.Userid,
  5550. Ctable = dto.Ctable,
  5551. Diid = dto.Diid,
  5552. IsDel = 0,
  5553. FilePath = saveFilePath,
  5554. FileName = fileStream.FileName
  5555. };
  5556. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5557. {
  5558. fileStream.CopyTo(fs);
  5559. fs.Flush();
  5560. }
  5561. saveArr.Add(file);
  5562. }
  5563. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5564. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5565. jw = JsonView(true, "保存成功!", new
  5566. {
  5567. count = addResult,
  5568. filesName = saveArr.Select(x => x.FileName)
  5569. });
  5570. }
  5571. catch (Exception ex)
  5572. {
  5573. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5574. {
  5575. count = 0,
  5576. filesName = Array.Empty<string>(),
  5577. });
  5578. }
  5579. return Ok(jw);
  5580. }
  5581. /// <summary>
  5582. /// 查询各模块已保存文件
  5583. /// </summary>
  5584. /// <param name="dto"></param>
  5585. /// <returns></returns>
  5586. [HttpPost]
  5587. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5588. {
  5589. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5590. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5591. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5592. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5593. {
  5594. expression = Expressionable.Create<Grp_GroupModelFile>()
  5595. .And(x => visaIds.Contains(x.CreateUserId));
  5596. }
  5597. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5598. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5599. .Where(expression.ToExpression())
  5600. .ToList();
  5601. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5602. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5603. {
  5604. x.FileName,
  5605. x.Id,
  5606. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5607. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5608. })));
  5609. }
  5610. /// <summary>
  5611. /// 下载该团组下的所有文件
  5612. /// </summary>
  5613. /// <param name="dto"></param>
  5614. /// <returns></returns>
  5615. [HttpPost]
  5616. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5617. {
  5618. var jw = JsonView(false);
  5619. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5620. if (groupInfo == null)
  5621. {
  5622. jw.Msg = "团组信息不存在!";
  5623. return Ok(jw);
  5624. }
  5625. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5626. var isModule = Convert.ToBoolean(dto.isModule);
  5627. var Zips = new Dictionary<string, Stream>();
  5628. var io = new IOOperatorHelper();
  5629. if (isModule)
  5630. {
  5631. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5632. foreach (var moduleArr in moduleGroup)
  5633. {
  5634. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5635. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5636. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5637. var chiZips = new Dictionary<string, Stream>();
  5638. foreach (var item in moduleArr)
  5639. {
  5640. if (System.IO.File.Exists(item.FilePath))
  5641. {
  5642. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5643. {
  5644. byte[] bytes = new byte[fileStream.Length];
  5645. fileStream.Read(bytes, 0, bytes.Length);
  5646. fileStream.Close();
  5647. Stream stream = new MemoryStream(bytes);
  5648. chiZips.Add(item.FileName, stream);
  5649. }
  5650. }
  5651. }
  5652. if (chiZips.Count > 0)
  5653. {
  5654. var byts = io.ConvertZipStream(chiZips);
  5655. Stream stream = new MemoryStream(byts);
  5656. Zips.Add(key.Name + "_.zip", stream);
  5657. }
  5658. }
  5659. }
  5660. else
  5661. {
  5662. foreach (var item in dbQuery)
  5663. {
  5664. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5665. {
  5666. byte[] bytes = new byte[fileStream.Length];
  5667. fileStream.Read(bytes, 0, bytes.Length);
  5668. fileStream.Close();
  5669. var stream = new MemoryStream(bytes);
  5670. while (Zips.ContainsKey(item.FileName))
  5671. {
  5672. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5673. }
  5674. Zips.Add(item.FileName, stream);
  5675. }
  5676. }
  5677. }
  5678. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5679. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5680. if (Zips.Count > 0)
  5681. {
  5682. var byts = io.ConvertZipStream(Zips);
  5683. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5684. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5685. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5686. }
  5687. else
  5688. {
  5689. jw.Msg = "暂无生成文件!";
  5690. }
  5691. return Ok(jw);
  5692. }
  5693. /// <summary>
  5694. /// 下载该团组下此模块的所有文件
  5695. /// </summary>
  5696. /// <param name="dto"></param>
  5697. /// <returns></returns>
  5698. [HttpPost]
  5699. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5700. {
  5701. var jw = JsonView(false);
  5702. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5703. if (groupInfo == null)
  5704. {
  5705. jw.Msg = "团组信息不存在!";
  5706. return Ok(jw);
  5707. }
  5708. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5709. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5710. && x.IsDel == 0);
  5711. if (key == null)
  5712. {
  5713. jw.Msg = "Ctable指向错误!";
  5714. return Ok(jw);
  5715. }
  5716. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5717. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5718. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5719. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5720. var io = new IOOperatorHelper();
  5721. var Zips = new Dictionary<string, Stream>();
  5722. foreach (var item in dbQuery)
  5723. {
  5724. if (System.IO.File.Exists(item.FilePath))
  5725. {
  5726. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5727. {
  5728. byte[] bytes = new byte[fileStream.Length];
  5729. fileStream.Read(bytes, 0, bytes.Length);
  5730. fileStream.Close();
  5731. var stream = new MemoryStream(bytes);
  5732. while (Zips.ContainsKey(item.FileName))
  5733. {
  5734. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5735. }
  5736. Zips.Add(item.FileName, stream);
  5737. }
  5738. }
  5739. }
  5740. if (Zips.Count > 0)
  5741. {
  5742. var byts = io.ConvertZipStream(Zips);
  5743. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5744. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5745. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5746. }
  5747. else
  5748. {
  5749. jw.Msg = "暂无生成文件!";
  5750. }
  5751. return Ok(jw);
  5752. }
  5753. /// <summary>
  5754. /// 删除该团组下的指定文件
  5755. /// </summary>
  5756. /// <param name="dto"></param>
  5757. /// <returns></returns>
  5758. [HttpPost]
  5759. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5760. {
  5761. var jw = JsonView(false);
  5762. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5763. if (sing == null)
  5764. {
  5765. jw.Msg = "暂无";
  5766. return Ok(jw);
  5767. }
  5768. if (System.IO.File.Exists(sing.FilePath))
  5769. {
  5770. try
  5771. {
  5772. System.IO.File.Delete(sing.FilePath);
  5773. }
  5774. catch (Exception ex)
  5775. {
  5776. jw.Msg = "删除失败!" + ex.Message;
  5777. return Ok(jw);
  5778. }
  5779. }
  5780. sing.IsDel = 1;
  5781. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5782. sing.DeleteUserId = dto.UserId;
  5783. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5784. jw = JsonView(true, "删除成功!");
  5785. return Ok(jw);
  5786. }
  5787. #endregion
  5788. #region 共享文件上传
  5789. /// <summary>
  5790. /// 共享文件数据初始化
  5791. /// </summary>
  5792. /// <returns></returns>
  5793. [HttpGet]
  5794. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5795. {
  5796. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5797. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5798. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5799. .Select(x => x.Id)
  5800. .ToList()
  5801. .Contains(userid);
  5802. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5803. .Where(x => x.STid == 111 && x.IsDel == 0)
  5804. .Select(x => new
  5805. {
  5806. x.Name,
  5807. x.Id,
  5808. }).ToList();
  5809. if (isMarketingDepartment)
  5810. {
  5811. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5812. }
  5813. if (portType == 1)
  5814. {
  5815. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5816. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5817. .Where(x => x.IsDel == 0)
  5818. .OrderByDescending(x => x.VisitDate)
  5819. .Select(x => new
  5820. {
  5821. x.TeamName,
  5822. x.Id,
  5823. x.CityId,
  5824. })
  5825. .ToList()
  5826. .Select(x =>
  5827. {
  5828. var provinceId = x.CityId;
  5829. var isDefualtVal = true;
  5830. if (provinceId > 0)
  5831. {
  5832. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5833. if (parentId != null)
  5834. {
  5835. isDefualtVal = false;
  5836. provinceId = (int)parentId;
  5837. }
  5838. }
  5839. if (isDefualtVal)
  5840. {
  5841. provinceId = 122; //默认四川
  5842. }
  5843. return new
  5844. {
  5845. x.TeamName,
  5846. x.Id,
  5847. provinceId,
  5848. };
  5849. })
  5850. .ToList();
  5851. return Ok(JsonView(true, "SUCCESS!", new
  5852. {
  5853. dropDownType,
  5854. dropDownGroupList,
  5855. isMarketingDepartment
  5856. }));
  5857. }
  5858. else if (portType == 2 || portType == 3)
  5859. {
  5860. return Ok(JsonView(true, "SUCCESS!", new
  5861. {
  5862. dropDownType,
  5863. isMarketingDepartment
  5864. }));
  5865. }
  5866. else
  5867. {
  5868. return Ok(JsonView(false, "portType有误!"));
  5869. }
  5870. }
  5871. /// <summary>
  5872. /// 共享文件上传
  5873. /// </summary>
  5874. /// <param name="dto"></param>
  5875. /// <returns></returns>
  5876. [HttpPost]
  5877. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5878. {
  5879. var isGroup = new List<int> { 1412 };
  5880. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5881. {
  5882. return Ok(JsonView(false, "该文件需要关联团组!"));
  5883. }
  5884. if (dto.Files == null || dto.Files.Count == 0)
  5885. {
  5886. return Ok(JsonView(false, "无文件信息!"));
  5887. }
  5888. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5889. {
  5890. return Ok(JsonView(false, "文件大小超过20M!"));
  5891. }
  5892. if (dto.Userid < 1)
  5893. {
  5894. return Ok(JsonView(false, "请传入有效的Userid!"));
  5895. }
  5896. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5897. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5898. .Select((u, j) => new
  5899. {
  5900. u.CnName,
  5901. UserId = u.Id,
  5902. j.JobName,
  5903. })
  5904. .First();
  5905. if (jobInfo == null)
  5906. {
  5907. return Ok(JsonView(false, "请传入有效的Userid!"));
  5908. }
  5909. var commonFileExtensions = new List<string>
  5910. {
  5911. // 文本文件
  5912. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5913. // 图片文件
  5914. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5915. // 视频文件
  5916. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5917. // 音频文件
  5918. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5919. // 压缩文件
  5920. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5921. // 数据文件
  5922. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5923. };
  5924. try
  5925. {
  5926. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5927. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5928. commonFileExtensions.AddRange(settingExtend);
  5929. }
  5930. catch (Exception)
  5931. { }
  5932. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5933. if (setdata == null)
  5934. {
  5935. return Ok(JsonView(false, "请传入有效的FileType!"));
  5936. }
  5937. var insertList = new List<Grp_GroupShareFile>();
  5938. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5939. if (!Directory.Exists(winPath))
  5940. {
  5941. Directory.CreateDirectory(winPath);
  5942. }
  5943. foreach (var item in dto.Files)
  5944. {
  5945. var houzui = Path.GetExtension(item.FileName);
  5946. if (!commonFileExtensions.Contains(houzui))
  5947. {
  5948. return Ok(JsonView(false, "未知后缀名称!"));
  5949. }
  5950. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5951. var saveFilePath = winPath + fileName;
  5952. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5953. {
  5954. item.CopyTo(fs);
  5955. fs.Flush();
  5956. }
  5957. var fileDetail = new Grp_GroupShareFile()
  5958. {
  5959. CreateUserId = dto.Userid,
  5960. CreateTime = DateTime.Now,
  5961. UploadJob = jobInfo.JobName,
  5962. FileName = fileName,
  5963. FileType = dto.FileType,
  5964. Diid = dto.Diid,
  5965. FilePath = winPath + fileName,
  5966. };
  5967. insertList.Add(fileDetail);
  5968. }
  5969. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5970. return Ok(JsonView(true, "保存成功!"));
  5971. }
  5972. /// <summary>
  5973. /// 查询共享文件列表
  5974. /// </summary>
  5975. /// <param name="dto"></param>
  5976. /// <returns></returns>
  5977. [HttpPost]
  5978. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5979. {
  5980. var isGroup = new List<int> { 1412 };
  5981. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5982. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5983. .And(x => x.Diid == dto.Diid)
  5984. .And(x => x.FileType == dto.FileType)
  5985. .And(x => x.IsDel == 0)
  5986. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5987. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5988. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5989. int totalCount = 0;
  5990. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5991. .Where(queryExpression.ToExpression())
  5992. .OrderBy(x => x.UploadJob)
  5993. .Select(x => new
  5994. {
  5995. x.Id,
  5996. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5997. x.FileName,
  5998. x.FileType,
  5999. x.CreateTime,
  6000. })
  6001. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6002. return Ok(JsonView(true, "SUCCESS!", new
  6003. {
  6004. FileList = dbQuery,
  6005. dto.PageSize,
  6006. dto.PageIndex,
  6007. totalCount
  6008. }));
  6009. }
  6010. /// <summary>
  6011. /// 删除共享文件模块下的指定文件
  6012. /// </summary>
  6013. /// <param name="dto"></param>
  6014. /// <returns></returns>
  6015. [HttpPost]
  6016. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6017. {
  6018. var jw = JsonView(false);
  6019. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6020. if (sing == null)
  6021. {
  6022. jw.Msg = "暂无文件信息!";
  6023. return Ok(jw);
  6024. }
  6025. if (sing.CreateUserId != dto.UserId)
  6026. {
  6027. jw.Msg = "只能删除自己上传的文件!";
  6028. return Ok(jw);
  6029. }
  6030. if (System.IO.File.Exists(sing.FilePath))
  6031. {
  6032. try
  6033. {
  6034. System.IO.File.Delete(sing.FilePath);
  6035. }
  6036. catch (Exception ex)
  6037. {
  6038. jw.Msg = "删除失败!" + ex.Message;
  6039. return Ok(jw);
  6040. }
  6041. }
  6042. sing.IsDel = 1;
  6043. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6044. sing.DeleteUserId = dto.UserId;
  6045. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6046. jw = JsonView(true, "删除成功!");
  6047. return Ok(jw);
  6048. }
  6049. #endregion
  6050. #region 团组英文资料
  6051. /// <summary>
  6052. /// 查询团组英文所有资料
  6053. /// </summary>
  6054. /// <param name="dto"></param>
  6055. /// <returns></returns>
  6056. [HttpPost]
  6057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6058. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6059. {
  6060. try
  6061. {
  6062. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6063. if (groupData.Code != 0)
  6064. {
  6065. return Ok(JsonView(false, groupData.Msg));
  6066. }
  6067. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6068. }
  6069. catch (Exception ex)
  6070. {
  6071. return Ok(JsonView(false, ex.Message));
  6072. throw;
  6073. }
  6074. }
  6075. /// <summary>
  6076. /// 团组英文资料操作(Status:1.新增,2.修改)
  6077. /// </summary>
  6078. /// <param name="dto"></param>
  6079. /// <returns></returns>
  6080. [HttpPost]
  6081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6082. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6083. {
  6084. try
  6085. {
  6086. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6087. if (groupData.Code != 0)
  6088. {
  6089. return Ok(JsonView(false, groupData.Msg));
  6090. }
  6091. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6092. }
  6093. catch (Exception ex)
  6094. {
  6095. return Ok(JsonView(false, ex.Message));
  6096. throw;
  6097. }
  6098. }
  6099. /// <summary>
  6100. /// 团组英文资料Id查询数据
  6101. /// </summary>
  6102. /// <param name="dto"></param>
  6103. /// <returns></returns>
  6104. [HttpPost]
  6105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6106. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6107. {
  6108. try
  6109. {
  6110. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6111. if (_DelegationEnData != null)
  6112. {
  6113. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6114. }
  6115. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6116. }
  6117. catch (Exception ex)
  6118. {
  6119. return Ok(JsonView(false, "程序错误!"));
  6120. throw;
  6121. }
  6122. }
  6123. /// <summary>
  6124. /// 团组英文资料删除
  6125. /// </summary>
  6126. /// <param name="dto"></param>
  6127. /// <returns></returns>
  6128. [HttpPost]
  6129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6130. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6131. {
  6132. try
  6133. {
  6134. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6135. if (!res)
  6136. {
  6137. return Ok(JsonView(false, "删除失败"));
  6138. }
  6139. return Ok(JsonView(true, "删除成功!"));
  6140. }
  6141. catch (Exception ex)
  6142. {
  6143. return Ok(JsonView(false, ex.Message));
  6144. throw;
  6145. }
  6146. }
  6147. #endregion
  6148. #region 导出邀请函
  6149. /// <summary>
  6150. /// 导出邀请函页面初始化
  6151. /// </summary>
  6152. /// <param name="dto"></param>
  6153. /// <returns></returns>
  6154. [HttpPost]
  6155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6156. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6157. {
  6158. try
  6159. {
  6160. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6161. var crm_Deles = new List<Crm_DeleClient>();
  6162. if (dto.DiId == 0)
  6163. {
  6164. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6165. }
  6166. else
  6167. {
  6168. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6169. }
  6170. return Ok(JsonView(true, "查询成功!", new
  6171. {
  6172. deleClient = crm_Deles,
  6173. delegations = grp_Delegations
  6174. }));
  6175. }
  6176. catch (Exception ex)
  6177. {
  6178. return Ok(JsonView(false, "程序错误!"));
  6179. throw;
  6180. }
  6181. }
  6182. /// <summary>
  6183. /// 导出邀请函
  6184. /// </summary>
  6185. /// <param name="dto"></param>
  6186. /// <returns></returns>
  6187. [HttpPost]
  6188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6189. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6190. {
  6191. #region 参数验证
  6192. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6193. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6194. #endregion
  6195. try
  6196. {
  6197. var transDic = new Dictionary<string, string>();
  6198. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6199. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6200. From Grp_TourClientList tcl
  6201. Left Join
  6202. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6203. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6204. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6205. From Crm_DeleClient dc
  6206. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6207. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6208. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6209. Where dc.IsDel = 0) temp
  6210. On temp.DcId =tcl.ClientId
  6211. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6212. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6213. var texts = new List<string>();
  6214. if (datas.Count != 0)
  6215. {
  6216. foreach (TourClientListDetailsView item in datas)
  6217. {
  6218. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6219. {
  6220. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6221. }
  6222. else
  6223. {
  6224. string name = item.LastName + item.FirstName;
  6225. texts.Add(name);
  6226. }
  6227. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6228. {
  6229. if (!transDic.ContainsKey(item.Job))
  6230. {
  6231. texts.Add(item.Job);
  6232. }
  6233. }
  6234. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6235. {
  6236. texts.Add(item.CompanyFullName);
  6237. }
  6238. }
  6239. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6240. if (transData.Count > 0)
  6241. {
  6242. foreach (TranslateResult item in transData)
  6243. {
  6244. if (!transDic.ContainsKey(item.Query))
  6245. {
  6246. transDic.Add(item.Query, item.Translation);
  6247. }
  6248. }
  6249. }
  6250. var list = new List<GuestList>();
  6251. foreach (var dele in datas)
  6252. {
  6253. var guestList = new GuestList();
  6254. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6255. {
  6256. guestList.Name = dele.Pinyin;
  6257. }
  6258. else
  6259. {
  6260. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6261. guestList.Name = Name;
  6262. }
  6263. if (dele.Sex == 0)
  6264. {
  6265. guestList.Sex = "Male";
  6266. }
  6267. else if (dele.Sex == 1)
  6268. {
  6269. guestList.Sex = "Female";
  6270. }
  6271. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6272. if (!string.IsNullOrEmpty(dele.Job))
  6273. {
  6274. guestList.Job = dele.Job;
  6275. }
  6276. list.Add(guestList);
  6277. }
  6278. //载入模板
  6279. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6280. var builder = new DocumentBuilder(doc);
  6281. //获取word里所有表格
  6282. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6283. //获取所填表格的序数
  6284. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6285. var rowStart = tableOne.Rows[0]; //获取第1行
  6286. //循环赋值
  6287. for (int i = 0; i < list.Count; i++)
  6288. {
  6289. builder.MoveToCell(0, i + 1, 0, 0);
  6290. builder.Write(list[i].Name.ToString());
  6291. builder.MoveToCell(0, i + 1, 1, 0);
  6292. builder.Write(list[i].Sex.ToString());
  6293. builder.MoveToCell(0, i + 1, 2, 0);
  6294. builder.Write(list[i].DOB.ToString());
  6295. builder.MoveToCell(0, i + 1, 3, 0);
  6296. builder.Write(list[i].Job.ToString());
  6297. }
  6298. //删除多余行
  6299. while (tableOne.Rows.Count > list.Count + 1)
  6300. {
  6301. tableOne.Rows.RemoveAt(list.Count + 1);
  6302. }
  6303. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6304. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6305. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6306. doc.Save(filePath);
  6307. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6308. return Ok(JsonView(true, "操作成功!", Url));
  6309. }
  6310. else
  6311. {
  6312. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6313. }
  6314. }
  6315. catch (Exception ex)
  6316. {
  6317. return Ok(JsonView(false, ex.Message));
  6318. throw;
  6319. }
  6320. }
  6321. #endregion
  6322. #region 团组经理模块 出入境费用
  6323. /// <summary>
  6324. /// 团组模块 - 出入境费用 - 省份基础数据源
  6325. /// </summary>
  6326. /// <returns></returns>
  6327. [HttpGet]
  6328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6329. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6330. {
  6331. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6332. }
  6333. /// <summary>
  6334. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6335. /// </summary>
  6336. /// <param name="dto"></param>
  6337. /// <returns></returns>
  6338. [HttpPost]
  6339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6340. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6341. {
  6342. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6343. var groupNamFirst = groupNameData.FirstOrDefault();
  6344. //SetDataInfoView
  6345. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6346. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6347. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6348. //验证城市归属并给默认值
  6349. int provinceId = 122;
  6350. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6351. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6352. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6353. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6354. return Ok(JsonView(true, "查询成功!", new
  6355. {
  6356. GroupNameData = groupNameData,
  6357. CurrencyData = _CurrencyData,
  6358. WordTypeData = wordTypeData,
  6359. ExcelTypeData = excelTypeData,
  6360. CurrencyInit = _currencyInfos,
  6361. ViewPermissionData = viewPermissionData
  6362. }));
  6363. }
  6364. /// <summary>
  6365. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6366. /// </summary>
  6367. /// <returns></returns>
  6368. [HttpGet("{provinceId}")]
  6369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6370. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6371. {
  6372. //验证城市归属并给默认值
  6373. if (provinceId < 1) provinceId = 122;
  6374. /*
  6375. * 122 四川
  6376. * 108 贵州
  6377. * 103 重庆
  6378. * 132 云南
  6379. */
  6380. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6381. return Ok(JsonView(true, "查询成功!", new
  6382. {
  6383. WordTypeData = wordTypeData,
  6384. ExcelTypeData = excelTypeData,
  6385. }));
  6386. }
  6387. /// <summary>
  6388. /// 团组模块 - 出入境费用
  6389. /// 实时汇率 tips
  6390. /// 签证费用 tips
  6391. /// 机票费用 tips
  6392. /// </summary>
  6393. /// <returns></returns>
  6394. [HttpPost]
  6395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6396. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6397. {
  6398. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6399. //默认币种显示
  6400. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6401. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6402. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6403. return Ok(JsonView(true, "查询成功!", new
  6404. {
  6405. //GroupNameData = groupNameData.Data,
  6406. visaData = visaData.Data,
  6407. airData,
  6408. reteInfos
  6409. }));
  6410. }
  6411. /// <summary>
  6412. /// 团组模块 - 出入境费用 - Info
  6413. /// </summary>
  6414. /// <param name="dto"></param>
  6415. /// <returns></returns>
  6416. [HttpPost]
  6417. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6419. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6420. {
  6421. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6422. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6423. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6424. }
  6425. /// <summary>
  6426. /// 团组模块 - 出入境费用 - 设置view权限
  6427. /// </summary>
  6428. /// <returns></returns>
  6429. [HttpPost]
  6430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6431. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6432. {
  6433. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6434. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6435. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6436. var permissions = new List<Grp_EnterExitCostPermission>();
  6437. foreach (var userId in dto.UserIds)
  6438. {
  6439. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6440. }
  6441. if (permissions.Any())
  6442. {
  6443. _sqlSugar.BeginTran();
  6444. try
  6445. {
  6446. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6447. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6448. if (result < 1)
  6449. {
  6450. _sqlSugar.RollbackTran();
  6451. return Ok(JsonView(false));
  6452. }
  6453. }
  6454. catch (Exception ex)
  6455. {
  6456. _sqlSugar.RollbackTran();
  6457. return Ok(JsonView(false, ex.Message));
  6458. }
  6459. _sqlSugar.CommitTran();
  6460. return Ok(JsonView(true));
  6461. }
  6462. return Ok(JsonView(false));
  6463. }
  6464. /// <summary>
  6465. /// 团组模块 - 出入境费用 - Add And Update
  6466. /// </summary>
  6467. /// <returns></returns>
  6468. [HttpPost]
  6469. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6471. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6472. {
  6473. try
  6474. {
  6475. var rateRecords = new List<RateRecordInfo>();
  6476. #region 汇率保存前存储
  6477. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  6478. if (info != null)
  6479. {
  6480. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  6481. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  6482. {
  6483. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  6484. {
  6485. CurrencyCode = x.CurrencyCode,
  6486. CurrencyName = x.CurrencyName,
  6487. UpdatePreRate = x.Rate,
  6488. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  6489. }).ToList();
  6490. }
  6491. else
  6492. {
  6493. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6494. {
  6495. CurrencyCode = x.CurrencyCode,
  6496. CurrencyName = x.CurrencyName,
  6497. UpdatePreRate = 0.00M,
  6498. UpdateBreRate = x.Rate
  6499. }).ToList();
  6500. }
  6501. }
  6502. else
  6503. {
  6504. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6505. {
  6506. CurrencyCode = x.CurrencyCode,
  6507. CurrencyName = x.CurrencyName,
  6508. UpdatePreRate = 0.00M,
  6509. UpdateBreRate = x.Rate
  6510. }).ToList();
  6511. }
  6512. #endregion
  6513. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6514. if (dto.DayOtherPriceData.Any())
  6515. {
  6516. var inserList = dto.DayOtherPriceData
  6517. .Where(x => x.Id == 0)
  6518. .Select(x => new Grp_DayOtherPrice
  6519. {
  6520. Cost = x.Cost,
  6521. Id = x.Id,
  6522. CreateTime = DateTime.Now,
  6523. CreateUserId = dto.UserId,
  6524. Currency = x.Currency,
  6525. Diid = x.DiId,
  6526. Index = x.Index,
  6527. IsDel = 0,
  6528. SetDataId = x.SetDataId,
  6529. SubTotal = x.SubTotal,
  6530. Remark = x.Remark
  6531. })
  6532. .ToList();
  6533. var updateList = dto.DayOtherPriceData
  6534. .Where(x => x.Id != 0)
  6535. .Select(x => new Grp_DayOtherPrice
  6536. {
  6537. Cost = x.Cost,
  6538. Id = x.Id,
  6539. CreateTime = DateTime.Now,
  6540. CreateUserId = dto.UserId,
  6541. Currency = x.Currency,
  6542. Diid = x.DiId,
  6543. Index = x.Index,
  6544. IsDel = 0,
  6545. SetDataId = x.SetDataId,
  6546. SubTotal = x.SubTotal,
  6547. Remark = x.Remark
  6548. })
  6549. .ToList();
  6550. //添加
  6551. _sqlSugar.BeginTran();
  6552. if (inserList.Any())
  6553. {
  6554. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6555. }
  6556. if (updateList.Any())
  6557. {
  6558. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6559. }
  6560. _sqlSugar.CommitTran();
  6561. }
  6562. if (data.Code != 0)
  6563. {
  6564. return Ok(JsonView(false, data.Msg));
  6565. }
  6566. //生成默认文件pdf并且通知人员
  6567. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6568. {
  6569. DiId = dto.DiId,
  6570. ExportType = 1,
  6571. SubTypeId = 1005
  6572. }, "pdf");
  6573. //发送通知
  6574. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6575. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6576. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6577. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6578. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6579. //汇率信息记录
  6580. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6581. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  6582. //汇率验证、反推
  6583. (bool isSendMsg,string msgContent,List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  6584. if (isSendMsg)
  6585. {
  6586. //消息推送
  6587. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId,dto.UserId,msgContent);
  6588. }
  6589. #region //日志汇率记录
  6590. //按照已使用币种记录
  6591. if (checkCurrencys != null && checkCurrencys.Count > 0)
  6592. {
  6593. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  6594. //汇率记录中加入实时汇率
  6595. if (liveRates != null && liveRates.Count > 0)
  6596. {
  6597. foreach (var item in rateRecords)
  6598. {
  6599. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  6600. }
  6601. }
  6602. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  6603. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  6604. var logContent = new StringBuilder();
  6605. foreach (var item in rateRecords)
  6606. {
  6607. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  6608. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  6609. logContent.AppendLine(msg);
  6610. }
  6611. _eec_textLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】\r\n{logContent}", teamName, dto.DiId, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logContent.ToString());
  6612. }
  6613. #endregion
  6614. return Ok(JsonView(true, data.Msg, data.Data));
  6615. }
  6616. catch (Exception ex)
  6617. {
  6618. return Ok(JsonView(false, ex.Message));
  6619. }
  6620. }
  6621. /// <summary>
  6622. /// 团组模块 - 出入境费用 - Confirm 费用
  6623. /// </summary>
  6624. /// <returns></returns>
  6625. [HttpPost]
  6626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6627. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6628. {
  6629. //TODO:测试完毕需把对应的用户ID更改
  6630. //1、数据表添加字段
  6631. //2、更改字段接口()
  6632. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6633. //3、确认成功 给财务发送消息
  6634. if (_view.Code == 200)
  6635. {
  6636. if (dto.Type == 1)
  6637. {
  6638. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6639. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6640. }
  6641. }
  6642. return Ok(_view);
  6643. }
  6644. /// <summary>
  6645. /// 团组模块 - 出入境费用 - File download
  6646. /// </summary>
  6647. /// <param name="dto"></param>
  6648. /// <returns></returns>
  6649. [HttpPost]
  6650. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6652. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6653. {
  6654. try
  6655. {
  6656. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6657. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6658. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6659. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6660. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6661. 3 团组成员名单 1 团组成员名单", ""));
  6662. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6663. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6664. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6665. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6666. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6667. //数据源
  6668. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6669. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6670. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6671. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6672. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6673. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6674. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6675. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6676. .Select((x, a, b) => new
  6677. {
  6678. x.Index,
  6679. itemName = a.Name,
  6680. CurrencyStr = b.Name,
  6681. x.Cost,
  6682. x.SubTotal,
  6683. x.Remark
  6684. })
  6685. .OrderBy((x) => x.Index)
  6686. .ToList(); //其他款项费用
  6687. var peiceItemCurrencys = new List<string>();
  6688. if (_DayAndCosts.Any())
  6689. {
  6690. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6691. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6692. }
  6693. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6694. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6695. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6696. {
  6697. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6698. }
  6699. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6700. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6701. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6702. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6703. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6704. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6705. .Select((tcl, dc, cc) => new ClientInfo
  6706. {
  6707. LastName = dc.LastName,
  6708. FirstName = dc.FirstName,
  6709. Sex = dc.Sex,
  6710. Birthday = dc.BirthDay,
  6711. Company = cc.CompanyFullName,
  6712. Job = dc.Job
  6713. })
  6714. .ToList();
  6715. foreach (var item in DeleClientList)
  6716. {
  6717. EncryptionProcessor.DecryptProperties(item);
  6718. }
  6719. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6720. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6721. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6722. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6723. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6724. if (dto.ExportType == 1) //明细表
  6725. {
  6726. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6727. {
  6728. //获取模板
  6729. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6730. //载入模板
  6731. var doc = new Document(tempPath);
  6732. var builder = new DocumentBuilder(doc);
  6733. var dic = new Dictionary<string, string>();
  6734. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6735. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6736. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6737. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6738. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6739. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6740. //境内费用(其他费用)
  6741. if (_EnterExitCosts.ChoiceOne == 1)
  6742. {
  6743. string row1_1 = "";
  6744. if (_EnterExitCosts.Visa > 0)
  6745. {
  6746. //insidePayTotal += _EnterExitCosts.Visa;
  6747. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 人民币/人";
  6748. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6749. //{
  6750. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6751. //}
  6752. }
  6753. string row1_2 = "";
  6754. if (_EnterExitCosts.YiMiao > 0)
  6755. {
  6756. //insidePayTotal += _EnterExitCosts.YiMiao;
  6757. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 人民币/人";
  6758. }
  6759. if (_EnterExitCosts.HeSuan > 0)
  6760. {
  6761. //insidePayTotal += _EnterExitCosts.HeSuan;
  6762. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 人民币/人";
  6763. }
  6764. if (_EnterExitCosts.Service > 0)
  6765. {
  6766. //insidePayTotal += _EnterExitCosts.Service;
  6767. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 人民币/人";
  6768. }
  6769. string row1_3 = "";
  6770. if (_EnterExitCosts.Safe > 0)
  6771. {
  6772. //insidePayTotal += _EnterExitCosts.Safe;
  6773. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 人民币/人";
  6774. }
  6775. if (_EnterExitCosts.Ticket > 0)
  6776. {
  6777. //insidePayTotal += _EnterExitCosts.Ticket;
  6778. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 人民币/人";
  6779. }
  6780. string row1 = "";
  6781. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6782. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6783. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6784. row1 += $"备注:{_EnterExitCosts.Remark}";
  6785. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6786. dic.Add("Row1Str", row1);
  6787. }
  6788. string airTotalStr = string.Empty,
  6789. airPriceStr = string.Empty;
  6790. //经济舱
  6791. if (_EnterExitCosts.SumJJC == 1)
  6792. {
  6793. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6794. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6795. }
  6796. //公务舱
  6797. if (_EnterExitCosts.SumGWC == 1)
  6798. {
  6799. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6800. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6801. }
  6802. //头等舱
  6803. if (_EnterExitCosts.SumTDC == 1)
  6804. {
  6805. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6806. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6807. }
  6808. //汇率描述
  6809. string rateStr = "";
  6810. if (peiceItemCurrencyInfos.Any())
  6811. {
  6812. rateStr = "\r\n汇率描述:";
  6813. foreach (var item in peiceItemCurrencyInfos)
  6814. {
  6815. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  6816. }
  6817. }
  6818. string twoItemRemark = "备注:";
  6819. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6820. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6821. dic.Add("AirTotalStr", airTotalStr);
  6822. dic.Add("AirPriceStr", airPriceStr);
  6823. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6824. dic.Add("TwoItemRemark", twoItemRemark);
  6825. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6826. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6827. int table1Row = 0,
  6828. table2Row = 0,
  6829. table3Row = 0,
  6830. table4Row = 0,
  6831. table5Row = 0;
  6832. //住宿费
  6833. if (_EnterExitCosts.ChoiceThree == 1)
  6834. {
  6835. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6836. table1Row = dac1.Count;
  6837. #region 填充word表格内容
  6838. for (int i = 0; i < dac1.Count; i++)
  6839. {
  6840. Grp_DayAndCost dac = dac1[i];
  6841. if (dac == null) continue;
  6842. builder.MoveToCell(0, i, 0, 0);
  6843. builder.Write("第" + dac.Days.ToString() + "晚:");
  6844. builder.MoveToCell(0, i, 1, 0);
  6845. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6846. //builder.Write(dac.Place == null ? "" : dac.Place);
  6847. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6848. builder.MoveToCell(0, i, 2, 0);
  6849. builder.Write("费用标准:");
  6850. string curr = "";
  6851. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6852. if (currData != null)
  6853. {
  6854. curr = currData.Name;
  6855. }
  6856. builder.MoveToCell(0, i, 3, 0);
  6857. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6858. builder.MoveToCell(0, i, 4, 0);
  6859. builder.Write("费用小计:");
  6860. builder.MoveToCell(0, i, 5, 0);
  6861. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6862. }
  6863. #endregion
  6864. }
  6865. else dic.Add("SubZS", "0.00");
  6866. //删除多余行
  6867. while (table1.Rows.Count > table1Row)
  6868. {
  6869. table1.Rows.RemoveAt(table1Row);
  6870. }
  6871. //伙食费
  6872. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6873. if (_EnterExitCosts.ChoiceFour == 1)
  6874. {
  6875. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6876. table2Row = dac2.Count;
  6877. #region 填充word表格内容
  6878. for (int i = 0; i < dac2.Count; i++)
  6879. {
  6880. Grp_DayAndCost dac = dac2[i];
  6881. if (dac == null) continue;
  6882. builder.MoveToCell(1, i, 0, 0);
  6883. builder.Write("第" + dac.Days.ToString() + "天:");
  6884. builder.MoveToCell(1, i, 1, 0);
  6885. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6886. builder.MoveToCell(1, i, 2, 0);
  6887. builder.Write("费用标准:");
  6888. string curr = "";
  6889. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6890. if (currData != null)
  6891. {
  6892. curr = currData.Name;
  6893. }
  6894. builder.MoveToCell(1, i, 3, 0);
  6895. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6896. builder.MoveToCell(1, i, 4, 0);
  6897. builder.Write("费用小计:");
  6898. builder.MoveToCell(1, i, 5, 0);
  6899. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6900. }
  6901. #endregion
  6902. }
  6903. else dic.Add("SubHS", "0.00");
  6904. //删除多余行
  6905. while (table2.Rows.Count > table2Row)
  6906. {
  6907. table2.Rows.RemoveAt(table2Row);
  6908. }
  6909. //公杂费
  6910. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6911. if (_EnterExitCosts.ChoiceFive == 1)
  6912. {
  6913. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6914. table3Row = dac3.Count;
  6915. #region 填充word表格内容
  6916. for (int i = 0; i < dac3.Count; i++)
  6917. {
  6918. Grp_DayAndCost dac = dac3[i];
  6919. if (dac == null) continue;
  6920. builder.MoveToCell(2, i, 0, 0);
  6921. builder.Write("第" + dac.Days.ToString() + "天:");
  6922. builder.MoveToCell(2, i, 1, 0);
  6923. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6924. builder.MoveToCell(2, i, 2, 0);
  6925. builder.Write("费用标准:");
  6926. string curr = "";
  6927. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6928. if (currData != null)
  6929. {
  6930. curr = currData.Name;
  6931. }
  6932. builder.MoveToCell(2, i, 3, 0);
  6933. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6934. builder.MoveToCell(2, i, 4, 0);
  6935. builder.Write("费用小计:");
  6936. builder.MoveToCell(2, i, 5, 0);
  6937. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6938. }
  6939. //删除多余行
  6940. while (table3.Rows.Count > table3Row)
  6941. {
  6942. table3.Rows.RemoveAt(table3Row);
  6943. }
  6944. #endregion
  6945. }
  6946. else dic.Add("SubGZF", "0.00");
  6947. //删除多余行
  6948. while (table3.Rows.Count > table3Row)
  6949. {
  6950. table3.Rows.RemoveAt(table3Row);
  6951. }
  6952. //培训费
  6953. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6954. if (_EnterExitCosts.ChoiceSix == 1)
  6955. {
  6956. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  6957. dic.Add("SubPX", pxStr);
  6958. table4Row = dac4.Count;
  6959. #region 填充word表格内容
  6960. for (int i = 0; i < dac4.Count; i++)
  6961. {
  6962. Grp_DayAndCost dac = dac4[i];
  6963. if (dac == null) continue;
  6964. builder.MoveToCell(3, i, 0, 0);
  6965. builder.Write("第" + dac.Days.ToString() + "天:");
  6966. builder.MoveToCell(3, i, 1, 0);
  6967. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6968. builder.MoveToCell(3, i, 2, 0);
  6969. builder.Write("费用标准:");
  6970. string curr = "";
  6971. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6972. if (currData != null)
  6973. {
  6974. curr = currData.Name;
  6975. }
  6976. builder.MoveToCell(3, i, 3, 0);
  6977. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6978. builder.MoveToCell(3, i, 4, 0);
  6979. builder.Write("费用小计:");
  6980. builder.MoveToCell(3, i, 5, 0);
  6981. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6982. }
  6983. #endregion
  6984. }
  6985. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6986. //删除多余行
  6987. while (table4.Rows.Count > table4Row)
  6988. {
  6989. table4.Rows.RemoveAt(table4Row);
  6990. }
  6991. //其他费用
  6992. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6993. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6994. {
  6995. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  6996. dic.Add("titleQi", qtStr);
  6997. table5Row = dac5.Count;
  6998. #region 填充word表格内容
  6999. for (int i = 0; i < dac5.Count; i++)
  7000. {
  7001. var dac = dac5[i];
  7002. if (dac == null) continue;
  7003. builder.MoveToCell(4, i, 0, 0);
  7004. builder.Write("第" + dac.Index.ToString() + "项:");
  7005. builder.MoveToCell(4, i, 1, 0);
  7006. builder.Write(dac.itemName);
  7007. builder.MoveToCell(4, i, 2, 0);
  7008. builder.Write("费用标准:");
  7009. builder.MoveToCell(4, i, 3, 0);
  7010. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7011. builder.MoveToCell(4, i, 4, 0);
  7012. builder.Write("费用小计:");
  7013. builder.MoveToCell(4, i, 5, 0);
  7014. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7015. builder.MoveToCell(4, i, 6, 0);
  7016. builder.Write("备注:");
  7017. builder.MoveToCell(4, i, 7, 0);
  7018. builder.Write(dac.Remark);
  7019. }
  7020. #endregion
  7021. }
  7022. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7023. //删除多余行
  7024. while (table5.Rows.Count > table5Row)
  7025. {
  7026. table5.Rows.RemoveAt(table5Row);
  7027. }
  7028. //加上其他费用
  7029. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7030. decimal subJJC = 0.00M,
  7031. subGWC = 0.00M,
  7032. subTDC = 0.00M;
  7033. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7034. string totalLabel = string.Format("全部费用总计:");
  7035. //经济舱
  7036. if (_EnterExitCosts.SumJJC == 1)
  7037. {
  7038. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7039. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7040. }
  7041. //公务舱
  7042. if (_EnterExitCosts.SumGWC == 1)
  7043. {
  7044. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7045. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7046. }
  7047. //头等舱
  7048. if (_EnterExitCosts.SumTDC == 1)
  7049. {
  7050. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7051. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7052. }
  7053. //TotalLabel
  7054. dic.Add("TotalLabel", totalLabel);
  7055. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7056. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7057. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7058. #region 填充word模板书签内容
  7059. foreach (var key in dic.Keys)
  7060. {
  7061. Bookmark bookmark = doc.Range.Bookmarks[key];
  7062. if (bookmark != null)
  7063. {
  7064. builder.MoveToBookmark(key);
  7065. builder.Write(dic[key]);
  7066. }
  7067. }
  7068. #endregion
  7069. #region 设置页眉
  7070. string userLabel = string.Empty;
  7071. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7072. if (currUserInfo != null)
  7073. {
  7074. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7075. if (userInfo != null)
  7076. {
  7077. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7078. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7079. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7080. }
  7081. }
  7082. //设置页脚
  7083. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7084. #endregion
  7085. //文件名
  7086. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  7087. AsposeHelper.removewatermark_v2180();
  7088. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7089. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7090. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7091. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7092. }
  7093. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7094. {
  7095. //获取模板
  7096. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7097. //载入模板
  7098. var doc = new Document(tempPath);
  7099. var builder = new DocumentBuilder(doc);
  7100. var dic = new Dictionary<string, string>();
  7101. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7102. {
  7103. var list = new List<string>();
  7104. try
  7105. {
  7106. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7107. foreach (var item in spilitArr)
  7108. {
  7109. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7110. var depCode = spDotandEmpty[2].Substring(0, 3);
  7111. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7112. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7113. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7114. list.Add(depName);
  7115. list.Add(arrName);
  7116. }
  7117. list = list.Distinct().ToList();
  7118. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7119. }
  7120. catch (Exception)
  7121. {
  7122. dic.Add("ReturnCode", "行程录入不正确!");
  7123. }
  7124. }
  7125. else
  7126. {
  7127. dic.Add("ReturnCode", "未录入行程!");
  7128. }
  7129. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7130. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7131. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7132. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7133. {
  7134. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7135. dic.Add("Day", sp.Days.ToString());
  7136. }
  7137. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7138. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7139. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7140. //dic.Add("Names", Names);
  7141. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7142. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7143. decimal dac1totalPrice = 0.00M;
  7144. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7145. foreach (var dac in dac1)
  7146. {
  7147. if (dac.SubTotal == 0.00M)
  7148. {
  7149. continue;
  7150. }
  7151. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7152. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7153. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7154. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7155. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7156. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7157. builder.Write(currency);//币种
  7158. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7159. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7160. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7161. builder.Write("");//人数
  7162. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7163. builder.Write("");//天数
  7164. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7165. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7166. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7167. decimal rate = 0.00M;
  7168. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7169. builder.Write(rate.ToString("#0.0000"));//汇率
  7170. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7171. decimal rbmPrice = dac.SubTotal;
  7172. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7173. accommodationStartIndex++;
  7174. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7175. }
  7176. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7177. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7178. {
  7179. table1.Rows.RemoveAt(i - 1);
  7180. foodandotherStartIndex--;
  7181. }
  7182. if (dac2.Count == dac3.Count)//国家 币种 金额
  7183. {
  7184. for (int i = 0; i < dac2.Count; i++)
  7185. {
  7186. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7187. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7188. }
  7189. }
  7190. decimal dac2totalPrice = 0.00M;
  7191. foreach (var dac in dac2)
  7192. {
  7193. if (dac.SubTotal == 0)
  7194. {
  7195. continue;
  7196. }
  7197. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7198. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7199. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7200. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7201. builder.Write(currency);//币种
  7202. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7203. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7204. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7205. builder.Write("");//人数
  7206. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7207. builder.Write("");//天数
  7208. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7209. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7210. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7211. decimal rate = 0.00M;
  7212. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7213. builder.Write(rate.ToString("#0.0000"));//汇率
  7214. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7215. decimal rbmPrice = dac.SubTotal;
  7216. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7217. foodandotherStartIndex++;
  7218. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7219. }
  7220. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7221. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7222. {
  7223. table1.Rows.RemoveAt(i - 1);
  7224. }
  7225. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7226. string otherFeeStr = "";
  7227. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7228. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7229. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7230. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7231. foreach (var otherInfo in dac5)
  7232. {
  7233. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7234. }
  7235. #endregion
  7236. if (otherFeeStr.Length > 0)
  7237. {
  7238. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7239. otherFeeStr = $"({otherFeeStr})";
  7240. dic.Add("OtherFeeStr", otherFeeStr);
  7241. }
  7242. //总计
  7243. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7244. //国际旅费
  7245. string outsideAir = string.Empty;
  7246. string allPriceAir = string.Empty;
  7247. if (_EnterExitCosts.SumJJC == 1)
  7248. {
  7249. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7250. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7251. }
  7252. if (_EnterExitCosts.SumGWC == 1)
  7253. {
  7254. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7255. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7256. }
  7257. if (_EnterExitCosts.SumTDC == 1)
  7258. {
  7259. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7260. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7261. }
  7262. dic.Add("InTravelPrice", $"({outsideAir})");
  7263. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7264. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7265. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7266. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7267. foreach (var key in dic.Keys)
  7268. {
  7269. builder.MoveToBookmark(key);
  7270. builder.Write(dic[key]);
  7271. }
  7272. //模板文件名
  7273. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7274. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7275. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7276. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7277. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7278. }
  7279. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7280. {
  7281. //获取模板
  7282. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7283. //载入模板
  7284. var designer = new WorkbookDesigner
  7285. {
  7286. Workbook = new Workbook(tempPath)
  7287. };
  7288. var dic = new Dictionary<string, string>();
  7289. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7290. {
  7291. var list = new List<string>();
  7292. try
  7293. {
  7294. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7295. foreach (var item in spilitArr)
  7296. {
  7297. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7298. var depCode = spDotandEmpty[2].Substring(0, 3);
  7299. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7300. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7301. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7302. list.Add(depName);
  7303. list.Add(arrName);
  7304. }
  7305. list = list.Distinct().ToList();
  7306. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7307. }
  7308. catch (Exception)
  7309. {
  7310. dic.Add("ReturnCode", "行程录入不正确!");
  7311. }
  7312. }
  7313. else
  7314. {
  7315. dic.Add("ReturnCode", "未录入行程!");
  7316. }
  7317. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7318. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7319. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7320. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7321. {
  7322. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7323. dic.Add("Day", sp.Days.ToString());
  7324. }
  7325. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7326. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7327. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7328. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7329. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7330. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7331. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7332. designer.SetDataSource("Name", Names);
  7333. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7334. designer.SetDataSource("Day", dic["Day"] + "天");
  7335. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7336. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7337. int startIndex = 10;
  7338. const int startIndexcopy = 10;
  7339. if (dac2.Count == dac3.Count)//国家 币种 金额
  7340. {
  7341. for (int i = 0; i < dac2.Count; i++)
  7342. {
  7343. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7344. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7345. }
  7346. }
  7347. var dtdac1 = new DataTable();
  7348. var place = new List<string>();
  7349. dtdac1.Columns.AddRange(new DataColumn[] {
  7350. new(){ ColumnName = "city"},
  7351. new(){ ColumnName = "curr"},
  7352. new(){ ColumnName = "criterion"},
  7353. new(){ ColumnName = "number",DataType = typeof(int)},
  7354. new(){ ColumnName = "day",DataType = typeof(int)},
  7355. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7356. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7357. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7358. });
  7359. var dtdac2 = new DataTable();
  7360. dtdac2.Columns.AddRange(new DataColumn[] {
  7361. new(){ ColumnName = "city"},
  7362. new(){ ColumnName = "curr"},
  7363. new(){ ColumnName = "criterion"},
  7364. new(){ ColumnName = "number",DataType = typeof(int)},
  7365. new(){ ColumnName = "day",DataType = typeof(int)},
  7366. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7367. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7368. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7369. });
  7370. dtdac1.TableName = "tb1";
  7371. dtdac2.TableName = "tb2";
  7372. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7373. foreach (var item in dac1)
  7374. {
  7375. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7376. if (place.Contains(item.Place))
  7377. {
  7378. continue;
  7379. }
  7380. DataRow row = dtdac1.NewRow();
  7381. row["city"] = item.Place;
  7382. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7383. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7384. row["curr"] = currency;
  7385. row["rate"] = rate.ToString("#0.0000");
  7386. row["criterion"] = item.Cost.ToString("#0.00");
  7387. row["number"] = 1;
  7388. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7389. //row["costRMB"] = rbmPrice;
  7390. dtdac1.Rows.Add(row);
  7391. place.Add(item.Place);
  7392. }
  7393. place = new List<string>();
  7394. foreach (var item in dac2)
  7395. {
  7396. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7397. if (place.Contains(item.Place))
  7398. {
  7399. continue;
  7400. }
  7401. DataRow row = dtdac2.NewRow();
  7402. row["city"] = item.Place;
  7403. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7404. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7405. row["curr"] = currency;
  7406. row["rate"] = rate.ToString("#0.0000");
  7407. row["criterion"] = item.Cost.ToString("#0.00");
  7408. row["number"] = 1;
  7409. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7410. //row["cost"] = item.SubTotal;
  7411. //row["costRMB"] = rbmPrice;
  7412. dtdac2.Rows.Add(row);
  7413. place.Add(item.Place);
  7414. //dac2totalPrice += rbmPrice;
  7415. }
  7416. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7417. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7418. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7419. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7420. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7421. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7422. string cell4Str1 = string.Empty;
  7423. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7424. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7425. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7426. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7427. string cellStr = $" 5.其他费用(";
  7428. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7429. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7430. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7431. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7432. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7433. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7434. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7435. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7436. foreach (var otherInfo in dac5)
  7437. {
  7438. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7439. }
  7440. #endregion
  7441. if (cellStr.Length > 8)
  7442. {
  7443. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7444. }
  7445. cellStr += ")";
  7446. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7447. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7448. decimal pxFee = dac4.Sum(it => it.Cost);
  7449. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7450. string celllastStr1 = "";
  7451. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7452. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7453. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7454. celllastStr1 += $",国际旅费 元";
  7455. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7456. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7457. designer.SetDataSource("cell4Str", cell4Str);
  7458. designer.SetDataSource("cellStr", cellStr);
  7459. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7460. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7461. designer.SetDataSource("celllastStr", celllastStr);
  7462. Workbook wb = designer.Workbook;
  7463. var sheet = wb.Worksheets[0];
  7464. //绑定datatable数据集
  7465. designer.SetDataSource(dtdac1);
  7466. designer.SetDataSource(dtdac2);
  7467. designer.Process();
  7468. var rowStart = dtdac1.Rows.Count;
  7469. while (rowStart > 0)
  7470. {
  7471. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7472. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7473. startIndex++;
  7474. rowStart--;
  7475. }
  7476. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7477. startIndex += 1; //总计行
  7478. rowStart = dtdac2.Rows.Count;
  7479. while (rowStart > 0)
  7480. {
  7481. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7482. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7483. startIndex++;
  7484. rowStart--;
  7485. }
  7486. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7487. wb.CalculateFormula(true);
  7488. //模板文件名
  7489. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7490. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7491. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7492. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7493. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7494. }
  7495. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7496. {
  7497. //获取模板
  7498. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7499. //载入模板
  7500. var doc = new Document(tempPath);
  7501. var builder = new DocumentBuilder(doc);
  7502. var dic = new Dictionary<string, string>
  7503. {
  7504. { "GroupName", _DelegationInfo.TeamName },
  7505. { "ClientUnit", _DelegationInfo.ClientUnit }
  7506. };
  7507. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7508. string missionLeaderJob = "";//负责人job
  7509. //int groupNumber = 0; //团人数
  7510. if (DeleClientList.Count > 0)
  7511. {
  7512. missionLeader = DeleClientList[0]?.Name ?? "";
  7513. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7514. }
  7515. dic.Add("MissionLeader", missionLeader); //团负责人
  7516. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7517. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7518. #region MyRegion
  7519. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7520. //{
  7521. // List<string> list = new List<string>();
  7522. // try
  7523. // {
  7524. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7525. // foreach (var item in spilitArr)
  7526. // {
  7527. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7528. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7529. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7530. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7531. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7532. // list.Add(depName);
  7533. // list.Add(arrName);
  7534. // }
  7535. // list = list.Distinct().ToList();
  7536. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7537. // }
  7538. // catch (Exception)
  7539. // {
  7540. // dic.Add("ReturnCode", "行程录入不正确!");
  7541. // }
  7542. //}
  7543. //else
  7544. //{
  7545. // dic.Add("ReturnCode", "未录入行程!");
  7546. //}
  7547. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7548. dic.Add("ReturnCode", string.Join("、", countrys));
  7549. #endregion
  7550. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7551. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7552. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7553. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7554. //{
  7555. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7556. // dic.Add("Day", sp.Days.ToString());
  7557. //}
  7558. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7559. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7560. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7561. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7562. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7563. //培训人员名单
  7564. int cultivateRowIndex = 7;
  7565. foreach (var item in DeleClientList)
  7566. {
  7567. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7568. builder.Write(item.Name);
  7569. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7570. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7571. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7572. string birthDay = "";
  7573. if (item.Birthday != null)
  7574. {
  7575. DateTime dt = Convert.ToDateTime(item.Birthday);
  7576. birthDay = $"{dt.Year}.{dt.Month}";
  7577. }
  7578. builder.Write(birthDay);
  7579. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7580. builder.Write(item.Company);
  7581. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7582. builder.Write(item.Job);
  7583. cultivateRowIndex++;
  7584. }
  7585. //删除多余行
  7586. //cultivateRowIndex -= 2;
  7587. int delRows = 10 + 7 - cultivateRowIndex;
  7588. if (delRows > 0)
  7589. {
  7590. for (int i = 0; i < delRows; i++)
  7591. {
  7592. table1.Rows.RemoveAt(cultivateRowIndex);
  7593. //cultivateRowIndex++;
  7594. }
  7595. }
  7596. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7597. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7598. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7599. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7600. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7601. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7602. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7603. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7604. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7605. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7606. //其他费用
  7607. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7608. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7609. //其他费用合计
  7610. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7611. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7612. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7613. //公务舱合计
  7614. //国际旅费
  7615. //string outsideJJ = "";
  7616. //string allPriceJJ = "";
  7617. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7618. {
  7619. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7620. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7621. }
  7622. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7623. {
  7624. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7625. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7626. }
  7627. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7628. {
  7629. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7630. dic.Add("AirFeeTotal", airFeeTotalStr);
  7631. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7632. dic.Add("FeeTotal", feeTotalStr);
  7633. }
  7634. foreach (var key in dic.Keys)
  7635. {
  7636. builder.MoveToBookmark(key);
  7637. builder.Write(dic[key]);
  7638. }
  7639. //模板文件名
  7640. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7641. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7642. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7643. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7644. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7645. }
  7646. }
  7647. else if (dto.ExportType == 2) //表格
  7648. {
  7649. //利用键值对存放数据
  7650. Dictionary<string, string> dic = new Dictionary<string, string>();
  7651. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7652. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7653. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7654. dic.Add("Day", sp.Days.ToString());
  7655. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7656. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7657. {
  7658. //获取模板
  7659. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7660. //载入模板
  7661. var doc = new Document(tempPath);
  7662. var builder = new DocumentBuilder(doc);
  7663. dic.Add("TeamName", _DelegationInfo.TeamName);
  7664. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7665. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7666. string missionLeaderName = "",
  7667. missionLeaderJob = "";
  7668. if (DeleClientList.Count > 0)
  7669. {
  7670. missionLeaderName = DeleClientList[0].Name;
  7671. missionLeaderJob = DeleClientList[0].Job;
  7672. }
  7673. dic.Add("MissionLeaderName", missionLeaderName);
  7674. dic.Add("MissionLeaderJob", missionLeaderJob);
  7675. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7676. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7677. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7678. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7679. int rowCount = 10;//总人数行
  7680. int startRowIndex = 7; //起始行
  7681. for (int i = 0; i < DeleClientList.Count; i++)
  7682. {
  7683. builder.MoveToCell(0, startRowIndex, 0, 0);
  7684. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7685. builder.MoveToCell(0, startRowIndex, 1, 0);
  7686. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7687. builder.Write(sex);//性别
  7688. builder.MoveToCell(0, startRowIndex, 2, 0);
  7689. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7690. builder.MoveToCell(0, startRowIndex, 3, 0);
  7691. builder.Write(DeleClientList[i].Company);//工作单位
  7692. builder.MoveToCell(0, startRowIndex, 4, 0);
  7693. builder.Write(DeleClientList[i].Job);//职务及级别
  7694. builder.MoveToCell(0, startRowIndex, 5, 0);
  7695. builder.Write("");//人员属性
  7696. builder.MoveToCell(0, startRowIndex, 6, 0);
  7697. builder.Write("");//上次出国时间
  7698. startRowIndex++;
  7699. }
  7700. int nullRow = rowCount - DeleClientList.Count;//空行
  7701. for (int i = 0; i < nullRow; i++)
  7702. {
  7703. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7704. }
  7705. foreach (var key in dic.Keys)
  7706. {
  7707. builder.MoveToBookmark(key);
  7708. builder.Write(dic[key]);
  7709. }
  7710. //模板文件名
  7711. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7712. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7713. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7714. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7715. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7716. }
  7717. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7718. {
  7719. //获取模板
  7720. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7721. //载入模板
  7722. var doc = new Document(tempPath);
  7723. var builder = new DocumentBuilder(doc);
  7724. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7725. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7726. dic.Add("Names", Names);
  7727. int accommodationRows = 12;
  7728. //int foodandotherRows = 12;
  7729. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7730. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7731. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7732. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7733. int accommodationStartIndex = 6;
  7734. decimal dac1totalPrice = 0.00M;
  7735. foreach (var dac in dac1)
  7736. {
  7737. if (dac.SubTotal == 0)
  7738. {
  7739. continue;
  7740. }
  7741. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7742. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7743. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7744. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7745. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7746. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7747. builder.Write(currency);//币种
  7748. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7749. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7750. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7751. builder.Write("");//人数
  7752. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7753. builder.Write("");//天数
  7754. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7755. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7756. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7757. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7758. builder.Write(rate.ToString("#0.0000"));//汇率
  7759. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7760. decimal rbmPrice = rate * dac.SubTotal;
  7761. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7762. accommodationStartIndex++;
  7763. dac1totalPrice += rbmPrice;
  7764. }
  7765. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7766. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7767. builder.Write("小计");
  7768. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7769. builder.Write(dac1totalPrice.ToString("#0.00"));
  7770. accommodationStartIndex++;
  7771. int nullRow = accommodationRows - dac1.Count;
  7772. //删除空行
  7773. //if (nullRow > 0)
  7774. //{
  7775. // int rowIndex = accommodationStartIndex;
  7776. // for (int i = 0; i < nullRow; i++)
  7777. // {
  7778. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7779. // row.Remove();
  7780. // rowIndex++;
  7781. // }
  7782. //}
  7783. if (dac2.Count == dac3.Count)//国家 币种 金额
  7784. {
  7785. for (int i = 0; i < dac2.Count; i++)
  7786. {
  7787. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7788. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7789. }
  7790. }
  7791. int foodandotherStartIndex = 19;//
  7792. decimal dac2totalPrice = 0.00M;
  7793. foreach (var dac in dac2)
  7794. {
  7795. if (dac.SubTotal == 0)
  7796. {
  7797. continue;
  7798. }
  7799. //foodandotherStartIndex = 12;
  7800. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7801. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7802. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7803. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7804. builder.Write(currency);//币种
  7805. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7806. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7807. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7808. builder.Write("");//人数
  7809. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7810. builder.Write("");//天数
  7811. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7812. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7813. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7814. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7815. builder.Write(rate.ToString("#0.0000"));//汇率
  7816. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7817. decimal rbmPrice = rate * dac.SubTotal;
  7818. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7819. foodandotherStartIndex++;
  7820. dac2totalPrice += rbmPrice;
  7821. }
  7822. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7823. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7824. //删除空行
  7825. //if (dac2.Count < foodandotherRows)
  7826. //{
  7827. // while (table2.Rows.Count > dac2.Count)
  7828. // {
  7829. // table2.Rows.RemoveAt(dac2.Count);
  7830. // }
  7831. //}
  7832. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7833. string otherFeeStr = "";
  7834. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7835. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7836. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7837. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7838. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7839. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7840. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7841. foreach (var otherInfo in dac5)
  7842. {
  7843. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7844. }
  7845. #endregion
  7846. if (otherFeeStr.Length > 0)
  7847. {
  7848. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7849. otherFeeStr = $"({otherFeeStr})";
  7850. dic.Add("OtherFeeStr", otherFeeStr);
  7851. }
  7852. foreach (var key in dic.Keys)
  7853. {
  7854. builder.MoveToBookmark(key);
  7855. builder.Write(dic[key]);
  7856. }
  7857. //模板文件名
  7858. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7859. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7860. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7861. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7862. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7863. }
  7864. }
  7865. else if (dto.ExportType == 3)
  7866. {
  7867. if (dto.SubTypeId == 1) //团组成员名单
  7868. {
  7869. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7870. //获取模板
  7871. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7872. //载入模板
  7873. var doc = new Document(tempPath);
  7874. var builder = new DocumentBuilder(doc);
  7875. //获取word里所有表格
  7876. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7877. //获取所填表格的序数
  7878. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7879. var rowStart = tableOne.Rows[0]; //获取第1行
  7880. //循环赋值
  7881. for (int i = 0; i < DeleClientList.Count; i++)
  7882. {
  7883. builder.MoveToCell(0, i + 1, 0, 0);
  7884. builder.Write(DeleClientList[i].Name);
  7885. builder.MoveToCell(0, i + 1, 1, 0);
  7886. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7887. builder.Write(sex);
  7888. builder.MoveToCell(0, i + 1, 2, 0);
  7889. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7890. builder.MoveToCell(0, i + 1, 3, 0);
  7891. builder.Write(DeleClientList[i].Company);
  7892. builder.MoveToCell(0, i + 1, 4, 0);
  7893. builder.Write(DeleClientList[i].Job);
  7894. }
  7895. //删除多余行
  7896. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7897. {
  7898. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7899. }
  7900. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7901. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7902. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7903. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7904. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7905. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7906. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7907. }
  7908. }
  7909. return Ok(JsonView(400, "操作失败!", ""));
  7910. }
  7911. catch (Exception ex)
  7912. {
  7913. return Ok(JsonView(400, ex.Message, ""));
  7914. }
  7915. }
  7916. /// <summary>
  7917. /// 获取三公费用标准city
  7918. /// </summary>
  7919. /// <param name="placeData"></param>
  7920. /// <param name="nationalTravelFeeId"></param>
  7921. /// <returns></returns>
  7922. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7923. {
  7924. string _city = string.Empty;
  7925. if (placeData.Count < 1) return _city;
  7926. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7927. if (data == null) return _city;
  7928. string country = data.Country;
  7929. string city = data.City;
  7930. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7931. else _city = city;
  7932. return _city;
  7933. }
  7934. ///// <summary>
  7935. ///// 团组模块 - 出入境费用 - 明细表导出
  7936. ///// </summary>
  7937. ///// <returns></returns>
  7938. //[HttpPost]
  7939. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7940. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7941. //{
  7942. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7943. // if (data.Code != 0)
  7944. // {
  7945. // return Ok(JsonView(false, data.Msg));
  7946. // }
  7947. // return Ok(JsonView(true, data.Msg, data.Data));
  7948. //}
  7949. /// <summary>
  7950. /// 团组模块 - 出入境费用 - 一键清空
  7951. /// </summary>
  7952. /// <returns></returns>
  7953. [HttpPost]
  7954. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7956. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7957. {
  7958. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7959. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7960. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7961. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7962. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7963. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7964. .SetColumns(x => new Grp_DayOtherPrice
  7965. {
  7966. IsDel = 1,
  7967. DeleteUserId = dto.UserId,
  7968. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7969. })
  7970. .ExecuteCommandAsync();
  7971. if (_view.Code == 0)
  7972. {
  7973. return Ok(JsonView(true, "操作成功"));
  7974. }
  7975. return Ok(JsonView(false, "操作失败"));
  7976. }
  7977. /// <summary>
  7978. /// 团组模块 - 出入境费用 - 子项删除
  7979. /// </summary>
  7980. /// <returns></returns>
  7981. [HttpPost]
  7982. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7984. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7985. {
  7986. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7987. if (data.Code != 0)
  7988. {
  7989. return Ok(JsonView(false, data.Msg));
  7990. }
  7991. return Ok(JsonView(true, "操作成功!", data.Data));
  7992. }
  7993. /// <summary>
  7994. /// 删除三公其他费用
  7995. /// </summary>
  7996. /// <param name="dto"></param>
  7997. /// <returns></returns>
  7998. [HttpPost]
  7999. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8000. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8001. {
  8002. var jw = JsonView(false, "删除失败!");
  8003. var data = new Grp_DayOtherPrice()
  8004. {
  8005. Id = dto.Id,
  8006. IsDel = 1,
  8007. DeleteUserId = dto.DeleteUserId,
  8008. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8009. };
  8010. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8011. if (del > 0)
  8012. {
  8013. jw.Code = 200;
  8014. jw.Msg = "删除成功!";
  8015. }
  8016. return Ok(jw);
  8017. }
  8018. /// <summary>
  8019. /// 团组模块 - 出入境国家费用标准 List
  8020. /// </summary>
  8021. /// <returns></returns>
  8022. [HttpPost]
  8023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8024. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8025. {
  8026. int provinceId = dto.ProvinceId;
  8027. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8028. var nftData = await _sqlSugar
  8029. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8030. JoinType.Left, ntf.Currency == sd1.Id,
  8031. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8032. JoinType.Left, ntf.ProvinceId == c.Id
  8033. ))
  8034. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8035. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8036. {
  8037. Id = ntf.Id,
  8038. ProvinceId = ntf.ProvinceId,
  8039. ProvinceName = c.Name_CN,
  8040. Continent = ntf.Continent,
  8041. Country = ntf.Country,
  8042. City = ntf.City,
  8043. Currency = ntf.Currency,
  8044. CurrencyCode = sd1.Name,
  8045. CurrencyName = sd1.Remark,
  8046. RoomCost = ntf.RoomCost,
  8047. FoodCost = ntf.FoodCost,
  8048. PublicCost = ntf.PublicCost,
  8049. LastUpdateUserId = ntf.LastUpdateUserId,
  8050. LastUpdateUserName = u.CnName,
  8051. LastUpdateTime = ntf.LastUpdateTime
  8052. })
  8053. .ToListAsync();
  8054. return Ok(JsonView(true, "查询成功!", nftData));
  8055. }
  8056. /// <summary>
  8057. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8058. /// </summary>
  8059. /// <returns></returns>
  8060. [HttpPost]
  8061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8062. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8063. {
  8064. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8065. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8066. List<string> countryData = new List<string>();
  8067. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8068. countryData = countryData.Distinct().ToList();
  8069. List<dynamic> dataSource = new List<dynamic>();
  8070. foreach (var item in countryData)
  8071. {
  8072. var cityData1 = new List<string>();
  8073. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8074. var countryData2 = new
  8075. {
  8076. CountryName = item,
  8077. CityData = cityData1
  8078. };
  8079. if (!dataSource.Contains(countryData2))
  8080. {
  8081. dataSource.Add(countryData2);
  8082. }
  8083. }
  8084. return Ok(JsonView(true, "查询成功!", dataSource));
  8085. }
  8086. /// <summary>
  8087. /// 团组模块 - 出入境国家费用标准 Page List
  8088. /// </summary>
  8089. /// <returns></returns>
  8090. [HttpPost]
  8091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8092. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8093. {
  8094. int portId = dto.PortType,
  8095. pageIndex = dto.PageIndex,
  8096. pageSize = dto.PageSize;
  8097. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8098. if (pageIndex == 0) pageIndex = 1;
  8099. if (pageSize == 0) pageSize = 10;
  8100. RefAsync<int> total = 0;
  8101. var nationalTravelFeeData = await _sqlSugar
  8102. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8103. JoinType.Left, ntf.Currency == sd1.Id,
  8104. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8105. JoinType.Left, ntf.ProvinceId == sd2.Id
  8106. ))
  8107. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8108. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8109. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8110. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8111. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8112. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8113. {
  8114. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8115. Id = ntf.Id,
  8116. ProvinceId = ntf.ProvinceId,
  8117. ProvinceName = sd2.Name_CN,
  8118. Continent = ntf.Continent,
  8119. Country = ntf.Country,
  8120. City = ntf.City,
  8121. Currency = ntf.Currency,
  8122. CurrencyCode = sd1.Name,
  8123. CurrencyName = sd1.Remark,
  8124. RoomCost = ntf.RoomCost,
  8125. FoodCost = ntf.FoodCost,
  8126. PublicCost = ntf.PublicCost,
  8127. LastUpdateUserId = ntf.LastUpdateUserId,
  8128. LastUpdateUserName = u.CnName,
  8129. LastUpdateTime = ntf.LastUpdateTime,
  8130. Remark = ntf.Remark
  8131. })
  8132. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8133. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8134. }
  8135. /// <summary>
  8136. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8137. /// </summary>
  8138. /// <returns></returns>
  8139. [HttpPost]
  8140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8141. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8142. {
  8143. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8144. int portId = dto.PortType;
  8145. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8146. string whereSql = string.Empty;
  8147. if (!string.IsNullOrEmpty(dto.Country))
  8148. {
  8149. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8150. }
  8151. if (!string.IsNullOrEmpty(dto.City))
  8152. {
  8153. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8154. }
  8155. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8156. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8157. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8158. From Grp_NationalTravelFee gntf
  8159. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8160. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8161. Where gntf.Isdel = 0 {0} ", whereSql);
  8162. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8163. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8164. }
  8165. /// <summary>
  8166. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8167. /// </summary>
  8168. /// <returns></returns>
  8169. [HttpPost]
  8170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8171. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8172. {
  8173. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8174. }
  8175. /// <summary>
  8176. /// 团组模块 - 出入境国家费用标准 - Del
  8177. /// </summary>
  8178. /// <returns></returns>
  8179. [HttpPost]
  8180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8181. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8182. {
  8183. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8184. {
  8185. Id = dto.Id,
  8186. DeleteUserId = dto.DeleteUserId,
  8187. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8188. IsDel = 1
  8189. };
  8190. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8191. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8192. .WhereColumns(it => new { it.Id })
  8193. .ExecuteCommandAsync();
  8194. if (delStatus <= 0)
  8195. {
  8196. return Ok(JsonView(false, "删除失败!"));
  8197. }
  8198. return Ok(JsonView(true, "操作成功!"));
  8199. }
  8200. /// <summary>
  8201. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8202. /// 注:Get 请求Headers 加 Token
  8203. /// </summary>
  8204. /// <param name="groupId"></param>
  8205. /// <returns></returns>
  8206. [HttpGet("{groupId}")]
  8207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8208. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8209. {
  8210. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8211. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8212. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8213. data.ForEach(x =>
  8214. {
  8215. x.CreateUserId = _currUserInfo.UserId;
  8216. });
  8217. if (data.Any())
  8218. {
  8219. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8220. if (add > 0)
  8221. {
  8222. return Ok(JsonView(true, "操作成功!"));
  8223. }
  8224. }
  8225. return Ok(JsonView(false, "未操作!"));
  8226. }
  8227. #endregion
  8228. #region 团组经理模块 出入境费用-草稿
  8229. /// <summary>
  8230. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8231. /// </summary>
  8232. /// <returns></returns>
  8233. [HttpGet]
  8234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8235. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8236. {
  8237. var provData = await _groupRepository.ProvinceBasicSource();
  8238. return Ok(JsonView(true, "查询成功!", provData));
  8239. }
  8240. /// <summary>
  8241. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8242. /// </summary>
  8243. /// <returns></returns>
  8244. [HttpGet("{provinceId}")]
  8245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8246. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8247. {
  8248. //验证城市归属并给默认值
  8249. if (provinceId < 1) provinceId = 122;
  8250. /*
  8251. * 122 四川
  8252. * 108 贵州
  8253. * 103 重庆
  8254. * 132 云南
  8255. */
  8256. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8257. return Ok(JsonView(true, "查询成功!", new
  8258. {
  8259. WordTypeData = wordTypeData,
  8260. ExcelTypeData = excelTypeData,
  8261. }));
  8262. }
  8263. /// <summary>
  8264. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8265. /// </summary>
  8266. /// <returns></returns>
  8267. [HttpPost]
  8268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8269. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8270. {
  8271. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8272. .Where(x => x.IsDel == 0)
  8273. .OrderByDescending(x => x.CreateTime)
  8274. .Select(x => new { x.Id, x.DraftName })
  8275. .ToListAsync();
  8276. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8277. //SetDataInfoView
  8278. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8279. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8280. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8281. int provinceId = dto.ProvinceId;
  8282. if (provinceId < 1) provinceId = 122;
  8283. /*
  8284. * 122 四川
  8285. * 108 贵州
  8286. * 103 重庆
  8287. * 132 云南
  8288. */
  8289. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8290. //默认币种显示
  8291. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8292. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8293. return Ok(JsonView(true, "查询成功!", new
  8294. {
  8295. DraftNameDatas = draftNameDatas,
  8296. CurrencyData = _CurrencyData,
  8297. WordTypeData = wordTypeData,
  8298. ExcelTypeData = excelTypeData,
  8299. CurrencyInit = _currencyInfos,
  8300. ViewPermissionData = viewPermissionData
  8301. }));
  8302. }
  8303. /// <summary>
  8304. /// 团组模块 - 出入境费用-草稿
  8305. /// 实时汇率 tips
  8306. /// 机票费用 tips
  8307. /// </summary>
  8308. /// <returns></returns>
  8309. [HttpPost]
  8310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8311. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8312. {
  8313. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8314. return Ok(JsonView(true, "查询成功!", new
  8315. {
  8316. //GroupNameData = groupNameData.Data,
  8317. //visaData = visaData.Data,
  8318. //airData = airData.Data,
  8319. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8320. }));
  8321. }
  8322. /// <summary>
  8323. /// 团组模块 - 出入境费用-草稿
  8324. /// 签证费用 tips
  8325. /// </summary>
  8326. /// <returns></returns>
  8327. [HttpPost]
  8328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8329. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8330. {
  8331. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8332. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8333. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8334. .Select(x => x.NationalTravelFeeId)
  8335. .Distinct()
  8336. .ToListAsync();
  8337. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8338. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8339. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8340. .Select(x => x.Country)
  8341. .Distinct()
  8342. .ToArrayAsync();
  8343. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8344. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8345. return Ok(JsonView(true, "查询成功!", new
  8346. {
  8347. totalAmt,
  8348. remark
  8349. }));
  8350. }
  8351. /// <summary>
  8352. /// 团组模块 - 出入境费用-草稿 - Info
  8353. /// </summary>
  8354. /// <returns></returns>
  8355. [HttpPost]
  8356. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8358. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8359. {
  8360. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8361. }
  8362. /// <summary>
  8363. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8364. /// </summary>
  8365. /// <returns></returns>
  8366. [HttpPost]
  8367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8368. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8369. {
  8370. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8371. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8372. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8373. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8374. foreach (var userId in dto.UserIds)
  8375. {
  8376. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8377. }
  8378. if (permissions.Any())
  8379. {
  8380. _sqlSugar.BeginTran();
  8381. try
  8382. {
  8383. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8384. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8385. if (result < 1)
  8386. {
  8387. _sqlSugar.RollbackTran();
  8388. return Ok(JsonView(false));
  8389. }
  8390. }
  8391. catch (Exception ex)
  8392. {
  8393. _sqlSugar.RollbackTran();
  8394. return Ok(JsonView(false, ex.Message));
  8395. }
  8396. _sqlSugar.CommitTran();
  8397. return Ok(JsonView(true));
  8398. }
  8399. return Ok(JsonView(false));
  8400. }
  8401. /// <summary>
  8402. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8403. /// </summary>
  8404. /// <returns></returns>
  8405. [HttpPost]
  8406. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8408. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8409. {
  8410. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8411. if (data.Code != 0)
  8412. {
  8413. return Ok(JsonView(false, data.Msg));
  8414. }
  8415. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8416. //汇率信息记录
  8417. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8418. return Ok(JsonView(true, data.Msg, data.Data));
  8419. }
  8420. /// <summary>
  8421. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8422. /// </summary>
  8423. /// <param name="dto"></param>
  8424. /// <returns></returns>
  8425. [HttpPost]
  8426. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8428. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8429. {
  8430. try
  8431. {
  8432. var id = dto.Id;
  8433. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8434. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8435. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8436. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8437. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8438. 3 团组成员名单 1 团组成员名单", ""));
  8439. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8440. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8441. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8442. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8443. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8444. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8445. //数据源
  8446. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8447. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8448. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8449. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8450. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8451. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8452. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8453. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8454. .Select((x, a, b) => new
  8455. {
  8456. x.Index,
  8457. itemName = a.Name,
  8458. CurrencyStr = b.Name,
  8459. x.Cost,
  8460. x.SubTotal,
  8461. x.Remark
  8462. })
  8463. .OrderBy((x) => x.Index)
  8464. .ToList(); //其他款项费用
  8465. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8466. var peiceItemCurrencys = new List<string>();
  8467. if (_DayAndCosts.Any())
  8468. {
  8469. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8470. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8471. }
  8472. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8473. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8474. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8475. {
  8476. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8477. }
  8478. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8479. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8480. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8481. if (dto.ExportType == 1) //明细表
  8482. {
  8483. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8484. {
  8485. //获取模板
  8486. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8487. //载入模板
  8488. Document doc = new Document(tempPath);
  8489. DocumentBuilder builder = new DocumentBuilder(doc);
  8490. //利用键值对存放数据
  8491. Dictionary<string, string> dic = new Dictionary<string, string>();
  8492. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8493. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8494. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8495. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8496. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8497. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8498. //境内费用(其他费用)
  8499. if (_EnterExitCosts.ChoiceOne == 1)
  8500. {
  8501. string row1_1 = "";
  8502. if (_EnterExitCosts.Visa > 0)
  8503. {
  8504. //insidePayTotal += _EnterExitCosts.Visa;
  8505. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8506. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8507. //{
  8508. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8509. //}
  8510. }
  8511. string row1_2 = "";
  8512. if (_EnterExitCosts.YiMiao > 0)
  8513. {
  8514. //insidePayTotal += _EnterExitCosts.YiMiao;
  8515. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8516. }
  8517. if (_EnterExitCosts.HeSuan > 0)
  8518. {
  8519. //insidePayTotal += _EnterExitCosts.HeSuan;
  8520. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8521. }
  8522. if (_EnterExitCosts.Service > 0)
  8523. {
  8524. //insidePayTotal += _EnterExitCosts.Service;
  8525. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8526. }
  8527. string row1_3 = "";
  8528. if (_EnterExitCosts.Safe > 0)
  8529. {
  8530. //insidePayTotal += _EnterExitCosts.Safe;
  8531. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8532. }
  8533. if (_EnterExitCosts.Ticket > 0)
  8534. {
  8535. //insidePayTotal += _EnterExitCosts.Ticket;
  8536. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8537. }
  8538. string row1 = "";
  8539. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8540. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8541. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8542. row1 += $"备注:{_EnterExitCosts.Remark}";
  8543. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8544. dic.Add("Row1Str", row1);
  8545. }
  8546. string airTotalStr = string.Empty,
  8547. airPriceStr = string.Empty;
  8548. //经济舱
  8549. if (_EnterExitCosts.SumJJC == 1)
  8550. {
  8551. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8552. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8553. }
  8554. //公务舱
  8555. if (_EnterExitCosts.SumGWC == 1)
  8556. {
  8557. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8558. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8559. }
  8560. //头等舱
  8561. if (_EnterExitCosts.SumTDC == 1)
  8562. {
  8563. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8564. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8565. }
  8566. //汇率描述
  8567. string rateStr = "";
  8568. if (peiceItemCurrencyInfos.Any())
  8569. {
  8570. rateStr = "\r\n汇率描述:";
  8571. foreach (var item in peiceItemCurrencyInfos)
  8572. {
  8573. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8574. }
  8575. }
  8576. string twoItemRemark = "备注:";
  8577. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8578. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8579. dic.Add("AirTotalStr", airTotalStr);
  8580. dic.Add("AirPriceStr", airPriceStr);
  8581. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8582. dic.Add("TwoItemRemark", twoItemRemark);
  8583. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8584. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8585. int table1Row = 0,
  8586. table2Row = 0,
  8587. table3Row = 0,
  8588. table4Row = 0,
  8589. table5Row = 0;
  8590. //住宿费
  8591. if (_EnterExitCosts.ChoiceThree == 1)
  8592. {
  8593. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8594. table1Row = dac1.Count;
  8595. #region 填充word表格内容
  8596. for (int i = 0; i < dac1.Count; i++)
  8597. {
  8598. var dac = dac1[i];
  8599. if (dac == null) continue;
  8600. builder.MoveToCell(0, i, 0, 0);
  8601. builder.Write("第" + dac.Days.ToString() + "晚:");
  8602. builder.MoveToCell(0, i, 1, 0);
  8603. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8604. //builder.Write(dac.Place == null ? "" : dac.Place);
  8605. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8606. builder.MoveToCell(0, i, 2, 0);
  8607. builder.Write("费用标准:");
  8608. string curr = "";
  8609. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8610. if (currData != null)
  8611. {
  8612. curr = currData.Name;
  8613. }
  8614. builder.MoveToCell(0, i, 3, 0);
  8615. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8616. builder.MoveToCell(0, i, 4, 0);
  8617. builder.Write("费用小计:");
  8618. builder.MoveToCell(0, i, 5, 0);
  8619. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8620. }
  8621. #endregion
  8622. }
  8623. else dic.Add("SubZS", "0.00");
  8624. //删除多余行
  8625. while (table1.Rows.Count > table1Row)
  8626. {
  8627. table1.Rows.RemoveAt(table1Row);
  8628. }
  8629. //伙食费
  8630. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8631. if (_EnterExitCosts.ChoiceFour == 1)
  8632. {
  8633. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8634. table2Row = dac2.Count;
  8635. #region 填充word表格内容
  8636. for (int i = 0; i < dac2.Count; i++)
  8637. {
  8638. var dac = dac2[i];
  8639. if (dac == null) continue;
  8640. builder.MoveToCell(1, i, 0, 0);
  8641. builder.Write("第" + dac.Days.ToString() + "天:");
  8642. builder.MoveToCell(1, i, 1, 0);
  8643. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8644. builder.MoveToCell(1, i, 2, 0);
  8645. builder.Write("费用标准:");
  8646. string curr = "";
  8647. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8648. if (currData != null)
  8649. {
  8650. curr = currData.Name;
  8651. }
  8652. builder.MoveToCell(1, i, 3, 0);
  8653. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8654. builder.MoveToCell(1, i, 4, 0);
  8655. builder.Write("费用小计:");
  8656. builder.MoveToCell(1, i, 5, 0);
  8657. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8658. }
  8659. #endregion
  8660. }
  8661. else dic.Add("SubHS", "0.00");
  8662. //删除多余行
  8663. while (table2.Rows.Count > table2Row)
  8664. {
  8665. table2.Rows.RemoveAt(table2Row);
  8666. }
  8667. //公杂费
  8668. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8669. if (_EnterExitCosts.ChoiceFive == 1)
  8670. {
  8671. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8672. table3Row = dac3.Count;
  8673. #region 填充word表格内容
  8674. for (int i = 0; i < dac3.Count; i++)
  8675. {
  8676. var dac = dac3[i];
  8677. if (dac == null) continue;
  8678. builder.MoveToCell(2, i, 0, 0);
  8679. builder.Write("第" + dac.Days.ToString() + "天:");
  8680. builder.MoveToCell(2, i, 1, 0);
  8681. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8682. builder.MoveToCell(2, i, 2, 0);
  8683. builder.Write("费用标准:");
  8684. string curr = "";
  8685. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8686. if (currData != null)
  8687. {
  8688. curr = currData.Name;
  8689. }
  8690. builder.MoveToCell(2, i, 3, 0);
  8691. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8692. builder.MoveToCell(2, i, 4, 0);
  8693. builder.Write("费用小计:");
  8694. builder.MoveToCell(2, i, 5, 0);
  8695. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8696. }
  8697. //删除多余行
  8698. while (table3.Rows.Count > table3Row)
  8699. {
  8700. table3.Rows.RemoveAt(table3Row);
  8701. }
  8702. #endregion
  8703. }
  8704. else dic.Add("SubGZF", "0.00");
  8705. //删除多余行
  8706. while (table3.Rows.Count > table3Row)
  8707. {
  8708. table3.Rows.RemoveAt(table3Row);
  8709. }
  8710. //培训费
  8711. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8712. if (_EnterExitCosts.ChoiceSix == 1)
  8713. {
  8714. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8715. dic.Add("SubPX", pxStr);
  8716. table4Row = dac4.Count;
  8717. #region 填充word表格内容
  8718. for (int i = 0; i < dac4.Count; i++)
  8719. {
  8720. var dac = dac4[i];
  8721. if (dac == null) continue;
  8722. builder.MoveToCell(3, i, 0, 0);
  8723. builder.Write("第" + dac.Days.ToString() + "天:");
  8724. builder.MoveToCell(3, i, 1, 0);
  8725. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8726. builder.MoveToCell(3, i, 2, 0);
  8727. builder.Write("费用标准:");
  8728. string curr = "";
  8729. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8730. if (currData != null)
  8731. {
  8732. curr = currData.Name;
  8733. }
  8734. builder.MoveToCell(3, i, 3, 0);
  8735. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8736. builder.MoveToCell(3, i, 4, 0);
  8737. builder.Write("费用小计:");
  8738. builder.MoveToCell(3, i, 5, 0);
  8739. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8740. }
  8741. #endregion
  8742. }
  8743. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8744. //删除多余行
  8745. while (table4.Rows.Count > table4Row)
  8746. {
  8747. table4.Rows.RemoveAt(table4Row);
  8748. }
  8749. //其他费用
  8750. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8751. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8752. {
  8753. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8754. dic.Add("titleQi", qtStr);
  8755. table5Row = dac5.Count;
  8756. #region 填充word表格内容
  8757. for (int i = 0; i < dac5.Count; i++)
  8758. {
  8759. var dac = dac5[i];
  8760. if (dac == null) continue;
  8761. builder.MoveToCell(4, i, 0, 0);
  8762. builder.Write("第" + dac.Index.ToString() + "项:");
  8763. builder.MoveToCell(4, i, 1, 0);
  8764. builder.Write(dac.itemName);
  8765. builder.MoveToCell(4, i, 2, 0);
  8766. builder.Write("费用标准:");
  8767. builder.MoveToCell(4, i, 3, 0);
  8768. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8769. builder.MoveToCell(4, i, 4, 0);
  8770. builder.Write("费用小计:");
  8771. builder.MoveToCell(4, i, 5, 0);
  8772. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8773. builder.MoveToCell(4, i, 6, 0);
  8774. builder.Write("备注:");
  8775. builder.MoveToCell(4, i, 7, 0);
  8776. builder.Write(dac.Remark);
  8777. }
  8778. #endregion
  8779. }
  8780. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8781. //删除多余行
  8782. while (table5.Rows.Count > table5Row)
  8783. {
  8784. table5.Rows.RemoveAt(table5Row);
  8785. }
  8786. //加上其他费用
  8787. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8788. decimal subJJC = 0.00M,
  8789. subGWC = 0.00M,
  8790. subTDC = 0.00M;
  8791. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8792. string totalLabel = string.Format("全部费用总计:");
  8793. //经济舱
  8794. if (_EnterExitCosts.SumJJC == 1)
  8795. {
  8796. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8797. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8798. }
  8799. //公务舱
  8800. if (_EnterExitCosts.SumGWC == 1)
  8801. {
  8802. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8803. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8804. }
  8805. //头等舱
  8806. if (_EnterExitCosts.SumTDC == 1)
  8807. {
  8808. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8809. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8810. }
  8811. //TotalLabel
  8812. dic.Add("TotalLabel", totalLabel);
  8813. #region 填充word模板书签内容
  8814. foreach (var key in dic.Keys)
  8815. {
  8816. Bookmark bookmark = doc.Range.Bookmarks[key];
  8817. if (bookmark != null)
  8818. {
  8819. builder.MoveToBookmark(key);
  8820. builder.Write(dic[key]);
  8821. }
  8822. }
  8823. #endregion
  8824. //文件名
  8825. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8826. strFileName = CommonFun.ValidFileName(strFileName);
  8827. AsposeHelper.removewatermark_v2180();
  8828. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8829. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8830. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8831. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8832. }
  8833. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8834. {
  8835. //获取模板
  8836. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8837. //载入模板
  8838. Document doc = new Document(tempPath);
  8839. DocumentBuilder builder = new DocumentBuilder(doc);
  8840. Dictionary<string, string> dic = new Dictionary<string, string>();
  8841. string returnCodeLabel = string.Empty;
  8842. if (nationalTravelFeeData.Any())
  8843. {
  8844. List<string> list = new List<string>();
  8845. foreach (var item in nationalTravelFeeData)
  8846. {
  8847. list.Add($"{item.Country}({item.City})");
  8848. }
  8849. list = list.Distinct().ToList();
  8850. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8851. }
  8852. var countryLabel = string.Empty;
  8853. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8854. if (countryData.Any())
  8855. {
  8856. countryLabel = string.Join("、", countryData);
  8857. }
  8858. dic.Add("ReturnCodeAir", returnCodeLabel);
  8859. dic.Add("VisitStartDate", "-");
  8860. dic.Add("VisitEndDate", "-");
  8861. dic.Add("Day", "-");
  8862. dic.Add("VisitCountry", countryLabel);
  8863. dic.Add("ClientUnit", "-");
  8864. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8865. //dic.Add("Names", Names);
  8866. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8867. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8868. decimal dac1totalPrice = 0.00M;
  8869. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8870. foreach (var dac in dac1)
  8871. {
  8872. if (dac.SubTotal == 0.00M)
  8873. {
  8874. continue;
  8875. }
  8876. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8877. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8878. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8879. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8880. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8881. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8882. builder.Write(currency);//币种
  8883. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8884. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8885. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8886. builder.Write("");//人数
  8887. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8888. builder.Write("");//天数
  8889. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8890. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8891. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8892. decimal rate = 0.00M;
  8893. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8894. builder.Write(rate.ToString("#0.0000"));//汇率
  8895. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8896. decimal rbmPrice = dac.SubTotal;
  8897. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8898. accommodationStartIndex++;
  8899. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8900. }
  8901. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8902. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8903. {
  8904. table1.Rows.RemoveAt(i - 1);
  8905. foodandotherStartIndex--;
  8906. }
  8907. if (dac2.Count == dac3.Count)//国家 币种 金额
  8908. {
  8909. for (int i = 0; i < dac2.Count; i++)
  8910. {
  8911. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8912. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8913. }
  8914. }
  8915. decimal dac2totalPrice = 0.00M;
  8916. foreach (var dac in dac2)
  8917. {
  8918. if (dac.SubTotal == 0)
  8919. {
  8920. continue;
  8921. }
  8922. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8923. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8924. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8925. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8926. builder.Write(currency);//币种
  8927. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8928. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8929. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8930. builder.Write("");//人数
  8931. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8932. builder.Write("");//天数
  8933. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8934. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8935. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8936. decimal rate = 0.00M;
  8937. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8938. builder.Write(rate.ToString("#0.0000"));//汇率
  8939. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8940. decimal rbmPrice = dac.SubTotal;
  8941. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8942. foodandotherStartIndex++;
  8943. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8944. }
  8945. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8946. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8947. {
  8948. table1.Rows.RemoveAt(i - 1);
  8949. }
  8950. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8951. string otherFeeStr = "";
  8952. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8953. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8954. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8955. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8956. foreach (var otherInfo in dac5)
  8957. {
  8958. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8959. }
  8960. #endregion
  8961. if (otherFeeStr.Length > 0)
  8962. {
  8963. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8964. otherFeeStr = $"({otherFeeStr})";
  8965. dic.Add("OtherFeeStr", otherFeeStr);
  8966. }
  8967. //总计
  8968. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8969. //国际旅费
  8970. string outsideAir = string.Empty;
  8971. string allPriceAir = string.Empty;
  8972. if (_EnterExitCosts.SumJJC == 1)
  8973. {
  8974. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8975. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8976. }
  8977. if (_EnterExitCosts.SumGWC == 1)
  8978. {
  8979. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8980. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8981. }
  8982. if (_EnterExitCosts.SumTDC == 1)
  8983. {
  8984. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8985. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8986. }
  8987. dic.Add("InTravelPrice", $"({outsideAir})");
  8988. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8989. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8990. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8991. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8992. foreach (var key in dic.Keys)
  8993. {
  8994. builder.MoveToBookmark(key);
  8995. builder.Write(dic[key]);
  8996. }
  8997. //模板文件名
  8998. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8999. strFileName = CommonFun.ValidFileName(strFileName);
  9000. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9001. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9002. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9003. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9004. }
  9005. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9006. {
  9007. //获取模板
  9008. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9009. //载入模板
  9010. WorkbookDesigner designer = new WorkbookDesigner();
  9011. designer.Workbook = new Workbook(tempPath);
  9012. Dictionary<string, string> dic = new Dictionary<string, string>();
  9013. string returnCodeLabel = string.Empty;
  9014. if (nationalTravelFeeData.Any())
  9015. {
  9016. List<string> list = new List<string>();
  9017. foreach (var item in nationalTravelFeeData)
  9018. {
  9019. list.Add($"{item.Country}({item.City})");
  9020. }
  9021. list = list.Distinct().ToList();
  9022. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9023. }
  9024. var countryLabel = string.Empty;
  9025. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9026. if (countryData.Any())
  9027. {
  9028. countryLabel = string.Join("、", countryData);
  9029. }
  9030. dic.Add("ReturnCodeAir", returnCodeLabel);
  9031. dic.Add("VisitStartDate", "-");
  9032. dic.Add("VisitEndDate", "-");
  9033. dic.Add("Day", "0");
  9034. dic.Add("VisitCountry", countryLabel);
  9035. dic.Add("ClientUnit", "-");
  9036. designer.SetDataSource("ClientUnit", "-");
  9037. designer.SetDataSource("VisitCountry", countryLabel);
  9038. designer.SetDataSource("Group", "-");
  9039. designer.SetDataSource("ClientUnitTitle", "-");
  9040. designer.SetDataSource("Name", "-");
  9041. designer.SetDataSource("VisitStartDate", "-");
  9042. designer.SetDataSource("Day", "0");
  9043. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9044. designer.SetDataSource("ReturnCodeAir", "-");
  9045. int startIndex = 10;
  9046. const int startIndexcopy = 10;
  9047. if (dac2.Count == dac3.Count)//国家 币种 金额
  9048. {
  9049. for (int i = 0; i < dac2.Count; i++)
  9050. {
  9051. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9052. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9053. }
  9054. }
  9055. DataTable dtdac1 = new DataTable();
  9056. List<string> place = new List<string>();
  9057. dtdac1.Columns.AddRange(new DataColumn[] {
  9058. new DataColumn(){ ColumnName = "city"},
  9059. new DataColumn(){ ColumnName = "curr"},
  9060. new DataColumn(){ ColumnName = "criterion"},
  9061. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9062. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9063. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9064. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9065. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9066. });
  9067. DataTable dtdac2 = new DataTable();
  9068. dtdac2.Columns.AddRange(new DataColumn[] {
  9069. new DataColumn(){ ColumnName = "city"},
  9070. new DataColumn(){ ColumnName = "curr"},
  9071. new DataColumn(){ ColumnName = "criterion"},
  9072. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9073. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9074. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9075. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9076. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9077. });
  9078. dtdac1.TableName = "tb1";
  9079. dtdac2.TableName = "tb2";
  9080. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9081. foreach (var item in dac1)
  9082. {
  9083. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9084. if (place.Contains(item.Place))
  9085. {
  9086. continue;
  9087. }
  9088. DataRow row = dtdac1.NewRow();
  9089. row["city"] = item.Place;
  9090. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9091. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9092. row["curr"] = currency;
  9093. row["rate"] = rate.ToString("#0.0000");
  9094. row["criterion"] = item.Cost.ToString("#0.00");
  9095. row["number"] = 1;
  9096. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9097. //row["costRMB"] = rbmPrice;
  9098. dtdac1.Rows.Add(row);
  9099. place.Add(item.Place);
  9100. }
  9101. place = new List<string>();
  9102. foreach (var item in dac2)
  9103. {
  9104. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9105. if (place.Contains(item.Place))
  9106. {
  9107. continue;
  9108. }
  9109. DataRow row = dtdac2.NewRow();
  9110. row["city"] = item.Place;
  9111. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9112. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9113. row["curr"] = currency;
  9114. row["rate"] = rate.ToString("#0.0000");
  9115. row["criterion"] = item.Cost.ToString("#0.00");
  9116. row["number"] = 1;
  9117. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9118. //row["cost"] = item.SubTotal;
  9119. //row["costRMB"] = rbmPrice;
  9120. dtdac2.Rows.Add(row);
  9121. place.Add(item.Place);
  9122. //dac2totalPrice += rbmPrice;
  9123. }
  9124. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9125. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9126. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9127. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9128. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9129. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9130. string cell4Str1 = string.Empty;
  9131. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9132. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9133. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9134. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9135. string cellStr = $" 5.其他费用(";
  9136. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9137. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9138. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9139. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9140. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9141. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9142. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9143. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9144. foreach (var otherInfo in dac5)
  9145. {
  9146. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9147. }
  9148. #endregion
  9149. if (cellStr.Length > 8)
  9150. {
  9151. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9152. }
  9153. cellStr += ")";
  9154. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9155. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9156. decimal pxFee = dac4.Sum(it => it.Cost);
  9157. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9158. string celllastStr1 = "";
  9159. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9160. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9161. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9162. celllastStr1 += $",国际旅费 元";
  9163. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9164. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9165. designer.SetDataSource("cell4Str", cell4Str);
  9166. designer.SetDataSource("cellStr", cellStr);
  9167. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9168. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9169. designer.SetDataSource("celllastStr", celllastStr);
  9170. Workbook wb = designer.Workbook;
  9171. var sheet = wb.Worksheets[0];
  9172. //绑定datatable数据集
  9173. designer.SetDataSource(dtdac1);
  9174. designer.SetDataSource(dtdac2);
  9175. designer.Process();
  9176. var rowStart = dtdac1.Rows.Count;
  9177. while (rowStart > 0)
  9178. {
  9179. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9180. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9181. startIndex++;
  9182. rowStart--;
  9183. }
  9184. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9185. startIndex += 1; //总计行
  9186. rowStart = dtdac2.Rows.Count;
  9187. while (rowStart > 0)
  9188. {
  9189. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9190. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9191. startIndex++;
  9192. rowStart--;
  9193. }
  9194. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9195. wb.CalculateFormula(true);
  9196. //模板文件名
  9197. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9198. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9199. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9200. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9201. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9202. }
  9203. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9204. {
  9205. //获取模板
  9206. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9207. //载入模板
  9208. Document doc = new Document(tempPath);
  9209. DocumentBuilder builder = new DocumentBuilder(doc);
  9210. Dictionary<string, string> dic = new Dictionary<string, string>();
  9211. dic.Add("GroupName", "-");
  9212. dic.Add("ClientUnit", "-");
  9213. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9214. //string missionLeaderJob = "";//负责人job
  9215. //int groupNumber = 0; //团人数
  9216. dic.Add("MissionLeader", "-"); //团负责人
  9217. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9218. dic.Add("GroupNumber", "0"); //团人数
  9219. dic.Add("Day", "0");
  9220. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9221. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9222. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9223. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9224. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9225. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9226. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9227. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9228. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9229. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9230. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9231. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9232. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9233. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9234. //其他费用
  9235. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9236. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9237. //其他费用合计
  9238. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9239. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9240. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9241. //公务舱合计
  9242. //国际旅费
  9243. //string outsideJJ = "";
  9244. //string allPriceJJ = "";
  9245. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9246. {
  9247. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9248. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9249. }
  9250. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9251. {
  9252. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9253. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9254. }
  9255. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9256. {
  9257. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9258. dic.Add("AirFeeTotal", airFeeTotalStr);
  9259. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9260. dic.Add("FeeTotal", feeTotalStr);
  9261. }
  9262. foreach (var key in dic.Keys)
  9263. {
  9264. builder.MoveToBookmark(key);
  9265. builder.Write(dic[key]);
  9266. }
  9267. //模板文件名
  9268. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9269. strFileName = CommonFun.ValidFileName(strFileName);
  9270. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9271. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9272. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9273. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9274. }
  9275. }
  9276. else if (dto.ExportType == 2) //表格
  9277. {
  9278. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9279. }
  9280. else if (dto.ExportType == 3)
  9281. {
  9282. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9283. }
  9284. return Ok(JsonView(400, "只可导出明细表!", ""));
  9285. }
  9286. catch (Exception ex)
  9287. {
  9288. return Ok(JsonView(400, ex.Message, ""));
  9289. }
  9290. }
  9291. /// <summary>
  9292. /// 获取三公费用标准city
  9293. /// </summary>
  9294. /// <param name="placeData"></param>
  9295. /// <param name="nationalTravelFeeId"></param>
  9296. /// <returns></returns>
  9297. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9298. {
  9299. string _city = string.Empty;
  9300. if (!placeData.Any()) return _city;
  9301. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9302. if (data == null) return _city;
  9303. string country = data.Country;
  9304. string city = data.City;
  9305. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9306. else _city = city;
  9307. return _city;
  9308. }
  9309. /// <summary>
  9310. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9311. /// </summary>
  9312. /// <returns></returns>
  9313. [HttpPost]
  9314. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9316. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9317. {
  9318. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9319. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9320. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9321. if (_view.Code == 0)
  9322. {
  9323. return Ok(JsonView(true, "操作成功"));
  9324. }
  9325. return Ok(JsonView(false, "操作失败"));
  9326. }
  9327. /// <summary>
  9328. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9329. /// </summary>
  9330. /// <returns></returns>
  9331. [HttpPost]
  9332. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9334. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9335. {
  9336. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9337. if (data.Code != 0)
  9338. {
  9339. return Ok(JsonView(false, data.Msg));
  9340. }
  9341. return Ok(JsonView(true, "操作成功!", data.Data));
  9342. }
  9343. /// <summary>
  9344. /// 三公其他费用草稿 删除
  9345. /// </summary>
  9346. /// <param name="dto"></param>
  9347. /// <returns></returns>
  9348. [HttpPost]
  9349. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9350. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9351. {
  9352. var jw = JsonView(false, "删除失败!");
  9353. var data = new Grp_DayOtherPriceDraft()
  9354. {
  9355. Id = dto.Id,
  9356. IsDel = 1,
  9357. DeleteUserId = dto.DeleteUserId,
  9358. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9359. };
  9360. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9361. if (del > 0)
  9362. {
  9363. jw.Code = 200;
  9364. jw.Msg = "删除成功!";
  9365. }
  9366. return Ok(jw);
  9367. }
  9368. /// <summary>
  9369. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9370. /// </summary>
  9371. /// <returns></returns>
  9372. [HttpPost]
  9373. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9374. {
  9375. var jw = JsonView(false);
  9376. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9377. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9378. jw.Code = StatusCodes.Status200OK;
  9379. jw.Msg = "操作成功!";
  9380. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9381. return Ok(jw);
  9382. }
  9383. /// <summary>
  9384. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9385. /// </summary>
  9386. /// <param name="dto"></param>
  9387. /// <returns></returns>
  9388. [HttpPost]
  9389. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9390. {
  9391. int userId = dto.UserId,
  9392. portId = dto.PortType,
  9393. groupId = dto.GroupId,
  9394. draftId = dto.DraftId;
  9395. _portTypeData.Add(1);
  9396. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9397. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9398. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9399. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9400. _sqlSugar.BeginTran();
  9401. try
  9402. {
  9403. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9404. if (draftDatas == null)
  9405. {
  9406. _sqlSugar.RollbackTran();
  9407. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9408. }
  9409. //验证可覆盖已有数据 两边创建人需为同一人;
  9410. int draftCreateUserId = draftDatas.CreateUserId,
  9411. formalCreateUserId = 0;
  9412. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9413. if (formalData != null)
  9414. {
  9415. formalCreateUserId = formalData.CreateUserId;
  9416. if (draftCreateUserId != formalCreateUserId)
  9417. {
  9418. _sqlSugar.RollbackTran();
  9419. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9420. }
  9421. }
  9422. //默认添加查看、编辑权限(创建人、自己)
  9423. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9424. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9425. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9426. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9427. newExterData.DiId = groupId;
  9428. newExterData.CreateUserId = userId;
  9429. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9430. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9431. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9432. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9433. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9434. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9435. //数据如果存在执行删除
  9436. if (enterExitCostInfo != null)
  9437. {
  9438. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9439. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9440. .Where(x => x.Id == enterExitCostInfo.Id)
  9441. .ExecuteCommand();
  9442. _sqlSugar.Updateable<Grp_DayAndCost>()
  9443. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9444. .Where(x => x.DiId == groupId)
  9445. .ExecuteCommand();
  9446. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9447. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9448. .Where(x => x.Diid == groupId)
  9449. .ExecuteCommand();
  9450. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9451. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9452. .Where(x => x.GroupId == groupId)
  9453. .ExecuteCommand();
  9454. }
  9455. //执行insert
  9456. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9457. if (insertId < 1)
  9458. {
  9459. _sqlSugar.RollbackTran();
  9460. return Ok(JsonView(false, "草稿数据导入失败!"));
  9461. }
  9462. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9463. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9464. #region 默认添加权限
  9465. #endregion
  9466. _sqlSugar.CommitTran();
  9467. //执行操作之后
  9468. //生成默认文件pdf并且通知人员
  9469. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9470. {
  9471. DiId = groupId,
  9472. ExportType = 1,
  9473. SubTypeId = 1005
  9474. }, "pdf");
  9475. //发送通知
  9476. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9477. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9478. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9479. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9480. //汇率信息记录
  9481. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9482. return Ok(JsonView(true));
  9483. }
  9484. catch (Exception ex)
  9485. {
  9486. _sqlSugar.RollbackTran();
  9487. return Ok(JsonView(false, ex.Message));
  9488. }
  9489. }
  9490. #endregion
  9491. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9492. /// <summary>
  9493. /// 获取币种基础数据(含逻辑处理)
  9494. /// </summary>
  9495. /// <returns></returns>
  9496. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9497. {
  9498. return await GeneralMethod.EnterExitCostInitRate();
  9499. }
  9500. /// <summary>
  9501. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9502. /// </summary>
  9503. /// <returns></returns>
  9504. [HttpPost]
  9505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9506. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9507. {
  9508. //验证城市归属并给默认值
  9509. int provinceId = dto.ProvinceId;
  9510. if (provinceId < 1) provinceId = 122;
  9511. var dataSource = await _sqlSugar
  9512. .Queryable<Sys_SetData>()
  9513. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9514. .ToListAsync();
  9515. var fileTypes = new List<EecSetDataInfoView>();
  9516. //三公费用-Word明细类型
  9517. var wordTypeData = dataSource
  9518. .Where(it => it.STid == 72)
  9519. .Select(x => new EecSetDataInfoView
  9520. {
  9521. ParentId = 1,
  9522. Id = x.Id,
  9523. Name = x.Name
  9524. })
  9525. .ToArray();
  9526. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9527. var excelTypeData = dataSource
  9528. .Where(it => it.STid == 73)
  9529. .Select(x => new EecSetDataInfoView
  9530. {
  9531. ParentId = 2,
  9532. Id = x.Id,
  9533. Name = x.Name
  9534. })
  9535. .ToArray();
  9536. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9537. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9538. fileTypes.Add(groupNameList);
  9539. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9540. //默认币种显示
  9541. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9542. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9543. return Ok(JsonView(true, "查询成功!", new
  9544. {
  9545. FileTypeData = fileTypes,
  9546. CurrencyInit = _currencyInfos,
  9547. viewPermissionData = viewPermissionData
  9548. }));
  9549. }
  9550. /// <summary>
  9551. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9552. /// </summary>
  9553. /// <returns></returns>
  9554. [HttpPost]
  9555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9556. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9557. {
  9558. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9559. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9560. RefAsync<int> total = 0;
  9561. int diId = 0;
  9562. var status = int.TryParse(dto.GroupName, out diId);
  9563. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9564. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9565. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9566. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9567. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9568. .OrderByDescending(x => x.VisitStartDate)
  9569. .Select(x => new EnterExitCostMobileGroupView()
  9570. {
  9571. Id = x.Id,
  9572. GroupName = x.TeamName,
  9573. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9574. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9575. ProvinceId = x.CityId
  9576. })
  9577. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9578. //处理省份Id
  9579. if (data.Any())
  9580. {
  9581. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9582. if (provCityDatas.Any())
  9583. {
  9584. foreach (var item in data)
  9585. {
  9586. var provinceId = item.ProvinceId;
  9587. var isDefualtVal = true;
  9588. if (provinceId > 0)
  9589. {
  9590. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9591. if (parentId != null)
  9592. {
  9593. isDefualtVal = false;
  9594. item.ProvinceId = (int)parentId;
  9595. }
  9596. }
  9597. if (isDefualtVal)
  9598. {
  9599. item.ProvinceId = 122; //默认四川
  9600. }
  9601. }
  9602. }
  9603. }
  9604. //处理是否显示
  9605. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9606. {
  9607. foreach (var item in data)
  9608. {
  9609. item.IsView = true;
  9610. }
  9611. }
  9612. return Ok(JsonView(true, "查询成功!", data, total));
  9613. }
  9614. /// <summary>
  9615. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9616. /// </summary>
  9617. /// <returns></returns>
  9618. [HttpPost]
  9619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9620. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9621. {
  9622. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9623. RefAsync<int> total = 0;
  9624. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9625. .Where(x => x.IsDel == 0 && x.STid == 66)
  9626. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9627. .Select(x => new
  9628. {
  9629. id = x.Id,
  9630. name = x.Name,
  9631. remark = x.Remark,
  9632. })
  9633. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9634. return Ok(JsonView(true, "查询成功!", data, total));
  9635. }
  9636. /// <summary>
  9637. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9638. /// </summary>
  9639. /// <returns></returns>
  9640. [HttpPost]
  9641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9642. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9643. {
  9644. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9645. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9646. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9647. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9648. var groupOtherRateData = groupRateData.TeamRates;
  9649. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9650. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9651. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9652. groupOtherRateData = groupOtherRateData
  9653. .Select(x => new TeamRateDescAddCurrencyIdView
  9654. {
  9655. CurrencyId = x.CurrencyId,
  9656. CurrencyName = x.CurrencyName,
  9657. CurrencyCode = x.CurrencyCode,
  9658. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9659. }).ToList();
  9660. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9661. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9662. }
  9663. /// <summary>
  9664. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9665. /// </summary>
  9666. /// <returns></returns>
  9667. [HttpPost]
  9668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9669. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9670. {
  9671. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9672. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9673. var tipsData = new List<int>() { 1, 2, 3 };
  9674. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9675. if (dto.TipsType == 1)
  9676. {
  9677. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9678. }
  9679. else if (dto.TipsType == 2)
  9680. {
  9681. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9682. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9683. }
  9684. else if (dto.TipsType == 3)
  9685. {
  9686. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9687. return Ok(JsonView(true, "查询成功!", airData));
  9688. }
  9689. return Ok(JsonView(false));
  9690. }
  9691. /// <summary>
  9692. /// 团组模块 - 出入境国家费用标准-移动端 List
  9693. /// </summary>
  9694. /// <returns></returns>
  9695. [HttpPost]
  9696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9697. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9698. {
  9699. Stopwatch sw = new Stopwatch();
  9700. sw.Start();
  9701. int provinceId = dto.ProvinceId;
  9702. if (provinceId < 1) provinceId = 122; // 默认四川
  9703. RefAsync<int> total = 0;
  9704. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9705. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9706. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9707. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9708. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9709. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9710. .Select((ntf, sd, u, sd1) => new
  9711. {
  9712. Id = ntf.Id,
  9713. Area = $"{ntf.Country}-{ntf.City}",
  9714. Currency = ntf.Currency,
  9715. CurrencyCode = sd.Name,
  9716. CurrencyName = sd.Remark,
  9717. RoomCost = ntf.RoomCost,
  9718. FoodCost = ntf.FoodCost,
  9719. PublicCost = ntf.PublicCost,
  9720. TrainCost = ntf.TrainCost,
  9721. LastUpdateUserId = ntf.LastUpdateUserId,
  9722. LastUpdateUserName = u.CnName,
  9723. LastUpdateTime = ntf.LastUpdateTime
  9724. })
  9725. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9726. sw.Stop();
  9727. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9728. }
  9729. /// <summary>
  9730. /// 团组模块 - 出入境费用-移动端 - Info
  9731. /// </summary>
  9732. /// <returns></returns>
  9733. [HttpPost]
  9734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9735. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9736. {
  9737. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9738. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9739. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9740. return Ok(data);
  9741. }
  9742. /// <summary>
  9743. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9744. /// </summary>
  9745. /// <returns></returns>
  9746. [HttpPost]
  9747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9748. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9749. {
  9750. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9751. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9752. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9753. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9754. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9755. mobileInfo.DiId = dto.DiId;
  9756. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9757. if (eecInfo == null) return Ok(mobileInfo);
  9758. //验证查看权限
  9759. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9760. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9761. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9762. mobileInfo.IsAssignPerm = isSet;
  9763. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9764. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9765. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9766. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9767. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9768. {
  9769. SubId = dac.Id,
  9770. DiId = dac.DiId,
  9771. Type = dac.Type,
  9772. Days = dac.Days,
  9773. NationalTravelFeeId = dac.NationalTravelFeeId,
  9774. Arae = $"{ntf.Country}-{ntf.City}",
  9775. Cost = dac.Cost,
  9776. Currency = dac.Currency,
  9777. CurrencyName = sd.Name,
  9778. SubTotal = dac.SubTotal,
  9779. })
  9780. .ToList();
  9781. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9782. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9783. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9784. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9785. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9786. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9787. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9788. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9789. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9790. //其他款项
  9791. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9792. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9793. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9794. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9795. .OrderBy((dop, sd1, sd2) => dop.Index)
  9796. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9797. {
  9798. SubId = dop.Id,
  9799. DiId = dop.Diid,
  9800. Index = dop.Index,
  9801. SetDataId = dop.SetDataId,
  9802. SetDataName = sd1.Name,
  9803. Cost = dop.Cost,
  9804. Currency = dop.Currency,
  9805. CurrencyName = sd2.Remark,
  9806. SubTotal = dop.SubTotal,
  9807. Remark = dop.Remark,
  9808. })
  9809. .ToArray();
  9810. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9811. return Ok(mobileInfo);
  9812. }
  9813. /// <summary>
  9814. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9815. /// </summary>
  9816. /// <returns></returns>
  9817. [HttpPost]
  9818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9819. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9820. {
  9821. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9822. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9823. //验证查看权限
  9824. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9825. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9826. var userIds = await _sqlSugar
  9827. .Queryable<Grp_EnterExitCostPermission>()
  9828. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9829. .Select(x => x.UserId)
  9830. .ToArrayAsync();
  9831. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9832. var perUsersView = new List<dynamic>();
  9833. foreach (var item in perUsers)
  9834. {
  9835. bool isView1 = false;
  9836. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9837. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9838. }
  9839. return Ok(JsonView(perUsersView));
  9840. }
  9841. /// <summary>
  9842. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9843. /// </summary>
  9844. /// <returns></returns>
  9845. [HttpPost]
  9846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9847. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9848. {
  9849. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9850. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9851. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9852. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9853. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9854. //验证查看权限
  9855. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9856. //if (!isView) return Ok(JsonView(false, msg));
  9857. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9858. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9859. var subType = dto.SubType;
  9860. if (subType == 1) //1:境内费用
  9861. {
  9862. var oneData = new ChoiceOneMobileSubInfoView()
  9863. {
  9864. Id = eecInfo.Id,
  9865. ChoiceOne = eecInfo.ChoiceOne,
  9866. ChoiceOneTotalCost = eecInfo.InsidePay,
  9867. Visa = eecInfo.Visa,
  9868. VisaRemark = eecInfo.VisaRemark,
  9869. YiMiao = eecInfo.YiMiao,
  9870. HeSuan = eecInfo.HeSuan,
  9871. Service = eecInfo.Service,
  9872. Ticket = eecInfo.Ticket,
  9873. Safe = eecInfo.Safe,
  9874. FirstItemRemark = eecInfo.FirstItemRemark
  9875. };
  9876. return Ok(JsonView(oneData));
  9877. }
  9878. else if (subType == 2) //2:国际旅费
  9879. {
  9880. var twoData = new ChoiceTwoMobileSubInfoView()
  9881. {
  9882. Id = eecInfo.Id,
  9883. ChoiceTwoJJ = eecInfo.SumJJC,
  9884. OutsideJJPay = eecInfo.OutsideJJPay,
  9885. ChoiceTwoGW = eecInfo.SumGWC,
  9886. OutsideGWPay = eecInfo.OutsideGWPay,
  9887. ChoiceTwoTD = eecInfo.SumTDC,
  9888. OutsideTDPay = eecInfo.OutsideTDPay,
  9889. AirJJ = eecInfo.AirJJ,
  9890. AirGW = eecInfo.AirGW,
  9891. AirTD = eecInfo.AirTD,
  9892. CityTranffic = eecInfo.CityTranffic,
  9893. TwoItemRemark = eecInfo.TwoItemRemark
  9894. };
  9895. return Ok(JsonView(twoData));
  9896. }
  9897. else if (subType == 3) //3:住宿费
  9898. {
  9899. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9900. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9901. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9902. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9903. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9904. {
  9905. SubId = dac.Id,
  9906. DiId = dac.DiId,
  9907. Type = dac.Type,
  9908. Days = dac.Days,
  9909. NationalTravelFeeId = dac.NationalTravelFeeId,
  9910. Arae = $"{ntf.Country}-{ntf.City}",
  9911. Cost = dac.Cost,
  9912. Currency = dac.Currency,
  9913. CurrencyName = sd.Name,
  9914. SubTotal = dac.SubTotal,
  9915. })
  9916. .ToArray();
  9917. var data = new ChoiceMobileSubInfo3To6View()
  9918. {
  9919. ParentId = eecInfo.Id,
  9920. Choice = eecInfo.ChoiceThree,
  9921. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9922. Details = dayAndCostDatas
  9923. };
  9924. return Ok(JsonView(data));
  9925. }
  9926. else if (subType == 4) //4:伙食费
  9927. {
  9928. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9929. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9930. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9931. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9932. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9933. {
  9934. SubId = dac.Id,
  9935. DiId = dac.DiId,
  9936. Type = dac.Type,
  9937. Days = dac.Days,
  9938. NationalTravelFeeId = dac.NationalTravelFeeId,
  9939. Arae = $"{ntf.Country}-{ntf.City}",
  9940. Cost = dac.Cost,
  9941. Currency = dac.Currency,
  9942. CurrencyName = sd.Name,
  9943. SubTotal = dac.SubTotal,
  9944. })
  9945. .ToArray();
  9946. var data = new ChoiceMobileSubInfo3To6View()
  9947. {
  9948. ParentId = eecInfo.Id,
  9949. Choice = eecInfo.ChoiceFour,
  9950. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9951. Details = dayAndCostDatas
  9952. };
  9953. return Ok(JsonView(data));
  9954. }
  9955. else if (subType == 5) //5:公杂费
  9956. {
  9957. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9958. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9959. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9960. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9961. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9962. {
  9963. SubId = dac.Id,
  9964. DiId = dac.DiId,
  9965. Type = dac.Type,
  9966. Days = dac.Days,
  9967. NationalTravelFeeId = dac.NationalTravelFeeId,
  9968. Arae = $"{ntf.Country}-{ntf.City}",
  9969. Cost = dac.Cost,
  9970. Currency = dac.Currency,
  9971. CurrencyName = sd.Name,
  9972. SubTotal = dac.SubTotal,
  9973. })
  9974. .ToArray();
  9975. var data = new ChoiceMobileSubInfo3To6View()
  9976. {
  9977. ParentId = eecInfo.Id,
  9978. Choice = eecInfo.ChoiceFive,
  9979. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9980. Details = dayAndCostDatas
  9981. };
  9982. return Ok(JsonView(data));
  9983. }
  9984. else if (subType == 6) //6:培训费
  9985. {
  9986. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9987. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9988. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9989. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9990. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9991. {
  9992. SubId = dac.Id,
  9993. DiId = dac.DiId,
  9994. Type = dac.Type,
  9995. Days = dac.Days,
  9996. NationalTravelFeeId = dac.NationalTravelFeeId,
  9997. Arae = $"{ntf.Country}-{ntf.City}",
  9998. Cost = dac.Cost,
  9999. Currency = dac.Currency,
  10000. CurrencyName = sd.Name,
  10001. SubTotal = dac.SubTotal,
  10002. })
  10003. .ToArray();
  10004. var data = new ChoiceMobileSubInfo3To6View()
  10005. {
  10006. ParentId = eecInfo.Id,
  10007. Choice = eecInfo.ChoiceSix,
  10008. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10009. Details = dayAndCostDatas
  10010. };
  10011. return Ok(JsonView(data));
  10012. }
  10013. else if (subType == 7) //7:其他
  10014. {
  10015. //其他款项
  10016. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10017. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10018. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10019. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10020. .OrderBy((dop, sd1, sd2) => dop.Index)
  10021. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10022. {
  10023. SubId = dop.Id,
  10024. DiId = dop.Diid,
  10025. Index = dop.Index,
  10026. SetDataId = dop.SetDataId,
  10027. SetDataName = sd1.Name,
  10028. Cost = dop.Cost,
  10029. Currency = dop.Currency,
  10030. CurrencyName = sd2.Name,
  10031. SubTotal = dop.SubTotal,
  10032. Remark = dop.Remark,
  10033. })
  10034. .ToArray();
  10035. var data = new ChoiceSevenMobileSubInfoView()
  10036. {
  10037. ParentId = eecInfo.Id,
  10038. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10039. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10040. Details = otherData
  10041. };
  10042. return Ok(JsonView(data));
  10043. }
  10044. return Ok(JsonView(false));
  10045. }
  10046. #region op
  10047. ///// <summary>
  10048. ///// 移动端更新费用消息通知
  10049. ///// </summary>
  10050. ///// <param name="diid"></param>
  10051. ///// <param name="id"></param>
  10052. ///// <param name="currUserId"></param>
  10053. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10054. //{
  10055. // try
  10056. // {
  10057. // ////生成默认文件pdf并且通知人员
  10058. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10059. // //{
  10060. // // DiId = diid,
  10061. // // ExportType = 1,
  10062. // // SubTypeId = 1005
  10063. // //}, "pdf");
  10064. // ////发送通知
  10065. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10066. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10067. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10068. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10069. // ////汇率信息记录
  10070. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10071. // }
  10072. // catch (Exception ex)
  10073. // {
  10074. // //记录日志
  10075. // throw;
  10076. // }
  10077. //}
  10078. /// <summary>
  10079. /// 验证出入境费用数据是否存在
  10080. /// 不存在添加
  10081. /// </summary>
  10082. /// <param name="diId"></param>
  10083. /// <param name="currUserId"></param>
  10084. /// <returns></returns>
  10085. /// <exception cref="CustomException"></exception>
  10086. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10087. {
  10088. var parentId = 0;
  10089. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10090. if (info != null)
  10091. {
  10092. parentId = info.Id;
  10093. }
  10094. else
  10095. {
  10096. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10097. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10098. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10099. parentId = addId;
  10100. }
  10101. return parentId;
  10102. }
  10103. /// <summary>
  10104. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10105. /// </summary>
  10106. /// <returns></returns>
  10107. [HttpPost]
  10108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10109. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10110. {
  10111. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10112. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10113. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10114. //验证编辑权限
  10115. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10116. //if (!isEdit) return Ok(JsonView(false, msg));
  10117. var permissions = new List<Grp_EnterExitCostPermission>();
  10118. foreach (var userId in dto.UserIds)
  10119. {
  10120. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10121. }
  10122. if (permissions.Any())
  10123. {
  10124. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10125. {
  10126. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10127. }
  10128. _sqlSugar.BeginTran();
  10129. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10130. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10131. if (result < 1)
  10132. {
  10133. _sqlSugar.RollbackTran();
  10134. return Ok(JsonView(false));
  10135. }
  10136. _sqlSugar.CommitTran();
  10137. return Ok(JsonView(true));
  10138. }
  10139. return Ok(JsonView(false));
  10140. }
  10141. /// <summary>
  10142. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10143. /// </summary>
  10144. /// <returns></returns>
  10145. [HttpPost]
  10146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10147. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10148. {
  10149. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10150. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10151. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10152. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10153. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10154. int id = dto.Id;
  10155. if (id <= 0) //add
  10156. {
  10157. //int provinceId = dto.ProvinceId;
  10158. int groupId = dto.DiId;
  10159. //if (provinceId < 1) provinceId = 122;
  10160. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10161. info.LastUpdateUserId = dto.CurrUserId;
  10162. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10163. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10164. if (add < 1) return Ok(JsonView(false));
  10165. id = add;
  10166. }
  10167. else //update
  10168. {
  10169. ////验证编辑权限
  10170. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10171. //if (!isEdit) return Ok(JsonView(false, msg));
  10172. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  10173. {
  10174. CurrencyRemark = currencyStr,
  10175. LastUpdateUserId = dto.CurrUserId,
  10176. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10177. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10178. if (upd < 1) return Ok(JsonView(false));
  10179. }
  10180. #region 汇率变更时更改币种相关费用
  10181. var opDayCosts = new List<Grp_DayAndCost>();
  10182. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10183. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10184. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10185. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10186. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10187. .Select((dac, sd) => new
  10188. {
  10189. dac.Id,
  10190. dac.DiId,
  10191. CurrencyCode = sd.Name,
  10192. dac.Cost
  10193. })
  10194. .ToList();
  10195. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10196. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10197. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10198. .Select((dop, sd) => new
  10199. {
  10200. dop.Id,
  10201. dop.Diid,
  10202. CurrencyCode = sd.Name,
  10203. dop.Cost
  10204. })
  10205. .ToList();
  10206. if (dayCosts.Count > 0)
  10207. {
  10208. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10209. foreach (var dc in new_dayCosts)
  10210. {
  10211. var thisCurrency = dc.Key.ToUpper();
  10212. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10213. if (thisRate == 0.00M) continue;
  10214. foreach (var dcSub in dc)
  10215. {
  10216. opDayCosts.Add(new Grp_DayAndCost()
  10217. {
  10218. Id = dcSub.Id,
  10219. DiId = dcSub.DiId,
  10220. Cost = dcSub.Cost,
  10221. SubTotal = dcSub.Cost * thisRate,
  10222. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10223. });
  10224. }
  10225. }
  10226. if (opDayCosts.Count > 0)
  10227. {
  10228. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10229. }
  10230. }
  10231. if (dayOtherCosts.Count > 0)
  10232. {
  10233. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10234. foreach (var dc in new_dayOtherCosts)
  10235. {
  10236. var thisCurrency = dc.Key.ToUpper();
  10237. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10238. if (thisRate == 0.00M) continue;
  10239. foreach (var dcSub in dc)
  10240. {
  10241. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10242. {
  10243. Id = dcSub.Id,
  10244. Diid = dcSub.Diid,
  10245. Cost = dcSub.Cost,
  10246. SubTotal = dcSub.Cost * thisRate,
  10247. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10248. });
  10249. }
  10250. }
  10251. if (opDayOtherCosts.Count > 0)
  10252. {
  10253. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10254. }
  10255. }
  10256. #endregion
  10257. //消息通知
  10258. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10259. //汇率信息记录
  10260. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10261. return Ok(JsonView(new { parentId = id }));
  10262. }
  10263. /// <summary>
  10264. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10265. /// </summary>
  10266. /// <returns></returns>
  10267. [HttpPost]
  10268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10269. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10270. {
  10271. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10272. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10273. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10274. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10275. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10276. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  10277. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10278. int id = dto.Id;
  10279. if (id <= 0) //add
  10280. {
  10281. checkboxInfo.CreateUserId = dto.CurrUserId;
  10282. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10283. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10284. if (add < 1) return Ok(JsonView(false));
  10285. }
  10286. else //update
  10287. {
  10288. ////验证编辑权限
  10289. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10290. //if (!isEdit) return Ok(JsonView(false, msg));
  10291. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10292. .UpdateColumns(x => new
  10293. {
  10294. x.ChoiceOne,
  10295. x.ChoiceTwo,
  10296. x.SumJJC,
  10297. x.SumGWC,
  10298. x.SumTDC,
  10299. x.ChoiceThree,
  10300. x.ChoiceFour,
  10301. x.ChoiceFive,
  10302. x.ChoiceSix,
  10303. x.OtherExpenses_Checked
  10304. })
  10305. .Where(x => x.Id == id)
  10306. .ExecuteCommandAsync();
  10307. if (upd < 1) return Ok(JsonView(false));
  10308. }
  10309. return Ok(JsonView(new { parentId = id }));
  10310. }
  10311. /// <summary>
  10312. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10313. /// </summary>
  10314. /// <returns></returns>
  10315. [HttpPost]
  10316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10317. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10318. {
  10319. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10320. // if (provinceId < 1) provinceId = 122;
  10321. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10322. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10323. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10324. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10325. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10326. var checkboxInfo = new Grp_EnterExitCost()
  10327. {
  10328. Id = id,
  10329. //ProvinceId = provinceId,
  10330. DiId = diId,
  10331. CreateUserId = currUserId,
  10332. LastUpdateUserId = dto.CurrUserId,
  10333. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10334. };
  10335. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10336. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10337. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10338. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10339. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10340. if (id <= 0) //add
  10341. {
  10342. checkboxInfo.CreateUserId = dto.CurrUserId;
  10343. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10344. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10345. if (add < 1) return Ok(JsonView(false));
  10346. }
  10347. else //update
  10348. {
  10349. ////验证编辑权限
  10350. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10351. //if (!isEdit) return Ok(JsonView(false, msg));
  10352. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10353. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  10354. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  10355. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10356. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10357. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10358. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10359. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10360. .Where(x => x.Id == id)
  10361. .ExecuteCommandAsync();
  10362. if (upd < 1) return Ok(JsonView(false));
  10363. }
  10364. return Ok(JsonView(new { parentId = id }));
  10365. }
  10366. /// <summary>
  10367. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10368. /// </summary>
  10369. /// <returns></returns>
  10370. [HttpPost]
  10371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10372. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10373. {
  10374. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10375. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10376. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10377. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10378. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10379. info.FirstItemRemark = dto.FirstItemRemark;
  10380. info.LastUpdateUserId = dto.CurrUserId;
  10381. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10382. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10383. int id = dto.Id;
  10384. if (id <= 0) //add
  10385. {
  10386. info.CreateUserId = dto.CurrUserId;
  10387. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10388. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10389. if (add < 1) return Ok(JsonView(false));
  10390. id = add;
  10391. }
  10392. else //update
  10393. {
  10394. ////验证编辑权限
  10395. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10396. //if (!isEdit) return Ok(JsonView(false, msg));
  10397. var upd = await _sqlSugar.Updateable(info)
  10398. .UpdateColumns(x => new
  10399. {
  10400. x.ChoiceOne,
  10401. x.InsidePay,
  10402. x.VisaRemark,
  10403. x.Visa,
  10404. x.Service,
  10405. x.Safe,
  10406. x.Ticket,
  10407. x.HeSuan,
  10408. x.YiMiao,
  10409. x.FirstItemRemark,
  10410. x.LastUpdateUserId,
  10411. x.LastUpdateTime
  10412. })
  10413. .Where(x => x.Id == id)
  10414. .ExecuteCommandAsync();
  10415. if (upd < 1) return Ok(JsonView(false));
  10416. }
  10417. //消息通知
  10418. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10419. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10420. }
  10421. /// <summary>
  10422. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10423. /// </summary>
  10424. /// <returns></returns>
  10425. [HttpPost]
  10426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10427. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10428. {
  10429. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10430. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10431. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10432. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10433. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10434. info.DiId = dto.DiId;
  10435. //info.ProvinceId = dto.ProvinceId;
  10436. info.OutsideJJPay = dto.OutsideJJPay;
  10437. info.OutsideGWPay = dto.OutsideGWPay;
  10438. info.OutsideTDPay = dto.OutsideTDPay;
  10439. info.AirJJ = dto.AirJJ;
  10440. info.AirGW = dto.AirGW;
  10441. info.AirTD = dto.AirTD;
  10442. info.CityTranffic = dto.CityTranffic;
  10443. info.TwoItemRemark = dto.TwoItemRemark;
  10444. info.SumJJC = dto.ChoiceTwoJJ;
  10445. info.SumGWC = dto.ChoiceTwoGW;
  10446. info.SumTDC = dto.ChoiceTwoTD;
  10447. info.LastUpdateUserId = dto.CurrUserId;
  10448. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10449. int id = dto.Id;
  10450. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10451. if (id <= 0) //add i
  10452. {
  10453. info.CreateUserId = dto.CurrUserId;
  10454. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10455. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10456. if (addId <= 0) return Ok(JsonView(false));
  10457. id = addId;
  10458. }
  10459. else //update
  10460. {
  10461. ////验证编辑权限
  10462. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10463. //if (!isEdit) return Ok(JsonView(false, msg));
  10464. var upd = await _sqlSugar.Updateable(info)
  10465. .UpdateColumns(x => new
  10466. {
  10467. x.SumJJC,
  10468. x.OutsideJJPay,
  10469. x.SumGWC,
  10470. x.OutsideGWPay,
  10471. x.SumTDC,
  10472. x.OutsideTDPay,
  10473. x.AirJJ,
  10474. x.AirGW,
  10475. x.AirTD,
  10476. x.CityTranffic,
  10477. x.TwoItemRemark,
  10478. x.LastUpdateTime,
  10479. x.LastUpdateUserId
  10480. })
  10481. .Where(x => x.Id == id)
  10482. .ExecuteCommandAsync();
  10483. if (upd < 1) return Ok(JsonView(false));
  10484. }
  10485. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10486. gwcItemTotal = info.AirGW + info.CityTranffic;
  10487. tdcItemTotal = info.AirTD + info.CityTranffic;
  10488. //消息通知
  10489. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10490. return Ok(JsonView(new
  10491. {
  10492. parentId = id,
  10493. choiceTwoJJ = dto.ChoiceTwoJJ,
  10494. jjcItemTotal = jjcItemTotal,
  10495. choiceTwoGW = dto.ChoiceTwoGW,
  10496. gwcItemTotal = gwcItemTotal,
  10497. choiceTwoTD = dto.ChoiceTwoTD,
  10498. tdcItemTotal = tdcItemTotal
  10499. }));
  10500. }
  10501. /// <summary>
  10502. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10503. /// </summary>
  10504. /// <returns></returns>
  10505. [HttpPost]
  10506. [ApiExplorerSettings(IgnoreApi = true)]
  10507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10508. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10509. {
  10510. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10511. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10512. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10513. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10514. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10515. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10516. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10517. var infos = infos1.Select(x => new Grp_DayAndCost
  10518. {
  10519. Id = x.Id,
  10520. DiId = dto.DiId,
  10521. Type = dto.FeeType,
  10522. Days = x.Days,
  10523. NationalTravelFeeId = x.NationalTravelFeeId,
  10524. Cost = x.Cost,
  10525. Currency = x.Currency,
  10526. SubTotal = x.SubTotal,
  10527. CreateUserId = dto.CurrUserId
  10528. })
  10529. .ToList();
  10530. var adds = infos.Where(x => x.Id <= 0).ToList();
  10531. var upds = infos.Where(x => x.Id > 0).ToList();
  10532. if (adds.Count > 0)
  10533. {
  10534. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10535. if (add < 1) return Ok(JsonView(false));
  10536. }
  10537. if (upds.Count > 0)
  10538. {
  10539. var upd = await _sqlSugar.Updateable(adds)
  10540. .UpdateColumns(x => new
  10541. {
  10542. x.Days,
  10543. x.NationalTravelFeeId,
  10544. x.Cost,
  10545. x.Currency,
  10546. x.SubTotal
  10547. })
  10548. .WhereColumns(x => new { x.Id })
  10549. .ExecuteCommandAsync();
  10550. if (upd < 1) return Ok(JsonView(false));
  10551. }
  10552. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10553. //消息通知
  10554. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10555. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10556. return Ok(JsonView(new { itemTotal = itemTotal }));
  10557. }
  10558. /// <summary>
  10559. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10560. /// </summary>
  10561. /// <returns></returns>
  10562. [HttpPost]
  10563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10564. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10565. {
  10566. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10567. int subId = dto.SubId, feeType = dto.FeeType;
  10568. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10569. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10570. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10571. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10572. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10573. subInfo.Id = subId;
  10574. subInfo.DiId = dto.DiId;
  10575. if (feeType == 3) subInfo.Type = 1;
  10576. else if (feeType == 4) subInfo.Type = 2;
  10577. else if (feeType == 5) subInfo.Type = 3;
  10578. else if (feeType == 6) subInfo.Type = 4;
  10579. subInfo.CreateUserId = dto.CurrUserId;
  10580. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10581. if (parentId < 1) return Ok(JsonView(false));
  10582. //子表op
  10583. if (subId < 1)
  10584. {
  10585. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10586. if (subAdd < 1) return Ok(JsonView(false));
  10587. }
  10588. else
  10589. {
  10590. ////验证编辑权限
  10591. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10592. //if (!isEdit) return Ok(JsonView(false, msg));
  10593. var subUpd = await _sqlSugar.Updateable(subInfo)
  10594. .UpdateColumns(x => new
  10595. {
  10596. x.Days,
  10597. x.NationalTravelFeeId,
  10598. x.Cost,
  10599. x.Currency,
  10600. x.SubTotal
  10601. })
  10602. .WhereColumns(x => new { x.Id })
  10603. .ExecuteCommandAsync();
  10604. if (subUpd < 1) return Ok(JsonView(false));
  10605. }
  10606. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10607. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10608. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10609. }
  10610. /// <summary>
  10611. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10612. /// </summary>
  10613. /// <returns></returns>
  10614. [HttpPost]
  10615. [ApiExplorerSettings(IgnoreApi = true)]
  10616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10617. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10618. {
  10619. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10620. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10621. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10622. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10623. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10624. {
  10625. Id = x.Id,
  10626. Diid = dto.DiId,
  10627. SetDataId = x.SetDataId,
  10628. Index = x.Index,
  10629. Cost = x.Cost,
  10630. Currency = x.Currency,
  10631. SubTotal = x.SubTotal,
  10632. CreateUserId = dto.CurrUserId,
  10633. Remark = x.Remark
  10634. }).ToList();
  10635. var adds = infos.Where(x => x.Id <= 0).ToList();
  10636. var upds = infos.Where(x => x.Id > 0).ToList();
  10637. if (adds.Count > 0)
  10638. {
  10639. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10640. if (add < 1) return Ok(JsonView(false));
  10641. }
  10642. if (upds.Count > 0)
  10643. {
  10644. var upd = await _sqlSugar.Updateable(adds)
  10645. .UpdateColumns(x => new
  10646. {
  10647. x.Index,
  10648. x.SetDataId,
  10649. x.Cost,
  10650. x.Currency,
  10651. x.SubTotal,
  10652. x.Remark
  10653. })
  10654. .WhereColumns(x => new { x.Id })
  10655. .ExecuteCommandAsync();
  10656. if (upd < 1) return Ok(JsonView(false));
  10657. }
  10658. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10659. //消息通知
  10660. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10661. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10662. return Ok(JsonView(new { itemTotal = itemTotal }));
  10663. }
  10664. /// <summary>
  10665. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10666. /// </summary>
  10667. /// <returns></returns>
  10668. [HttpPost]
  10669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10670. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10671. {
  10672. int subId = dto.SubId;
  10673. int diId = dto.Diid;
  10674. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10675. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10676. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10677. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10678. subInfo.Id = subId;
  10679. subInfo.Diid = dto.Diid;
  10680. subInfo.CreateUserId = dto.CurrUserId;
  10681. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10682. if (parentId < 1) return Ok(JsonView(false));
  10683. #region 子表op
  10684. if (subId < 1)//add
  10685. {
  10686. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10687. if (subAdd < 1) return Ok(JsonView(false));
  10688. }
  10689. else //upd
  10690. {
  10691. ////验证编辑权限
  10692. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10693. //if (!isEdit) return Ok(JsonView(false, msg));
  10694. var subUpd = await _sqlSugar.Updateable(subInfo)
  10695. .UpdateColumns(x => new
  10696. {
  10697. x.Index,
  10698. x.SetDataId,
  10699. x.Cost,
  10700. x.Currency,
  10701. x.SubTotal,
  10702. x.Remark
  10703. })
  10704. .WhereColumns(x => new { x.Id })
  10705. .ExecuteCommandAsync();
  10706. if (subUpd < 1) return Ok(JsonView(false));
  10707. }
  10708. #endregion
  10709. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10710. //消息通知
  10711. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10712. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10713. }
  10714. /// <summary>
  10715. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10716. /// </summary>
  10717. /// <returns></returns>
  10718. [HttpPost]
  10719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10720. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10721. {
  10722. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10723. if (data.Code != 0)
  10724. {
  10725. return Ok(JsonView(false, data.Msg));
  10726. }
  10727. return Ok(JsonView(true, "操作成功!", data.Data));
  10728. }
  10729. /// <summary>
  10730. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10731. /// </summary>
  10732. /// <param name="dto"></param>
  10733. /// <returns></returns>
  10734. [HttpPost]
  10735. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10736. {
  10737. var data = new Grp_DayOtherPrice()
  10738. {
  10739. Id = dto.Id,
  10740. IsDel = 1,
  10741. DeleteUserId = dto.DeleteUserId,
  10742. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10743. };
  10744. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10745. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10746. return Ok(JsonView(false, "删除失败!"));
  10747. }
  10748. #endregion
  10749. #endregion
  10750. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10751. /// <summary>
  10752. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10753. /// </summary>
  10754. /// <returns></returns>
  10755. [HttpGet]
  10756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10757. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10758. {
  10759. var provData = await _groupRepository.ProvinceBasicSource();
  10760. return Ok(JsonView(true, "查询成功!", provData));
  10761. }
  10762. /// <summary>
  10763. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10764. /// </summary>
  10765. /// <returns></returns>
  10766. [HttpPost]
  10767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10768. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10769. {
  10770. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10771. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10772. RefAsync<int> total = 0;
  10773. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10774. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10775. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10776. .Select(x => new
  10777. {
  10778. Id = x.Id,
  10779. DraftName = x.DraftName,
  10780. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10781. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10782. .Any()
  10783. })
  10784. .OrderByDescending(x => x.Id)
  10785. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10786. return Ok(JsonView(true, "查询成功!", data, total));
  10787. }
  10788. /// <summary>
  10789. /// 出入境费用-草稿 移动端
  10790. /// 获取币种基础数据(含逻辑处理)
  10791. /// </summary>
  10792. /// <returns></returns>
  10793. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10794. {
  10795. return await GeneralMethod.EnterExitCostInitRate();
  10796. }
  10797. /// <summary>
  10798. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10799. /// </summary>
  10800. /// <returns></returns>
  10801. [HttpPost]
  10802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10803. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10804. {
  10805. //验证城市归属并给默认值
  10806. int provinceId = dto.ProvinceId;
  10807. if (provinceId < 1) provinceId = 122;
  10808. var dataSource = await _sqlSugar
  10809. .Queryable<Sys_SetData>()
  10810. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10811. .ToListAsync();
  10812. //三公费用-Word明细类型
  10813. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10814. .Select(x => new SetDataInfoView
  10815. {
  10816. Id = x.Id,
  10817. Name = x.Name,
  10818. Remark = x.Remark
  10819. })
  10820. .ToList();
  10821. //三公费用-Excel明细类型
  10822. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10823. .Select(x => new SetDataInfoView
  10824. {
  10825. Id = x.Id,
  10826. Name = x.Name,
  10827. Remark = x.Remark
  10828. })
  10829. .ToList();
  10830. //默认币种显示
  10831. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10832. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10833. return Ok(JsonView(true, "查询成功!", new
  10834. {
  10835. WordTypeData = wordTypeData,
  10836. ExcelTypeData = excelTypeData,
  10837. CurrencyInit = _currencyInfos,
  10838. viewPermissionData = viewPermissionData
  10839. }));
  10840. }
  10841. /// <summary>
  10842. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10843. /// </summary>
  10844. /// <returns></returns>
  10845. [HttpPost]
  10846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10847. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10848. {
  10849. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10850. RefAsync<int> total = 0;
  10851. int diId = 0;
  10852. var status = int.TryParse(dto.GroupName, out diId);
  10853. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10854. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10855. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10856. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10857. .OrderByDescending(x => x.VisitStartDate)
  10858. .Select(x => new
  10859. {
  10860. Id = x.Id,
  10861. GroupName = x.TeamName
  10862. })
  10863. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10864. return Ok(JsonView(true, "查询成功!", data, total));
  10865. }
  10866. /// <summary>
  10867. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10868. /// </summary>
  10869. /// <returns></returns>
  10870. [HttpPost]
  10871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10872. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10873. {
  10874. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10875. RefAsync<int> total = 0;
  10876. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10877. .Where(x => x.IsDel == 0 && x.STid == 66)
  10878. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10879. .Select(x => new
  10880. {
  10881. id = x.Id,
  10882. name = x.Name,
  10883. remark = x.Remark,
  10884. })
  10885. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10886. return Ok(JsonView(true, "查询成功!", data, total));
  10887. }
  10888. /// <summary>
  10889. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10890. /// </summary>
  10891. /// <returns></returns>
  10892. [HttpPost]
  10893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10894. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10895. {
  10896. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10897. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10898. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10899. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10900. var groupOtherRateData = groupRateData.TeamRates;
  10901. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10902. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10903. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10904. groupOtherRateData = groupOtherRateData
  10905. .Select(x => new TeamRateDescAddCurrencyIdView
  10906. {
  10907. CurrencyId = x.CurrencyId,
  10908. CurrencyName = x.CurrencyName,
  10909. CurrencyCode = x.CurrencyCode,
  10910. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10911. }).ToList();
  10912. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10913. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10914. }
  10915. /// <summary>
  10916. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10917. /// </summary>
  10918. /// <returns></returns>
  10919. [HttpPost]
  10920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10921. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10922. {
  10923. int portType = dto.PortType;
  10924. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10925. var tipsData = new List<int>() { 1, 2, 3 };
  10926. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10927. if (dto.TipsType == 1)
  10928. {
  10929. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10930. }
  10931. else if (dto.TipsType == 2)
  10932. {
  10933. if (portType == 2)
  10934. {
  10935. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10936. }
  10937. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10938. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10939. .Select(x => x.NationalTravelFeeId)
  10940. .Distinct()
  10941. .ToListAsync();
  10942. if (portType == 2)
  10943. {
  10944. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10945. }
  10946. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10947. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10948. .Select(x => x.Country)
  10949. .Distinct()
  10950. .ToArrayAsync();
  10951. if (portType == 2)
  10952. {
  10953. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10954. }
  10955. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10956. return Ok(JsonView(true, "查询成功!", new
  10957. {
  10958. totalAmt = totalAmt,
  10959. remark = remark
  10960. }));
  10961. }
  10962. else if (dto.TipsType == 3)
  10963. {
  10964. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10965. }
  10966. return Ok(JsonView(false));
  10967. }
  10968. /// <summary>
  10969. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10970. /// </summary>
  10971. /// <returns></returns>
  10972. [HttpPost]
  10973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10974. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10975. {
  10976. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10977. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10978. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10979. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10980. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10981. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10982. var info = new Grp_EnterExitCostDraft()
  10983. {
  10984. ProvinceId = dto.ProvinceId,
  10985. DraftName = dto.DraftName,
  10986. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10987. CreateUserId = dto.CurrUserId
  10988. };
  10989. _sqlSugar.BeginTran();
  10990. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10991. if (draftId < 1)
  10992. {
  10993. _sqlSugar.RollbackTran();
  10994. return Ok(JsonView(false, "草稿创建失败!"));
  10995. }
  10996. //添加默认权限
  10997. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10998. _sqlSugar.CommitTran();
  10999. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11000. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11001. mobileInfo.Id = draftId;
  11002. mobileInfo.DraftName = dto.DraftName;
  11003. mobileInfo.Currencys = rateInfos;
  11004. mobileInfo.IsAssignPerm = assignPerm;
  11005. return Ok(JsonView(mobileInfo));
  11006. }
  11007. /// <summary>
  11008. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11009. /// </summary>
  11010. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11011. /// <summary>
  11012. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11013. /// </summary>
  11014. /// <returns></returns>
  11015. [HttpPost]
  11016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11017. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11018. {
  11019. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11020. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11021. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11022. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11023. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11024. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11025. //验证查看编辑权限
  11026. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11027. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11028. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11029. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11030. mobileInfo.IsAssignPerm = assignPerm;
  11031. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11032. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11033. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11034. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11035. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11036. {
  11037. ParentId = dac.ParentId,
  11038. SubId = dac.Id,
  11039. Type = dac.Type,
  11040. Days = dac.Days,
  11041. NationalTravelFeeId = dac.NationalTravelFeeId,
  11042. Arae = $"{ntf.Country}-{ntf.City}",
  11043. Cost = dac.Cost,
  11044. Currency = dac.Currency,
  11045. CurrencyName = sd.Name,
  11046. SubTotal = dac.SubTotal,
  11047. })
  11048. .ToList();
  11049. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11050. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11051. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11052. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11053. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11054. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11055. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11056. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11057. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11058. //其他款项
  11059. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11060. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11061. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11062. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11063. .OrderBy((dop, sd1, sd2) => dop.Index)
  11064. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11065. {
  11066. ParentId = dop.ParentId,
  11067. SubId = dop.Id,
  11068. Index = dop.Index,
  11069. SetDataId = dop.SetDataId,
  11070. SetDataName = sd1.Name,
  11071. Cost = dop.Cost,
  11072. Currency = dop.Currency,
  11073. CurrencyName = sd2.Remark,
  11074. SubTotal = dop.SubTotal,
  11075. Remark = dop.Remark,
  11076. })
  11077. .ToArray();
  11078. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11079. return Ok(mobileInfo);
  11080. }
  11081. /// <summary>
  11082. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11083. /// </summary>
  11084. /// <returns></returns>
  11085. [HttpPost]
  11086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11087. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11088. {
  11089. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11090. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11091. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11092. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11093. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11094. //验证查看编辑权限
  11095. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11096. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11097. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11098. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11099. var subType = dto.SubType;
  11100. if (subType == 1) //1:境内费用
  11101. {
  11102. var oneData = new ChoiceOneMobileSubInfoView()
  11103. {
  11104. Id = eecInfo.Id,
  11105. ChoiceOne = eecInfo.ChoiceOne,
  11106. ChoiceOneTotalCost = eecInfo.InsidePay,
  11107. Visa = eecInfo.Visa,
  11108. VisaRemark = eecInfo.VisaRemark,
  11109. YiMiao = eecInfo.YiMiao,
  11110. HeSuan = eecInfo.HeSuan,
  11111. Service = eecInfo.Service,
  11112. Ticket = eecInfo.Ticket,
  11113. Safe = eecInfo.Safe,
  11114. FirstItemRemark = eecInfo.FirstItemRemark
  11115. };
  11116. return Ok(JsonView(oneData));
  11117. }
  11118. else if (subType == 2) //2:国际旅费
  11119. {
  11120. var twoData = new ChoiceTwoMobileSubInfoView()
  11121. {
  11122. Id = eecInfo.Id,
  11123. ChoiceTwoJJ = eecInfo.SumJJC,
  11124. OutsideJJPay = eecInfo.OutsideJJPay,
  11125. ChoiceTwoGW = eecInfo.SumGWC,
  11126. OutsideGWPay = eecInfo.OutsideGWPay,
  11127. ChoiceTwoTD = eecInfo.SumTDC,
  11128. OutsideTDPay = eecInfo.OutsideTDPay,
  11129. AirJJ = eecInfo.AirJJ,
  11130. AirGW = eecInfo.AirGW,
  11131. AirTD = eecInfo.AirTD,
  11132. CityTranffic = eecInfo.CityTranffic,
  11133. TwoItemRemark = eecInfo.TwoItemRemark
  11134. };
  11135. return Ok(JsonView(twoData));
  11136. }
  11137. else if (subType == 3) //3:住宿费
  11138. {
  11139. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11140. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11141. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11142. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11143. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11144. {
  11145. ParentId = dac.ParentId,
  11146. SubId = dac.Id,
  11147. Type = dac.Type,
  11148. Days = dac.Days,
  11149. NationalTravelFeeId = dac.NationalTravelFeeId,
  11150. Arae = $"{ntf.Country}-{ntf.City}",
  11151. Cost = dac.Cost,
  11152. Currency = dac.Currency,
  11153. CurrencyName = sd.Name,
  11154. SubTotal = dac.SubTotal,
  11155. })
  11156. .ToArray();
  11157. var data = new ChoiceDraftMobileSubInfo3To6View()
  11158. {
  11159. ParentId = eecInfo.Id,
  11160. Choice = eecInfo.ChoiceThree,
  11161. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11162. Details = dayAndCostDatas
  11163. };
  11164. return Ok(JsonView(data));
  11165. }
  11166. else if (subType == 4) //4:伙食费
  11167. {
  11168. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11169. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11170. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11171. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11172. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11173. {
  11174. ParentId = dac.ParentId,
  11175. SubId = dac.Id,
  11176. Type = dac.Type,
  11177. Days = dac.Days,
  11178. NationalTravelFeeId = dac.NationalTravelFeeId,
  11179. Arae = $"{ntf.Country}-{ntf.City}",
  11180. Cost = dac.Cost,
  11181. Currency = dac.Currency,
  11182. CurrencyName = sd.Name,
  11183. SubTotal = dac.SubTotal,
  11184. })
  11185. .ToArray();
  11186. var data = new ChoiceDraftMobileSubInfo3To6View()
  11187. {
  11188. ParentId = eecInfo.Id,
  11189. Choice = eecInfo.ChoiceFour,
  11190. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11191. Details = dayAndCostDatas
  11192. };
  11193. return Ok(JsonView(data));
  11194. }
  11195. else if (subType == 5) //5:公杂费
  11196. {
  11197. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11198. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11199. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11200. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11201. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11202. {
  11203. ParentId = dac.ParentId,
  11204. SubId = dac.Id,
  11205. Type = dac.Type,
  11206. Days = dac.Days,
  11207. NationalTravelFeeId = dac.NationalTravelFeeId,
  11208. Arae = $"{ntf.Country}-{ntf.City}",
  11209. Cost = dac.Cost,
  11210. Currency = dac.Currency,
  11211. CurrencyName = sd.Name,
  11212. SubTotal = dac.SubTotal,
  11213. })
  11214. .ToArray();
  11215. var data = new ChoiceDraftMobileSubInfo3To6View()
  11216. {
  11217. ParentId = eecInfo.Id,
  11218. Choice = eecInfo.ChoiceFive,
  11219. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11220. Details = dayAndCostDatas
  11221. };
  11222. return Ok(JsonView(data));
  11223. }
  11224. else if (subType == 6) //6:培训费
  11225. {
  11226. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11227. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11228. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11229. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11230. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11231. {
  11232. ParentId = dac.ParentId,
  11233. SubId = dac.Id,
  11234. Type = dac.Type,
  11235. Days = dac.Days,
  11236. NationalTravelFeeId = dac.NationalTravelFeeId,
  11237. Arae = $"{ntf.Country}-{ntf.City}",
  11238. Cost = dac.Cost,
  11239. Currency = dac.Currency,
  11240. CurrencyName = sd.Name,
  11241. SubTotal = dac.SubTotal,
  11242. })
  11243. .ToArray();
  11244. var data = new ChoiceDraftMobileSubInfo3To6View()
  11245. {
  11246. ParentId = eecInfo.Id,
  11247. Choice = eecInfo.ChoiceSix,
  11248. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11249. Details = dayAndCostDatas
  11250. };
  11251. return Ok(JsonView(data));
  11252. }
  11253. else if (subType == 7) //7:其他
  11254. {
  11255. //其他款项
  11256. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11257. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11258. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11259. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11260. .OrderBy((dop, sd1, sd2) => dop.Index)
  11261. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11262. {
  11263. ParentId = dop.ParentId,
  11264. SubId = dop.Id,
  11265. Index = dop.Index,
  11266. SetDataId = dop.SetDataId,
  11267. SetDataName = sd1.Name,
  11268. Cost = dop.Cost,
  11269. Currency = dop.Currency,
  11270. CurrencyName = sd2.Name,
  11271. SubTotal = dop.SubTotal,
  11272. Remark = dop.Remark,
  11273. })
  11274. .ToArray();
  11275. var data = new ChoiceSevenDraftMobileSubInfoView()
  11276. {
  11277. ParentId = eecInfo.Id,
  11278. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11279. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11280. Details = otherData
  11281. };
  11282. return Ok(JsonView(data));
  11283. }
  11284. return Ok(JsonView(false));
  11285. }
  11286. #region op
  11287. ///// <summary>
  11288. ///// 移动端更新费用消息通知
  11289. ///// </summary>
  11290. ///// <param name="draftId"></param>
  11291. ///// <param name="id"></param>
  11292. ///// <param name="currUserId"></param>
  11293. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11294. //{
  11295. // try
  11296. // {
  11297. // ////生成默认文件pdf并且通知人员
  11298. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11299. // //{
  11300. // // DiId = draftId,
  11301. // // ExportType = 1,
  11302. // // SubTypeId = 1005
  11303. // //}, "pdf");
  11304. // ////发送通知
  11305. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11306. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11307. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11308. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11309. // ////汇率信息记录
  11310. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11311. // }
  11312. // catch (Exception ex)
  11313. // {
  11314. // //记录日志
  11315. // throw;
  11316. // }
  11317. //}
  11318. /// <summary>
  11319. /// 验证出入境费用数据是否存在
  11320. /// 不存在添加
  11321. /// </summary>
  11322. /// <param name="draftId"></param>
  11323. /// <param name="currUserId"></param>
  11324. /// <returns></returns>
  11325. /// <exception cref="CustomException"></exception>
  11326. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11327. {
  11328. var parentId = 0;
  11329. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11330. if (info != null) parentId = info.Id;
  11331. else
  11332. {
  11333. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11334. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11335. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11336. parentId = addId;
  11337. }
  11338. return parentId;
  11339. }
  11340. /// <summary>
  11341. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11342. /// </summary>
  11343. /// <returns></returns>
  11344. [HttpPost]
  11345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11346. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11347. {
  11348. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11349. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11350. //验证查看权限
  11351. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11352. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11353. var userIds = await _sqlSugar
  11354. .Queryable<Grp_EnterExitCostDraftPermission>()
  11355. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11356. .Select(x => x.UserId)
  11357. .ToArrayAsync();
  11358. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11359. var perUsersView = new List<dynamic>();
  11360. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11361. var viewPermissionData = new List<PermissionViewUserview>();
  11362. if (feeBasePerm.Any())
  11363. {
  11364. foreach (var item in feeBasePerm)
  11365. {
  11366. if (item.Users.Any())
  11367. {
  11368. viewPermissionData.AddRange(item.Users);
  11369. }
  11370. }
  11371. }
  11372. foreach (var item in perUsers)
  11373. {
  11374. bool isView1 = false;
  11375. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11376. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11377. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11378. }
  11379. return Ok(JsonView(perUsersView));
  11380. }
  11381. /// <summary>
  11382. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11383. /// </summary>
  11384. /// <returns></returns>
  11385. [HttpPost]
  11386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11387. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11388. {
  11389. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11390. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11391. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11392. //验证查看编辑权限
  11393. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11394. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11395. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11396. foreach (var userId in dto.UserIds)
  11397. {
  11398. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11399. }
  11400. if (permissions.Any())
  11401. {
  11402. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11403. {
  11404. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11405. }
  11406. _sqlSugar.BeginTran();
  11407. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11408. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11409. if (result < 1)
  11410. {
  11411. _sqlSugar.RollbackTran();
  11412. return Ok(JsonView(false));
  11413. }
  11414. _sqlSugar.CommitTran();
  11415. return Ok(JsonView(true));
  11416. }
  11417. return Ok(JsonView(false));
  11418. }
  11419. /// <summary>
  11420. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11421. /// </summary>
  11422. /// <returns></returns>
  11423. [HttpPost]
  11424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11425. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11426. {
  11427. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11428. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11429. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11430. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11431. int id = dto.DraftId;
  11432. if (id <= 0) //add
  11433. {
  11434. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11435. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11436. if (add < 1) return Ok(JsonView(false));
  11437. id = add;
  11438. }
  11439. else //update
  11440. {
  11441. //验证查看编辑权限
  11442. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11443. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11444. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11445. if (upd < 1) return Ok(JsonView(false));
  11446. }
  11447. return Ok(JsonView(new { parentId = id }));
  11448. }
  11449. /// <summary>
  11450. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11451. /// </summary>
  11452. /// <returns></returns>
  11453. [HttpPost]
  11454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11455. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11456. {
  11457. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11458. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11459. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11460. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11461. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11462. int id = dto.DraftId;
  11463. if (id <= 0) //add
  11464. {
  11465. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11466. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11467. if (add < 1) return Ok(JsonView(false));
  11468. id = add;
  11469. }
  11470. else //update
  11471. {
  11472. //验证查看编辑权限
  11473. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11474. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11475. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11476. if (upd < 1) return Ok(JsonView(false));
  11477. }
  11478. #region 汇率变更时更改币种相关费用
  11479. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11480. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11481. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11482. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11483. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11484. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11485. .Select((dac, sd) => new
  11486. {
  11487. dac.Id,
  11488. dac.ParentId,
  11489. CurrencyCode = sd.Name,
  11490. dac.Cost
  11491. })
  11492. .ToList();
  11493. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11494. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11495. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11496. .Select((dop, sd) => new
  11497. {
  11498. dop.Id,
  11499. dop.ParentId,
  11500. CurrencyCode = sd.Name,
  11501. dop.Cost
  11502. })
  11503. .ToList();
  11504. if (dayCosts.Count > 0)
  11505. {
  11506. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11507. foreach (var dc in new_dayCosts)
  11508. {
  11509. var thisCurrency = dc.Key.ToUpper();
  11510. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11511. if (thisRate == 0.00M) continue;
  11512. foreach (var dcSub in dc)
  11513. {
  11514. opDayCosts.Add(new Grp_DayAndCostDraft()
  11515. {
  11516. Id = dcSub.Id,
  11517. ParentId = dcSub.ParentId,
  11518. Cost = dcSub.Cost,
  11519. SubTotal = dcSub.Cost * thisRate,
  11520. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11521. });
  11522. }
  11523. }
  11524. if (opDayCosts.Count > 0)
  11525. {
  11526. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11527. }
  11528. }
  11529. if (dayOtherCosts.Count > 0)
  11530. {
  11531. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11532. foreach (var dc in new_dayOtherCosts)
  11533. {
  11534. var thisCurrency = dc.Key.ToUpper();
  11535. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11536. if (thisRate == 0.00M) continue;
  11537. foreach (var dcSub in dc)
  11538. {
  11539. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11540. {
  11541. Id = dcSub.Id,
  11542. ParentId = dcSub.ParentId,
  11543. Cost = dcSub.Cost,
  11544. SubTotal = dcSub.Cost * thisRate,
  11545. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11546. });
  11547. }
  11548. }
  11549. if (opDayOtherCosts.Count > 0)
  11550. {
  11551. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11552. }
  11553. }
  11554. #endregion
  11555. ////消息通知
  11556. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11557. ////汇率信息记录
  11558. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11559. return Ok(JsonView(new { parentId = id }));
  11560. }
  11561. /// <summary>
  11562. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11563. /// </summary>
  11564. /// <returns></returns>
  11565. [HttpPost]
  11566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11567. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11568. {
  11569. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11570. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11571. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11572. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11573. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11574. int id = dto.DraftId;
  11575. if (id <= 0) //add
  11576. {
  11577. checkboxInfo.ProvinceId = dto.ProvinceId;
  11578. checkboxInfo.CreateUserId = dto.CurrUserId;
  11579. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11580. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11581. if (add < 1) return Ok(JsonView(false));
  11582. }
  11583. else //update
  11584. {
  11585. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11586. .UpdateColumns(x => new
  11587. {
  11588. x.ChoiceOne,
  11589. x.ChoiceTwo,
  11590. x.SumJJC,
  11591. x.SumGWC,
  11592. x.SumTDC,
  11593. x.ChoiceThree,
  11594. x.ChoiceFour,
  11595. x.ChoiceFive,
  11596. x.ChoiceSix,
  11597. x.OtherExpenses_Checked
  11598. })
  11599. .Where(x => x.Id == id)
  11600. .ExecuteCommandAsync();
  11601. if (upd < 1) return Ok(JsonView(false));
  11602. }
  11603. return Ok(JsonView(new { parentId = id }));
  11604. }
  11605. /// <summary>
  11606. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11607. /// </summary>
  11608. /// <returns></returns>
  11609. [HttpPost]
  11610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11611. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11612. {
  11613. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11614. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11615. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11616. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11617. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11618. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11619. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11620. var checkboxInfo = new Grp_EnterExitCostDraft()
  11621. {
  11622. Id = draftId,
  11623. ProvinceId = dto.ProvinceId,
  11624. CreateUserId = currUserId
  11625. };
  11626. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11627. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11628. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11629. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11630. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11631. if (draftId <= 0) //add
  11632. {
  11633. checkboxInfo.CreateUserId = dto.CurrUserId;
  11634. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11635. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11636. if (add < 1) return Ok(JsonView(false));
  11637. }
  11638. else //update
  11639. {
  11640. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11641. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11642. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11643. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11644. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11645. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11646. .Where(x => x.Id == draftId)
  11647. .ExecuteCommandAsync();
  11648. if (upd < 1) return Ok(JsonView(false));
  11649. }
  11650. return Ok(JsonView(new { parentId = draftId }));
  11651. }
  11652. /// <summary>
  11653. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11654. /// </summary>
  11655. /// <returns></returns>
  11656. [HttpPost]
  11657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11658. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11659. {
  11660. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11661. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11662. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11663. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11664. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11665. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11666. info.ProvinceId = dto.ProvinceId;
  11667. info.FirstItemRemark = dto.FirstItemRemark;
  11668. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11669. if (id <= 0) //add
  11670. {
  11671. info.CreateUserId = dto.CurrUserId;
  11672. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11673. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11674. if (add < 1) return Ok(JsonView(false));
  11675. id = add;
  11676. }
  11677. else //update
  11678. {
  11679. var upd = await _sqlSugar.Updateable(info)
  11680. .UpdateColumns(x => new
  11681. {
  11682. x.ChoiceOne,
  11683. x.InsidePay,
  11684. x.VisaRemark,
  11685. x.Visa,
  11686. x.Service,
  11687. x.Safe,
  11688. x.Ticket,
  11689. x.HeSuan,
  11690. x.YiMiao,
  11691. x.FirstItemRemark
  11692. })
  11693. .Where(x => x.Id == id)
  11694. .ExecuteCommandAsync();
  11695. if (upd < 1) return Ok(JsonView(false));
  11696. }
  11697. ////消息通知
  11698. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11699. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11700. }
  11701. /// <summary>
  11702. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11703. /// </summary>
  11704. /// <returns></returns>
  11705. [HttpPost]
  11706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11707. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11708. {
  11709. int id = dto.DraftId;
  11710. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11711. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11712. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11713. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11714. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11715. info.ProvinceId = dto.ProvinceId;
  11716. info.OutsideJJPay = dto.OutsideJJPay;
  11717. info.OutsideGWPay = dto.OutsideGWPay;
  11718. info.OutsideTDPay = dto.OutsideTDPay;
  11719. info.AirJJ = dto.AirJJ;
  11720. info.AirGW = dto.AirGW;
  11721. info.AirTD = dto.AirTD;
  11722. info.CityTranffic = dto.CityTranffic;
  11723. info.TwoItemRemark = dto.TwoItemRemark;
  11724. info.SumJJC = dto.ChoiceTwoJJ;
  11725. info.SumGWC = dto.ChoiceTwoGW;
  11726. info.SumTDC = dto.ChoiceTwoTD;
  11727. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11728. if (id <= 0) //add
  11729. {
  11730. info.CreateUserId = dto.CurrUserId;
  11731. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11732. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11733. if (addId <= 0) return Ok(JsonView(false));
  11734. id = addId;
  11735. }
  11736. else //update
  11737. {
  11738. var upd = await _sqlSugar.Updateable(info)
  11739. .UpdateColumns(x => new
  11740. {
  11741. x.SumJJC,
  11742. x.OutsideJJPay,
  11743. x.SumGWC,
  11744. x.OutsideGWPay,
  11745. x.SumTDC,
  11746. x.OutsideTDPay,
  11747. x.AirJJ,
  11748. x.AirGW,
  11749. x.AirTD,
  11750. x.CityTranffic,
  11751. x.TwoItemRemark
  11752. })
  11753. .Where(x => x.Id == id)
  11754. .ExecuteCommandAsync();
  11755. if (upd < 1) return Ok(JsonView(false));
  11756. }
  11757. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11758. gwcItemTotal = info.AirGW + info.CityTranffic;
  11759. tdcItemTotal = info.AirTD + info.CityTranffic;
  11760. ////消息通知
  11761. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11762. return Ok(JsonView(new
  11763. {
  11764. parentId = id,
  11765. choiceTwoJJ = dto.ChoiceTwoJJ,
  11766. jjcItemTotal = jjcItemTotal,
  11767. choiceTwoGW = dto.ChoiceTwoGW,
  11768. gwcItemTotal = gwcItemTotal,
  11769. choiceTwoTD = dto.ChoiceTwoTD,
  11770. tdcItemTotal = tdcItemTotal
  11771. }));
  11772. }
  11773. /// <summary>
  11774. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11775. /// </summary>
  11776. /// <returns></returns>
  11777. [HttpPost]
  11778. [ApiExplorerSettings(IgnoreApi = true)]
  11779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11780. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11781. {
  11782. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11783. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11784. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11785. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11786. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11787. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11788. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11789. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11790. {
  11791. Id = x.Id,
  11792. ParentId = dto.DraftId,
  11793. Type = dto.FeeType,
  11794. Days = x.Days,
  11795. NationalTravelFeeId = x.NationalTravelFeeId,
  11796. Cost = x.Cost,
  11797. Currency = x.Currency,
  11798. SubTotal = x.SubTotal,
  11799. CreateUserId = dto.CurrUserId
  11800. })
  11801. .ToList();
  11802. var adds = infos.Where(x => x.Id <= 0).ToList();
  11803. var upds = infos.Where(x => x.Id > 0).ToList();
  11804. if (adds.Count > 0)
  11805. {
  11806. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11807. if (add < 1) return Ok(JsonView(false));
  11808. }
  11809. if (upds.Count > 0)
  11810. {
  11811. var upd = await _sqlSugar.Updateable(adds)
  11812. .UpdateColumns(x => new
  11813. {
  11814. x.Days,
  11815. x.NationalTravelFeeId,
  11816. x.Cost,
  11817. x.Currency,
  11818. x.SubTotal
  11819. })
  11820. .WhereColumns(x => new { x.Id })
  11821. .ExecuteCommandAsync();
  11822. if (upd < 1) return Ok(JsonView(false));
  11823. }
  11824. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11825. ////消息通知
  11826. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11827. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11828. return Ok(JsonView(new { itemTotal = itemTotal }));
  11829. }
  11830. /// <summary>
  11831. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11832. /// </summary>
  11833. /// <returns></returns>
  11834. [HttpPost]
  11835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11836. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11837. {
  11838. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11839. int subId = dto.SubId, feeType = dto.FeeType;
  11840. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11841. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11842. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11843. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11844. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11845. subInfo.Id = subId;
  11846. subInfo.ParentId = dto.DraftId;
  11847. if (feeType == 3) subInfo.Type = 1;
  11848. else if (feeType == 4) subInfo.Type = 2;
  11849. else if (feeType == 5) subInfo.Type = 3;
  11850. else if (feeType == 6) subInfo.Type = 4;
  11851. subInfo.CreateUserId = dto.CurrUserId;
  11852. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11853. if (parentId < 1) return Ok(JsonView(false));
  11854. //子表op
  11855. if (subId < 1)
  11856. {
  11857. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11858. if (subAdd < 1) return Ok(JsonView(false));
  11859. }
  11860. else
  11861. {
  11862. var subUpd = await _sqlSugar.Updateable(subInfo)
  11863. .UpdateColumns(x => new
  11864. {
  11865. x.Days,
  11866. x.NationalTravelFeeId,
  11867. x.Cost,
  11868. x.Currency,
  11869. x.SubTotal
  11870. })
  11871. .WhereColumns(x => new { x.Id })
  11872. .ExecuteCommandAsync();
  11873. if (subUpd < 1) return Ok(JsonView(false));
  11874. }
  11875. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11876. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11877. }
  11878. /// <summary>
  11879. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11880. /// </summary>
  11881. /// <returns></returns>
  11882. [HttpPost]
  11883. [ApiExplorerSettings(IgnoreApi = true)]
  11884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11885. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11886. {
  11887. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11888. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11889. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11890. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11891. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11892. {
  11893. Id = x.Id,
  11894. ParentId = dto.DraftId,
  11895. SetDataId = x.SetDataId,
  11896. Index = x.Index,
  11897. Cost = x.Cost,
  11898. Currency = x.Currency,
  11899. SubTotal = x.SubTotal,
  11900. CreateUserId = dto.CurrUserId,
  11901. Remark = x.Remark
  11902. }).ToList();
  11903. var adds = infos.Where(x => x.Id <= 0).ToList();
  11904. var upds = infos.Where(x => x.Id > 0).ToList();
  11905. if (adds.Count > 0)
  11906. {
  11907. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11908. if (add < 1) return Ok(JsonView(false));
  11909. }
  11910. if (upds.Count > 0)
  11911. {
  11912. var upd = await _sqlSugar.Updateable(adds)
  11913. .UpdateColumns(x => new
  11914. {
  11915. x.Index,
  11916. x.SetDataId,
  11917. x.Cost,
  11918. x.Currency,
  11919. x.SubTotal,
  11920. x.Remark
  11921. })
  11922. .WhereColumns(x => new { x.Id })
  11923. .ExecuteCommandAsync();
  11924. if (upd < 1) return Ok(JsonView(false));
  11925. }
  11926. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11927. //消息通知
  11928. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11929. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11930. return Ok(JsonView(new { itemTotal = itemTotal }));
  11931. }
  11932. /// <summary>
  11933. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11934. /// </summary>
  11935. /// <returns></returns>
  11936. [HttpPost]
  11937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11938. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11939. {
  11940. int subId = dto.SubId, id = dto.DraftId;
  11941. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11942. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11943. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11944. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11945. subInfo.Id = subId;
  11946. subInfo.ParentId = id;
  11947. subInfo.CreateUserId = dto.CurrUserId;
  11948. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11949. if (parentId < 1) return Ok(JsonView(false));
  11950. #region 子表op
  11951. if (subId < 1)//add
  11952. {
  11953. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11954. if (subAdd < 1) return Ok(JsonView(false));
  11955. }
  11956. else //upd
  11957. {
  11958. var subUpd = await _sqlSugar.Updateable(subInfo)
  11959. .UpdateColumns(x => new
  11960. {
  11961. x.Index,
  11962. x.SetDataId,
  11963. x.Cost,
  11964. x.Currency,
  11965. x.SubTotal,
  11966. x.Remark
  11967. })
  11968. .WhereColumns(x => new { x.Id })
  11969. .ExecuteCommandAsync();
  11970. if (subUpd < 1) return Ok(JsonView(false));
  11971. }
  11972. #endregion
  11973. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11974. ////消息通知
  11975. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11976. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11977. }
  11978. /// <summary>
  11979. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11980. /// </summary>
  11981. /// <returns></returns>
  11982. [HttpPost]
  11983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11984. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11985. {
  11986. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11987. if (data.Code != 0)
  11988. {
  11989. return Ok(JsonView(false, data.Msg));
  11990. }
  11991. return Ok(JsonView(true, "操作成功!", data.Data));
  11992. }
  11993. /// <summary>
  11994. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11995. /// </summary>
  11996. /// <param name="dto"></param>
  11997. /// <returns></returns>
  11998. [HttpPost]
  11999. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12000. {
  12001. var data = new Grp_DayOtherPriceDraft()
  12002. {
  12003. Id = dto.Id,
  12004. IsDel = 1,
  12005. DeleteUserId = dto.DeleteUserId,
  12006. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12007. };
  12008. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12009. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12010. return Ok(JsonView(false, "删除失败!"));
  12011. }
  12012. #endregion
  12013. #endregion
  12014. #region 团组经理模块 出入境费用报价表
  12015. /// <summary>
  12016. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12017. /// </summary>
  12018. /// <returns></returns>
  12019. [HttpPost]
  12020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12021. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12022. {
  12023. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12024. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12025. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12026. initRates.Insert(0, cnyInfo);
  12027. liveRates.Insert(0, cnyInfo);
  12028. return Ok(JsonView(true, "查询成功!", new
  12029. {
  12030. InitRates = initRates,
  12031. LiveRates = liveRates
  12032. }));
  12033. }
  12034. /// <summary>
  12035. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12036. /// </summary>
  12037. /// <returns></returns>
  12038. [HttpPost]
  12039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12040. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12041. {
  12042. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12043. }
  12044. /// <summary>
  12045. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12046. /// </summary>
  12047. /// <returns></returns>
  12048. [HttpPost]
  12049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12050. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12051. {
  12052. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12053. }
  12054. /// <summary>
  12055. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12056. /// </summary>
  12057. /// <returns></returns>
  12058. [HttpPost]
  12059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12060. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12061. {
  12062. int groupId = dto.DiId,
  12063. currUserId = dto.CurrUserId;
  12064. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12065. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12066. //验证报价数据是否存在
  12067. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12068. if (isNull != null)
  12069. {
  12070. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12071. if (!info1.Rates.Any())
  12072. {
  12073. var rates = await GeneralMethod.EnterExitCostInitRate();
  12074. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12075. info1.Rates = rates.ToArray();
  12076. }
  12077. return Ok(JsonView(info1));
  12078. }
  12079. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12080. result.GroupId = groupId;
  12081. //处理报价名称
  12082. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12083. if (groupInfo != null)
  12084. {
  12085. var visitCountry = groupInfo.VisitCountry;
  12086. if (!string.IsNullOrEmpty(visitCountry))
  12087. {
  12088. string quoteName = string.Empty;
  12089. if (visitCountry.Contains("|"))
  12090. {
  12091. var countrys = visitCountry.Split("|");
  12092. quoteName = string.Join("、", countrys);
  12093. }
  12094. else quoteName = visitCountry;
  12095. quoteName += $"团组报价表";
  12096. result.Name = quoteName;
  12097. }
  12098. }
  12099. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12100. if (info.Code != StatusCodes.Status200OK)
  12101. {
  12102. if (!result.Rates.Any())
  12103. {
  12104. var rates = await GeneralMethod.EnterExitCostInitRate();
  12105. result.Rates = rates.ToArray();
  12106. }
  12107. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12108. }
  12109. var infoView = info.Data as EnterExitCostInfoView;
  12110. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12111. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12112. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12113. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12114. var eecRates = infoView.Currencys;
  12115. //默认添加人名币
  12116. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12117. {
  12118. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12119. }
  12120. //处理团组人数
  12121. int pplNum = 1;
  12122. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12123. var views = new List<QuoteSubItemInfo>();
  12124. #region 数据填充
  12125. var intTravelCosts = new List<QuoteSubItemInfo>();
  12126. #region 机票费用 1354
  12127. int intTravelIndex = 1;
  12128. if (infoView.SumJJC == 1)
  12129. {
  12130. intTravelCosts.Add(new QuoteSubItemInfo
  12131. {
  12132. ItemId = 1354,
  12133. Index = intTravelIndex,
  12134. FeeName = "经济舱",
  12135. UnitPrice = infoView.AirJJ,
  12136. Currency = "CNY",
  12137. Quantity = 1,
  12138. PplNum = 1,
  12139. TotalAmt = infoView.AirJJ,
  12140. Remark = "",
  12141. });
  12142. intTravelIndex++;
  12143. }
  12144. if (infoView.SumGWC == 1)
  12145. {
  12146. intTravelCosts.Add(new QuoteSubItemInfo
  12147. {
  12148. ItemId = 1354,
  12149. Index = intTravelIndex,
  12150. FeeName = "公务舱",
  12151. UnitPrice = infoView.AirGW,
  12152. Currency = "CNY",
  12153. Quantity = 1,
  12154. PplNum = 1,
  12155. TotalAmt = infoView.AirGW,
  12156. Remark = "",
  12157. });
  12158. intTravelIndex++;
  12159. }
  12160. if (infoView.SumTDC == 1)
  12161. {
  12162. intTravelCosts.Add(new QuoteSubItemInfo
  12163. {
  12164. ItemId = 1354,
  12165. Index = intTravelIndex,
  12166. FeeName = "头等舱",
  12167. UnitPrice = infoView.AirTD,
  12168. Currency = "CNY",
  12169. Quantity = 1,
  12170. PplNum = 1,
  12171. TotalAmt = infoView.AirTD,
  12172. Remark = "",
  12173. });
  12174. intTravelIndex++;
  12175. }
  12176. intTravelCosts.Add(new QuoteSubItemInfo
  12177. {
  12178. ItemId = 1354,
  12179. Index = intTravelIndex,
  12180. FeeName = "城市间交通费用",
  12181. UnitPrice = infoView.CityTranffic,
  12182. Currency = "CNY",
  12183. Quantity = 1,
  12184. PplNum = pplNum,
  12185. TotalAmt = infoView.CityTranffic * pplNum,
  12186. Remark = "",
  12187. });
  12188. views.AddRange(intTravelCosts);
  12189. #endregion
  12190. var accomCosts = new List<QuoteSubItemInfo>();
  12191. #region 住宿费 1355
  12192. if (infoView.QuarterageData.Any())
  12193. {
  12194. int accomIndex = 1;
  12195. int accomItemTypeId = 1355;
  12196. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12197. foreach (var item in groupData)
  12198. {
  12199. string feeName = string.Empty;
  12200. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12201. if (countryInfo != null)
  12202. {
  12203. feeName = countryInfo.Country;
  12204. var city = countryInfo.City;
  12205. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12206. {
  12207. feeName += $"-{city}";
  12208. }
  12209. }
  12210. var hotelInfo = item.FirstOrDefault();
  12211. if (hotelInfo == null) continue;
  12212. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12213. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12214. int quantity = item.ToList().Count;
  12215. accomCosts.Add(new QuoteSubItemInfo
  12216. {
  12217. ItemId = accomItemTypeId,
  12218. Index = accomIndex,
  12219. FeeName = feeName,
  12220. UnitPrice = hotelInfo.Cost,
  12221. Currency = thisCurrency,
  12222. Quantity = quantity,
  12223. PplNum = pplNum,
  12224. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12225. Remark = "",
  12226. });
  12227. accomIndex++;
  12228. }
  12229. views.AddRange(accomCosts);
  12230. }
  12231. #endregion
  12232. var mealCosts = new List<QuoteSubItemInfo>();
  12233. #region 餐饮费 1356
  12234. if (infoView.BoardWagesData.Any())
  12235. {
  12236. var mealIndex = 1;
  12237. int mealItemTypeId = 1356;
  12238. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12239. foreach (var item in groupData)
  12240. {
  12241. string feeName = string.Empty;
  12242. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12243. if (countryInfo != null)
  12244. {
  12245. feeName = countryInfo.Country;
  12246. var city = countryInfo.City;
  12247. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12248. {
  12249. feeName += $"-{city}";
  12250. }
  12251. }
  12252. var mealInfo = item.FirstOrDefault();
  12253. if (mealInfo == null) continue;
  12254. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12255. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12256. int quantity = item.ToList().Count;
  12257. mealCosts.Add(new QuoteSubItemInfo
  12258. {
  12259. ItemId = mealItemTypeId,
  12260. Index = mealIndex,
  12261. FeeName = feeName,
  12262. UnitPrice = mealInfo.Cost,
  12263. Currency = thisCurrency,
  12264. Quantity = quantity,
  12265. PplNum = pplNum,
  12266. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12267. Remark = "",
  12268. });
  12269. mealIndex++;
  12270. }
  12271. views.AddRange(mealCosts);
  12272. }
  12273. #endregion
  12274. var miscCosts = new List<QuoteSubItemInfo>();
  12275. #region 公杂费 1364
  12276. if (infoView.MiscellaneousFeeData.Any())
  12277. {
  12278. var miscIndex = 1;
  12279. int miscItemTypeId = 1364;
  12280. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12281. foreach (var item in groupData)
  12282. {
  12283. string feeName = string.Empty;
  12284. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12285. if (countryInfo != null)
  12286. {
  12287. feeName = countryInfo.Country;
  12288. var city = countryInfo.City;
  12289. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12290. {
  12291. feeName += $"-{city}";
  12292. }
  12293. }
  12294. var miscInfo = item.FirstOrDefault();
  12295. if (miscInfo == null) continue;
  12296. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12297. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12298. int quantity = item.ToList().Count;
  12299. miscCosts.Add(new QuoteSubItemInfo
  12300. {
  12301. ItemId = miscItemTypeId,
  12302. Index = miscIndex,
  12303. FeeName = feeName,
  12304. UnitPrice = miscInfo.Cost,
  12305. Currency = thisCurrency,
  12306. Quantity = quantity,
  12307. PplNum = pplNum,
  12308. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12309. Remark = "",
  12310. });
  12311. miscIndex++;
  12312. }
  12313. views.AddRange(miscCosts);
  12314. }
  12315. #endregion
  12316. #region 签证+保险 1362
  12317. int visaInsIndex = 1;
  12318. int visaInsItemTypeId = 1362;
  12319. if (infoView.Visa > 0)
  12320. {
  12321. views.Add(new QuoteSubItemInfo()
  12322. {
  12323. ItemId = visaInsItemTypeId,
  12324. Index = visaInsIndex,
  12325. FeeName = $"签证",
  12326. UnitPrice = infoView.Visa,
  12327. Currency = $"CNY",
  12328. Quantity = 1,
  12329. PplNum = pplNum,
  12330. TotalAmt = infoView.Visa * pplNum,
  12331. Remark = "",
  12332. });
  12333. visaInsIndex++;
  12334. }
  12335. if (infoView.Safe > 0)
  12336. {
  12337. views.Add(new QuoteSubItemInfo()
  12338. {
  12339. ItemId = visaInsItemTypeId,
  12340. Index = visaInsIndex,
  12341. FeeName = $"保险",
  12342. UnitPrice = infoView.Safe,
  12343. Currency = $"CNY",
  12344. Quantity = 1,
  12345. PplNum = pplNum,
  12346. TotalAmt = infoView.Safe * pplNum,
  12347. Remark = "",
  12348. });
  12349. }
  12350. #endregion
  12351. #region 服务费 1363
  12352. int serviceFeeIndex = 1;
  12353. int serviceFeeItemTypeId = 1363;
  12354. if (infoView.Service > 0)
  12355. {
  12356. views.Add(new QuoteSubItemInfo()
  12357. {
  12358. ItemId = serviceFeeItemTypeId,
  12359. Index = serviceFeeIndex,
  12360. FeeName = $"服务费",
  12361. UnitPrice = infoView.Service,
  12362. Currency = $"CNY",
  12363. Quantity = 1,
  12364. PplNum = pplNum,
  12365. TotalAmt = infoView.Service * pplNum,
  12366. Remark = "",
  12367. });
  12368. }
  12369. #endregion
  12370. #endregion
  12371. if (result.FeeItems.Any())
  12372. {
  12373. result.FeeItems.Select(x =>
  12374. {
  12375. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12376. if (feeInfos.Any()) x.Infos = feeInfos;
  12377. return x;
  12378. }
  12379. ).OrderBy(x => x.Index)
  12380. .ToList();
  12381. if (!result.Rates.Any())
  12382. {
  12383. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12384. else
  12385. {
  12386. var rates = await GeneralMethod.EnterExitCostInitRate();
  12387. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12388. result.Rates = rates.ToArray();
  12389. }
  12390. }
  12391. }
  12392. return Ok(JsonView(result));
  12393. }
  12394. /// <summary>
  12395. /// 团组模块 - 出入境费用报价表 - Info
  12396. /// </summary>
  12397. /// <returns></returns>
  12398. [HttpPost]
  12399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12400. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12401. {
  12402. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12403. if (!info.Rates.Any())
  12404. {
  12405. var rates = await GeneralMethod.EnterExitCostInitRate();
  12406. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12407. info.Rates = rates.ToArray();
  12408. }
  12409. return Ok(JsonView(info));
  12410. }
  12411. /// <summary>
  12412. /// 团组模块 - 出入境费用报价表 - OP
  12413. /// </summary>
  12414. /// <returns></returns>
  12415. [HttpPost]
  12416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12417. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12418. {
  12419. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12420. }
  12421. /// <summary>
  12422. /// 团组模块 - 出入境费用报价表 - 删除 项
  12423. /// </summary>
  12424. /// <returns></returns>
  12425. [HttpPost]
  12426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12427. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12428. {
  12429. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12430. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12431. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12432. }
  12433. /// <summary>
  12434. /// 团组模块 - 出入境费用报价表 - 导出
  12435. /// </summary>
  12436. /// <returns></returns>
  12437. [HttpPost]
  12438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12439. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12440. {
  12441. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12442. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12443. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12444. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12445. var rates = info.Rates;
  12446. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12447. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12448. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12449. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12450. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12451. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12452. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12453. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12454. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12455. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12456. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12457. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12458. //获取模板
  12459. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12460. var designer = new WorkbookDesigner();
  12461. designer.Workbook = new Workbook(tempPath);
  12462. designer.SetDataSource("QuoteName", info.Name);
  12463. designer.SetDataSource("CompanyTitle", "公司名称");
  12464. designer.SetDataSource("CompanyLabel", "");
  12465. #region 国际旅费
  12466. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12467. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12468. {
  12469. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12470. var label = new StringBuilder();
  12471. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12472. if (infos.Any())
  12473. {
  12474. label.Append(infos.Sum(x => x.PplNum));
  12475. label.Append("人全程机票:");
  12476. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12477. label.AppendLine("元");
  12478. }
  12479. foreach (var item in intTravelCosts.Infos)
  12480. {
  12481. label.Append(item.FeeName);
  12482. label.Append(":");
  12483. label.Append(item.UnitPrice.TruncDecimals(2));
  12484. label.Append("元/人*");
  12485. label.Append(item.PplNum);
  12486. label.AppendLine("人");
  12487. }
  12488. if (label.HasValue())
  12489. {
  12490. label.Append("\r\n以上小计:");
  12491. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12492. label.Append("元");
  12493. }
  12494. designer.SetDataSource("IntTravelLabel", label.ToString());
  12495. }
  12496. #endregion
  12497. #region 住宿费
  12498. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12499. if (accomCosts != null && accomCosts.Infos.Any())
  12500. {
  12501. string currencyName = string.Empty,
  12502. countryName = string.Empty;
  12503. decimal rate = 1.0000M;
  12504. var label = new StringBuilder();
  12505. label.AppendLine("全程五星酒店,每人1间房");
  12506. foreach (var item in accomCosts.Infos)
  12507. {
  12508. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12509. string name = string.Empty, thisCountryName = string.Empty;
  12510. if (item.FeeName.Contains('-'))
  12511. {
  12512. var feeName = item.FeeName.Split('-');
  12513. thisCountryName = feeName[0];
  12514. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12515. name = feeName[1];
  12516. }
  12517. else name = item.FeeName;
  12518. string thisFeeName = string.Empty;
  12519. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12520. else thisFeeName = $"\r\n{name}:";
  12521. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12522. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12523. rate = rateInfo?.Rate ?? 1.0000M;
  12524. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12525. label.AppendLine(subLabel);
  12526. }
  12527. if (label.HasValue())
  12528. {
  12529. //以上小计:52440元(美金汇率:7.5 )
  12530. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12531. label.AppendLine(subLabel);
  12532. }
  12533. designer.SetDataSource("AccomLabel", label.ToString());
  12534. }
  12535. #endregion
  12536. #region 餐饮费
  12537. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12538. if (mealCosts != null && mealCosts.Infos.Any())
  12539. {
  12540. string currencyName = string.Empty;
  12541. decimal rate = 1.0000M;
  12542. var label = new StringBuilder();
  12543. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12544. foreach (var item in mealCosts.Infos)
  12545. {
  12546. string name = string.Empty;
  12547. if (item.FeeName.Contains('-'))
  12548. {
  12549. var feeName = item.FeeName.Split('-');
  12550. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12551. }
  12552. else name = $"\r\n{item.FeeName}:";
  12553. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12554. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12555. rate = rateInfo?.Rate ?? 1.0000M;
  12556. label.Append(name);
  12557. label.Append(item.UnitPrice.TruncDecimals(2));
  12558. label.Append(currencyName);
  12559. label.Append("/天*");
  12560. label.Append(item.Quantity.ToString("#0"));
  12561. label.Append('*');
  12562. label.Append(item.PplNum);
  12563. label.Append("人\r\n");
  12564. }
  12565. if (label.HasValue())
  12566. {
  12567. label.Append("\r\n以上小计:");
  12568. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12569. label.Append("元\r\n(");
  12570. label.Append("汇率:");
  12571. label.Append(rate.TruncDecimals(4));
  12572. label.Append(')');
  12573. }
  12574. designer.SetDataSource("MealLabel", label.ToString());
  12575. }
  12576. #endregion
  12577. #region 车辆安排
  12578. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12579. if (vehArranges != null && vehArranges.Infos.Any())
  12580. {
  12581. string currencyName = string.Empty;
  12582. //decimal rate = 1.0000M;
  12583. var label = new StringBuilder();
  12584. foreach (var item in vehArranges.Infos)
  12585. {
  12586. label.AppendLine();
  12587. label.AppendLine();
  12588. label.Append(item.FeeName);
  12589. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12590. }
  12591. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12592. }
  12593. #endregion
  12594. #region 邀请函发放对象
  12595. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12596. designer.SetDataSource("InviteToContent", "");
  12597. #endregion
  12598. #region 邀请函费
  12599. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12600. var is_label = new StringBuilder();
  12601. if (inviteCosts != null && inviteCosts.Infos.Any())
  12602. {
  12603. string currencyName = string.Empty;
  12604. decimal rate = 1.0000M;
  12605. foreach (var item in inviteCosts.Infos)
  12606. {
  12607. //乌兹别克斯坦:2000美金
  12608. currencyName = item.Currency;
  12609. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12610. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12611. is_label.AppendLine(label);
  12612. }
  12613. if (is_label.HasValue())
  12614. {
  12615. //以上小计:28500元(美金汇率:7.5)
  12616. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12617. is_label.AppendLine(label);
  12618. }
  12619. }
  12620. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12621. #endregion
  12622. #region 邀请函发放时间
  12623. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12624. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12625. #endregion
  12626. #region 公务活动(含翻译)
  12627. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12628. var oa_label = new StringBuilder();
  12629. if (officialActs != null && officialActs.Infos.Any())
  12630. {
  12631. string currencyName = string.Empty;
  12632. decimal rate = 1.0000M;
  12633. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12634. foreach (var item in officialActs.Infos)
  12635. {
  12636. //乌兹别克斯坦:1000美金/场
  12637. currencyName = item.Currency;
  12638. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12639. string label_remark = string.Empty;
  12640. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12641. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12642. }
  12643. label_content += "*总费用中未含超出公务活动价格";
  12644. //8场公务活动(以上小计:60000元)
  12645. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12646. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12647. oa_label.AppendLine(label_title);
  12648. oa_label.AppendLine(label_content);
  12649. }
  12650. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12651. #endregion
  12652. #region 签证+保险
  12653. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12654. var vi_label = new StringBuilder();
  12655. if (visaIns != null && visaIns.Infos.Any())
  12656. {
  12657. foreach (var item in visaIns.Infos)
  12658. {
  12659. //签证:500元/人
  12660. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12661. vi_label.AppendLine(label);
  12662. }
  12663. if (vi_label.HasValue())
  12664. {
  12665. //以上小计:6000元
  12666. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12667. vi_label.AppendLine(label);
  12668. }
  12669. }
  12670. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12671. #endregion
  12672. #region 服务费
  12673. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12674. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12675. #endregion
  12676. #region 公杂费
  12677. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12678. var pm_label = new StringBuilder();
  12679. if (pubMiscs != null && pubMiscs.Infos.Any())
  12680. {
  12681. string currencyName = string.Empty,
  12682. countryName = string.Empty;
  12683. decimal rate = 1.0000M;
  12684. foreach (var item in pubMiscs.Infos)
  12685. {
  12686. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12687. string name = string.Empty, thisCountryName = string.Empty;
  12688. if (item.FeeName.Contains('-'))
  12689. {
  12690. var feeName = item.FeeName.Split('-');
  12691. thisCountryName = feeName[0];
  12692. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12693. name = feeName[1];
  12694. }
  12695. else name = item.FeeName;
  12696. string thisFeeName = string.Empty;
  12697. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12698. else thisFeeName = $"\r\n{name}:";
  12699. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12700. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12701. rate = rateInfo?.Rate ?? 1.0000M;
  12702. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12703. pm_label.AppendLine(label);
  12704. }
  12705. if (pm_label.HasValue())
  12706. {
  12707. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12708. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12709. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12710. pm_label.AppendLine(string.Format("部分发放成员"));
  12711. }
  12712. }
  12713. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12714. #endregion
  12715. #region 税费
  12716. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12717. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12718. #endregion
  12719. #region 合计(单位:元)
  12720. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12721. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12722. #endregion
  12723. #region 汇率 Remark
  12724. var rate_label = new StringBuilder();
  12725. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12726. foreach (var item in rateGroups)
  12727. {
  12728. //美元汇率按\r\n1:7.5
  12729. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12730. rate_label.AppendLine(label);
  12731. }
  12732. designer.SetDataSource("RateLabel", rate_label.ToString());
  12733. #endregion
  12734. designer.Process();
  12735. //文件名
  12736. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12737. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12738. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12739. return Ok(JsonView(true, "成功", url));
  12740. }
  12741. #endregion
  12742. #region 签证费用录入
  12743. /// <summary>
  12744. /// 根据diid查询签证费用列表
  12745. /// </summary>
  12746. /// <param name="dto"></param>
  12747. /// <returns></returns>
  12748. [HttpPost]
  12749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12750. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12751. {
  12752. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12753. if (groupData.Code != 0)
  12754. {
  12755. return Ok(JsonView(false, groupData.Msg));
  12756. }
  12757. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12758. }
  12759. /// <summary>
  12760. /// 根据签证费用Id查询单条数据及c表数据
  12761. /// </summary>
  12762. /// <param name="dto"></param>
  12763. /// <returns></returns>
  12764. [HttpPost]
  12765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12766. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12767. {
  12768. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12769. if (groupData.Code != 0)
  12770. {
  12771. return Ok(JsonView(false, groupData.Msg));
  12772. }
  12773. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12774. }
  12775. /// <summary>
  12776. /// 签证费用删除
  12777. /// </summary>
  12778. /// <param name="dto"></param>
  12779. /// <returns></returns>
  12780. [HttpPost]
  12781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12782. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12783. {
  12784. _sqlSugar.BeginTran();
  12785. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12786. if (!res)
  12787. {
  12788. _sqlSugar.RollbackTran();
  12789. return Ok(JsonView(false, "删除失败"));
  12790. }
  12791. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12792. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12793. .SetColumns(a => new Grp_CreditCardPayment()
  12794. {
  12795. IsDel = 1,
  12796. DeleteUserId = dto.DeleteUserId,
  12797. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12798. })
  12799. .ExecuteCommand();
  12800. if (resSub < 1)
  12801. {
  12802. _sqlSugar.RollbackTran();
  12803. return Ok(JsonView(false, "删除失败"));
  12804. }
  12805. _sqlSugar.CommitTran();
  12806. return Ok(JsonView(true, "删除成功!"));
  12807. }
  12808. /// <summary>
  12809. /// 签证费用录入下拉框初始化
  12810. /// </summary>
  12811. /// <returns></returns>
  12812. [HttpPost]
  12813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12814. public async Task<IActionResult> VisaPriceAddSelect()
  12815. {
  12816. //支付方式
  12817. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12818. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12819. //币种
  12820. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12821. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12822. //乘客类型
  12823. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12824. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12825. //卡类型
  12826. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12827. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12828. //代办费类型
  12829. var agencyFeeTypeData = new List<dynamic>() {
  12830. new { id = 0 , Text = "未选择" },
  12831. new { id = 1 , Text = "小公务" },
  12832. new { id = 2 , Text = "大公务" },
  12833. };
  12834. //签证费用标准国家Data
  12835. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12836. var data = new
  12837. {
  12838. Payment = _Payment,
  12839. CurrencyList = _CurrencyList,
  12840. PassengerType = _PassengerType,
  12841. BankCard = _BankCard,
  12842. AgencyFeeType = agencyFeeTypeData,
  12843. CountryFeeData = visaCountryFeeData
  12844. };
  12845. return Ok(JsonView(true, "查询成功!", data));
  12846. }
  12847. /// <summary>
  12848. /// 签证费用录入操作(Status:1.新增,2.修改)
  12849. /// </summary>
  12850. /// <param name="dto"></param>
  12851. /// <returns></returns>
  12852. [HttpPost]
  12853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12854. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12855. {
  12856. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12857. if (groupData.Code != 0)
  12858. {
  12859. return Ok(JsonView(false, groupData.Msg));
  12860. }
  12861. #region 应用推送
  12862. try
  12863. {
  12864. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12865. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12866. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12867. //2024-10-21 新增LZ UID
  12868. var userIds = new List<int>() { 21 };
  12869. string title = $"系统通知";
  12870. string content = "";
  12871. var diId = dto.DiId;
  12872. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12873. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12874. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12875. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12876. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12877. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12878. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12879. }
  12880. catch (Exception ex)
  12881. {
  12882. }
  12883. #endregion
  12884. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12885. }
  12886. #endregion
  12887. #region 签证提成录入
  12888. /// <summary>
  12889. /// 签证提成录入
  12890. /// 基础数据
  12891. /// </summary>
  12892. /// <returns></returns>
  12893. [HttpGet]
  12894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12895. public async Task<IActionResult> VisaCommissionInit()
  12896. {
  12897. return Ok(await _visaCommissionRep.Init());
  12898. }
  12899. /// <summary>
  12900. /// 签证提成录入
  12901. /// Item
  12902. /// </summary>
  12903. /// <param name="_dto"></param>
  12904. /// <returns></returns>
  12905. [HttpPost]
  12906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12907. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12908. {
  12909. var validator = new VisaCommissionItemDtoValidator();
  12910. var validatorRes = await validator.ValidateAsync(_dto);
  12911. if (!validatorRes.IsValid)
  12912. {
  12913. var sb = new StringBuilder();
  12914. foreach (var item in validatorRes.Errors)
  12915. {
  12916. sb.AppendLine(item.ErrorMessage);
  12917. }
  12918. return Ok(JsonView(false, sb.ToString()));
  12919. }
  12920. return Ok(await _visaCommissionRep.Item(_dto));
  12921. }
  12922. /// <summary>
  12923. /// 签证提成录入
  12924. /// Save
  12925. /// </summary>
  12926. /// <param name="_dto"></param>
  12927. /// <returns></returns>
  12928. [HttpPost]
  12929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12930. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12931. {
  12932. //参数验证
  12933. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12934. foreach (var item in _dto.Items)
  12935. {
  12936. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12937. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12938. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12939. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12940. }
  12941. return Ok(await _visaCommissionRep.Save(_dto));
  12942. }
  12943. /// <summary>
  12944. /// 签证提成录入
  12945. /// Create
  12946. /// </summary>
  12947. /// <param name="_dto"></param>
  12948. /// <returns></returns>
  12949. [HttpPost]
  12950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12951. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12952. {
  12953. var validator = new VisaCommissionCreateDtoValidator();
  12954. var validatorRes = await validator.ValidateAsync(_dto);
  12955. if (!validatorRes.IsValid)
  12956. {
  12957. var sb = new StringBuilder();
  12958. foreach (var item in validatorRes.Errors)
  12959. {
  12960. sb.AppendLine(item.ErrorMessage);
  12961. }
  12962. return Ok(JsonView(false, sb.ToString()));
  12963. }
  12964. return Ok(await _visaCommissionRep.Create(_dto));
  12965. }
  12966. /// <summary>
  12967. /// 签证提成录入
  12968. /// Put(编辑)
  12969. /// </summary>
  12970. /// <param name="id"></param>
  12971. /// <param name="_dto"></param>
  12972. /// <returns></returns>
  12973. [HttpPut]
  12974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12975. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12976. {
  12977. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12978. var validator = new VisaCommissionCreateDtoValidator();
  12979. var validatorRes = await validator.ValidateAsync(_dto);
  12980. if (!validatorRes.IsValid)
  12981. {
  12982. var sb = new StringBuilder();
  12983. foreach (var item in validatorRes.Errors)
  12984. {
  12985. sb.AppendLine(item.ErrorMessage);
  12986. }
  12987. return Ok(JsonView(false, sb.ToString()));
  12988. }
  12989. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12990. }
  12991. /// <summary>
  12992. /// 签证提成录入
  12993. /// Del
  12994. /// </summary>
  12995. /// <param name="id"></param>
  12996. /// <param name="currUserId"></param>
  12997. /// <returns></returns>
  12998. [HttpPost]
  12999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13000. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13001. {
  13002. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13003. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13004. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13005. }
  13006. #endregion
  13007. #region op费用录入
  13008. /// <summary>
  13009. /// 根据diid查询op费用列表
  13010. /// </summary>
  13011. /// <param name="dto"></param>
  13012. /// <returns></returns>
  13013. [HttpPost]
  13014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13015. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13016. {
  13017. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13018. if (groupData.Code != 0)
  13019. {
  13020. return Ok(JsonView(false, groupData.Msg));
  13021. }
  13022. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13023. }
  13024. /// <summary>
  13025. /// 根据op费用Id查询单条数据及c表数据
  13026. /// </summary>
  13027. /// <param name="dto"></param>
  13028. /// <returns></returns>
  13029. [HttpPost]
  13030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13031. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13032. {
  13033. try
  13034. {
  13035. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13036. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13037. var data = new
  13038. {
  13039. CarTouristGuideGround = _groupData,
  13040. CreditCardPayment = _creditCardPayment
  13041. };
  13042. return Ok(JsonView(true, "查询成功!", data));
  13043. }
  13044. catch (Exception ex)
  13045. {
  13046. return Ok(JsonView(false, "程序错误!"));
  13047. }
  13048. }
  13049. /// <summary>
  13050. /// op费用删除
  13051. /// </summary>
  13052. /// <param name="dto"></param>
  13053. /// <returns></returns>
  13054. [HttpPost]
  13055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13056. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13057. {
  13058. try
  13059. {
  13060. _sqlSugar.BeginTran();
  13061. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13062. if (!res)
  13063. {
  13064. return Ok(JsonView(false, "删除失败"));
  13065. }
  13066. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13067. {
  13068. IsDel = 1,
  13069. DeleteUserId = dto.DeleteUserId,
  13070. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13071. }).ExecuteCommandAsync();
  13072. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13073. {
  13074. IsDel = 1,
  13075. DeleteUserId = dto.DeleteUserId,
  13076. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13077. }).ExecuteCommandAsync();
  13078. #region 删除超支相关数据
  13079. //删除导入的超支数据
  13080. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13081. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13082. {
  13083. IsDel = 1,
  13084. DeleteUserId = dto.DeleteUserId,
  13085. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13086. }).ExecuteCommand();
  13087. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13088. {
  13089. IsDel = 1,
  13090. DeleteUserId = dto.DeleteUserId,
  13091. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13092. }).ExecuteCommand();
  13093. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13094. {
  13095. IsDel = 1,
  13096. DeleteUserId = dto.DeleteUserId,
  13097. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13098. }).ExecuteCommand();
  13099. #endregion
  13100. _sqlSugar.CommitTran();
  13101. return Ok(JsonView(true, "删除成功!"));
  13102. }
  13103. catch (Exception ex)
  13104. {
  13105. _sqlSugar.RollbackTran();
  13106. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13107. }
  13108. }
  13109. /// <summary>
  13110. /// op费用录入操作(Status:1.新增,2.修改)
  13111. /// </summary>
  13112. /// <param name="dto"></param>
  13113. /// <returns></returns>
  13114. [HttpPost]
  13115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13116. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13117. {
  13118. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13119. if (groupData.Code != 0)
  13120. {
  13121. return Ok(JsonView(false, groupData.Msg));
  13122. }
  13123. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13124. }
  13125. /// <summary>
  13126. /// 填写费用详细页面初始化绑定
  13127. /// </summary>
  13128. /// <param name="dto"></param>
  13129. /// <returns></returns>
  13130. [HttpPost]
  13131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13132. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13133. {
  13134. try
  13135. {
  13136. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13137. if (groupData.Code != 0)
  13138. {
  13139. return Ok(JsonView(false, groupData.Msg));
  13140. }
  13141. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13142. }
  13143. catch (Exception ex)
  13144. {
  13145. return Ok(JsonView(false, ex.Message));
  13146. }
  13147. }
  13148. /// <summary>
  13149. /// 根据op费用Id查询详细数据
  13150. /// </summary>
  13151. /// <param name="dto"></param>
  13152. /// <returns></returns>
  13153. [HttpPost]
  13154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13155. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13156. {
  13157. try
  13158. {
  13159. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13160. if (groupData.Code != 0)
  13161. {
  13162. return Ok(JsonView(false, groupData.Msg));
  13163. }
  13164. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13165. }
  13166. catch (Exception ex)
  13167. {
  13168. return Ok(JsonView(false, ex.Message));
  13169. }
  13170. }
  13171. /// <summary>
  13172. /// OP费用录入填写详情
  13173. /// </summary>
  13174. /// <param name="dto"></param>
  13175. /// <returns></returns>
  13176. [HttpPost]
  13177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13178. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13179. {
  13180. try
  13181. {
  13182. #region 参数校验
  13183. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13184. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13185. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13186. #endregion
  13187. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13188. if (groupData.Code != 0)
  13189. {
  13190. return Ok(JsonView(false, groupData.Msg));
  13191. }
  13192. //自动审核
  13193. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13194. #region 尾款自动审核
  13195. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13196. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  13197. if (opinfos.PriceType == 1062)
  13198. {
  13199. var isAuto = false;
  13200. //找对应的首付款
  13201. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13202. .InnerJoin<Grp_CreditCardPayment>((x,a) => a.IsDel == 0 && a.CTable == 79 && a.CId == x.Id && a.DIId == x.DiId && (a.IsAuditGM == 1 || a.IsAuditGM == 3 ))
  13203. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  13204. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  13205. x.PriceType == 1061 && x.DiId == dto.DiId);
  13206. if (firstPrice!= null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  13207. {
  13208. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  13209. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  13210. if (balance >= opinfos.ServiceQuotedPrice)
  13211. {
  13212. isAuto = true;
  13213. }
  13214. }
  13215. if (isAuto)
  13216. {
  13217. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13218. .SetColumns(a => new Grp_CreditCardPayment
  13219. {
  13220. IsAuditGM = 3, //自动审核通过
  13221. AuditGMOperate = 4,
  13222. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13223. })
  13224. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  13225. .ExecuteCommand();
  13226. }
  13227. }
  13228. #endregion
  13229. #region 应用推送
  13230. try
  13231. {
  13232. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13233. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13234. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13235. //2024-10-21 新增LZ UID
  13236. var userIds = new List<int>() { 21 };
  13237. string title = $"系统通知";
  13238. var diId = dto.DiId;
  13239. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13240. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13241. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13242. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13243. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13244. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13245. }
  13246. catch (Exception ex)
  13247. {
  13248. }
  13249. #endregion
  13250. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13251. }
  13252. catch (Exception ex)
  13253. {
  13254. return Ok(JsonView(false, ex.Message));
  13255. }
  13256. }
  13257. /// <summary>
  13258. /// 获取三公详细所有城市
  13259. /// </summary>
  13260. /// <returns></returns>
  13261. [HttpGet]
  13262. public IActionResult OpCarCityResult()
  13263. {
  13264. var jw = JsonView(false);
  13265. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13266. {
  13267. x.Id,
  13268. x.Country,
  13269. x.City,
  13270. }).ToList();
  13271. if (data.Count > 0)
  13272. {
  13273. jw = JsonView(true, "获取成功!", data);
  13274. }
  13275. else
  13276. {
  13277. jw.Msg = "城市数据为空!";
  13278. jw.Data = Array.Empty<string>();
  13279. }
  13280. return Ok(jw);
  13281. }
  13282. /// <summary>
  13283. /// 导出地接费用明细
  13284. /// </summary>
  13285. /// <param name="dto"></param>
  13286. /// <returns></returns>
  13287. [HttpPost]
  13288. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13289. {
  13290. var jw = JsonView(false);
  13291. if (dto.Diid < 1)
  13292. {
  13293. jw.Msg = "请输入正确的diid!";
  13294. return Ok(jw);
  13295. }
  13296. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13297. if (group == null)
  13298. {
  13299. jw.Msg = "未找到团组信息!";
  13300. return Ok(jw);
  13301. }
  13302. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13303. if (localGuideArr.Count == 0)
  13304. {
  13305. jw.Msg = "该团组暂无地接信息!";
  13306. return Ok(jw);
  13307. }
  13308. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13309. var overspendSoure = new Dictionary<int, int>
  13310. {
  13311. { 91, 982 }, //车
  13312. { 92 , 1059} ,//导游
  13313. { 994 , 1073}, //翻译
  13314. { 988 , 1074 }, //早餐
  13315. { 93 , 1075 }, //午餐
  13316. { 989 , 1076 }, //晚餐
  13317. };
  13318. var Zips = new Dictionary<string, Stream>();
  13319. foreach (var groupArr in localGroup)
  13320. {
  13321. var keyValue = groupArr.Key;
  13322. if (int.TryParse(keyValue, out int cityid))
  13323. {
  13324. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13325. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13326. }
  13327. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13328. foreach (var item in groupArr)
  13329. {
  13330. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13331. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13332. new Grp_CarTouristGuideGroundReservationsContentExtend
  13333. {
  13334. Count = a.Count,
  13335. CreateTime = a.CreateTime,
  13336. CreateUserId = a.CreateUserId,
  13337. CTGGRId = a.CTGGRId,
  13338. Currency = a.Currency,
  13339. DatePrice = a.DatePrice,
  13340. DeleteTime = a.DeleteTime,
  13341. DeleteUserId = a.DeleteUserId,
  13342. DiId = a.DiId,
  13343. Id = a.Id,
  13344. IsDel = a.IsDel,
  13345. Price = a.Price,
  13346. PriceContent = a.PriceContent,
  13347. Remark = a.Remark,
  13348. SId = a.SId,
  13349. SidName = b.Name,
  13350. Units = a.Units,
  13351. }
  13352. ).ToList();
  13353. if (content.Count > 0)
  13354. {
  13355. contentArr.Add(content);
  13356. }
  13357. }
  13358. //open excel
  13359. //set excel
  13360. //save excel
  13361. try
  13362. {
  13363. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13364. IWorkbook workbook;
  13365. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13366. {
  13367. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13368. }
  13369. else
  13370. {
  13371. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13372. }
  13373. ISheet sheet = workbook.GetSheetAt(0);
  13374. var rowStartIndex = 2;
  13375. var clounmCount = 10;
  13376. var initStyleRow = sheet.GetRow(2);
  13377. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13378. //var overspendArrDetail =
  13379. var existsId = new List<CarCompare>();
  13380. var lastElem = arr.Last();
  13381. var thisSid = -1;
  13382. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13383. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13384. {
  13385. Name = "未知币种!",
  13386. Remark = "未知币种!",
  13387. };
  13388. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13389. Action cloneRowFn = () =>
  13390. {
  13391. rowStartIndex++;
  13392. var cloneRow = sheet.CreateRow(rowStartIndex);
  13393. // 复制样式
  13394. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13395. {
  13396. ICell sourceCell = initStyleRow.GetCell(i);
  13397. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13398. // 确保单元格存在样式
  13399. if (sourceCell.CellStyle != null)
  13400. {
  13401. targetCell.CellStyle = sourceCell.CellStyle;
  13402. }
  13403. }
  13404. };
  13405. var mergeRow = () =>
  13406. {
  13407. for (int i = 2; i < sheet.LastRowNum; i++)
  13408. {
  13409. var row = sheet.GetRow(i);
  13410. var cellFirst = row.GetCell(0);
  13411. var thisIndex = i + 1;
  13412. while (thisIndex < sheet.LastRowNum)
  13413. {
  13414. var nextRow = sheet.GetRow(thisIndex);
  13415. var nextCellFirst = nextRow.GetCell(0);
  13416. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13417. {
  13418. thisIndex++;
  13419. }
  13420. else
  13421. {
  13422. break;
  13423. }
  13424. }
  13425. thisIndex--;
  13426. if (thisIndex != i)
  13427. {
  13428. //合并row
  13429. var cellRangeAddress = new CellRangeAddress(
  13430. i, // 起始行索引(0-based)
  13431. thisIndex, // 结束行索引(0-based)
  13432. 0, // 起始列索引(0-based)
  13433. 0 // 结束列索引(0-based)
  13434. );
  13435. sheet.AddMergedRegion(cellRangeAddress);
  13436. i = thisIndex;
  13437. }
  13438. }
  13439. };
  13440. var chaoshiNumber = 0;
  13441. var totalNumber = 0.00M;
  13442. string lastStr = "";
  13443. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13444. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13445. {
  13446. b.IsAuditGM,
  13447. x.Id,
  13448. x.Area,
  13449. b.PayPercentage,
  13450. b.PayMoney,
  13451. }).ToList();
  13452. string yesPayment = "", noPayment = "";
  13453. foreach (var item in queryCarArrByCityAndDiid)
  13454. {
  13455. if (item.IsAuditGM == 1)
  13456. {
  13457. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13458. }
  13459. else
  13460. {
  13461. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13462. }
  13463. }
  13464. lastStr = yesPayment + noPayment;
  13465. foreach (var item in arr)
  13466. {
  13467. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13468. {
  13469. if (thisSid != item.SId)
  13470. {
  13471. if (thisSid == -1)
  13472. {
  13473. thisSid = item.SId;
  13474. }
  13475. else
  13476. {
  13477. //合并小计行
  13478. //创建合并区域的实例
  13479. var cellRangeAddress = new CellRangeAddress(
  13480. rowStartIndex, // 起始行索引(0-based)
  13481. rowStartIndex, // 结束行索引(0-based)
  13482. 0, // 起始列索引(0-based)
  13483. 3 // 结束列索引(0-based)
  13484. );
  13485. sheet.AddMergedRegion(cellRangeAddress);
  13486. var CellStyle = workbook.CreateCellStyle();
  13487. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13488. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13489. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13490. for (int i = 0; i <= clounmCount; i++)
  13491. {
  13492. if (i > 6)
  13493. {
  13494. var CellStyle1 = workbook.CreateCellStyle();
  13495. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13496. IFont Font = workbook.CreateFont(); // 创建字体
  13497. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13498. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13499. CellStyle1.SetFont(Font);
  13500. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13501. }
  13502. else
  13503. {
  13504. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13505. }
  13506. }
  13507. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13508. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13509. //超时合计
  13510. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13511. //超时数
  13512. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13513. //超时合计费用
  13514. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13515. thisSid = item.SId;
  13516. cloneRowFn();
  13517. chaoshiNumber = 0;
  13518. totalNumber = 0;
  13519. }
  13520. }
  13521. IRow row = sheet.GetRow(rowStartIndex);
  13522. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13523. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13524. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13525. if (isOpenOverspendSoure)
  13526. {
  13527. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13528. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13529. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13530. }
  13531. for (int i = 0; i <= clounmCount; i++)
  13532. {
  13533. var cell = row.GetCell(i);
  13534. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13535. if (cell == null)
  13536. {
  13537. cell = row.CreateCell(i);
  13538. }
  13539. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13540. fontRed.CloneStyleFrom(cell.CellStyle);
  13541. IFont Font = workbook.CreateFont(); // 创建字体
  13542. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13543. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13544. fontRed.SetFont(Font);
  13545. byte[] rgb = new byte[3] { 255, 242, 204 };
  13546. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13547. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13548. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13549. if (workbook is XSSFWorkbook)
  13550. {
  13551. BackgroundColor255_242_204.FillForegroundColor = 0;
  13552. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13553. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13554. }
  13555. else
  13556. {
  13557. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13558. }
  13559. if (i == 1 || i > 6)
  13560. {
  13561. if (i > 6)
  13562. {
  13563. fontRed.FillForegroundColor = 0;
  13564. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13565. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13566. }
  13567. cell.CellStyle = fontRed;
  13568. }
  13569. if (i > 2 && i < 7)
  13570. {
  13571. cell.CellStyle = BackgroundColor255_242_204;
  13572. }
  13573. cell.SetCellValue(setCellValue); //写入单元格
  13574. }
  13575. if (overspendSoure.ContainsKey(thisSid))
  13576. {
  13577. var overspendId = overspendSoure[thisSid];
  13578. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13579. }
  13580. cloneRowFn();
  13581. existsId.Add(new CarCompare
  13582. {
  13583. DataPrice = item.DatePrice.ObjToDate(),
  13584. Sid = item.SId
  13585. });
  13586. }
  13587. if (item.Equals(lastElem))
  13588. {
  13589. //合并小计行
  13590. //创建合并区域的实例
  13591. var cellRangeAddress = new CellRangeAddress(
  13592. rowStartIndex, // 起始行索引(0-based)
  13593. rowStartIndex, // 结束行索引(0-based)
  13594. 0, // 起始列索引(0-based)
  13595. 3 // 结束列索引(0-based)
  13596. );
  13597. sheet.AddMergedRegion(cellRangeAddress);
  13598. var CellStyle = workbook.CreateCellStyle();
  13599. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13600. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13601. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13602. for (int i = 0; i <= clounmCount; i++)
  13603. {
  13604. if (i > 6)
  13605. {
  13606. var CellStyle1 = workbook.CreateCellStyle();
  13607. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13608. IFont Font = workbook.CreateFont(); // 创建字体
  13609. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13610. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13611. CellStyle1.SetFont(Font);
  13612. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13613. }
  13614. else
  13615. {
  13616. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13617. }
  13618. }
  13619. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13620. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13621. //超时合计
  13622. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13623. //超时数
  13624. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13625. //超时合计费用
  13626. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13627. cloneRowFn();
  13628. // 创建合并区域的实例
  13629. cellRangeAddress = new CellRangeAddress(
  13630. rowStartIndex, // 起始行索引(0-based)
  13631. rowStartIndex, // 结束行索引(0-based)
  13632. 0, // 起始列索引(0-based)
  13633. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13634. );
  13635. // 添加合并区域
  13636. sheet.AddMergedRegion(cellRangeAddress);
  13637. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13638. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13639. }
  13640. }
  13641. mergeRow();
  13642. // 保存修改后的Excel文件到新文件
  13643. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13644. // new FileStream(newFilePath, FileMode.CreateNew)
  13645. using (var stream = new MemoryStream())
  13646. {
  13647. workbook.Write(stream, true);
  13648. stream.Flush();
  13649. stream.Seek(0, SeekOrigin.Begin);
  13650. var memoryStream = new MemoryStream();
  13651. stream.CopyTo(memoryStream);
  13652. memoryStream.Seek(0, SeekOrigin.Begin);
  13653. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13654. }
  13655. workbook.Close();
  13656. workbook.Dispose();
  13657. }
  13658. catch (Exception ex)
  13659. {
  13660. jw.Msg = "出现异常!" + ex.Message;
  13661. return Ok(jw);
  13662. }
  13663. }
  13664. if (Zips.Count > 0)
  13665. {
  13666. var io = new IOOperatorHelper();
  13667. var byts = io.ConvertZipStream(Zips);
  13668. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13669. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13670. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13671. }
  13672. else
  13673. {
  13674. jw.Msg = "暂无生成文件!";
  13675. }
  13676. return Ok(jw);
  13677. }
  13678. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13679. {
  13680. string outStr = string.Empty;
  13681. switch (i)
  13682. {
  13683. case 0:
  13684. outStr = arr[0].SidName;
  13685. break;
  13686. case 1:
  13687. outStr = arr[0].DataPriceStr;
  13688. break;
  13689. case 2:
  13690. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13691. break;
  13692. case 4:
  13693. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13694. break;
  13695. case 7:
  13696. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13697. {
  13698. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13699. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13700. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13701. }
  13702. break;
  13703. case 8:
  13704. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13705. {
  13706. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13707. }
  13708. break;
  13709. case 9:
  13710. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13711. {
  13712. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13713. }
  13714. break;
  13715. case 10:
  13716. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13717. {
  13718. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13719. }
  13720. break;
  13721. }
  13722. return outStr;
  13723. }
  13724. #region OP行程单
  13725. /// <summary>
  13726. /// OP行程单初始化
  13727. /// </summary>
  13728. /// <param name="dto"></param>
  13729. /// <returns></returns>
  13730. [HttpPost]
  13731. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13732. {
  13733. var jw = JsonView(false);
  13734. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13735. var group = groupList.First();
  13736. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13737. if (group == null)
  13738. {
  13739. jw.Msg = "暂无团组!";
  13740. return Ok(jw);
  13741. }
  13742. group = groupList.Find(x => x.Id == diid);
  13743. if (group == null)
  13744. {
  13745. jw.Msg = "请输入正确的团组ID!";
  13746. return Ok(jw);
  13747. }
  13748. string city = string.Empty;
  13749. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13750. if (blackCode.Count > 0)
  13751. {
  13752. var black = blackCode.First();
  13753. black.BlackCode = black.BlackCode ?? "";
  13754. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13755. if (blackSp.Length > 0)
  13756. {
  13757. try
  13758. {
  13759. var cityArrCode = new List<string>(20);
  13760. foreach (var item in blackSp)
  13761. {
  13762. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13763. var IndexSelect = itemSp[2];
  13764. var cityArrCodeLength = cityArrCode.Count - 1;
  13765. var startCity = IndexSelect.Substring(0, 3);
  13766. if (cityArrCodeLength > 0)
  13767. {
  13768. var arrEndCity = cityArrCode[cityArrCodeLength];
  13769. if (arrEndCity != startCity)
  13770. {
  13771. cityArrCode.Add(startCity.ToUpper());
  13772. }
  13773. }
  13774. else
  13775. {
  13776. cityArrCode.Add(startCity.ToUpper());
  13777. }
  13778. var endCity = IndexSelect.Substring(3, 3);
  13779. cityArrCode.Add(endCity.ToUpper());
  13780. }
  13781. var cityThree = string.Empty;
  13782. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13783. cityThree = cityThree.TrimEnd(',');
  13784. if (string.IsNullOrWhiteSpace(cityThree))
  13785. {
  13786. throw new
  13787. Exception("error");
  13788. }
  13789. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13790. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13791. foreach (var item in cityArrCode)
  13792. {
  13793. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13794. if (find != null)
  13795. {
  13796. city += find.City + "/";
  13797. }
  13798. else
  13799. {
  13800. city += item + "三字码未收入/";
  13801. }
  13802. }
  13803. city = city.TrimEnd('/');
  13804. }
  13805. catch (Exception e)
  13806. {
  13807. city = "黑屏代码格式不正确!";
  13808. }
  13809. }
  13810. }
  13811. else
  13812. {
  13813. city = "未录入黑屏代码";
  13814. }
  13815. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13816. {
  13817. Date = x.Date,
  13818. Days = x.Days,
  13819. Diffgroup = x.Diffgroup,
  13820. Diid = x.Diid,
  13821. Traffic_First = x.Traffic_First,
  13822. Traffic_Second = x.Traffic_Second,
  13823. Trip = x.Trip,
  13824. WeekDay = x.WeekDay,
  13825. Id = x.Id
  13826. }).ToList();
  13827. jw.Data = new
  13828. {
  13829. groupList = groupList.Select(x => new
  13830. {
  13831. x.Id,
  13832. x.TeamName,
  13833. x.TourCode
  13834. }).ToList(),
  13835. groupInfo = new
  13836. {
  13837. group.VisitDays,
  13838. group.TourCode,
  13839. group.VisitPNumber,
  13840. group.TeamName,
  13841. city
  13842. },
  13843. OpTravelList
  13844. };
  13845. jw.Code = 200;
  13846. jw.Msg = "操作成功!";
  13847. return Ok(jw);
  13848. }
  13849. /// <summary>
  13850. /// 删除团组行程单
  13851. /// </summary>
  13852. /// <returns></returns>
  13853. [HttpPost]
  13854. public IActionResult DelTravel(DelOpTravelDto dto)
  13855. {
  13856. var jw = JsonView(false);
  13857. if (dto.UserId <= 0 || dto.Diid <= 0)
  13858. {
  13859. jw.Msg = "请输入正确的参数!";
  13860. return Ok(jw);
  13861. }
  13862. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13863. .SetColumns(x => new Grp_TravelList
  13864. {
  13865. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13866. DeleteUserId = dto.UserId,
  13867. IsDel = 1,
  13868. }).ExecuteCommand();
  13869. jw = JsonView(true);
  13870. return Ok(jw);
  13871. }
  13872. /// <summary>
  13873. /// 行程单保存
  13874. /// </summary>
  13875. /// <returns></returns>
  13876. [HttpPost]
  13877. public IActionResult TravelSave(TravelSaveDto dto)
  13878. {
  13879. var jw = JsonView(false);
  13880. if (dto.Arr.Count > 0)
  13881. {
  13882. try
  13883. {
  13884. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13885. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13886. .ToList();
  13887. _sqlSugar.BeginTran();
  13888. foreach (var item in dto.Arr)
  13889. {
  13890. if (item.Id == 0)
  13891. {
  13892. throw new Exception("请传入正确的Id");
  13893. }
  13894. //比较上一次的差异
  13895. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13896. if (findTravel != null)
  13897. {
  13898. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13899. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13900. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13901. }
  13902. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13903. .SetColumns(x => new Grp_TravelList
  13904. {
  13905. Trip = item.Trip
  13906. }).ExecuteCommand();
  13907. }
  13908. _sqlSugar.CommitTran();
  13909. jw = JsonView(true);
  13910. }
  13911. catch (Exception ex)
  13912. {
  13913. _sqlSugar.RollbackTran();
  13914. jw.Msg = "程序异常!" + ex.Message;
  13915. }
  13916. }
  13917. else
  13918. {
  13919. jw.Msg = "请传入正确的参数!";
  13920. }
  13921. return Ok(jw);
  13922. }
  13923. private static string CheckStr(string original, string changed)
  13924. {
  13925. // 创建diff_match_patch对象
  13926. var dmp = new diff_match_patch();
  13927. // 计算差异
  13928. List<Diff> diffs = dmp.diff_main(original, changed);
  13929. // 清理和合并差异
  13930. dmp.diff_cleanupSemantic(diffs);
  13931. // 使用StringBuilder构建最终的字符串
  13932. var finalString = new StringBuilder();
  13933. // 输出差异结果,并构建变动后的字符串
  13934. foreach (Diff diff in diffs)
  13935. {
  13936. switch (diff.operation)
  13937. {
  13938. case Operation.EQUAL:
  13939. // 相等的部分,直接添加到最终字符串
  13940. finalString.Append(diff.text);
  13941. break;
  13942. case Operation.INSERT:
  13943. // 插入的部分,添加标记并添加到最终字符串
  13944. finalString.Append("[++]" + diff.text + "[++]");
  13945. break;
  13946. case Operation.DELETE:
  13947. // 删除的部分,不添加到最终字符串
  13948. //finalString.Append("[++]" + diff.text + "[++]");
  13949. break;
  13950. }
  13951. }
  13952. // 输出变动后的字符串
  13953. return finalString.ToString();
  13954. }
  13955. private class tagContent
  13956. {
  13957. public DateTime Date { get; set; }
  13958. public string StartTag { get; set; }
  13959. public string EndTag { get; set; }
  13960. public string Content { get; set; }
  13961. public static int tagLength { get { return 3; } }
  13962. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13963. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13964. public bool IsFinally { get; set; }
  13965. }
  13966. private static List<string> ExtractContentBetweenTags(string input, string tag)
  13967. {
  13968. var results = new List<string>();
  13969. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13970. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13971. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13972. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13973. string[] strValueArr = new string[1];
  13974. foreach (System.Text.RegularExpressions.Match match in matches)
  13975. {
  13976. var strValue = match.Groups[1].Value;
  13977. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13978. }
  13979. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13980. return results;
  13981. }
  13982. /// <summary>
  13983. /// 导出行程单
  13984. /// </summary>
  13985. /// <param name="dto"></param>
  13986. /// <returns></returns>
  13987. [HttpPost]
  13988. public IActionResult ExportTravel(ExportTravelDto dto)
  13989. {
  13990. var jw = JsonView(false);
  13991. jw.Data = "";
  13992. int diid = 0;
  13993. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13994. if (Find == null)
  13995. {
  13996. jw.Msg = "请选择正确的团组!";
  13997. return Ok(jw);
  13998. }
  13999. else
  14000. {
  14001. diid = Find.Id;
  14002. }
  14003. //数据源
  14004. var _travelList = new List<Grp_TravelList>();
  14005. DataTable dtBlack = null;
  14006. try
  14007. {
  14008. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14009. }
  14010. catch (Exception)
  14011. {
  14012. jw.Msg = "机票黑屏代码有误!";
  14013. return Ok(jw);
  14014. }
  14015. string CityStr = string.Empty;
  14016. if (dtBlack.Rows.Count == 0)
  14017. {
  14018. jw.Msg = "机票黑屏代码有误!";
  14019. return Ok(jw);
  14020. }
  14021. else
  14022. {
  14023. foreach (DataRow row in dtBlack.Rows)
  14024. {
  14025. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14026. {
  14027. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14028. return Ok(jw);
  14029. }
  14030. }
  14031. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14032. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14033. }
  14034. // 指定的文字
  14035. var targetTextDic = new Dictionary<string, List<string>>();
  14036. //创建数据源Table
  14037. var dtSource = new DataTable();
  14038. dtSource.Columns.Add("Days", typeof(string));
  14039. dtSource.Columns.Add("Date", typeof(string));
  14040. dtSource.Columns.Add("Week", typeof(string));
  14041. dtSource.Columns.Add("Traffic", typeof(string));
  14042. dtSource.Columns.Add("Trip", typeof(string));
  14043. //获取数据,放到datatable
  14044. foreach (var item in _travelList)
  14045. {
  14046. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14047. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14048. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14049. .Replace("[++]", string.Empty);
  14050. DataRow dr = dtSource.NewRow();
  14051. dr["Days"] = item.Days;
  14052. dr["Date"] = item.Date;
  14053. dr["Week"] = item.WeekDay;
  14054. dr["Traffic"] = item.Traffic_First
  14055. + "\r\n"
  14056. + item.Traffic_Second;
  14057. dr["Trip"] = item.Trip;
  14058. dtSource.Rows.Add(dr);
  14059. }
  14060. var dic = new Dictionary<string, string>
  14061. {
  14062. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14063. { "City", CityStr },
  14064. { "Days", Find.VisitDays.ToString() },
  14065. { "DeleCode", Find.TourCode },
  14066. { "Pnum", Find.VisitPNumber.ToString() }
  14067. };
  14068. //模板路径
  14069. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14070. //载入模板
  14071. Document doc = null;
  14072. DocumentBuilder builder = null;
  14073. try
  14074. {
  14075. //载入模板
  14076. doc = new Document(tempPath);
  14077. builder = new DocumentBuilder(doc);
  14078. }
  14079. catch (Exception)
  14080. {
  14081. jw.Msg = "模板位置不存在!";
  14082. return Ok(jw);
  14083. }
  14084. foreach (var key in dic.Keys)
  14085. {
  14086. Bookmark bookmark = doc.Range.Bookmarks[key];
  14087. if (bookmark != null)
  14088. {
  14089. builder.MoveToBookmark(key);
  14090. builder.Write(dic[key]);
  14091. }
  14092. }
  14093. //获取word里所有表格
  14094. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14095. //获取所填表格的序数
  14096. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14097. try
  14098. {
  14099. //循环赋值
  14100. for (int i = 0; i < dtSource.Rows.Count; i++)
  14101. {
  14102. builder.MoveToCell(0, i + 1, 0, 0);
  14103. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14104. builder.MoveToCell(0, i + 1, 1, 0);
  14105. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14106. builder.MoveToCell(0, i + 1, 2, 0);
  14107. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14108. var trip = dtSource.Rows[i]["Trip"].ToString();
  14109. builder.MoveToCell(0, i + 1, 3, 0);
  14110. builder.Write(trip);
  14111. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14112. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14113. // 获取特定索引的段落
  14114. Paragraph paragraph = (Paragraph)paragraphs[0];
  14115. Run run = paragraph.Runs[0];
  14116. Aspose.Words.Font font = run.Font;
  14117. font.Name = "黑体";
  14118. //设置双休红色
  14119. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14120. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14121. paragraph = (Paragraph)paragraphs[1];
  14122. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14123. {
  14124. run = paragraph.Runs[0];
  14125. font = run.Font;
  14126. font.Color = Color.Red;
  14127. }
  14128. }
  14129. }
  14130. catch (Exception ex)
  14131. {
  14132. }
  14133. //删除多余行
  14134. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14135. {
  14136. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14137. }
  14138. var targetTextList = new List<string>();
  14139. // 遍历文档中的表格
  14140. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14141. {
  14142. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14143. {
  14144. var cellIndex = 0;
  14145. foreach (Cell cell in row.Cells)
  14146. {
  14147. if (cellIndex == 1 && row.Cells.Count == 4)
  14148. {
  14149. foreach (var target in targetTextDic.Keys)
  14150. {
  14151. if (cell.GetText().Contains(target))
  14152. {
  14153. targetTextList = targetTextDic[target];
  14154. break;
  14155. }
  14156. }
  14157. }
  14158. // 遍历单元格中的所有段落
  14159. foreach (Paragraph paragraph in cell.Paragraphs)
  14160. {
  14161. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14162. var runs = new List<Run>();
  14163. foreach (Run run in paragraph.Runs)
  14164. {
  14165. runs.Add(run);
  14166. }
  14167. foreach (Run run in runs)
  14168. {
  14169. foreach (var targetText in targetTextList)
  14170. {
  14171. // 检查文字是否包含指定文字
  14172. if (run.Text.Contains(targetText))
  14173. {
  14174. // 将包含的部分设置为红色
  14175. HighlightText(run, targetText, Color.Red);
  14176. }
  14177. }
  14178. }
  14179. }
  14180. cellIndex++;
  14181. }
  14182. }
  14183. }
  14184. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14185. if (!Directory.Exists(savePath))
  14186. {
  14187. try
  14188. {
  14189. Directory.CreateDirectory(savePath);
  14190. }
  14191. catch
  14192. {
  14193. }
  14194. }
  14195. string path = savePath + Find.TeamName + "出访日程";
  14196. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14197. try
  14198. {
  14199. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14200. string postfix = ".docx";
  14201. if (dto.IsPDF == 1)
  14202. {
  14203. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14204. postfix = ".pdf";
  14205. }
  14206. doc.Save(path + postfix, saveFormat);
  14207. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14208. }
  14209. catch (Exception)
  14210. {
  14211. jw = JsonView(false);
  14212. }
  14213. return Ok(jw);
  14214. }
  14215. /// <summary>
  14216. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14217. /// </summary>
  14218. /// <param name="num"></param>
  14219. /// <returns></returns>
  14220. static string GetNum(string num)
  14221. {
  14222. string str = "";
  14223. switch (num)
  14224. {
  14225. case "1":
  14226. str = "一";
  14227. break;
  14228. case "2":
  14229. str = "二";
  14230. break;
  14231. case "3":
  14232. str = "三";
  14233. break;
  14234. case "4":
  14235. str = "四";
  14236. break;
  14237. case "5":
  14238. str = "五";
  14239. break;
  14240. case "6":
  14241. str = "六";
  14242. break;
  14243. case "7":
  14244. str = "七";
  14245. break;
  14246. case "8":
  14247. str = "八";
  14248. break;
  14249. case "9":
  14250. str = "九";
  14251. break;
  14252. case "10":
  14253. str = "十";
  14254. break;
  14255. case "11":
  14256. str = "十一";
  14257. break;
  14258. case "12":
  14259. str = "十二";
  14260. break;
  14261. case "一":
  14262. str = "1";
  14263. break;
  14264. case "二":
  14265. str = "2";
  14266. break;
  14267. case "三":
  14268. str = "3";
  14269. break;
  14270. case "四":
  14271. str = "4";
  14272. break;
  14273. case "五":
  14274. str = "5";
  14275. break;
  14276. case "六":
  14277. str = "6";
  14278. break;
  14279. case "七":
  14280. str = "7";
  14281. break;
  14282. case "八":
  14283. str = "8";
  14284. break;
  14285. case "九":
  14286. str = "9";
  14287. break;
  14288. case "十":
  14289. str = "10";
  14290. break;
  14291. case "十一":
  14292. str = "11";
  14293. break;
  14294. case "十二":
  14295. str = "12";
  14296. break;
  14297. }
  14298. return str;
  14299. }
  14300. /// <summary>
  14301. /// 高亮包含指定文字的部分
  14302. /// </summary>
  14303. /// <param name="run"></param>
  14304. /// <param name="targetText"></param>
  14305. /// <param name="color"></param>
  14306. static void HighlightText(Run run, string targetText, Color color)
  14307. {
  14308. string text = run.Text;
  14309. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14310. if (startIndex >= 0)
  14311. {
  14312. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14313. // 前部分
  14314. if (startIndex > 0)
  14315. {
  14316. Run beforeRun = (Run)run.Clone(true);
  14317. beforeRun.Text = text.Substring(0, startIndex);
  14318. parentParagraph.InsertBefore(beforeRun, run);
  14319. }
  14320. // 匹配部分
  14321. Run matchRun = (Run)run.Clone(true);
  14322. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14323. matchRun.Font.Color = color;
  14324. parentParagraph.InsertBefore(matchRun, run);
  14325. // 后部分
  14326. if (startIndex + targetText.Length < text.Length)
  14327. {
  14328. Run afterRun = (Run)run.Clone(true);
  14329. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14330. parentParagraph.InsertBefore(afterRun, run);
  14331. }
  14332. // 删除原始Run
  14333. run.Remove();
  14334. }
  14335. }
  14336. #endregion
  14337. #endregion
  14338. #region 团组成本
  14339. /// <summary>
  14340. /// 团组成本数据初始化
  14341. /// </summary>
  14342. /// <param name="dto"></param>
  14343. /// <returns></returns>
  14344. [HttpPost]
  14345. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14346. {
  14347. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14348. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14349. WHEN COUNT(*) >= 0 THEN 'True'
  14350. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14351. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14352. ").ToList(); //团组列表
  14353. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14354. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14355. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14356. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14357. if (groupinfoValue != null)
  14358. {
  14359. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14360. var spArr = new string[1] { countryArr };
  14361. if (countryArr.Contains("|"))
  14362. {
  14363. spArr = countryArr.Split("|");
  14364. }
  14365. else if (countryArr.Contains("、"))
  14366. {
  14367. spArr = countryArr.Split("、");
  14368. }
  14369. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14370. {
  14371. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14372. if (dbQueryCountry != null)
  14373. {
  14374. visaCountryInfoArr.Add(dbQueryCountry);
  14375. }
  14376. }
  14377. }
  14378. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14379. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14380. #region 屏蔽黑屏代码生成
  14381. //var create = _GroupCostRepository.
  14382. // CreateGroupCostByBlackCode(dto.Diid);
  14383. //if (groupCost.Count == 0 && create.Code == 0)
  14384. //{
  14385. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14386. //}
  14387. #endregion
  14388. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14389. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14390. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14391. groupCostMap = groupCostMap.Select(x =>
  14392. {
  14393. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14394. {
  14395. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14396. }
  14397. return x;
  14398. }).ToList();
  14399. //GroupCostParameter.Add(new
  14400. // Grp_GroupCostParameter());
  14401. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14402. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14403. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14404. return Ok(JsonView(new
  14405. {
  14406. groupList,
  14407. groupInfo,
  14408. groupChecks,
  14409. groupCost = groupCostMap,
  14410. hotelNumber,
  14411. GroupCostParameter = GroupCostParameterMap,
  14412. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14413. {
  14414. x.VisaCountry,
  14415. x.VisaPrice,
  14416. x.Id,
  14417. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14418. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14419. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14420. x.VisaTime, // 一般签证时间
  14421. x.PettyBusinessAgencyFee, //小公务代办费
  14422. x.GrandBusinessAgencyFee //大公务代办费
  14423. }).ToList(),
  14424. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14425. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14426. hotelIsTrue,
  14427. groupModuleOperators
  14428. }));
  14429. }
  14430. /// <summary>
  14431. /// 团组成本信息保存
  14432. /// </summary>
  14433. /// <param name="dto"></param>
  14434. /// <returns></returns>
  14435. [HttpPost]
  14436. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14437. {
  14438. if (dto.Diid <= 0 || dto.Userid <= 0)
  14439. {
  14440. return Ok(JsonView(false));
  14441. }
  14442. JsonView jw = null;
  14443. bool isTrue = false;
  14444. #region 复制团组成本
  14445. //if (dto.Diid == 2581)
  14446. //{
  14447. // dto.Diid = 2599;
  14448. // dto.CheckBoxs.ForEach(x =>
  14449. // {
  14450. // x.Diid = 2599;
  14451. // });
  14452. // dto.GroupCosts.ForEach(x =>
  14453. // {
  14454. // x.Diid = 2599;
  14455. // });
  14456. // dto.CostTypeHotelNumbers.ForEach(x =>
  14457. // {
  14458. // x.Diid = 2599;
  14459. // });
  14460. // dto.GroupCostParameters.ForEach(x =>
  14461. // {
  14462. // x.DiId = 2599;
  14463. // });
  14464. //}
  14465. #endregion
  14466. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14467. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14468. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14469. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14470. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14471. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14472. try
  14473. {
  14474. _sqlSugar.BeginTran();
  14475. isTrue = await _GroupCostRepository.
  14476. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14477. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14478. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14479. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14480. _sqlSugar.CommitTran();
  14481. jw = JsonView(true, "保存成功!", isTrue);
  14482. }
  14483. catch (Exception)
  14484. {
  14485. _sqlSugar.RollbackTran();
  14486. jw = JsonView(false);
  14487. }
  14488. return Ok(jw);
  14489. }
  14490. /// <summary>
  14491. /// 复制团组成本信息
  14492. /// </summary>
  14493. /// <param name="dto"></param>
  14494. /// <returns></returns>
  14495. [HttpPost]
  14496. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14497. {
  14498. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14499. {
  14500. return Ok(JsonView(false, "参数有误!"));
  14501. }
  14502. #region 复制团组成本
  14503. dto.Diid = dto.ToGroupId;
  14504. dto.CheckBoxs.ForEach(x =>
  14505. {
  14506. x.Diid = dto.ToGroupId;
  14507. });
  14508. dto.GroupCosts.ForEach(x =>
  14509. {
  14510. x.Diid = dto.ToGroupId;
  14511. });
  14512. dto.CostTypeHotelNumbers.ForEach(x =>
  14513. {
  14514. x.Diid = dto.ToGroupId;
  14515. });
  14516. dto.GroupCostParameters.ForEach(x =>
  14517. {
  14518. x.DiId = dto.ToGroupId;
  14519. });
  14520. #endregion
  14521. JsonView jw = null;
  14522. bool isTrue = false;
  14523. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14524. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14525. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14526. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14527. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14528. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14529. try
  14530. {
  14531. _sqlSugar.BeginTran();
  14532. isTrue = await _GroupCostRepository.
  14533. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14534. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14535. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14536. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14537. _sqlSugar.CommitTran();
  14538. jw = JsonView(true, "保存成功!", isTrue);
  14539. }
  14540. catch (Exception)
  14541. {
  14542. _sqlSugar.RollbackTran();
  14543. jw = JsonView(false);
  14544. }
  14545. return Ok(jw);
  14546. }
  14547. /// <summary>
  14548. /// 司兼导数据
  14549. /// </summary>
  14550. /// <param name="dto"></param>
  14551. /// <returns></returns>
  14552. [HttpPost]
  14553. public IActionResult GetCarGuides(CarGuidesDto dto)
  14554. {
  14555. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14556. return Ok(JsonView(true, "获取成功!", Data));
  14557. }
  14558. /// <summary>
  14559. /// 导游数据
  14560. /// </summary>
  14561. /// <param name="dto"></param>
  14562. /// <returns></returns>
  14563. [HttpPost]
  14564. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14565. {
  14566. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14567. // 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
  14568. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14569. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14570. return Ok(JsonView(true, "获取成功!", Data));
  14571. }
  14572. /// <summary>
  14573. /// 成本车数据
  14574. /// </summary>
  14575. /// <param name="dto"></param>
  14576. /// <returns></returns>
  14577. [HttpPost]
  14578. public IActionResult GetCarInfo(CarGuidesDto dto)
  14579. {
  14580. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14581. return Ok(JsonView(true, "获取成功!", Data));
  14582. }
  14583. /// <summary>
  14584. /// 景点数据
  14585. /// </summary>
  14586. /// <param name="dto"></param>
  14587. /// <returns></returns>
  14588. [HttpPost]
  14589. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14590. {
  14591. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14592. return Ok(JsonView(true, "获取成功!", Data));
  14593. }
  14594. /// <summary>
  14595. /// 成本通知
  14596. /// </summary>
  14597. /// <param name="dto"></param>
  14598. /// <returns></returns>
  14599. [HttpPost]
  14600. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14601. {
  14602. if (dto.Diid < 0)
  14603. {
  14604. return Ok(JsonView(false));
  14605. }
  14606. JsonView jw;
  14607. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14608. if (GroupCostParameter != null)
  14609. {
  14610. int IsShare = 0;
  14611. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14612. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14613. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14614. string msg = string.Empty;
  14615. if (isTrue)
  14616. {
  14617. if (IsShare == 0)
  14618. {
  14619. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14620. }
  14621. else
  14622. {
  14623. #region 企微通知对应岗位用户
  14624. try
  14625. {
  14626. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14627. }
  14628. catch (Exception)
  14629. {
  14630. }
  14631. #endregion
  14632. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14633. }
  14634. jw = JsonView(isTrue, msg, new { IsShare });
  14635. }
  14636. else
  14637. {
  14638. msg = "修改失败!";
  14639. jw = JsonView(isTrue, msg);
  14640. }
  14641. }
  14642. else
  14643. {
  14644. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14645. }
  14646. return Ok(jw);
  14647. }
  14648. /// <summary>
  14649. /// 导出报价单
  14650. /// </summary>
  14651. /// <param name="dto"></param>
  14652. /// <returns></returns>
  14653. [HttpPost]
  14654. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14655. {
  14656. if (dto.Diid == 0)
  14657. {
  14658. return Ok(JsonView(false, "请传递团组id"));
  14659. }
  14660. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14661. if (deleInfo.Code != 0)
  14662. {
  14663. return Ok(JsonView(false, "团组信息查询失败!"));
  14664. }
  14665. var di = deleInfo.Data as DelegationInfoWebView;
  14666. if (di != null)
  14667. {
  14668. di.TeamName = di.TeamName.Replace("|", "、");
  14669. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14670. //文件名
  14671. string strFileName = di.TeamName + "-收款账单.doc";
  14672. //获取模板
  14673. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14674. //载入模板
  14675. Document doc = new Document(tmppath);
  14676. decimal TotalPrice = 0.00M;
  14677. string itemStr = string.Empty;
  14678. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14679. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14680. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14681. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14682. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14683. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14684. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14685. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14686. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14687. foreach (var cost in groupCostType)
  14688. {
  14689. var List = cost.ToList();
  14690. if (cost.Key == "A")
  14691. {
  14692. foreach (var ListItem in List)
  14693. {
  14694. if (ListItem.number > 0)
  14695. {
  14696. if (ListItem.code.Contains("TBR"))
  14697. {
  14698. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14699. }
  14700. else
  14701. {
  14702. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14703. }
  14704. TotalPrice += (ListItem.number * ListItem.price);
  14705. }
  14706. }
  14707. }
  14708. else
  14709. {
  14710. itemStr = itemStr.Insert(0, "A段\r\n");
  14711. itemStr += "B段\r\n";
  14712. foreach (var ListItem in List)
  14713. {
  14714. if (ListItem.number > 0)
  14715. {
  14716. if (ListItem.code.Contains("TBR"))
  14717. {
  14718. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14719. }
  14720. else
  14721. {
  14722. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14723. }
  14724. TotalPrice += (ListItem.number * ListItem.price);
  14725. }
  14726. }
  14727. }
  14728. }
  14729. #region 替换Word模板书签内容
  14730. Dictionary<string, string> marks = new Dictionary<string, string>();
  14731. marks.Add("To", di.ClientUnit);//付款方
  14732. marks.Add("ToTel", di.TellPhone);//付款方电话
  14733. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14734. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14735. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14736. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14737. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14738. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14739. marks.Add("PayItemContent", itemStr);//详细信息
  14740. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14741. #endregion
  14742. ////注
  14743. //if (doc.Range.Bookmarks["Attention"] != null)
  14744. //{
  14745. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14746. // mark.Text = frList[0].Attention;
  14747. //}
  14748. foreach (var item in marks.Keys)
  14749. {
  14750. if (doc.Range.Bookmarks[item] != null)
  14751. {
  14752. Bookmark mark = doc.Range.Bookmarks[item];
  14753. mark.Text = marks[item];
  14754. }
  14755. }
  14756. byte[] bytes = null;
  14757. using (MemoryStream stream = new MemoryStream())
  14758. {
  14759. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14760. bytes = stream.ToArray();
  14761. }
  14762. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14763. return Ok(JsonView(true, "", new
  14764. {
  14765. Data = bytes,
  14766. strFileName,
  14767. }));
  14768. }
  14769. else
  14770. {
  14771. return Ok(JsonView(false, "团组信息不存在!"));
  14772. }
  14773. }
  14774. /// <summary>
  14775. /// 导出团组成本
  14776. /// </summary>
  14777. /// <param name="dto"></param>
  14778. /// <returns></returns>
  14779. [HttpPost]
  14780. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14781. {
  14782. var jw = JsonView(false);
  14783. if (dto.Diid == 0)
  14784. {
  14785. return Ok(JsonView(false, "请传递团组id"));
  14786. }
  14787. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14788. if (deleInfo.Code != 0)
  14789. {
  14790. return Ok(JsonView(false, "团组信息查询失败!"));
  14791. }
  14792. var di = deleInfo.Data as DelegationInfoWebView;
  14793. if (di == null)
  14794. {
  14795. return Ok(JsonView(false, "团组信息查询失败!"));
  14796. }
  14797. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14798. WorkbookDesigner designer = new WorkbookDesigner();
  14799. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14800. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14801. List<int> hideColumnList = new List<int>();
  14802. var ColumnSetting = new[]
  14803. {
  14804. new { tag = "VF", Index = 4, P = "CarCost" },
  14805. new { tag = "VN", Index = 5, P = "CarNumber" },
  14806. new { tag = "VRD", Index = 6, P = "CarTiming" },
  14807. new { tag = "T/G S", Index = 7, P = "TGS" },
  14808. new { tag = "TGWH", Index = 8, P = "TGWH" },
  14809. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  14810. new { tag = "T/G M", Index = 10, P = "TGM" },
  14811. new { tag = "T/G A", Index = 11, P = "TGA" },
  14812. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  14813. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  14814. new { tag = "C/F S", Index = 14, P = "CFS" },
  14815. new { tag = "C/F M", Index = 15, P = "CFM" },
  14816. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  14817. new { tag = "B", Index = 17, P = "B" },
  14818. new { tag = "L", Index = 18, P = "L" },
  14819. new { tag = "D", Index = 19, P = "D" },
  14820. new { tag = "TBR", Index = 20, P = "TBR" },
  14821. new { tag = "SGR", Index = 21, P = "SGR" },
  14822. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  14823. new { tag = "Suite", Index = 23, P = "Suite" },
  14824. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  14825. new { tag = "T/V", Index = 25, P = "TV" },
  14826. new { tag = "1/L", Index = 26, P = "iL" },
  14827. new { tag = "I/F", Index = 27, P = "IF" },
  14828. new { tag = "EF", Index = 28, P = "EF" },
  14829. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  14830. new { tag = "TE", Index = 30, P = "TE" },
  14831. new { tag = "T/G T", Index = 31, P = "TGTips" },
  14832. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  14833. new { tag = "P/C", Index = 33, P = "PC" },
  14834. new { tag = "T/L F", Index = 34, P = "TLF" },
  14835. new { tag = "E/C T", Index = 35, P = "ECT" }
  14836. };
  14837. Func<string, bool> isEmpty = (str) =>
  14838. {
  14839. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  14840. {
  14841. return true;
  14842. }
  14843. if (string.IsNullOrWhiteSpace(str))
  14844. {
  14845. return true;
  14846. }
  14847. return false;
  14848. };
  14849. for (int i = 0; i < List_GC.Count; i++)
  14850. {
  14851. GroupCost_Excel gc = new GroupCost_Excel();
  14852. gc.Id = List_GC[i].Id;
  14853. gc.Diid = List_GC[i].Diid.ToString();
  14854. gc.DAY = List_GC[i].DAY;
  14855. string week = "";
  14856. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14857. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14858. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14859. gc.ITIN = List_GC[i].ITIN;
  14860. gc.CarType = List_GC[i].CarType;
  14861. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  14862. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  14863. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  14864. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  14865. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  14866. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  14867. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  14868. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  14869. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  14870. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  14871. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  14872. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  14873. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  14874. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  14875. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  14876. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  14877. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  14878. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  14879. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  14880. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  14881. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  14882. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  14883. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  14884. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  14885. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  14886. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  14887. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  14888. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  14889. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  14890. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  14891. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  14892. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  14893. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  14894. gc.EFR = List_GC[i].EFR;
  14895. List_GC1.Add(gc);
  14896. }
  14897. if (List_GC1.Count > 0)
  14898. {
  14899. var p = List_GC1[0];
  14900. var prs = p.GetType().GetProperties();
  14901. foreach (var item in prs)
  14902. {
  14903. var tp = item.PropertyType;
  14904. if (tp == typeof(int))
  14905. {
  14906. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  14907. if (val == 0)
  14908. {
  14909. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14910. if (columnSetting != null)
  14911. {
  14912. hideColumnList.Add(columnSetting.Index);
  14913. }
  14914. }
  14915. }
  14916. if (tp == typeof(decimal))
  14917. {
  14918. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  14919. if (val == 0)
  14920. {
  14921. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14922. if (columnSetting != null)
  14923. {
  14924. hideColumnList.Add(columnSetting.Index);
  14925. }
  14926. }
  14927. }
  14928. if (tp == typeof(string))
  14929. {
  14930. var val = List_GC1.Sum(x =>
  14931. {
  14932. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  14933. if (decimal.TryParse(str, out decimal str_De))
  14934. {
  14935. return str_De;
  14936. }
  14937. else
  14938. {
  14939. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  14940. }
  14941. });
  14942. if (val == 0)
  14943. {
  14944. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14945. if (columnSetting != null)
  14946. {
  14947. hideColumnList.Add(columnSetting.Index);
  14948. }
  14949. }
  14950. }
  14951. }
  14952. }
  14953. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14954. dt.TableName = "TB";
  14955. //报表标题等不用dt的值
  14956. designer.SetDataSource("TeamName", dto.title.TeamName);
  14957. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14958. designer.SetDataSource("Tax", dto.title.Tax);
  14959. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14960. designer.SetDataSource("Currency", dto.title.Currency);
  14961. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14962. designer.SetDataSource("Rate", dto.title.Rate);
  14963. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14964. var Aparams = hotels.Find(x => x.Type == "Default");
  14965. if (Aparams == null)
  14966. {
  14967. return Ok(jw);
  14968. }
  14969. //酒店数量
  14970. var txtSGRNumber = Aparams.SGR.ToString();
  14971. var txtTBRNumber = Aparams.TBR.ToString();
  14972. var txtJSESNumber = Aparams.JSES.ToString();
  14973. var txtSUITENumbe = Aparams.SUITE.ToString();
  14974. if (dto.costType == "B")
  14975. {
  14976. Aparams = hotels.Find(x => x.Type == "A");
  14977. var Bparams = hotels.Find(x => x.Type == "B");
  14978. if (Aparams == null || Bparams == null)
  14979. {
  14980. return Ok(jw);
  14981. }
  14982. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14983. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14984. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14985. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14986. }
  14987. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14988. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14989. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14990. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14991. var ws = designer.Workbook.Worksheets[1];
  14992. int Row = List_GC.Count;
  14993. int startIndex = 0;
  14994. int HideRows = 0;
  14995. Row = 0;
  14996. List<int> hideRowsList = new List<int>();
  14997. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14998. #region A段left数据
  14999. var left = dto.leftInfo.Find(x => x.Type == "A");
  15000. if (left == null)
  15001. {
  15002. return Ok(jw);
  15003. }
  15004. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15005. if (leftBindData != null)
  15006. {
  15007. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15008. designer.SetDataSource("VisaRS", leftBindData.rs);
  15009. designer.SetDataSource("VisaXS", leftBindData.xs);
  15010. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15011. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15012. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15013. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15014. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15015. }
  15016. else
  15017. {
  15018. hideRowsList.Add(Row + startIndex + HideRows);
  15019. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15020. }
  15021. HideRows += 2;
  15022. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  15023. if (leftBindData != null)
  15024. {
  15025. designer.SetDataSource("BXDRCB", leftBindData.cb);
  15026. designer.SetDataSource("BXRS", leftBindData.rs);
  15027. designer.SetDataSource("BXXS", leftBindData.xs);
  15028. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15029. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15030. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15031. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15032. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15033. }
  15034. else
  15035. {
  15036. hideRowsList.Add(Row + startIndex + HideRows);
  15037. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15038. }
  15039. HideRows += 2;
  15040. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15041. if (leftBindData != null)
  15042. {
  15043. designer.SetDataSource("HSDRCB", leftBindData.cb);
  15044. designer.SetDataSource("HSRS", leftBindData.rs);
  15045. designer.SetDataSource("HSXS", leftBindData.xs);
  15046. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15047. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15048. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15049. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15050. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15051. }
  15052. else
  15053. {
  15054. hideRowsList.Add(Row + startIndex + HideRows);
  15055. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15056. }
  15057. HideRows += 2;
  15058. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15059. if (leftBindData != null)
  15060. {
  15061. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  15062. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15063. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15064. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15065. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15066. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15067. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15068. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15069. }
  15070. else
  15071. {
  15072. hideRowsList.Add(Row + startIndex + HideRows);
  15073. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15074. }
  15075. HideRows += 2;
  15076. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15077. if (leftBindData != null)
  15078. {
  15079. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  15080. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15081. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15082. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15083. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15084. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15085. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15086. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15087. }
  15088. else
  15089. {
  15090. hideRowsList.Add(Row + startIndex + HideRows);
  15091. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15092. }
  15093. HideRows += 2;
  15094. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15095. if (leftBindData != null)
  15096. {
  15097. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15098. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15099. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15100. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15101. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15102. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15103. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15104. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15105. }
  15106. else
  15107. {
  15108. hideRowsList.Add(Row + startIndex + HideRows);
  15109. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15110. }
  15111. HideRows += 2;
  15112. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15113. if (leftBindData != null)
  15114. {
  15115. ////TBR
  15116. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15117. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15118. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15119. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15120. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15121. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15122. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15123. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15124. }
  15125. else
  15126. {
  15127. hideRowsList.Add(Row + startIndex + HideRows);
  15128. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15129. }
  15130. HideRows += 2;
  15131. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15132. if (leftBindData != null)
  15133. {
  15134. ////SGR
  15135. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  15136. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  15137. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  15138. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15139. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15140. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15141. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15142. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15143. }
  15144. else
  15145. {
  15146. hideRowsList.Add(Row + startIndex + HideRows);
  15147. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15148. }
  15149. HideRows += 2;
  15150. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15151. if (leftBindData != null)
  15152. {
  15153. ////JS/ES
  15154. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15155. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15156. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15157. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15158. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15159. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15160. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15161. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15162. }
  15163. else
  15164. {
  15165. hideRowsList.Add(Row + startIndex + HideRows);
  15166. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15167. }
  15168. HideRows += 2;
  15169. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15170. if (leftBindData != null)
  15171. {
  15172. ////SUITE
  15173. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15174. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15175. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15176. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15177. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15178. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15179. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15180. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15181. }
  15182. else
  15183. {
  15184. hideRowsList.Add(Row + startIndex + HideRows);
  15185. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15186. }
  15187. HideRows += 2;
  15188. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15189. if (leftBindData != null)
  15190. {
  15191. designer.SetDataSource("DJDRCB", leftBindData.cb);
  15192. designer.SetDataSource("DJRS", leftBindData.rs);
  15193. designer.SetDataSource("DJXS", leftBindData.xs);
  15194. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15195. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15196. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15197. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15198. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15199. }
  15200. else
  15201. {
  15202. hideRowsList.Add(Row + startIndex + HideRows);
  15203. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15204. }
  15205. HideRows += 2;
  15206. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15207. if (leftBindData != null)
  15208. {
  15209. designer.SetDataSource("HCPCB", leftBindData.cb);
  15210. designer.SetDataSource("HCPRS", leftBindData.rs);
  15211. designer.SetDataSource("HCPXS", leftBindData.xs);
  15212. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15213. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15214. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15215. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15216. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15217. }
  15218. else
  15219. {
  15220. hideRowsList.Add(Row + startIndex + HideRows);
  15221. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15222. }
  15223. HideRows += 2;
  15224. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15225. if (leftBindData != null)
  15226. {
  15227. designer.SetDataSource("CPCB", leftBindData.cb);
  15228. designer.SetDataSource("CPRS", leftBindData.rs);
  15229. designer.SetDataSource("CPXS", leftBindData.xs);
  15230. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15231. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15232. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15233. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15234. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15235. }
  15236. else
  15237. {
  15238. hideRowsList.Add(Row + startIndex + HideRows);
  15239. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15240. }
  15241. HideRows += 2;
  15242. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15243. if (leftBindData != null)
  15244. {
  15245. designer.SetDataSource("GWDRCD", leftBindData.cb);
  15246. designer.SetDataSource("GWRS", leftBindData.rs);
  15247. designer.SetDataSource("GWXS", leftBindData.xs);
  15248. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15249. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15250. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15251. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15252. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15253. }
  15254. else
  15255. {
  15256. hideRowsList.Add(Row + startIndex + HideRows);
  15257. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15258. }
  15259. HideRows += 2;
  15260. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15261. if (leftBindData != null)
  15262. {
  15263. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15264. designer.SetDataSource("LYJRS", leftBindData.rs);
  15265. designer.SetDataSource("LYJXS", leftBindData.xs);
  15266. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15267. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15268. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15269. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15270. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15271. }
  15272. else
  15273. {
  15274. hideRowsList.Add(Row + startIndex + HideRows);
  15275. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15276. }
  15277. #endregion
  15278. #region A段Right信息
  15279. var right = dto.rightInfo.Find(x => x.Type == "A");
  15280. if (right == null)
  15281. {
  15282. return Ok(jw);
  15283. }
  15284. HideRows += 4;
  15285. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15286. if (rightBindData != null)
  15287. {
  15288. //经济舱 + 双人间 TBR
  15289. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15290. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15291. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15292. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15293. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15294. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15295. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15296. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15297. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15298. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15299. }
  15300. else
  15301. {
  15302. hideRowsList.Add(Row + startIndex + HideRows);
  15303. }
  15304. HideRows += 2;
  15305. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15306. if (rightBindData != null)
  15307. {
  15308. //经济舱 + 单人间 SGR
  15309. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15310. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15311. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15312. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15313. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15314. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15315. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15316. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15317. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15318. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15319. }
  15320. else
  15321. {
  15322. hideRowsList.Add(Row + startIndex + HideRows);
  15323. }
  15324. HideRows += 2;
  15325. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15326. if (rightBindData != null)
  15327. {
  15328. //公务舱 + 单人间 SGR
  15329. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15330. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15331. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15332. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15333. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15334. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15335. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15336. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15337. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15338. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15339. }
  15340. else
  15341. {
  15342. hideRowsList.Add(Row + startIndex + HideRows);
  15343. }
  15344. HideRows += 2;
  15345. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15346. if (rightBindData != null)
  15347. {
  15348. //公务舱 + 小套房 JSES
  15349. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15350. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15351. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15352. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15353. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15354. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15355. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15356. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15357. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15358. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15359. }
  15360. else
  15361. {
  15362. hideRowsList.Add(Row + startIndex + HideRows);
  15363. }
  15364. HideRows += 2;
  15365. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15366. if (rightBindData != null)
  15367. {
  15368. //公务舱 + 小套房 JSES
  15369. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15370. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15371. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15372. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15373. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15374. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15375. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15376. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15377. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15378. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15379. }
  15380. else
  15381. {
  15382. hideRowsList.Add(Row + startIndex + HideRows);
  15383. }
  15384. HideRows += 2;
  15385. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15386. if (rightBindData != null)
  15387. {
  15388. //经济舱 + 大套房
  15389. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15390. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15391. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15392. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15393. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15394. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15395. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15396. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15397. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15398. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15399. }
  15400. else
  15401. {
  15402. hideRowsList.Add(Row + startIndex + HideRows);
  15403. }
  15404. HideRows += 2;
  15405. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15406. if (rightBindData != null)
  15407. {
  15408. //头等舱 + 小套房 JSES
  15409. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15410. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15411. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15412. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15413. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15414. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15415. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15416. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15417. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15418. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15419. }
  15420. else
  15421. {
  15422. hideRowsList.Add(Row + startIndex + HideRows);
  15423. }
  15424. HideRows += 2;
  15425. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15426. if (rightBindData != null)
  15427. {
  15428. //头等舱 + 大套房
  15429. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15430. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15431. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15432. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15433. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15434. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15435. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15436. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15437. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15438. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15439. }
  15440. else
  15441. {
  15442. hideRowsList.Add(Row + startIndex + HideRows);
  15443. }
  15444. #endregion
  15445. #region B段标题清空
  15446. designer.SetDataSource("CostBDRCB", "");
  15447. designer.SetDataSource("CostBRS", "");
  15448. designer.SetDataSource("CostBXS", "");
  15449. designer.SetDataSource("CostBZCB", "");
  15450. designer.SetDataSource("CostBDRBJ", "");
  15451. designer.SetDataSource("CostBZBJ", "");
  15452. designer.SetDataSource("CostBDRLR", "");
  15453. designer.SetDataSource("CostBZLR", "");
  15454. designer.SetDataSource("CostBDRCBOM", "");
  15455. designer.SetDataSource("CostBRSOM", "");
  15456. designer.SetDataSource("CostBZCBOM", "");
  15457. designer.SetDataSource("CostBDRBJOM", "");
  15458. designer.SetDataSource("CostBZBJOM", "");
  15459. designer.SetDataSource("CostBDRLROM", "");
  15460. designer.SetDataSource("CostBZLROM", "");
  15461. #endregion
  15462. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15463. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15464. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15465. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15466. designer.SetDataSource("DJName", "地接(CNY)");
  15467. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15468. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15469. designer.SetDataSource("GWName", "公务(CNY)");
  15470. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15471. designer.SetDataSource("LYJName", "零用金(CNY)");
  15472. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15473. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15474. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15475. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15476. designer.SetDataSource("BXName", "保险(CNY)");
  15477. designer.SetDataSource("VisaName", "签证(CNY)");
  15478. #region B段基本数据
  15479. if (dto.costType == "B")
  15480. {
  15481. left = dto.leftInfo.Find(x => x.Type == "B");
  15482. if (left == null)
  15483. {
  15484. return Ok(jw);
  15485. }
  15486. #region B段left数据
  15487. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15488. if (leftBindData != null)
  15489. {
  15490. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15491. designer.SetDataSource("BHSRS", leftBindData.rs);
  15492. designer.SetDataSource("BHSXS", leftBindData.xs);
  15493. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15494. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15495. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15496. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15497. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15498. }
  15499. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15500. if (leftBindData != null)
  15501. {
  15502. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15503. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15504. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15505. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15506. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15507. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15508. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15509. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15510. }
  15511. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15512. if (leftBindData != null)
  15513. {
  15514. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15515. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15516. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15517. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15518. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15519. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15520. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15521. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15522. }
  15523. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15524. if (leftBindData != null)
  15525. {
  15526. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15527. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15528. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15529. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15530. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15531. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15532. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15533. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15534. }
  15535. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15536. if (leftBindData != null)
  15537. {
  15538. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15539. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15540. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15541. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15542. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15543. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15544. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15545. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15546. }
  15547. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15548. if (leftBindData != null)
  15549. {
  15550. designer.SetDataSource("BCPCB", leftBindData.cb);
  15551. designer.SetDataSource("BCPRS", leftBindData.rs);
  15552. designer.SetDataSource("BCPXS", leftBindData.xs);
  15553. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15554. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15555. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15556. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15557. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15558. }
  15559. //TBR
  15560. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15561. if (leftBindData != null)
  15562. {
  15563. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15564. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15565. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15566. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15567. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15568. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15569. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15570. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15571. }
  15572. //SGR
  15573. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15574. if (leftBindData != null)
  15575. {
  15576. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15577. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15578. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15579. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15580. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15581. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15582. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15583. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15584. }
  15585. //JS/ES
  15586. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15587. if (leftBindData != null)
  15588. {
  15589. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15590. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15591. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15592. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15593. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15594. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15595. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15596. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15597. }
  15598. //SUITE
  15599. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15600. if (leftBindData != null)
  15601. {
  15602. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15603. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15604. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15605. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15606. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15607. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15608. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15609. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15610. }
  15611. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15612. if (leftBindData != null)
  15613. {
  15614. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15615. designer.SetDataSource("BDJRS", leftBindData.rs);
  15616. designer.SetDataSource("BDJXS", leftBindData.xs);
  15617. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15618. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15619. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15620. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15621. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15622. }
  15623. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15624. if (leftBindData != null)
  15625. {
  15626. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15627. designer.SetDataSource("BGWRS", leftBindData.rs);
  15628. designer.SetDataSource("BGWXS", leftBindData.xs);
  15629. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15630. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15631. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15632. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15633. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15634. }
  15635. #region 优化方案
  15636. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15637. //excelBind.Add("零用金", new {
  15638. //cb="",
  15639. //rs="",
  15640. //xs ="",
  15641. //zcb = "",
  15642. //});
  15643. #endregion
  15644. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15645. if (leftBindData != null)
  15646. {
  15647. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15648. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15649. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15650. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15651. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15652. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15653. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15654. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15655. }
  15656. #endregion
  15657. #region B段Right信息
  15658. right = dto.rightInfo.Find(x => x.Type == "B");
  15659. if (right == null)
  15660. {
  15661. return Ok(jw);
  15662. }
  15663. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15664. if (rightBindData != null)
  15665. {
  15666. //经济舱 + 双人间 TBR
  15667. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15668. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15669. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15670. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15671. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15672. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15673. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15674. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15675. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15676. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15677. }
  15678. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15679. if (rightBindData != null)
  15680. {
  15681. //经济舱 + 单人间 SGR
  15682. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15683. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15684. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15685. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15686. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15687. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15688. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15689. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15690. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15691. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15692. }
  15693. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15694. if (rightBindData != null)
  15695. {
  15696. //公务舱 + 单人间 SGR
  15697. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15698. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15699. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15700. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15701. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15702. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15703. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15704. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15705. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15706. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15707. }
  15708. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15709. if (rightBindData != null)
  15710. {
  15711. //公务舱 + 小套房 JSES
  15712. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15713. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15714. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15715. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15716. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15717. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15718. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15719. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15720. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15721. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15722. }
  15723. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15724. if (rightBindData != null)
  15725. {
  15726. //公务舱 + 小套房 JSES
  15727. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15728. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15729. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15730. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15731. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15732. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15733. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15734. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15735. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15736. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15737. }
  15738. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15739. if (rightBindData != null)
  15740. {
  15741. //经济舱 + 大套房
  15742. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15743. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15744. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15745. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15746. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15747. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15748. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15749. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15750. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15751. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15752. }
  15753. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15754. if (rightBindData != null)
  15755. {
  15756. //头等舱 + 小套房 JSES
  15757. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15758. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15759. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15760. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15761. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15762. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15763. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15764. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15765. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15766. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15767. }
  15768. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15769. if (rightBindData != null)
  15770. {
  15771. //头等舱 + 大套房
  15772. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15773. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15774. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15775. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15776. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15777. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15778. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15779. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15780. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15781. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15782. }
  15783. #endregion
  15784. #region 标题
  15785. designer.SetDataSource("CostBDRCB", "单人成本");
  15786. designer.SetDataSource("CostBRS", "人数");
  15787. designer.SetDataSource("CostBXS", "系数");
  15788. designer.SetDataSource("CostBZCB", "总成本");
  15789. designer.SetDataSource("CostBDRBJ", "单人报价");
  15790. designer.SetDataSource("CostBZBJ", "总报价");
  15791. designer.SetDataSource("CostBDRLR", "单人利润");
  15792. designer.SetDataSource("CostBZLR", "总利润");
  15793. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15794. designer.SetDataSource("CostBRSOM", "人数");
  15795. designer.SetDataSource("CostBZCBOM", "总成本");
  15796. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15797. designer.SetDataSource("CostBZBJOM", "总报价");
  15798. designer.SetDataSource("CostBDRLROM", "单人利润");
  15799. designer.SetDataSource("CostBZLROM", "总利润");
  15800. #endregion
  15801. }
  15802. #endregion
  15803. designer.SetDataSource("TzZCB2", TzZCB2);
  15804. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15805. designer.SetDataSource("TzZLR2", TzZLR2);
  15806. string[] dataSourceKeys = new string[]
  15807. {
  15808. "VF",
  15809. "TGS",
  15810. "TGOF",
  15811. "TGM",
  15812. "TGA",
  15813. "TGTF",
  15814. "TGEF",
  15815. "CFM",
  15816. "CFOF",
  15817. "B",
  15818. "L",
  15819. "D",
  15820. "TBR",
  15821. "SGR",
  15822. "JSES",
  15823. "Suite",
  15824. "TV",
  15825. "1L",
  15826. "IF",
  15827. "EF",
  15828. "BRF",
  15829. "TE",
  15830. "TGT",
  15831. "DRVT",
  15832. "PC",
  15833. "TLF",
  15834. "ECT"
  15835. };
  15836. foreach (var item in dataSourceKeys)
  15837. {
  15838. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  15839. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  15840. var find = dto.titleModel.FirstOrDefault(expr);
  15841. if (find != null)
  15842. {
  15843. designer.SetDataSource(item, find.text);
  15844. }
  15845. else
  15846. {
  15847. designer.SetDataSource(item, 0);
  15848. }
  15849. }
  15850. designer.SetDataSource(dt);
  15851. //根据数据源处理生成报表内容
  15852. designer.Process();
  15853. designer.Workbook.Worksheets[0].Name = "费用明细";
  15854. designer.Workbook.Worksheets[1].Name = "费用总核算";
  15855. Worksheet sheet = designer.Workbook.Worksheets[0];
  15856. #region 隐藏舱位
  15857. var settingAir = new[]
  15858. {
  15859. new { key = "经济舱", index = 7 },
  15860. new { key = "公务舱", index = 19 },
  15861. new { key = "头等舱", index = 11 }
  15862. };
  15863. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  15864. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  15865. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  15866. .Select((c, s) => s.Name)
  15867. .ToList()
  15868. .GroupBy(x => x)
  15869. .Select(x => x.Key);
  15870. foreach (var item in settingAir)
  15871. {
  15872. if (!airType.Contains(item.key))
  15873. {
  15874. hideRowsList.Add(item.index);
  15875. }
  15876. }
  15877. #endregion
  15878. foreach (var Rowindex in hideRowsList)
  15879. {
  15880. ws.Cells.HideRows(Rowindex, 2);
  15881. }
  15882. ws = designer.Workbook.Worksheets[0];
  15883. foreach (var Column in hideColumnList)
  15884. {
  15885. ws.Cells.HideColumns(Column, 1);
  15886. }
  15887. byte[] bytes = null;
  15888. string strFileName = di.TeamName + "-团组-成本.xls";
  15889. using (MemoryStream stream = new MemoryStream())
  15890. {
  15891. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15892. bytes = stream.ToArray();
  15893. }
  15894. return Ok(JsonView(true, "", new
  15895. {
  15896. Data = bytes,
  15897. strFileName,
  15898. }));
  15899. }
  15900. /// <summary>
  15901. /// 导出客户报表
  15902. /// </summary>
  15903. /// <returns></returns>
  15904. [HttpPost]
  15905. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15906. {
  15907. var jw = JsonView(false);
  15908. if (dto.Diid == 0)
  15909. {
  15910. return Ok(JsonView(false, "请传递团组id"));
  15911. }
  15912. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15913. if (deleInfo.Code != 0)
  15914. {
  15915. return Ok(JsonView(false, "团组信息查询失败!"));
  15916. }
  15917. var di = deleInfo.Data as DelegationInfoWebView;
  15918. if (di == null)
  15919. {
  15920. return Ok(JsonView(false, "团组信息查询失败!"));
  15921. }
  15922. //文件名
  15923. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15924. //获取模板
  15925. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15926. //载入模板
  15927. Document doc = new Document(tmppath);
  15928. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15929. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15930. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15931. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15932. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15933. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15934. if (AParameter == null)
  15935. {
  15936. return Ok(JsonView(false, "系数不存在!"));
  15937. }
  15938. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15939. , TzAirDesc, TzZCost;
  15940. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15941. = TzAirDesc = TzZCost = string.Empty;
  15942. TzNumber = AParameter.CostTypenumber.ToString();
  15943. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15944. CarGuides1 = dto.CarGuides1;
  15945. Meal = dto.Meal;
  15946. SubsidizedMeals = dto.SubsidizedMeals;
  15947. NightRepair = dto.NightRepair;
  15948. AttractionsTickets = dto.AttractionsTickets;
  15949. MiscellaneousFees = dto.MiscellaneousFees;
  15950. ATip = dto.ATip;
  15951. TzHotelDesc = "";
  15952. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15953. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15954. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15955. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15956. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15957. TzAirDesc = "";
  15958. TzZCost = dto.TzZCost;
  15959. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15960. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15961. var index = 1;
  15962. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15963. foreach (var item in TzHotelDescArr)
  15964. {
  15965. if (AinfoArr != null)
  15966. {
  15967. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15968. if (Ainfo != null)
  15969. {
  15970. if (int.Parse(Ainfo.rs) <= 0)
  15971. {
  15972. continue;
  15973. }
  15974. var hotelText = string.Empty;
  15975. switch (item)
  15976. {
  15977. case "SGR":
  15978. hotelText = "单人间";
  15979. break;
  15980. case "JSES":
  15981. hotelText = "小套房";
  15982. break;
  15983. case "SUITE":
  15984. hotelText = "套房";
  15985. break;
  15986. case "TBR":
  15987. hotelText = "双人间";
  15988. break;
  15989. }
  15990. if (item != "TBR")
  15991. {
  15992. 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";
  15993. }
  15994. else
  15995. {
  15996. 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";
  15997. }
  15998. index++;
  15999. }
  16000. }
  16001. }
  16002. index = 1;
  16003. foreach (var item in TzAirDescArr)
  16004. {
  16005. if (AinfoArr != null)
  16006. {
  16007. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16008. if (Ainfo != null)
  16009. {
  16010. if (int.Parse(Ainfo.rs) <= 0)
  16011. {
  16012. continue;
  16013. }
  16014. 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";
  16015. index++;
  16016. }
  16017. }
  16018. }
  16019. if (dto.costType == "B")
  16020. {
  16021. if (BParameter == null)
  16022. {
  16023. return Ok(JsonView(false, "B段系数不存在!"));
  16024. }
  16025. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16026. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16027. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16028. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16029. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16030. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16031. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16032. foreach (var item in TzHotelDescArr)
  16033. {
  16034. if (AinfoArr != null)
  16035. {
  16036. TzHotelDesc += "B段信息 \r\n";
  16037. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16038. if (Ainfo != null)
  16039. {
  16040. if (int.Parse(Ainfo.rs) <= 0)
  16041. {
  16042. continue;
  16043. }
  16044. var hotelText = string.Empty;
  16045. switch (item)
  16046. {
  16047. case "SGR":
  16048. hotelText = "单人间";
  16049. break;
  16050. case "JSES":
  16051. hotelText = "小套房";
  16052. break;
  16053. case "SUITE":
  16054. hotelText = "套房";
  16055. break;
  16056. case "TBR":
  16057. hotelText = "双人间";
  16058. break;
  16059. }
  16060. if (item != "TBR")
  16061. {
  16062. 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";
  16063. }
  16064. else
  16065. {
  16066. 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";
  16067. }
  16068. index++;
  16069. }
  16070. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16071. }
  16072. }
  16073. index = 1;
  16074. foreach (var item in TzAirDescArr)
  16075. {
  16076. if (AinfoArr != null)
  16077. {
  16078. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16079. if (Ainfo != null)
  16080. {
  16081. if (int.Parse(Ainfo.rs) <= 0)
  16082. {
  16083. continue;
  16084. }
  16085. 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";
  16086. index++;
  16087. }
  16088. }
  16089. }
  16090. }
  16091. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16092. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16093. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16094. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16095. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16096. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16097. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16098. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16099. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16100. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16101. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16102. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16103. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16104. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16105. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16106. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16107. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16108. DickeyValue.Add("TzZCost", TzZCost);
  16109. foreach (var key in DickeyValue.Keys)
  16110. {
  16111. if (doc.Range.Bookmarks[key] != null)
  16112. {
  16113. Bookmark mark = doc.Range.Bookmarks[key];
  16114. mark.Text = DickeyValue[key];
  16115. }
  16116. }
  16117. byte[] bytes = null;
  16118. string strFileName = di.TeamName + "-客户报价.doc";
  16119. using (MemoryStream stream = new MemoryStream())
  16120. {
  16121. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  16122. bytes = stream.ToArray();
  16123. }
  16124. return Ok(JsonView(true, "", new
  16125. {
  16126. Data = bytes,
  16127. strFileName,
  16128. }));
  16129. }
  16130. /// <summary>
  16131. /// 团组成本 各模块(酒店,地接,机票)成本提示
  16132. /// </summary>
  16133. /// <param name="dto"></param>
  16134. /// <returns></returns>
  16135. [HttpPost]
  16136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16137. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  16138. {
  16139. try
  16140. {
  16141. #region 参数验证
  16142. if (dto.DiId < 0)
  16143. {
  16144. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  16145. }
  16146. List<int> cTableIds = new List<int>() {
  16147. 76 ,//酒店预订
  16148. 77 ,//行程
  16149. 79 ,//车/导游地接
  16150. 80 ,//签证
  16151. 81 ,//邀请/公务活
  16152. 82 ,//团组客户保险
  16153. 85 ,//机票预订
  16154. 98 ,//其他款项
  16155. 285 ,//收款退还
  16156. 751 ,//酒店早餐
  16157. 1015 // 超支费用
  16158. };
  16159. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  16160. {
  16161. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  16162. }
  16163. #endregion
  16164. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  16165. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  16166. if (_GroupCostParameters.Count <= 0)
  16167. {
  16168. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  16169. }
  16170. if (_GroupCostParameters[0].IsShare == 0)
  16171. {
  16172. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  16173. }
  16174. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16175. //处理date为空问题
  16176. if (_GroupCosts.Count > 0)
  16177. {
  16178. for (int i = 0; i < _GroupCosts.Count; i++)
  16179. {
  16180. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  16181. {
  16182. if (i > 0)
  16183. {
  16184. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  16185. }
  16186. }
  16187. }
  16188. }
  16189. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  16190. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  16191. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  16192. string currCode = "";
  16193. #region currCode 验证
  16194. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16195. if (isInt)
  16196. {
  16197. var currData = currDatas.Find(it => it.Id == intCurrency);
  16198. if (currData != null)
  16199. {
  16200. currCode = currData.Name;
  16201. }
  16202. }
  16203. else
  16204. {
  16205. currCode = _GroupCostParameters[0].Currency.Trim();
  16206. }
  16207. #endregion
  16208. //op,酒店单段模式存储
  16209. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16210. {
  16211. CurrencyCode = currCode,
  16212. Rate = _GroupCostParameters[0].Rate,
  16213. CostType = _GroupCostParameters[0].CostType,
  16214. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16215. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16216. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16217. };
  16218. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16219. if (_GroupCostParameters.Count == 2)
  16220. {
  16221. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16222. }
  16223. foreach (var item in _GroupCostParameters)
  16224. {
  16225. decimal _rate = 1;
  16226. decimal _rate1 = item.Rate;
  16227. decimal _scale = 1;
  16228. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16229. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16230. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16231. //if (userInfo != null)
  16232. //{
  16233. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16234. // {
  16235. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16236. // {
  16237. // _scale = 1.00M;
  16238. // }
  16239. // }
  16240. //}
  16241. #endregion
  16242. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16243. {
  16244. CurrencyCode = currCode,
  16245. Rate = _rate1,
  16246. CostType = item.CostType,
  16247. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16248. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16249. CostTypeNumber = item.CostTypenumber
  16250. };
  16251. if (_GroupCostParameters.Count > 1)
  16252. {
  16253. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16254. }
  16255. else
  16256. {
  16257. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16258. }
  16259. if (dto.CTable == 79)//
  16260. {
  16261. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16262. modulePromptInfo.TotalCost = item.DJCB;
  16263. }
  16264. List<string> costTypes = new List<string>() { "A", "B" };
  16265. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16266. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16267. if (_GroupCostsDuplicates.Count() == 1)
  16268. {
  16269. _GroupCostsTypeData = _GroupCosts;
  16270. }
  16271. else
  16272. {
  16273. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16274. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16275. }
  16276. /*
  16277. * 76 酒店预订
  16278. * 77 行程
  16279. * 79 车/导游地接
  16280. * 80 签证
  16281. * 81 邀请/公务活动
  16282. * 82 团组客户保险
  16283. * 85 机票预订
  16284. * 98 其他款项
  16285. * 285 收款退还
  16286. * 751 酒店早餐
  16287. * 1015 超支费用
  16288. */
  16289. switch (dto.CTable)
  16290. {
  16291. case 76: // 酒店预订
  16292. _ModuleSubPromptInfo.AddRange(
  16293. _GroupCostsTypeData.Select(it => new
  16294. {
  16295. it.DAY,
  16296. it.Date,
  16297. it.ACCON,
  16298. it.ITIN,
  16299. it.SGR,
  16300. it.TBR,
  16301. it.JS_ES,
  16302. it.Suite
  16303. })
  16304. );
  16305. break;
  16306. case 79: // 车/导游地接
  16307. _ModuleSubPromptInfo.AddRange(
  16308. _GroupCostsTypeData.Select(it => new
  16309. {
  16310. Date = it.Date, //日期
  16311. CarFee = it.CarCost * _rate * _scale, //车费用
  16312. CarType = it.CarType, //车型
  16313. DriverFee = it.CFS * _rate * _scale, //司机工资
  16314. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16315. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16316. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16317. GuideFee = it.TGS * _rate * _scale, //导游费用
  16318. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16319. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16320. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16321. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16322. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16323. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16324. Breakfast = it.B * _rate * _scale, //早餐费
  16325. Lunch = it.L * _rate * _scale, //午餐费
  16326. Dinner = it.D * _rate * _scale, //晚餐费
  16327. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16328. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16329. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16330. TicketFee = it.EF * _rate * _scale, //门票费
  16331. TicketRemark = it.EFR, //门票费描述
  16332. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16333. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16334. SpentCash = it.PC * _rate * _scale, //零用金
  16335. LeadersFee = it.TLF * _rate * _scale, //领队费
  16336. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16337. })
  16338. );
  16339. break;
  16340. case 85: // 机票
  16341. List<dynamic> datas = new List<dynamic>();
  16342. datas.Add(
  16343. new
  16344. {
  16345. AirType = "经济舱",
  16346. AirNum = item.JJCRS,
  16347. AirDRCB = item.JJCCB,
  16348. AirZCB = (item.JJCRS * item.JJCCB)
  16349. }
  16350. );
  16351. datas.Add(
  16352. new
  16353. {
  16354. AirType = "公务舱",
  16355. AirNum = item.GWCRS,
  16356. AirDRCB = item.GWCCB,
  16357. AirZCB = (item.GWCRS * item.GWCCB)
  16358. }
  16359. );
  16360. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16361. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16362. modulePromptInfo.Data = new
  16363. {
  16364. airFeeData = datas,
  16365. airInitData = initDatas
  16366. };
  16367. _ModulePromptInfos.Add(modulePromptInfo);
  16368. break;
  16369. default:
  16370. break;
  16371. }
  16372. }
  16373. if (dto.CTable != 85)
  16374. {
  16375. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16376. _ModulePromptInfos.Add(_ModulePromptInfo);
  16377. }
  16378. _view.ModulePromptInfos = _ModulePromptInfos;
  16379. return Ok(JsonView(true, "操作成功!", _view));
  16380. }
  16381. catch (Exception ex)
  16382. {
  16383. return Ok(JsonView(false, ex.Message));
  16384. }
  16385. }
  16386. /// <summary>
  16387. /// 根据黑屏代码重新生成行程
  16388. /// </summary>
  16389. /// <param name="dto"></param>
  16390. /// <returns></returns>
  16391. [HttpPost]
  16392. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16393. {
  16394. var jw = JsonView(false, "Error");
  16395. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16396. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16397. .Select(x => new
  16398. {
  16399. x.Id,
  16400. x.Title
  16401. })
  16402. .ToList();
  16403. if (Create.Any())
  16404. {
  16405. jw.Msg = "获取成功!";
  16406. jw.Code = 200;
  16407. jw.Data = new
  16408. {
  16409. BlackCodeListSelect = Create,
  16410. blackCodeIsTrue = true
  16411. };
  16412. }
  16413. else
  16414. {
  16415. jw.Code = 400;
  16416. jw.Data = new
  16417. {
  16418. BlackCodeListSelect = Create,
  16419. blackCodeIsTrue = false,
  16420. };
  16421. }
  16422. return Ok(jw);
  16423. }
  16424. /// <summary>
  16425. /// 根据黑屏代码Id重新生成行程
  16426. /// </summary>
  16427. /// <param name="dto"></param>
  16428. /// <returns></returns>
  16429. [HttpPost]
  16430. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16431. {
  16432. var jw = JsonView(false, "Error");
  16433. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16434. if (result.Code == 0)
  16435. {
  16436. jw.Msg = "获取成功!";
  16437. jw.Code = 200;
  16438. jw.Data = new
  16439. {
  16440. groupCost = result.Data,
  16441. blackCodeIsTrue = true
  16442. };
  16443. }
  16444. else
  16445. {
  16446. jw.Code = 400;
  16447. jw.Data = new
  16448. {
  16449. groupCost = result.Data,
  16450. blackCodeIsTrue = false,
  16451. };
  16452. }
  16453. return Ok(jw);
  16454. }
  16455. /// <summary>
  16456. /// 成本获取OP历史车费用
  16457. /// </summary>
  16458. /// <param name="dto"></param>
  16459. /// <returns></returns>
  16460. [HttpPost]
  16461. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16462. {
  16463. var jw = JsonView(false);
  16464. try
  16465. {
  16466. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16467. //获取现有所有车的数据
  16468. if (!dto.Param.IsNullOrWhiteSpace())
  16469. {
  16470. string sql = $@"
  16471. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16472. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16473. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16474. 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
  16475. AND gctggr.ServiceEndTime is not NULL
  16476. ORDER by gctggrc.id DESC
  16477. ";
  16478. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16479. var numeberResult = await Task.Run(() =>
  16480. {
  16481. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16482. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16483. return numberArr;
  16484. });
  16485. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16486. foreach (var item in numeberResult)
  16487. {
  16488. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16489. {
  16490. Country = "数据异常!",
  16491. City = string.Empty,
  16492. };
  16493. item.Area = find.Country + " " + find.City;
  16494. }
  16495. dbResult.AddRange(numeberResult);
  16496. if (dto.Param.Contains("、"))
  16497. {
  16498. var sp = dto.Param.Split("、");
  16499. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16500. .Where(x =>
  16501. {
  16502. return System.Array.Exists(sp, e =>
  16503. {
  16504. bool where = false;
  16505. if (x.Area != null)
  16506. {
  16507. where = x.Area.Contains(e);
  16508. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16509. {
  16510. return false;
  16511. }
  16512. }
  16513. if (x.PriceName != null && !where)
  16514. {
  16515. where = x.PriceName.Contains(e);
  16516. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16517. {
  16518. return false;
  16519. }
  16520. }
  16521. return where;
  16522. });
  16523. }).ToList();
  16524. }
  16525. else
  16526. {
  16527. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16528. .Where(x =>
  16529. {
  16530. bool where = false;
  16531. if (x.Area != null)
  16532. {
  16533. where = x.Area.Contains(dto.Param);
  16534. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16535. {
  16536. return false;
  16537. }
  16538. }
  16539. if (x.PriceName != null && !where)
  16540. {
  16541. where = x.PriceName.Contains(dto.Param);
  16542. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16543. {
  16544. return false;
  16545. }
  16546. }
  16547. return where;
  16548. }
  16549. )
  16550. .ToList();
  16551. }
  16552. }
  16553. var view = dbResult.Select(x =>
  16554. {
  16555. decimal dp = 0.00M;
  16556. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16557. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16558. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16559. {
  16560. if (startB && endB)
  16561. {
  16562. var timesp = endD.Subtract(startD);
  16563. if ((timesp.Days + 1) != 0)
  16564. {
  16565. dp = x.Price / (timesp.Days + 1);
  16566. }
  16567. }
  16568. }
  16569. else
  16570. {
  16571. dp = x.Price;
  16572. }
  16573. return new
  16574. {
  16575. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16576. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16577. x.Area,
  16578. x.id,
  16579. price = x.Price.ToString("F2"),
  16580. x.PriceName,
  16581. x.PriceContent,
  16582. x.TeamName,
  16583. x.DatePrice,
  16584. dayPrice = dp.ToString("F2"),
  16585. };
  16586. }).OrderByDescending(x => x.id).ToList();
  16587. jw = JsonView(true, "获取成功!", view);
  16588. }
  16589. catch (Exception e)
  16590. {
  16591. jw = JsonView(false, e.Message);
  16592. }
  16593. return Ok(jw);
  16594. }
  16595. [HttpPost]
  16596. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16597. {
  16598. var jw = JsonView(true);
  16599. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16600. #region SQL语句
  16601. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16602. //{
  16603. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16604. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16605. // WHEN COUNT(*) >= 0 THEN 'True'
  16606. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16607. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16608. // ")
  16609. // .ToList();
  16610. //}
  16611. //else
  16612. //{
  16613. // string likeKey = string.Empty;
  16614. // foreach (var item in dto.Keyword)
  16615. // {
  16616. // likeKey += "%" + item;
  16617. // }
  16618. // likeKey += "%";
  16619. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16620. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16621. // WHEN COUNT(*) >= 0 THEN 'True'
  16622. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16623. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16624. // ")
  16625. // .ToList();
  16626. //}
  16627. #endregion
  16628. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16629. {
  16630. @KeyWord = dto.Keyword
  16631. });
  16632. if (table != null && table.Rows.Count > 0)
  16633. {
  16634. foreach (DataRow row in table.Rows)
  16635. {
  16636. matches.Add(new DelegationInfoAndIsTrueView
  16637. {
  16638. Id = row.Field<int>("Id"),
  16639. GroupName = row.Field<string>("GroupName"),
  16640. isTrue = row.Field<string>("isTrue")
  16641. });
  16642. }
  16643. }
  16644. if (matches.Any())
  16645. {
  16646. jw.Data = matches;
  16647. }
  16648. else
  16649. {
  16650. jw.Code = 201;
  16651. jw.Msg = "empty list";
  16652. jw.Data = new List<string>(1);
  16653. }
  16654. return Ok(jw);
  16655. }
  16656. /// <summary>
  16657. /// 报价Word下载
  16658. /// </summary>
  16659. /// <param name="dto"></param>
  16660. /// <returns></returns>
  16661. [HttpPost]
  16662. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16663. {
  16664. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16665. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16666. if (di == null)
  16667. {
  16668. return Ok(JsonView(false, "团组不存在!"));
  16669. }
  16670. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16671. if (mainPrice == null || mainPrice.IsShare == 0)
  16672. {
  16673. return Ok(JsonView(false, "团组成本不存在!"));
  16674. }
  16675. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16676. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16677. if (costTypeHotelNumbers == null)
  16678. {
  16679. return Ok(JsonView(false, "团组成本不存在!"));
  16680. }
  16681. //文件名
  16682. string strFileName = di.TeamName + "-收款账单.doc";
  16683. //获取模板
  16684. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16685. //载入模板
  16686. Document doc = new Document(tmppath);
  16687. decimal allPrice = 0.00M;
  16688. string itemStr = string.Empty;
  16689. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16690. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16691. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16692. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16693. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16694. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16695. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16696. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16697. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16698. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16699. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16700. {
  16701. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16702. ("BXRS", "BXCB", "BXXS", "bx"),
  16703. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16704. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16705. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16706. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16707. ("CPRS", "CPCB", "CPXS", "cp"),
  16708. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16709. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16710. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16711. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16712. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16713. ("DJRS", "DJCB", "DJXS", "dj"),
  16714. ("GWRS", "GWCB", "GWXS", "gw"),
  16715. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16716. };
  16717. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16718. var rightSum = 0.00M;
  16719. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16720. {
  16721. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16722. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16723. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16724. if (prefix == "tbr")
  16725. {
  16726. rsValue *= 2;
  16727. cbValue /= 2;
  16728. }
  16729. if (OtherCostPropertyBJ.Contains(prefix))
  16730. {
  16731. rightSum += cbValue * xsValue;
  16732. }
  16733. }
  16734. var hotelRooms = new Dictionary<string, int>
  16735. {
  16736. { "SGR", costTypeHotelNumbers.SGR },
  16737. { "TBR", costTypeHotelNumbers.TBR },
  16738. { "JSES", costTypeHotelNumbers.JSES },
  16739. { "SUITE", costTypeHotelNumbers.SUITE }
  16740. };
  16741. var flights = new Dictionary<string, int>
  16742. {
  16743. { "经济舱", mainPrice.JJCRS },
  16744. { "公务舱", mainPrice.GWCRS },
  16745. { "头等舱", mainPrice.TDCRS }
  16746. };
  16747. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16748. {
  16749. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16750. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16751. { "头等舱", new[] { "SUITE", "JSES" } }
  16752. };
  16753. var result = new Dictionary<string, int>();
  16754. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16755. foreach (var flight in flights.Keys)
  16756. {
  16757. // 获取当前舱位的匹配规则
  16758. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16759. {
  16760. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16761. }
  16762. }
  16763. #region right计算
  16764. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16765. {
  16766. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16767. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16768. airHotelPriceList.Add(new
  16769. AirHotelPrice
  16770. {
  16771. Name = "经济舱TBR",
  16772. Price = rightSum + air + hotel,
  16773. Count = result["经济舱TBR"] * 2
  16774. });
  16775. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16776. }
  16777. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16778. {
  16779. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16780. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16781. airHotelPriceList.Add(new
  16782. AirHotelPrice
  16783. {
  16784. Name = "经济舱SGR",
  16785. Price = rightSum + air + hotel,
  16786. Count = result["经济舱SGR"]
  16787. });
  16788. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16789. }
  16790. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16791. {
  16792. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16793. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16794. airHotelPriceList.Add(new
  16795. AirHotelPrice
  16796. {
  16797. Name = "公务舱SGR",
  16798. Price = rightSum + air + hotel,
  16799. Count = result["公务舱SGR"]
  16800. });
  16801. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16802. }
  16803. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16804. {
  16805. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16806. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16807. airHotelPriceList.Add(new
  16808. AirHotelPrice
  16809. {
  16810. Name = "公务舱JSES",
  16811. Price = rightSum + air + hotel,
  16812. Count = result["公务舱JSES"]
  16813. });
  16814. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16815. }
  16816. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16817. {
  16818. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16819. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16820. airHotelPriceList.Add(new
  16821. AirHotelPrice
  16822. {
  16823. Name = "公务舱SUITE",
  16824. Price = rightSum + air + hotel,
  16825. Count = result["公务舱SUITE"]
  16826. });
  16827. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16828. }
  16829. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16830. {
  16831. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16832. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16833. airHotelPriceList.Add(new
  16834. AirHotelPrice
  16835. {
  16836. Name = "经济舱SUITE",
  16837. Price = rightSum + air + hotel,
  16838. Count = result["经济舱SUITE"]
  16839. });
  16840. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16841. }
  16842. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16843. {
  16844. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16845. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16846. airHotelPriceList.Add(new
  16847. AirHotelPrice
  16848. {
  16849. Name = "头等舱JSES",
  16850. Price = rightSum + air + hotel,
  16851. Count = result["头等舱JSES"]
  16852. });
  16853. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16854. }
  16855. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16856. {
  16857. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16858. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16859. airHotelPriceList.Add(new
  16860. AirHotelPrice
  16861. {
  16862. Name = "头等舱SUITE",
  16863. Price = rightSum + air + hotel,
  16864. Count = result["头等舱SUITE"]
  16865. });
  16866. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16867. }
  16868. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16869. {
  16870. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16871. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16872. airHotelPriceList.Add(new
  16873. AirHotelPrice
  16874. {
  16875. Name = "经济舱JSES",
  16876. Price = rightSum + air + hotel,
  16877. Count = result["经济舱JSES"]
  16878. });
  16879. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16880. }
  16881. #endregion
  16882. foreach (var item in airSouer.Keys)
  16883. {
  16884. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16885. if (find != null && find.Count > 0)
  16886. {
  16887. if (item.Contains("TBR"))
  16888. {
  16889. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16890. }
  16891. else
  16892. {
  16893. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16894. }
  16895. }
  16896. }
  16897. #region 替换Word模板书签内容
  16898. Dictionary<string, string> marks = new Dictionary<string, string>();
  16899. marks.Add("To", di.ClientUnit);//付款方
  16900. marks.Add("ToTel", di.TellPhone);//付款方电话
  16901. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16902. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16903. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16904. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16905. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16906. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16907. marks.Add("PayItemContent", itemStr);//详细信息
  16908. marks.Add("Total", allPrice.ToString("F2"));//合计
  16909. #endregion
  16910. foreach (var item in marks.Keys)
  16911. {
  16912. if (doc.Range.Bookmarks[item] != null)
  16913. {
  16914. Bookmark mark = doc.Range.Bookmarks[item];
  16915. mark.Text = marks[item];
  16916. }
  16917. }
  16918. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16919. doc.Save(savePaht);
  16920. var jw = new JsonView();
  16921. jw.Msg = "生成成功!";
  16922. jw.Code = 200;
  16923. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16924. return Ok(jw);
  16925. }
  16926. /// <summary>
  16927. /// 详细报价费用Excel下载
  16928. /// </summary>
  16929. /// <param name="dto"></param>
  16930. /// <returns></returns>
  16931. [HttpPost]
  16932. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16933. {
  16934. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16935. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16936. if (di == null)
  16937. {
  16938. return Ok(JsonView(false, "团组不存在!"));
  16939. }
  16940. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16941. if (mainPrice == null || mainPrice.IsShare == 0)
  16942. {
  16943. return Ok(JsonView(false, "团组成本不存在!"));
  16944. }
  16945. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16946. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16947. if (costTypeHotelNumbers == null)
  16948. {
  16949. return Ok(JsonView(false, "团组成本不存在!"));
  16950. }
  16951. WorkbookDesigner designer = new WorkbookDesigner();
  16952. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16953. List<int> hideRowsList = new List<int>();
  16954. int conterStartIndex = 3;
  16955. int rowIndex = conterStartIndex;
  16956. designer.SetDataSource("GroupName", di.TeamName);
  16957. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16958. {
  16959. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16960. ("BXRS", "BXCB", "BXXS", "bx"),
  16961. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16962. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16963. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16964. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16965. ("CPRS", "CPCB", "CPXS", "cp") ,
  16966. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16967. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16968. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16969. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16970. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16971. ("DJRS", "DJCB", "DJXS", "dj") ,
  16972. ("GWRS", "GWCB", "GWXS", "gw") ,
  16973. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16974. };
  16975. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16976. var rightSum = 0.00M;
  16977. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16978. {
  16979. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16980. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16981. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16982. if (prefix == "tbr")
  16983. {
  16984. rsValue *= 2;
  16985. cbValue /= 2;
  16986. }
  16987. if (OtherCostPropertyBJ.Contains(prefix))
  16988. {
  16989. rightSum += cbValue * xsValue;
  16990. }
  16991. if (rsValue == 0)
  16992. {
  16993. hideRowsList.Add(rowIndex);
  16994. }
  16995. else
  16996. {
  16997. designer.SetDataSource($"{prefix}rs", rsValue);
  16998. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16999. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17000. }
  17001. rowIndex += 2;
  17002. }
  17003. var hotelRooms = new Dictionary<string, int>
  17004. {
  17005. { "SGR", costTypeHotelNumbers.SGR },
  17006. { "TBR", costTypeHotelNumbers.TBR },
  17007. { "JSES", costTypeHotelNumbers.JSES },
  17008. { "SUITE", costTypeHotelNumbers.SUITE }
  17009. };
  17010. var flights = new Dictionary<string, int>
  17011. {
  17012. { "经济舱", mainPrice.JJCRS },
  17013. { "公务舱", mainPrice.GWCRS },
  17014. { "头等舱", mainPrice.TDCRS }
  17015. };
  17016. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17017. {
  17018. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17019. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17020. { "头等舱", new[] { "SUITE", "JSES" } }
  17021. };
  17022. var result = new Dictionary<string, int>();
  17023. foreach (var flight in flights.Keys)
  17024. {
  17025. // 获取当前舱位的匹配规则
  17026. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17027. {
  17028. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17029. }
  17030. }
  17031. var allPrice = 0.00M;
  17032. #region right计算
  17033. int airRowIndex = 35;
  17034. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17035. {
  17036. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17037. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17038. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  17039. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17040. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17041. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17042. }
  17043. else
  17044. {
  17045. hideRowsList.Add(airRowIndex);
  17046. }
  17047. airRowIndex += 2;
  17048. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17049. {
  17050. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17051. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17052. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17053. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17054. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17055. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17056. }
  17057. else
  17058. {
  17059. hideRowsList.Add(airRowIndex);
  17060. }
  17061. airRowIndex += 2;
  17062. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17063. {
  17064. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17065. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17066. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17067. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17068. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17069. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17070. }
  17071. else
  17072. {
  17073. hideRowsList.Add(airRowIndex);
  17074. }
  17075. airRowIndex += 2;
  17076. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17077. {
  17078. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17079. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17080. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17081. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17082. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17083. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17084. }
  17085. else
  17086. {
  17087. hideRowsList.Add(airRowIndex);
  17088. }
  17089. airRowIndex += 2;
  17090. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17091. {
  17092. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17093. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17094. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17095. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17096. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17097. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17098. }
  17099. else
  17100. {
  17101. hideRowsList.Add(airRowIndex);
  17102. }
  17103. airRowIndex += 2;
  17104. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17105. {
  17106. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17107. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17108. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17109. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17110. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17111. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17112. }
  17113. else
  17114. {
  17115. hideRowsList.Add(airRowIndex);
  17116. }
  17117. airRowIndex += 2;
  17118. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17119. {
  17120. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17121. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17122. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  17123. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  17124. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  17125. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17126. }
  17127. else
  17128. {
  17129. hideRowsList.Add(airRowIndex);
  17130. }
  17131. airRowIndex += 2;
  17132. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17133. {
  17134. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17135. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17136. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  17137. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  17138. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  17139. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17140. }
  17141. else
  17142. {
  17143. hideRowsList.Add(airRowIndex);
  17144. }
  17145. airRowIndex += 2;
  17146. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17147. {
  17148. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17149. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17150. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  17151. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  17152. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  17153. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17154. }
  17155. else
  17156. {
  17157. hideRowsList.Add(airRowIndex);
  17158. }
  17159. #endregion
  17160. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  17161. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  17162. var ws = designer.Workbook.Worksheets[0];
  17163. foreach (var Rowindex in hideRowsList)
  17164. {
  17165. ws.Cells.HideRows(Rowindex, 2);
  17166. }
  17167. designer.Process();
  17168. designer.Workbook.Save(savePaht);
  17169. return Ok(JsonView(true, "生成成功!", new
  17170. {
  17171. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  17172. }));
  17173. }
  17174. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  17175. {
  17176. foreach (var roomType in roomTypes)
  17177. {
  17178. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  17179. {
  17180. hotelRooms[roomType]--;
  17181. flights[flightType]--;
  17182. if (roomType == "TBR")
  17183. {
  17184. flights[flightType]--; // 双人间在减少1
  17185. }
  17186. string key = flightType + roomType;
  17187. if (result.Keys.Contains(key))
  17188. {
  17189. result[key]++;
  17190. }
  17191. else
  17192. {
  17193. result.Add(key, 1);
  17194. }
  17195. }
  17196. }
  17197. }
  17198. private class AirHotelPrice
  17199. {
  17200. public string Name { get; set; }
  17201. public decimal Price { get; set; }
  17202. public int Count { get; set; }
  17203. }
  17204. /// <summary>
  17205. /// 团组系数设置
  17206. /// </summary>
  17207. /// <param name="dto"></param>
  17208. /// <returns></returns>
  17209. [HttpPost]
  17210. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17211. {
  17212. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17213. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17214. if (di == null)
  17215. {
  17216. return Ok(JsonView(false, "团组不存在!"));
  17217. }
  17218. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  17219. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  17220. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  17221. // FirstAsync(firstExpression.ToExpression());
  17222. #region JSON
  17223. string hcpJson = @"
  17224. [
  17225. {
  17226. ""min"": 1,
  17227. ""max"": 500,
  17228. ""value"": 1.50
  17229. },
  17230. {
  17231. ""min"": 501,
  17232. ""max"": 1000,
  17233. ""value"": 1.40
  17234. },
  17235. {
  17236. ""min"": 1001,
  17237. ""max"": 2000,
  17238. ""value"": 1.35
  17239. }
  17240. ]";
  17241. #endregion
  17242. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  17243. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  17244. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  17245. .ToList();
  17246. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  17247. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  17248. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  17249. // new List<(Predicate<decimal>, decimal)>()
  17250. // {
  17251. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  17252. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  17253. // }
  17254. // ));
  17255. #region 签证系数
  17256. var visaXS = 0.00M;
  17257. switch (dto.VisaCB)
  17258. {
  17259. case decimal n when (n > 1 && n < 500):
  17260. switch (dto.VisaRS)
  17261. {
  17262. case 2 or 3:
  17263. visaXS = 1.35M;
  17264. break;
  17265. case 4 or 5:
  17266. visaXS = 1.30M;
  17267. break;
  17268. case 6 or 7:
  17269. visaXS = 1.25M;
  17270. break;
  17271. case 8 or 9 or 10:
  17272. visaXS = 1.20M;
  17273. break;
  17274. case > 10:
  17275. visaXS = 1.15M;
  17276. break;
  17277. default:
  17278. visaXS = 0.00M;
  17279. break;
  17280. }
  17281. break;
  17282. case decimal n when (n >= 500 && n < 1000):
  17283. switch (dto.VisaRS)
  17284. {
  17285. case 2 or 3 or 4:
  17286. visaXS = 1.30M;
  17287. break;
  17288. case 5 or 6 or 7 or 8:
  17289. visaXS = 1.25M;
  17290. break;
  17291. case 9 or 10:
  17292. visaXS = 1.20M;
  17293. break;
  17294. case > 10:
  17295. visaXS = 1.15M;
  17296. break;
  17297. default:
  17298. visaXS = 0.00M;
  17299. break;
  17300. }
  17301. break;
  17302. default:
  17303. switch (dto.VisaRS)
  17304. {
  17305. case 2 or 3 or 4:
  17306. visaXS = 1.30M;
  17307. break;
  17308. case 5 or 6 or 7 or 8:
  17309. visaXS = 1.25M;
  17310. break;
  17311. case 9 or 10:
  17312. visaXS = 1.20M;
  17313. break;
  17314. case > 10:
  17315. visaXS = 1.15M;
  17316. break;
  17317. default:
  17318. visaXS = 0.00M;
  17319. break;
  17320. }
  17321. break;
  17322. }
  17323. #endregion
  17324. #region 火车系数
  17325. var hcpXS = 0.00M;
  17326. foreach (var (condition, result) in hcpSwitchDictionary)
  17327. {
  17328. if (condition(dto.HCPCB))
  17329. {
  17330. hcpXS = result;
  17331. break;
  17332. }
  17333. }
  17334. #endregion
  17335. #region 机票系数
  17336. #region 经济舱系数
  17337. var jjcXS = 0.00M;
  17338. switch (dto.JJCCB)
  17339. {
  17340. case decimal x when (x >= 1000 && x <= 3000):
  17341. jjcXS = 2.6M;
  17342. break;
  17343. case decimal x when (x >= 3001 && x <= 8000):
  17344. jjcXS = 2.3M;
  17345. break;
  17346. case decimal x when (x >= 8001 && x <= 15000):
  17347. jjcXS = 2.1M;
  17348. break;
  17349. case decimal x when (x >= 15001 && x <= 30000):
  17350. jjcXS = 1.95M;
  17351. break;
  17352. case > 30000:
  17353. jjcXS = 1.8M;
  17354. break;
  17355. default:
  17356. break;
  17357. }
  17358. #endregion
  17359. #region 公务舱系数
  17360. var gwcXS = 0.00M;
  17361. switch (dto.GWCCB)
  17362. {
  17363. case decimal x when (x >= 1000 && x <= 3000):
  17364. gwcXS = 2.5M;
  17365. break;
  17366. case decimal x when (x >= 3001 && x <= 8000):
  17367. gwcXS = 2.2M;
  17368. break;
  17369. case decimal x when (x >= 8001 && x <= 15000):
  17370. gwcXS = 2.0M;
  17371. break;
  17372. case decimal x when (x >= 15001 && x <= 30000):
  17373. gwcXS = 1.85M;
  17374. break;
  17375. case > 30000:
  17376. gwcXS = 1.7M;
  17377. break;
  17378. default:
  17379. break;
  17380. }
  17381. #endregion
  17382. #region 头等舱系数
  17383. var tdcXS = 0.00M;
  17384. switch (dto.TDCCB)
  17385. {
  17386. case > 70000:
  17387. tdcXS = 1.5M;
  17388. break;
  17389. default:
  17390. tdcXS = 1.9M;
  17391. break;
  17392. }
  17393. #endregion
  17394. #endregion
  17395. #region 酒店系数
  17396. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  17397. {
  17398. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  17399. {1.5M, new List<string>(){"越南社会主义共和国",
  17400. "老挝",
  17401. "柬埔寨",
  17402. "泰国",
  17403. "缅甸",
  17404. "马来西亚",
  17405. //"新加坡",
  17406. "文莱达鲁萨兰",
  17407. "印度尼西亚",
  17408. "东帝汶"}},
  17409. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  17410. };
  17411. #region SGR
  17412. var sgrXS = 1.25M;
  17413. #endregion
  17414. #region TBR
  17415. var tbrXS = 1.25M;
  17416. #endregion
  17417. #region JSES
  17418. var jsesXS = 1.25M;
  17419. #endregion
  17420. #region SUITE
  17421. var suiteXS = 1.25M;
  17422. #endregion
  17423. var countryArr = di.VisitCountry.Split("|");
  17424. foreach (var item in dic)
  17425. {
  17426. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  17427. .Count();
  17428. if (extsisCount > 0)
  17429. {
  17430. jsesXS = item.Key;
  17431. sgrXS = item.Key;
  17432. tbrXS = item.Key;
  17433. suiteXS = item.Key;
  17434. }
  17435. }
  17436. #endregion
  17437. #region 地接系数
  17438. var djXS = 0.00M;
  17439. switch (dto.DJRS)
  17440. {
  17441. case 2 or 3 :
  17442. djXS = 2.65M;
  17443. break;
  17444. case 4:
  17445. djXS = 2.6M;
  17446. break;
  17447. case 5 or 6:
  17448. djXS = 2.5M;
  17449. break;
  17450. case 7 or 8:
  17451. djXS = 2.4M;
  17452. break;
  17453. case 9 or 10:
  17454. djXS = 2.3M;
  17455. break;
  17456. case 11:
  17457. djXS = 2.2M;
  17458. break;
  17459. case 12:
  17460. djXS = 2.1M;
  17461. break;
  17462. case 13 or 14:
  17463. djXS = 2M;
  17464. break;
  17465. case 15:
  17466. djXS = 1.9M;
  17467. break;
  17468. case 16 or 17 or 18:
  17469. djXS = 1.8M;
  17470. break;
  17471. case 19 or 20:
  17472. djXS = 1.7M;
  17473. break;
  17474. }
  17475. #endregion
  17476. #region 零用金系数
  17477. var lyjXS = 0.00M;
  17478. switch (dto.LYJRS)
  17479. {
  17480. case 2:
  17481. lyjXS = 1.25M;
  17482. break;
  17483. case 3 or 4 or 5:
  17484. lyjXS = 1.2M;
  17485. break;
  17486. case int number when (number > 5 && number < 10):
  17487. lyjXS = 1.15M;
  17488. break;
  17489. case > 10:
  17490. lyjXS = 1.1M;
  17491. break;
  17492. default:
  17493. break;
  17494. }
  17495. #endregion
  17496. return Ok(JsonView(true, "查询成功", new ArrayList()
  17497. {
  17498. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  17499. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  17500. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  17501. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  17502. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  17503. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  17504. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  17505. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  17506. new { label = "地接系数", value = djXS, key = "djXS" },
  17507. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  17508. new { label = "公务系数", value = 2M, key = "gwXS" }
  17509. }));
  17510. }
  17511. #endregion
  17512. #region 酒店预订 New 2023-12-28 17:45
  17513. /// <summary>
  17514. /// 酒店预订
  17515. /// 酒店费用列表 根据团组Id查询
  17516. /// </summary>
  17517. /// <param name="_dto"></param>
  17518. /// <returns></returns>
  17519. [HttpPost]
  17520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17521. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17522. {
  17523. #region 参数验证
  17524. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17525. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17526. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17527. #region 团组操作权限验证 76 酒店预定模块
  17528. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17529. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17530. #endregion
  17531. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17532. #region 页面操作权限验证
  17533. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17534. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17535. #endregion
  17536. #endregion
  17537. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17538. }
  17539. /// <summary>
  17540. /// 酒店预订
  17541. /// 基础数据
  17542. /// </summary>
  17543. /// <param name="_dto"></param>
  17544. /// <returns></returns>
  17545. [HttpPost]
  17546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17547. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17548. {
  17549. #region 参数验证
  17550. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17551. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17552. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17553. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17554. #region 页面操作权限验证
  17555. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17556. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17557. #endregion
  17558. #region 团组操作权限验证 76 酒店预定模块
  17559. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17560. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17561. #endregion
  17562. #endregion
  17563. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17564. }
  17565. /// <summary>
  17566. /// 酒店预订
  17567. /// 创建 入住卷号码
  17568. /// </summary>
  17569. /// <param name="_dto"></param>
  17570. /// <returns></returns>
  17571. [HttpPost]
  17572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17573. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17574. {
  17575. #region 参数验证
  17576. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17577. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17578. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17579. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17580. #region 页面操作权限验证
  17581. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17582. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17583. #endregion
  17584. #region 团组操作权限验证 76 酒店预定模块
  17585. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17586. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17587. #endregion
  17588. #endregion
  17589. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17590. if (data.Code != 0)
  17591. {
  17592. return Ok(JsonView(false, data.Msg));
  17593. }
  17594. return Ok(JsonView(true, data.Msg, data.Data));
  17595. }
  17596. /// <summary>
  17597. /// 酒店预订
  17598. /// 详情
  17599. /// </summary>
  17600. /// <param name="_dto"></param>
  17601. /// <returns></returns>
  17602. [HttpPost]
  17603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17604. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17605. {
  17606. #region 参数验证
  17607. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17608. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17609. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17610. #region 团组操作权限验证 76 酒店预定模块
  17611. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17612. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17613. #endregion
  17614. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17615. #region 页面操作权限验证
  17616. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17617. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17618. #endregion
  17619. #endregion
  17620. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17621. }
  17622. /// <summary>
  17623. /// 酒店预订
  17624. /// Add Or Edit
  17625. /// </summary>
  17626. /// <param name="_dto"></param>
  17627. /// <returns></returns>
  17628. [HttpPost]
  17629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17630. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17631. {
  17632. #region 参数验证
  17633. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17634. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17635. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17636. #region 团组操作权限验证 76 酒店预定模块
  17637. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17638. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17639. #endregion
  17640. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17641. #region 页面操作权限验证
  17642. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17643. if (_dto.Id == 0) // Add
  17644. {
  17645. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17646. }
  17647. else if (_dto.Id > 1) // Edit
  17648. {
  17649. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17650. }
  17651. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17652. #endregion
  17653. #endregion
  17654. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17655. if (_view.Code != 200)
  17656. {
  17657. return Ok(_view);
  17658. }
  17659. #region 成本无酒店价格数据进入超支
  17660. _sqlSugar.BeginTran();
  17661. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17662. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17663. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17664. for (int i = 0; i < groupCost.Count; i++)
  17665. {
  17666. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17667. {
  17668. groupCost[i].Date = groupCost[i - 1].Date;
  17669. }
  17670. }
  17671. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17672. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17673. List<Fin_GroupExtraCostDto_OP>();
  17674. if (start_Bool && end_Bool)
  17675. {
  17676. while (start_Time < end_Time)
  17677. {
  17678. foreach (var item in groupCost_Grp)
  17679. {
  17680. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17681. {
  17682. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17683. {
  17684. extraCostList.Add(new
  17685. Fin_GroupExtraCostDto_OP
  17686. {
  17687. Area = _dto.AreaId,
  17688. coefficient = 1.5M,
  17689. createUser = _dto.UserId,
  17690. currency = _dto.CardPriceCurrency,
  17691. diId = _dto.DiId,
  17692. ManagerConfirm = 0,
  17693. SupervisorConfirm = 0,
  17694. SYsupervisorConfirm = 0,
  17695. editType = 1,
  17696. PortType = 1,
  17697. price = _dto.CardPrice,
  17698. PriceCount = 1,
  17699. priceType = 1027,
  17700. priceDetailType = 1044,
  17701. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17702. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17703. });
  17704. }
  17705. }
  17706. }
  17707. start_Time = start_Time.AddDays(1);
  17708. }
  17709. }
  17710. if (extraCostList.Any())
  17711. {
  17712. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17713. }
  17714. _sqlSugar.CommitTran();
  17715. #endregion
  17716. #region 应用推送
  17717. try
  17718. {
  17719. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17720. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17721. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17722. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17723. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17724. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17725. var diId = _dto.DiId;
  17726. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17727. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17728. #region 操作记录
  17729. var opInfo = new Crm_TableOperationRecord()
  17730. {
  17731. TableName = "Grp_HotelReservations",
  17732. PortType = _dto.PortType,
  17733. DataId = hotelId,
  17734. CreateUserId = _dto.UserId
  17735. };
  17736. //var opStatus = OperationEnum.NoOperation;
  17737. if (_dto.Id < 1) //添加操作
  17738. {
  17739. opInfo.OperationItem = OperationEnum.Add;
  17740. }
  17741. else if (_dto.Id > 0)
  17742. {
  17743. opInfo.OperationItem = OperationEnum.Edit;
  17744. }
  17745. string opRemark = string.Empty;
  17746. if (ccpInfo != null)
  17747. {
  17748. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17749. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17750. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17751. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17752. }
  17753. opInfo.Remark = opRemark;
  17754. await _tableorRep.AddAsync(opInfo);
  17755. #endregion
  17756. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17757. //2024-10-21 新增LZ UID
  17758. var userIds = new List<int>() { 21 };
  17759. string title = $"费用审核";
  17760. string content = "";
  17761. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17762. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17763. try
  17764. {
  17765. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17766. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17767. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17768. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17769. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17770. }
  17771. catch (Exception ex)
  17772. {
  17773. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17774. }
  17775. }
  17776. catch (Exception ex)
  17777. {
  17778. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17779. }
  17780. try
  17781. {
  17782. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17783. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17784. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17785. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17786. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17787. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17788. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17789. //自动审核
  17790. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17791. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17792. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17793. //2024-10-21 新增LZ UID
  17794. var userIds = new List<int>() { 21 };
  17795. string title = $"系统通知";
  17796. var diId = _dto.DiId;
  17797. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17798. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17799. string content = "";
  17800. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17801. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17802. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17803. }
  17804. catch (Exception ex)
  17805. {
  17806. }
  17807. #endregion
  17808. return Ok(_view);
  17809. }
  17810. /// <summary>
  17811. /// 酒店自动审核测试
  17812. /// Add Or Edit
  17813. /// </summary>
  17814. /// <param name="diid"></param>
  17815. /// <param name="dataId"></param>
  17816. /// <returns></returns>
  17817. [HttpPost]
  17818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17819. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17820. {
  17821. #region 应用推送
  17822. try
  17823. {
  17824. //自动审核
  17825. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17826. }
  17827. catch (Exception ex)
  17828. {
  17829. return Ok(JsonView(false, ex.Message));
  17830. }
  17831. #endregion
  17832. return Ok(JsonView(false, "操作成功"));
  17833. }
  17834. /// <summary>
  17835. /// 酒店预订
  17836. /// Del
  17837. /// </summary>
  17838. /// <param name="_dto"></param>
  17839. /// <returns></returns>
  17840. [HttpPost]
  17841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17842. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17843. {
  17844. #region 参数验证
  17845. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17846. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17847. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17848. #region 团组操作权限验证 76 酒店预定模块
  17849. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17850. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17851. #endregion
  17852. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17853. #region 页面操作权限验证
  17854. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17855. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17856. #endregion
  17857. #endregion
  17858. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  17859. #region 操作记录
  17860. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17861. {
  17862. TableName = "Grp_HotelReservations",
  17863. PortType = _dto.PortType,
  17864. OperationItem = OperationEnum.Del,
  17865. DataId = _dto.Id,
  17866. CreateUserId = _dto.UserId
  17867. });
  17868. #endregion
  17869. return Ok(data);
  17870. }
  17871. /// <summary>
  17872. /// 酒店预订
  17873. /// 生成VOUCHER
  17874. /// 2024.05.06 之前版本
  17875. /// </summary>
  17876. /// <param name="_dto"></param>
  17877. /// <returns></returns>
  17878. [HttpPost]
  17879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17880. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17881. {
  17882. try
  17883. {
  17884. #region 参数验证
  17885. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17886. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17887. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17888. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17889. #region 团组操作权限验证 76 酒店预定模块
  17890. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17891. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17892. #endregion
  17893. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17894. #region 页面操作权限验证
  17895. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17896. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17897. #endregion
  17898. #endregion
  17899. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17900. //判断数据是否完整
  17901. if (hr != null)
  17902. {
  17903. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17904. {
  17905. string strFileName = "HotelStatement/";
  17906. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17907. if (dele != null)
  17908. strFileName += dele.TourCode;
  17909. //载入模板
  17910. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17911. Document doc = new Document(sss);
  17912. DocumentBuilder builder = new DocumentBuilder(doc);
  17913. #region 替换Word模板书签内容
  17914. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17915. //入住卷预定号码
  17916. if (doc.Range.Bookmarks["VNO"] != null)
  17917. {
  17918. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17919. mark.Text = hr.CheckNumber;
  17920. }
  17921. //酒店时间
  17922. if (doc.Range.Bookmarks["Date"] != null)
  17923. {
  17924. Bookmark mark = doc.Range.Bookmarks["Date"];
  17925. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17926. }
  17927. //团号
  17928. if (doc.Range.Bookmarks["TNo"] != null)
  17929. {
  17930. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17931. mark.Text = dele.TourCode;
  17932. }
  17933. //预定号码
  17934. if (doc.Range.Bookmarks["BookingId"] != null)
  17935. {
  17936. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17937. mark.Text = hr.ReservationsNo;
  17938. }
  17939. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17940. {
  17941. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17942. mark.Text = hr.DetermineNo;
  17943. }
  17944. //酒店城市
  17945. if (doc.Range.Bookmarks["City"] != null)
  17946. {
  17947. Bookmark mark = doc.Range.Bookmarks["City"];
  17948. mark.Text = hr.City;
  17949. }
  17950. //酒店名称
  17951. if (doc.Range.Bookmarks["HName"] != null)
  17952. {
  17953. Bookmark mark = doc.Range.Bookmarks["HName"];
  17954. mark.Text = hr.HotelName;
  17955. }
  17956. //酒店地址
  17957. if (doc.Range.Bookmarks["Address"] != null)
  17958. {
  17959. Bookmark mark = doc.Range.Bookmarks["Address"];
  17960. mark.Text = hr.HotelAddress;
  17961. }
  17962. //酒店电话
  17963. if (doc.Range.Bookmarks["Tel"] != null)
  17964. {
  17965. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17966. mark.Text = hr.HotelTel;
  17967. }
  17968. //酒店传真
  17969. if (doc.Range.Bookmarks["Fax"] != null)
  17970. {
  17971. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17972. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17973. {
  17974. mark.Text = hr.HotelFax;
  17975. }
  17976. }
  17977. //入住时间
  17978. if (doc.Range.Bookmarks["CIn"] != null)
  17979. {
  17980. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17981. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17982. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17983. }
  17984. //退房时间
  17985. if (doc.Range.Bookmarks["COut"] != null)
  17986. {
  17987. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17988. Bookmark mark = doc.Range.Bookmarks["COut"];
  17989. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17990. }
  17991. //客户名称
  17992. if (doc.Range.Bookmarks["GName"] != null)
  17993. {
  17994. string guestName = "";
  17995. string[] clients = Array.Empty<string>();
  17996. if (hr.GuestName.Contains(","))
  17997. {
  17998. clients = hr.GuestName.Split(",");
  17999. }
  18000. else
  18001. {
  18002. clients = new string[] { hr.GuestName };
  18003. }
  18004. List<int> clientIds_int = new List<int>();
  18005. if (clients.Length > 0)
  18006. {
  18007. foreach (var item in clients)
  18008. {
  18009. if (item.IsNumeric())
  18010. {
  18011. clientIds_int.Add(int.Parse(item));
  18012. }
  18013. }
  18014. }
  18015. if (clientIds_int.Count > 0)
  18016. {
  18017. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18018. foreach (var client in _clientDatas)
  18019. {
  18020. //男
  18021. if (client.Sex == 0) guestName += $"Mr.";
  18022. //女
  18023. else if (client.Sex == 1) guestName += $"Ms.";
  18024. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18025. {
  18026. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18027. }
  18028. //guestName += $"{client.Pinyin},";
  18029. }
  18030. if (guestName.Length > 0)
  18031. {
  18032. guestName = guestName.Substring(0, guestName.Length - 1);
  18033. }
  18034. }
  18035. else
  18036. {
  18037. guestName = hr.GuestName;
  18038. }
  18039. Bookmark mark = doc.Range.Bookmarks["GName"];
  18040. mark.Text = guestName;
  18041. }
  18042. //房间介绍
  18043. if (doc.Range.Bookmarks["ROOM"] != null)
  18044. {
  18045. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18046. mark.Text = hr.RoomExplanation;
  18047. }
  18048. //报价描述
  18049. if (doc.Range.Bookmarks["NOTE"] != null)
  18050. {
  18051. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18052. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18053. if (ss != null)
  18054. mark.Text = ss.Name;
  18055. }
  18056. //入住时间
  18057. if (doc.Range.Bookmarks["CheckIn"] != null)
  18058. {
  18059. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18060. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18061. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18062. }
  18063. //退房时间
  18064. if (doc.Range.Bookmarks["CheckOut"] != null)
  18065. {
  18066. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18067. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18068. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18069. }
  18070. //日期
  18071. if (doc.Range.Bookmarks["DT"] != null)
  18072. {
  18073. Bookmark mark = doc.Range.Bookmarks["DT"];
  18074. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18075. }
  18076. //名称
  18077. if (doc.Range.Bookmarks["VName"] != null)
  18078. {
  18079. Bookmark mark = doc.Range.Bookmarks["VName"];
  18080. mark.Text = hr.HotelName;
  18081. }
  18082. //号码
  18083. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18084. {
  18085. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18086. mark.Text = hr.CheckNumber;
  18087. }
  18088. #endregion
  18089. strFileName += "VOUCHER.doc";
  18090. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18091. doc.Save(fileDir);
  18092. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18093. return Ok(JsonView(true, "操作成功!", Url));
  18094. }
  18095. else
  18096. {
  18097. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18098. }
  18099. }
  18100. else
  18101. {
  18102. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18103. }
  18104. }
  18105. catch (Exception ex)
  18106. {
  18107. return Ok(JsonView(false, ex.Message));
  18108. }
  18109. }
  18110. /// <summary>
  18111. /// 酒店预订
  18112. /// 生成VOUCHER
  18113. /// 2024.05.06 之后版本
  18114. /// </summary>
  18115. /// <param name="_dto"></param>
  18116. /// <returns></returns>
  18117. [HttpPost]
  18118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18119. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  18120. {
  18121. #region 参数验证
  18122. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18123. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18124. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18125. #region 团组操作权限验证 76 酒店预定模块
  18126. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18127. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18128. #endregion
  18129. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18130. #region 页面操作权限验证
  18131. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18132. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18133. #endregion
  18134. #endregion
  18135. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  18136. //判断数据是否完整
  18137. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18138. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18139. string strFileName = "HotelStatement/";
  18140. string guestNames = ""; //格式Mr.xxx Ms.xxx
  18141. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  18142. #region 数据处理
  18143. List<int> guestIds = new List<int>();
  18144. //int index = 0;
  18145. foreach (var item in hrDtas)
  18146. {
  18147. if (item.GuestName.Contains(","))
  18148. {
  18149. string[] guestIdArr = item.GuestName.Split(',');
  18150. foreach (var guestIdStr in guestIdArr)
  18151. {
  18152. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  18153. if (guestBool)
  18154. {
  18155. guestIds.Add(guestId);
  18156. }
  18157. }
  18158. }
  18159. else guestNames += item.GuestName;
  18160. var voucherInfo = new HotelVoucherInfoView()
  18161. {
  18162. HotelName = item.HotelName,
  18163. CheckInDate = item.CheckInDate,
  18164. CheckOutDate = item.CheckOutDate,
  18165. ConfirmationNumber = item.DetermineNo.Trim(),
  18166. RoomType = item.RoomExplanation
  18167. };
  18168. vouchers.Add(voucherInfo);
  18169. }
  18170. if (guestIds.Count > 0)
  18171. {
  18172. guestIds = guestIds.Distinct().ToList();
  18173. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  18174. if (guestDatas.Count > 0)
  18175. {
  18176. guestNames = "";
  18177. foreach (var guest in guestDatas)
  18178. {
  18179. string guestName = "";
  18180. if (guest.Sex == 0) guestName += @"MR.";
  18181. else if (guest.Sex == 1) guestName += @"MS.";
  18182. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18183. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18184. guestNames += @$"{guestName.Trim()}、";
  18185. }
  18186. if (guestNames.Length > 0)
  18187. {
  18188. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18189. }
  18190. }
  18191. }
  18192. #endregion
  18193. //载入模板
  18194. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  18195. Document doc = new Document(sss);
  18196. DocumentBuilder builder = new DocumentBuilder(doc);
  18197. if (doc.Range.Bookmarks["GuestName"] != null)
  18198. {
  18199. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  18200. mark.Text = guestNames;
  18201. }
  18202. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18203. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  18204. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  18205. for (int i = 1; i <= vouchers.Count; i++)
  18206. {
  18207. HotelVoucherInfoView hviv = vouchers[i - 1];
  18208. builder.MoveToCell(0, i, 0, 0);
  18209. builder.Write(hviv.HotelName);
  18210. builder.MoveToCell(0, i, 1, 0);
  18211. builder.Write(hviv.CheckInDate);
  18212. builder.MoveToCell(0, i, 2, 0);
  18213. builder.Write(hviv.CheckOutDate);
  18214. builder.MoveToCell(0, i, 3, 0);
  18215. builder.Write(hviv.RoomType);
  18216. builder.MoveToCell(0, i, 4, 0);
  18217. builder.Write(hviv.ConfirmationNumber);
  18218. }
  18219. //删除多余行
  18220. int currRowIndex = vouchers.Count + 1;
  18221. int delRows = 21 - currRowIndex;
  18222. if (delRows > 0)
  18223. {
  18224. for (int i = 0; i < delRows; i++)
  18225. {
  18226. table.Rows.RemoveAt(currRowIndex);
  18227. //cultivateRowIndex++;
  18228. }
  18229. }
  18230. strFileName += "VOUCHER.docx";
  18231. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18232. doc.Save(fileDir);
  18233. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18234. return Ok(JsonView(true, "操作成功!", Url));
  18235. }
  18236. /// <summary>
  18237. /// 酒店预订
  18238. /// 生成VOUCHER 批量生成
  18239. /// New
  18240. /// </summary>
  18241. /// <param name="_dto"></param>
  18242. /// <returns></returns>
  18243. [HttpPost]
  18244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18245. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  18246. {
  18247. #region 参数验证
  18248. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18249. if (_dto.PageId < 1) _dto.PageId = 28;
  18250. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18251. #region 团组操作权限验证 76 酒店预定模块
  18252. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18253. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18254. #endregion
  18255. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18256. #region 页面操作权限验证
  18257. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18258. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18259. #endregion
  18260. #endregion
  18261. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  18262. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  18263. .OrderBy(x => x.CheckInDate)
  18264. .ToListAsync();
  18265. //判断数据是否完整
  18266. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18267. string strFileName = "HotelStatement/";
  18268. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18269. if (dele != null)
  18270. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  18271. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  18272. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  18273. .Where(it => it.IsDel == 0)
  18274. .ToListAsync();
  18275. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  18276. for (int i = 0; i < hrDtas.Count; i++)
  18277. {
  18278. string guestNames = string.Empty;
  18279. List<int> guestIds = new List<int>();
  18280. var item = hrDtas[i];
  18281. //处理客户姓名
  18282. if (item.GuestName.Contains(","))
  18283. {
  18284. string[] guestIdArr = item.GuestName.Split(',');
  18285. foreach (var guestIdStr in guestIdArr)
  18286. if (int.TryParse(guestIdStr, out int guestId))
  18287. guestIds.Add(guestId);
  18288. }
  18289. else
  18290. {
  18291. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  18292. if (guestIdBool)
  18293. {
  18294. guestIds.Add(guestId);
  18295. }
  18296. //NaN
  18297. if (item.GuestName.Contains("NaN"))
  18298. {
  18299. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  18300. }
  18301. }
  18302. if (guestIds.Count > 0)
  18303. {
  18304. guestIds = guestIds.Distinct().ToList();
  18305. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  18306. if (guestDatas1.Count > 0)
  18307. {
  18308. guestNames = "";
  18309. foreach (var guest in guestDatas1)
  18310. {
  18311. string guestName = "";
  18312. if (guest.Sex == 0) guestName += @"MR.";
  18313. else if (guest.Sex == 1) guestName += @"MS.";
  18314. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18315. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18316. guestNames += @$"{guestName.Trim()}、";
  18317. }
  18318. if (guestNames.Length > 0)
  18319. {
  18320. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18321. }
  18322. }
  18323. }
  18324. //if (!string.IsNullOrEmpty(guestNames))
  18325. //{
  18326. hrDtas[i].GuestName = guestNames;
  18327. //}
  18328. }
  18329. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  18330. Document doc = new Document();
  18331. DocumentBuilder builder = new DocumentBuilder(doc);
  18332. try
  18333. {
  18334. builder.MoveToDocumentStart();
  18335. foreach (var item in hrDtas)
  18336. {
  18337. //标题
  18338. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18339. builder.ParagraphFormat.LineSpacing = 1;
  18340. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18341. builder.ParagraphFormat.Style.Font.Size = 9;
  18342. builder.ParagraphFormat.Style.Font.Bold = true;
  18343. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18344. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  18345. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18346. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18347. builder.ParagraphFormat.LineSpacing = 1;
  18348. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18349. builder.ParagraphFormat.Style.Font.Size = 9;
  18350. builder.ParagraphFormat.Style.Font.Bold = true;
  18351. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  18352. builder.StartTable();
  18353. // 设置边框颜色
  18354. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  18355. //设置边框样式
  18356. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  18357. //表格
  18358. #region 第一行
  18359. builder.InsertCell();
  18360. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18361. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18362. //builder.CellFormat.AllowAutoFit = false;
  18363. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18364. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18365. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18366. builder.CellFormat.WrapText = true; //自动换行
  18367. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18368. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  18369. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18370. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18371. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18372. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18373. builder.Write("TOUR NO:");
  18374. builder.InsertCell();
  18375. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18376. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18377. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18378. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18379. builder.ParagraphFormat.Style.Font.Bold = false;
  18380. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18381. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18382. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18383. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18384. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18385. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18386. builder.Write($"{dele?.TourCode ?? "-"}");
  18387. builder.InsertCell();
  18388. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18389. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18390. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18391. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18392. builder.ParagraphFormat.Style.Font.Bold = false;
  18393. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18394. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18395. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18396. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18397. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18398. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18399. builder.Write($"CITY:");
  18400. builder.InsertCell();
  18401. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18402. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18403. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18404. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18405. builder.ParagraphFormat.Style.Font.Bold = false;
  18406. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18407. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18408. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18409. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18410. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18411. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18412. builder.Write($"{item.City}");
  18413. builder.EndRow();
  18414. #endregion
  18415. #region 第二行
  18416. builder.InsertCell();
  18417. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18418. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18419. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18420. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18421. builder.ParagraphFormat.Style.Font.Bold = false;
  18422. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18423. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18424. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18425. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18426. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18427. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18428. builder.Write("CONFIRMATION NO:");
  18429. builder.InsertCell();
  18430. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18431. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18432. builder.ParagraphFormat.Style.Font.Size = 8;
  18433. builder.ParagraphFormat.Style.Font.Bold = false;
  18434. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18435. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18436. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18437. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18438. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18439. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18440. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18441. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18442. builder.Write($"{item.DetermineNo}");
  18443. builder.InsertCell();
  18444. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18445. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18446. builder.InsertCell();
  18447. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18448. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18449. builder.EndRow();
  18450. #endregion
  18451. #region 第三行
  18452. builder.InsertCell();
  18453. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18454. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18455. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18456. builder.ParagraphFormat.Style.Font.Bold = false;
  18457. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18458. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18459. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18460. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18461. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18462. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18463. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18464. builder.Write($"HOTEL NAME:");
  18465. builder.InsertCell();
  18466. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18467. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18468. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18469. builder.ParagraphFormat.Style.Font.Bold = false;
  18470. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18471. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18472. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18473. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18474. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18475. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18476. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18477. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18478. builder.Write($"{item.HotelName}");
  18479. builder.InsertCell();
  18480. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18481. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18482. builder.InsertCell();
  18483. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18484. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18485. builder.EndRow();
  18486. #endregion
  18487. #region 第四行
  18488. builder.InsertCell();
  18489. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18490. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18491. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18492. builder.ParagraphFormat.Style.Font.Bold = false;
  18493. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18494. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18495. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18496. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18497. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18498. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18499. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18500. builder.Write($"HOTEL ADDRESS:");
  18501. builder.InsertCell();
  18502. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18503. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18504. builder.ParagraphFormat.Style.Font.Size = 8;
  18505. builder.ParagraphFormat.Style.Font.Bold = false;
  18506. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18507. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18508. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18509. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18510. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18511. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18512. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18513. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18514. builder.Write($"{item.HotelAddress}");
  18515. builder.InsertCell();
  18516. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18517. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18518. builder.InsertCell();
  18519. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18520. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18521. builder.EndRow();
  18522. #endregion
  18523. #region 第五行
  18524. builder.InsertCell();
  18525. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18526. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18527. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18528. builder.ParagraphFormat.Style.Font.Bold = false;
  18529. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18530. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18531. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18532. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18533. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18534. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18535. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18536. builder.Write("TEL:");
  18537. builder.InsertCell();
  18538. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18539. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18540. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18541. builder.ParagraphFormat.Style.Font.Bold = false;
  18542. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18543. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18544. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18545. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18546. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18547. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18548. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18549. builder.Write($"{item.HotelTel}");
  18550. builder.InsertCell();
  18551. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18552. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18553. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18554. builder.ParagraphFormat.Style.Font.Bold = false;
  18555. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18556. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18557. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18558. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18559. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18560. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18561. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18562. builder.Write($"FAX:");
  18563. builder.InsertCell();
  18564. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18565. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18566. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18567. builder.ParagraphFormat.Style.Font.Bold = false;
  18568. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18569. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18570. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18571. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18572. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18573. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18574. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18575. builder.Write($"{item.HotelFax}");
  18576. builder.EndRow();
  18577. #endregion
  18578. #region 第六行
  18579. builder.InsertCell();
  18580. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18581. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18582. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18583. builder.ParagraphFormat.Style.Font.Bold = false;
  18584. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18585. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18586. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18587. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18588. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18589. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18590. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18591. builder.Write("CHECK IN:");
  18592. builder.InsertCell();
  18593. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18594. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18595. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18596. builder.ParagraphFormat.Style.Font.Bold = false;
  18597. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18598. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18599. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18600. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18601. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18602. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18603. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18604. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18605. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18606. builder.Write($"{checkInStr}");
  18607. builder.InsertCell();
  18608. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18609. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18610. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18611. builder.ParagraphFormat.Style.Font.Bold = false;
  18612. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18613. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18614. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18615. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18616. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18617. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18618. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18619. builder.Write($"CHECK OUT:");
  18620. builder.InsertCell();
  18621. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18622. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18623. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18624. builder.ParagraphFormat.Style.Font.Bold = false;
  18625. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18626. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18627. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18628. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18629. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18630. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18631. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18632. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18633. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18634. builder.Write($"{checkOutStr}");
  18635. builder.EndRow();
  18636. #endregion
  18637. #region 第七行
  18638. builder.InsertCell();
  18639. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18640. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18641. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18642. builder.ParagraphFormat.Style.Font.Bold = false;
  18643. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18644. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18645. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18646. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18647. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18648. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18649. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18650. builder.Write($"GUEST NAME:");
  18651. builder.InsertCell();
  18652. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18653. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18654. builder.ParagraphFormat.Style.Font.Size = 8;
  18655. builder.ParagraphFormat.Style.Font.Bold = false;
  18656. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18657. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18658. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18659. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18660. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18661. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18662. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18663. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18664. builder.Write($"{item.GuestName.Trim()}");
  18665. builder.InsertCell();
  18666. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18667. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18668. builder.InsertCell();
  18669. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18670. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18671. builder.EndRow();
  18672. #endregion
  18673. #region 第八行
  18674. builder.InsertCell();
  18675. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18676. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18677. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18678. builder.ParagraphFormat.Style.Font.Bold = false;
  18679. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18680. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18681. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18682. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18683. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18684. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18685. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18686. builder.Write($"ROOM TYPE:");
  18687. builder.InsertCell();
  18688. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18689. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18690. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18691. builder.ParagraphFormat.Style.Font.Bold = false;
  18692. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18693. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18694. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18695. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18696. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18697. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18698. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18699. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18700. builder.Write($"{item.RoomExplanation}");
  18701. builder.InsertCell();
  18702. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18703. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18704. builder.InsertCell();
  18705. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18706. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18707. builder.EndRow();
  18708. #endregion
  18709. #region 第九行
  18710. builder.InsertCell();
  18711. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18712. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18713. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18714. builder.ParagraphFormat.Style.Font.Bold = false;
  18715. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18716. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18717. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18718. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18719. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18720. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18721. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18722. builder.Write($"NOTE:");
  18723. builder.InsertCell();
  18724. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18725. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18726. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18727. builder.ParagraphFormat.Style.Font.Bold = false;
  18728. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18729. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18730. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18731. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18732. 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.");
  18733. builder.InsertCell();
  18734. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18735. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18736. builder.InsertCell();
  18737. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18738. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18739. builder.EndRow();
  18740. #endregion
  18741. builder.EndTable();
  18742. //换行
  18743. builder.Writeln("");
  18744. builder.Writeln("");
  18745. }
  18746. #region 获取文档中的所有表格 设置文字自适应
  18747. // 获取文档中的所有表格。
  18748. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18749. {
  18750. // 遍历表格中的所有行。
  18751. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18752. {
  18753. foreach (Cell cell in row.Cells)
  18754. {
  18755. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18756. cellFormat.Width = 0;
  18757. }
  18758. }
  18759. }
  18760. #endregion
  18761. #region 设置页眉
  18762. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18763. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18764. if (System.IO.File.Exists(voucherHeaderPath))
  18765. {
  18766. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18767. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18768. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18769. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18770. // 调整图片位置
  18771. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18772. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18773. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18774. shape.Left = 0; // 将图片距离页面左边缘的距离
  18775. shape.Width = 81; // 设置图片宽度
  18776. shape.Height = 36; // 设置图片高度
  18777. }
  18778. //靠右
  18779. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18780. //// 设置页脚上下边距
  18781. //builder.PageSetup.HeaderDistance = 42;
  18782. // 添加页眉线
  18783. Aspose.Words.Border borderHeader = null;
  18784. try
  18785. {
  18786. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18787. }
  18788. catch (Exception e)
  18789. {
  18790. // TODO Auto-generated catch block
  18791. //e.printStackTrace();
  18792. }
  18793. borderHeader.Shadow = true;
  18794. borderHeader.DistanceFromText = 2;
  18795. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18796. #endregion
  18797. }
  18798. catch (Exception ex)
  18799. {
  18800. }
  18801. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18802. doc.Save(fileDir);
  18803. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18804. return Ok(JsonView(true, "操作成功!", Url));
  18805. }
  18806. /// <summary>
  18807. /// 酒店预订
  18808. /// 生成 预定成本 Excel
  18809. /// </summary>
  18810. /// <param name="_dto"></param>
  18811. /// <returns></returns>
  18812. [HttpPost]
  18813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18814. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18815. {
  18816. #region 参数验证
  18817. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18818. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18819. if (!vadalitorRes.IsValid)
  18820. {
  18821. var errors = new StringBuilder();
  18822. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18823. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18824. }
  18825. #region 团组操作权限验证 76 酒店预定模块
  18826. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18827. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18828. #endregion
  18829. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18830. #region 页面操作权限验证
  18831. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18832. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18833. #endregion
  18834. #endregion
  18835. decimal _rate = 1.00M;
  18836. string _currency = string.Empty;
  18837. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18838. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18839. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18840. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18841. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18842. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18843. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18844. if (_GroupCostParameter == null)
  18845. {
  18846. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18847. bool isIntType = int.TryParse(_currency, out int currId);
  18848. if (isIntType)
  18849. {
  18850. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18851. }
  18852. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18853. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18854. if (currInfo == null)
  18855. {
  18856. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18857. }
  18858. else _rate = currInfo.Rate;
  18859. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18860. {
  18861. _rate = _GroupCostParameter.Rate;
  18862. }
  18863. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18864. //string strFileName = "HotelStatement/";
  18865. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18866. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18867. var rateDatas = new List<dynamic>();
  18868. #region 数据处理
  18869. foreach (var item in hrDtas)
  18870. {
  18871. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18872. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18873. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18874. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18875. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18876. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18877. {
  18878. continue;
  18879. }
  18880. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18881. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18882. string singleRoomFeeStr = string.Empty,
  18883. doubleRoomFeeStr = string.Empty,
  18884. suiteRoomFeeStr = string.Empty,
  18885. otherRoomFeeStr = string.Empty,
  18886. payMoneyStr = string.Empty,
  18887. cardPriceStr = string.Empty;
  18888. if (roomCurr.Equals("CNY"))
  18889. {
  18890. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18891. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18892. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18893. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18894. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18895. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18896. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18897. }
  18898. else
  18899. {
  18900. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18901. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18902. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18903. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18904. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18905. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18906. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18907. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18908. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18909. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18910. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18911. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18912. if (ccpPaymentCurrency.Equals("CNY"))
  18913. {
  18914. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18915. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18916. }
  18917. else
  18918. {
  18919. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18920. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18921. }
  18922. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18923. if (hotelcardPriceCurrency.Equals("CNY"))
  18924. {
  18925. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18926. }
  18927. else
  18928. {
  18929. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18930. }
  18931. }
  18932. string breakfastPriceStr = string.Empty,
  18933. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18934. governmentRentStr = string.Empty,
  18935. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18936. cityTaxStr = string.Empty,
  18937. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18938. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18939. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18940. {
  18941. if (breakfastCurrency1.Equals("CNY"))
  18942. {
  18943. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18944. }
  18945. else
  18946. {
  18947. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18948. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18949. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18950. }
  18951. }
  18952. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18953. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18954. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18955. {
  18956. if (governmentRentCurrency.Equals("CNY"))
  18957. {
  18958. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18959. }
  18960. else
  18961. {
  18962. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18963. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18964. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18965. }
  18966. }
  18967. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18968. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18969. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18970. {
  18971. if (cityTaxStrCurrency1.Equals("CNY"))
  18972. {
  18973. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18974. }
  18975. else
  18976. {
  18977. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18978. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18979. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18980. }
  18981. }
  18982. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18983. int payDId = roomInfo?.PayDId ?? 0;
  18984. pcfds.Add(new HotelReservations_PCFD_View()
  18985. {
  18986. City = item.City,
  18987. HotelName = item.HotelName,
  18988. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18989. // SingleRoomCount = item.SingleRoomCount,
  18990. SingleRoomPrice = singleRoomFeeStr,
  18991. // DoubleRoomCount = item.DoubleRoomCount,
  18992. DoubleRoomPrice = doubleRoomFeeStr,
  18993. //SuiteRoomCount = item.SuiteRoomCount,
  18994. SuiteRoomPrice = suiteRoomFeeStr,
  18995. OtherRoomPrice = otherRoomFeeStr,
  18996. //OtherRoomCount = item.OtherRoomCount,
  18997. BreakfastPrice = breakfastPriceStr,
  18998. GovernmentRent = governmentRentStr,
  18999. CityTax = cityTaxStr,
  19000. RoomExplanation = item.RoomExplanation,
  19001. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19002. PayTime = roomInfo?.ConsumptionDate,
  19003. BankNo = roomInfo?.BankNo,
  19004. PayMoney = payMoneyStr,
  19005. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19006. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19007. CardPrice = cardPriceStr,
  19008. Remark = ccpInfo.Remark
  19009. });
  19010. }
  19011. #endregion
  19012. //载入模板
  19013. WorkbookDesigner designer = new WorkbookDesigner();
  19014. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19015. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19016. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19017. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19018. var rateDatas1 = rateDatas.Distinct();
  19019. var rateStr = string.Empty;
  19020. foreach (var item in rateDatas1)
  19021. {
  19022. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19023. }
  19024. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19025. designer.SetDataSource("Opertor", userInfo.CnName);
  19026. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19027. dt.TableName = "ViewMyHotelReservations";
  19028. designer.SetDataSource(dt);
  19029. designer.Process();
  19030. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19031. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19032. designer.Workbook.Save(serverPath);
  19033. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19034. #region 删除指定行
  19035. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19036. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19037. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19038. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19039. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19040. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19041. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19042. cssIndex = dt.Columns["CityTax"].Ordinal,
  19043. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19044. remarkIndex = dt.Columns["Remark"].Ordinal;
  19045. //删除指定列
  19046. foreach (DataRow item in dt.Rows)
  19047. {
  19048. string singleStr = item["SingleRoomPrice"].ToString();
  19049. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19050. if (containsDigitButNotZero1) singleDel = false;
  19051. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19052. string doubleStr = item["DoubleRoomPrice"].ToString();
  19053. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19054. if (containsDigitButNotZero2) doubleDel = false;
  19055. string suiteStr = item["SuiteRoomPrice"].ToString();
  19056. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19057. if (containsDigitButNotZero3) suiteDel = false;
  19058. string otherStr = item["OtherRoomPrice"].ToString();
  19059. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19060. if (containsDigitButNotZero4) otherDel = false;
  19061. string zcStr = item["BreakfastPrice"].ToString();
  19062. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19063. if (containsDigitButNotZero5) zcDel = false;
  19064. string dsStr = item["GovernmentRent"].ToString();
  19065. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19066. if (containsDigitButNotZero6) dsDel = false;
  19067. string cssStr = item["CityTax"].ToString();
  19068. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19069. if (containsDigitButNotZero7) cssDel = false;
  19070. string cpStr = item["ConsumptionPatterns"].ToString();
  19071. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19072. string remarkStr = item["Remark"].ToString();
  19073. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19074. }
  19075. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19076. DeleteColumn(serverPath, cpIndex, cpDel);
  19077. DeleteColumn(serverPath, dsIndex, dsDel);
  19078. DeleteColumn(serverPath, cssIndex, cssDel);
  19079. DeleteColumn(serverPath, zcIndex, zcDel);
  19080. DeleteColumn(serverPath, otherIndex, otherDel);
  19081. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19082. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19083. DeleteColumn(serverPath, singleIndex, singleDel);
  19084. #endregion
  19085. //只保留第一个表格
  19086. DeleteSheet(serverPath);
  19087. return Ok(JsonView(true, "操作成功", url = rst));
  19088. }
  19089. else
  19090. {
  19091. _currency = _GroupCostParameter.Currency;
  19092. bool isIntType = int.TryParse(_currency, out int currId);
  19093. if (isIntType)
  19094. {
  19095. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19096. }
  19097. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19098. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19099. if (currInfo == null)
  19100. {
  19101. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19102. }
  19103. if (!_currency.ToUpper().Equals("CNY"))
  19104. {
  19105. _rate = _GroupCostParameter.Rate;
  19106. }
  19107. _rate = currInfo.Rate;
  19108. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19109. //string strFileName = "HotelStatement/";
  19110. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19111. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19112. #region 数据处理
  19113. foreach (var item in hrDtas)
  19114. {
  19115. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19116. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19117. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19118. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19119. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19120. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19121. string singleRoomFeeStr = string.Empty,
  19122. doubleRoomFeeStr = string.Empty,
  19123. suiteRoomFeeStr = string.Empty,
  19124. otherRoomFeeStr = string.Empty,
  19125. payMoneyStr = string.Empty,
  19126. cardPriceStr = string.Empty;
  19127. if (roomCurr.Equals(_currency))
  19128. {
  19129. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  19130. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  19131. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  19132. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  19133. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  19134. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  19135. }
  19136. else
  19137. {
  19138. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19139. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19140. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19141. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19142. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19143. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19144. }
  19145. string breakfastPriceStr = string.Empty,
  19146. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19147. governmentRentStr = string.Empty,
  19148. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19149. cityTaxStrStr = string.Empty,
  19150. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19151. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  19152. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  19153. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  19154. int payDId = roomInfo?.PayDId ?? 0;
  19155. pcfds.Add(new HotelReservations_PCFD_View()
  19156. {
  19157. City = item.City,
  19158. HotelName = item.HotelName,
  19159. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19160. // SingleRoomCount = item.SingleRoomCount,
  19161. SingleRoomPrice = singleRoomFeeStr,
  19162. // DoubleRoomCount = item.DoubleRoomCount,
  19163. DoubleRoomPrice = doubleRoomFeeStr,
  19164. //SuiteRoomCount = item.SuiteRoomCount,
  19165. SuiteRoomPrice = suiteRoomFeeStr,
  19166. OtherRoomPrice = otherRoomFeeStr,
  19167. //OtherRoomCount = item.OtherRoomCount,
  19168. BreakfastPrice = breakfastPriceStr,
  19169. GovernmentRent = governmentRentStr,
  19170. CityTax = cityTaxStrStr,
  19171. RoomExplanation = item.RoomExplanation,
  19172. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19173. PayTime = roomInfo?.ConsumptionDate,
  19174. BankNo = roomInfo?.BankNo,
  19175. PayMoney = payMoneyStr,
  19176. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19177. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19178. CardPrice = cardPriceStr,
  19179. Remark = ccpInfo.Remark
  19180. });
  19181. }
  19182. #endregion
  19183. //载入模板
  19184. WorkbookDesigner designer = new WorkbookDesigner();
  19185. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19186. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19187. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19188. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19189. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  19190. designer.SetDataSource("Opertor", userInfo.CnName);
  19191. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19192. dt.TableName = "ViewMyHotelReservations";
  19193. designer.SetDataSource(dt);
  19194. designer.Process();
  19195. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19196. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19197. designer.Workbook.Save(serverPath);
  19198. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19199. #region 删除指定行
  19200. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19201. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19202. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19203. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19204. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19205. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19206. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19207. cssIndex = dt.Columns["CityTax"].Ordinal,
  19208. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19209. remarkIndex = dt.Columns["Remark"].Ordinal;
  19210. //删除指定列
  19211. foreach (DataRow item in dt.Rows)
  19212. {
  19213. string singleStr = item["SingleRoomPrice"].ToString();
  19214. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19215. if (containsDigitButNotZero1) singleDel = false;
  19216. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19217. string doubleStr = item["DoubleRoomPrice"].ToString();
  19218. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19219. if (containsDigitButNotZero2) doubleDel = false;
  19220. string suiteStr = item["SuiteRoomPrice"].ToString();
  19221. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19222. if (containsDigitButNotZero3) suiteDel = false;
  19223. string otherStr = item["OtherRoomPrice"].ToString();
  19224. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19225. if (containsDigitButNotZero4) otherDel = false;
  19226. string zcStr = item["BreakfastPrice"].ToString();
  19227. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19228. if (containsDigitButNotZero5) zcDel = false;
  19229. string dsStr = item["GovernmentRent"].ToString();
  19230. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19231. if (containsDigitButNotZero6) dsDel = false;
  19232. string cssStr = item["CityTax"].ToString();
  19233. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19234. if (containsDigitButNotZero7) cssDel = false;
  19235. string cpStr = item["ConsumptionPatterns"].ToString();
  19236. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19237. string remarkStr = item["Remark"].ToString();
  19238. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19239. }
  19240. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19241. DeleteColumn(serverPath, cpIndex, cpDel);
  19242. DeleteColumn(serverPath, dsIndex, dsDel);
  19243. DeleteColumn(serverPath, cssIndex, cssDel);
  19244. DeleteColumn(serverPath, zcIndex, zcDel);
  19245. DeleteColumn(serverPath, otherIndex, otherDel);
  19246. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19247. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19248. DeleteColumn(serverPath, singleIndex, singleDel);
  19249. #endregion
  19250. //只保留第一个表格
  19251. DeleteSheet(serverPath);
  19252. return Ok(JsonView(true, "操作成功", url = rst));
  19253. }
  19254. //return Ok(JsonView(false));
  19255. }
  19256. /// <summary>
  19257. /// 删除指定列
  19258. /// </summary>
  19259. /// <param name="file"></param>
  19260. /// <param name="columnIndex"></param>
  19261. /// <param name="isDel"></param>
  19262. private void DeleteColumn(string file, int columnIndex, bool isDel)
  19263. {
  19264. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19265. //wb.Save(file);
  19266. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  19267. if (sheet1 != null)
  19268. {
  19269. if (isDel)
  19270. {
  19271. Cells cells = sheet1.Cells;
  19272. cells.DeleteColumn(columnIndex);
  19273. }
  19274. }
  19275. wb.Save(file);
  19276. }
  19277. /// <summary>
  19278. /// 删除sheet
  19279. /// </summary>
  19280. /// <param name="file"></param>
  19281. private void DeleteSheet(string file)
  19282. {
  19283. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19284. //wb.Save(file);
  19285. List<string> sheets = new List<string>();
  19286. foreach (var item in wb.Worksheets)
  19287. {
  19288. sheets.Add(item.Name);
  19289. }
  19290. if (sheets.Count > 0)
  19291. {
  19292. sheets.RemoveAt(0);//不删除第一个sheet
  19293. foreach (var item in sheets)
  19294. {
  19295. wb.Worksheets.RemoveAt(item);
  19296. }
  19297. }
  19298. wb.Save(file);
  19299. }
  19300. /// <summary>
  19301. /// 酒店预订
  19302. /// 确认单
  19303. /// </summary>
  19304. /// <param name="_dto"></param>
  19305. /// <returns></returns>
  19306. [HttpPost]
  19307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19308. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  19309. {
  19310. try
  19311. {
  19312. #region 参数验证
  19313. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19314. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19315. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19316. #region 团组操作权限验证 76 酒店预定模块
  19317. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19318. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19319. #endregion
  19320. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19321. #region 页面操作权限验证
  19322. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19323. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19324. #endregion
  19325. #endregion
  19326. //团组信息
  19327. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  19328. //酒店数据
  19329. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  19330. if (listhoteldata.Count < 0)
  19331. {
  19332. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  19333. }
  19334. //利datatable存储
  19335. DataTable dt = new DataTable();
  19336. dt.Columns.Add("CheckInDate", typeof(string));
  19337. dt.Columns.Add("City", typeof(string));
  19338. dt.Columns.Add("Hotel", typeof(string));
  19339. dt.Columns.Add("Room", typeof(string));
  19340. for (int i = 0; i < listhoteldata.Count; i++)
  19341. {
  19342. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  19343. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  19344. while (dayStart < dayEnd)
  19345. {
  19346. string temp = "";
  19347. DataRow row = dt.NewRow();
  19348. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  19349. row["City"] = listhoteldata[i].City;
  19350. row["Hotel"] = listhoteldata[i].HotelName;
  19351. if (listhoteldata[i].SingleRoomCount > 0)
  19352. {
  19353. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  19354. }
  19355. if (listhoteldata[i].DoubleRoomCount > 0)
  19356. {
  19357. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  19358. }
  19359. if (listhoteldata[i].SuiteRoomCount > 0)
  19360. {
  19361. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  19362. }
  19363. if (listhoteldata[i].OtherRoomCount > 0)
  19364. {
  19365. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  19366. }
  19367. row["Room"] = temp;
  19368. dt.Rows.Add(row);
  19369. dayStart = dayStart.AddDays(1);
  19370. }
  19371. }
  19372. Dictionary<string, string> dic = new Dictionary<string, string>();
  19373. dic.Add("Dele", di.TeamName);
  19374. dic.Add("City", di.VisitCountry);
  19375. //模板路径
  19376. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  19377. //载入模板
  19378. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  19379. DocumentBuilder builder = new DocumentBuilder(doc);
  19380. foreach (var key in dic.Keys)
  19381. {
  19382. builder.MoveToBookmark(key);
  19383. builder.Write(dic[key]);
  19384. }
  19385. //获取word里所有表格
  19386. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19387. //获取所填表格的序数
  19388. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19389. var rowStart = tableOne.Rows[0]; //获取第1行
  19390. //循环赋值
  19391. for (int i = 0; i < dt.Rows.Count; i++)
  19392. {
  19393. builder.MoveToCell(0, i + 1, 0, 0);
  19394. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  19395. builder.MoveToCell(0, i + 1, 1, 0);
  19396. builder.Write(dt.Rows[i]["City"].ToString());
  19397. builder.MoveToCell(0, i + 1, 2, 0);
  19398. builder.Write(dt.Rows[i]["Hotel"].ToString());
  19399. builder.MoveToCell(0, i + 1, 3, 0);
  19400. builder.Write(dt.Rows[i]["Room"].ToString());
  19401. }
  19402. //删除多余行
  19403. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  19404. {
  19405. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  19406. }
  19407. string strFileName = di.TeamName + "酒店确认单.doc";
  19408. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  19409. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  19410. return Ok(JsonView(true, "成功", url));
  19411. }
  19412. catch (Exception ex)
  19413. {
  19414. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  19415. }
  19416. }
  19417. #endregion
  19418. #region 团组状态
  19419. /// <summary>
  19420. /// 团组状态列表 Page
  19421. /// </summary>
  19422. /// <param name="dto">团组列表请求dto</param>
  19423. /// <returns></returns>
  19424. [HttpPost]
  19425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19426. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  19427. {
  19428. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19429. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  19430. {
  19431. string sqlWhere = string.Empty;
  19432. if (dto.IsSure == 0) //未完成
  19433. {
  19434. sqlWhere += string.Format(@" And IsSure = 0");
  19435. }
  19436. else if (dto.IsSure == 1) //已完成
  19437. {
  19438. sqlWhere += string.Format(@" And IsSure = 1");
  19439. }
  19440. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  19441. {
  19442. string tj = dto.SearchCriteria;
  19443. 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}%')",
  19444. tj, tj, tj, tj, tj);
  19445. }
  19446. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19447. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19448. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19449. From (
  19450. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19451. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19452. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19453. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19454. From Grp_DelegationInfo gdi
  19455. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19456. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19457. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19458. Where gdi.IsDel = 0 {0}
  19459. ) temp ", sqlWhere);
  19460. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19461. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19462. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19463. }
  19464. else
  19465. {
  19466. return Ok(JsonView(false, "查询失败"));
  19467. }
  19468. }
  19469. /// <summary>
  19470. /// 团组状态
  19471. /// 设置操作完成
  19472. /// </summary>
  19473. /// <param name="dto">团组列表请求dto</param>
  19474. /// <returns></returns>
  19475. [HttpPost]
  19476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19477. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19478. {
  19479. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19480. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19481. {
  19482. Id = dto.Id,
  19483. IsSure = 1
  19484. };
  19485. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19486. .UpdateColumns(it => new { it.IsSure })
  19487. .WhereColumns(it => new { it.Id })
  19488. .ExecuteCommandAsync();
  19489. if (result > 0)
  19490. {
  19491. return Ok(JsonView(true, "操作完成!"));
  19492. }
  19493. return Ok(JsonView(false, "操作失败!"));
  19494. }
  19495. #endregion
  19496. #region 保险费用录入
  19497. /// <summary>
  19498. /// 根据团组Id查询保险费用列表
  19499. /// </summary>
  19500. /// <param name="dto"></param>
  19501. /// <returns></returns>
  19502. [HttpPost]
  19503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19504. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19505. {
  19506. Result groupData = await _customersRep.CustomersByDiId(dto);
  19507. if (groupData.Code != 0)
  19508. {
  19509. return Ok(JsonView(false, groupData.Msg));
  19510. }
  19511. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19512. }
  19513. /// <summary>
  19514. /// 根据保险费用Id查询保险费用详细
  19515. /// </summary>
  19516. /// <param name="dto"></param>
  19517. /// <returns></returns>
  19518. [HttpPost]
  19519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19520. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19521. {
  19522. try
  19523. {
  19524. Result groupData = await _customersRep.CustomersById(dto);
  19525. if (groupData.Code != 0)
  19526. {
  19527. return Ok(JsonView(false, groupData.Msg));
  19528. }
  19529. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19530. }
  19531. catch (Exception ex)
  19532. {
  19533. return Ok(JsonView(false, ex.Message));
  19534. }
  19535. }
  19536. /// <summary>
  19537. /// 保险费用录入页面初始化绑定
  19538. /// </summary>
  19539. /// <param name="dto"></param>
  19540. /// <returns></returns>
  19541. [HttpPost]
  19542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19543. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19544. {
  19545. try
  19546. {
  19547. Result groupData = await _customersRep.CustomersInitialize(dto);
  19548. if (groupData.Code != 0)
  19549. {
  19550. return Ok(JsonView(false, groupData.Msg));
  19551. }
  19552. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19553. }
  19554. catch (Exception ex)
  19555. {
  19556. return Ok(JsonView(false, ex.Message));
  19557. }
  19558. }
  19559. /// <summary>
  19560. /// 保险费用操作(Status:1.新增,2.修改)
  19561. /// </summary>
  19562. /// <param name="dto"></param>
  19563. /// <returns></returns>
  19564. [HttpPost]
  19565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19566. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19567. {
  19568. Result groupData = await _customersRep.OpCustomers(dto);
  19569. if (groupData.Code != 0)
  19570. {
  19571. return Ok(JsonView(false, groupData.Msg));
  19572. }
  19573. #region 应用推送
  19574. try
  19575. {
  19576. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19577. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19578. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19579. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19580. //自动审核
  19581. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19582. //2024-10-21 新增LZ UID
  19583. var userIds = new List<int>() { 21 };
  19584. string title = $"系统通知";
  19585. var diId = dto.DiId;
  19586. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19587. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19588. string content = "";
  19589. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19590. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19591. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19592. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19593. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19594. }
  19595. catch (Exception ex)
  19596. {
  19597. }
  19598. #endregion
  19599. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19600. }
  19601. /// <summary>
  19602. /// 保险文件上传
  19603. /// </summary>
  19604. /// <param name="file"></param>
  19605. /// <returns></returns>
  19606. [HttpPost]
  19607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19608. public async Task<IActionResult> UploadCus(IFormFile file)
  19609. {
  19610. try
  19611. {
  19612. if (file != null)
  19613. {
  19614. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19615. //文件名称
  19616. string projectFileName = file.FileName;
  19617. //上传的文件的路径
  19618. string filePath = "";
  19619. if (!Directory.Exists(fileDir))
  19620. {
  19621. Directory.CreateDirectory(fileDir);
  19622. }
  19623. //上传的文件的路径
  19624. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19625. using (FileStream fs = System.IO.File.Create(filePath))
  19626. {
  19627. file.CopyTo(fs);
  19628. fs.Flush();
  19629. }
  19630. return Ok(JsonView(true, "上传成功!", projectFileName));
  19631. }
  19632. else
  19633. {
  19634. return Ok(JsonView(false, "上传失败!"));
  19635. }
  19636. }
  19637. catch (Exception ex)
  19638. {
  19639. return Ok(JsonView(false, ex.Message));
  19640. }
  19641. }
  19642. /// <summary>
  19643. /// 保险删除指定文件
  19644. /// </summary>
  19645. /// <param name="dto"></param>
  19646. /// <returns></returns>
  19647. [HttpPost]
  19648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19649. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19650. {
  19651. try
  19652. {
  19653. string filePath = "";
  19654. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19655. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19656. //int id = 0;
  19657. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19658. // 删除该文件
  19659. try
  19660. {
  19661. System.IO.File.Delete(filePath);
  19662. 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()
  19663. {
  19664. Attachment = "",
  19665. }).ExecuteCommandAsync();
  19666. if (result != 0)
  19667. {
  19668. return Ok(JsonView(true, "成功!"));
  19669. }
  19670. else
  19671. {
  19672. return Ok(JsonView(false, "失败!"));
  19673. }
  19674. }
  19675. catch (Exception)
  19676. {
  19677. 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()
  19678. {
  19679. Attachment = "",
  19680. }).ExecuteCommandAsync();
  19681. if (result != 0)
  19682. {
  19683. return Ok(JsonView(true, "成功!"));
  19684. }
  19685. else
  19686. {
  19687. return Ok(JsonView(false, "失败!"));
  19688. }
  19689. }
  19690. }
  19691. catch (Exception ex)
  19692. {
  19693. return Ok(JsonView(false, "程序错误!"));
  19694. throw;
  19695. }
  19696. }
  19697. /// <summary>
  19698. /// 保险费用操作(删除)
  19699. /// </summary>
  19700. /// <param name="dto"></param>
  19701. /// <returns></returns>
  19702. [HttpPost]
  19703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19704. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19705. {
  19706. try
  19707. {
  19708. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19709. if (!res)
  19710. {
  19711. return Ok(JsonView(false, "删除失败"));
  19712. }
  19713. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19714. {
  19715. IsDel = 1,
  19716. DeleteUserId = dto.DeleteUserId,
  19717. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19718. }).ExecuteCommandAsync();
  19719. return Ok(JsonView(true, "删除成功!"));
  19720. }
  19721. catch (Exception ex)
  19722. {
  19723. return Ok(JsonView(false, "程序错误!"));
  19724. throw;
  19725. }
  19726. }
  19727. #endregion
  19728. #region 接团客户名单 PageId 104
  19729. /// <summary>
  19730. /// 接团客户名单
  19731. /// 迁移数据(慎用!)
  19732. /// </summary>
  19733. /// <returns></returns>
  19734. [HttpPost]
  19735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19736. public async Task<IActionResult> PostTourClientListChange()
  19737. {
  19738. try
  19739. {
  19740. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19741. //var groupClinetData1
  19742. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19743. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19744. int updateCount = 0;
  19745. if (oldOAClientList.Count > 0)
  19746. {
  19747. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19748. _sqlSugar.BeginTran();
  19749. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19750. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19751. foreach (var item in oldOAClientList)
  19752. {
  19753. int comId = 0;
  19754. string format = "yyyy-MM-dd HH:mm:ss";
  19755. string data11 = "1990-01-01 00:00";
  19756. var data1 = IsValidDate(item.OPdate, format);
  19757. if (data1) data11 = item.OPdate;
  19758. //客户公司验证
  19759. if (!string.IsNullOrEmpty(item.Company))
  19760. {
  19761. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19762. if (clientComInfo == null) // add
  19763. {
  19764. var addInfo = new Crm_CustomerCompany()
  19765. {
  19766. CompanyAbbreviation = "",
  19767. CompanyFullName = item.Company,
  19768. Address = "",
  19769. PostCodes = "",
  19770. LastedOpUserId = item.OPer,
  19771. LastedOpDt = Convert.ToDateTime(data11),
  19772. CreateUserId = item.OPer,
  19773. CreateTime = Convert.ToDateTime(data11),
  19774. IsDel = 0
  19775. };
  19776. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19777. if (comId1 > 0) comId = comId1;
  19778. }
  19779. else comId = clientComInfo.Id;
  19780. }
  19781. //客户人员验证
  19782. int clientId = 0;
  19783. string name = item.LastName + item.Name;
  19784. if (!string.IsNullOrEmpty(name))
  19785. {
  19786. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19787. if (clientInfo == null)
  19788. {
  19789. DateTime? dateTime = null;
  19790. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19791. if (isDt) dateTime = birthDayDt;
  19792. var addInfo1 = new Crm_DeleClient()
  19793. {
  19794. CrmCompanyId = comId,
  19795. DiId = -1,
  19796. LastName = item.LastName,
  19797. FirstName = item.Name,
  19798. OldName = "",
  19799. Pinyin = item.Pinyin,
  19800. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19801. Marriage = 0,
  19802. Phone = item.Phone,
  19803. Job = item.Job,
  19804. BirthDay = dateTime
  19805. };
  19806. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19807. if (clientId1 > 0) clientId = clientId1;
  19808. }
  19809. else clientId = clientInfo.Id;
  19810. }
  19811. if (clientId < 1)
  19812. {
  19813. continue;
  19814. }
  19815. int airType = 0;
  19816. if (item.AirType == "超经舱") airType = 459;
  19817. else if (item.AirType == "公务舱") airType = 458;
  19818. else if (item.AirType == "经济舱") airType = 460;
  19819. else if (item.AirType == "其他") airType = 565;
  19820. else if (item.AirType == "头等舱") airType = 457;
  19821. var _TourClientListEntity = new Grp_TourClientList()
  19822. {
  19823. DiId = item.Diid,
  19824. ClientId = clientId,
  19825. CreateUserId = item.OPer,
  19826. CreateTime = Convert.ToDateTime(data11),
  19827. Remark = item.Remark,
  19828. IsDel = item.Isdel,
  19829. ShippingSpaceTypeId = airType,
  19830. ShippingSpaceSpecialNeeds = item.AirRemark,
  19831. HotelSpecialNeeds = item.RoomType
  19832. };
  19833. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19834. if (_TourClientList > 0)
  19835. {
  19836. updateCount++;
  19837. }
  19838. }
  19839. _sqlSugar.CommitTran();
  19840. }
  19841. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19842. }
  19843. catch (Exception ex)
  19844. {
  19845. _sqlSugar.RollbackTran();
  19846. return Ok(JsonView(false, ex.Message));
  19847. }
  19848. //return Ok(JsonView(true));
  19849. }
  19850. private bool IsValidDate(string dateString, string format)
  19851. {
  19852. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  19853. }
  19854. /// <summary>
  19855. /// 接团客户名单
  19856. /// 根据团组Id查询List
  19857. /// </summary>
  19858. /// <param name="_dto"></param>
  19859. /// <returns></returns>
  19860. [HttpPost]
  19861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19862. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19863. {
  19864. #region 参数验证
  19865. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19866. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19867. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19868. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19869. #region 页面操作权限验证
  19870. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19871. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19872. #endregion
  19873. #endregion
  19874. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19875. if (viewData.Code != 0)
  19876. {
  19877. return Ok(JsonView(false, viewData.Msg));
  19878. }
  19879. return Ok(JsonView(viewData.Data));
  19880. }
  19881. /// <summary>
  19882. /// 接团客户名单
  19883. /// 基础数据 Init
  19884. /// </summary>
  19885. /// <param name="_dto"></param>
  19886. /// <returns></returns>
  19887. [HttpPost]
  19888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19889. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19890. {
  19891. #region 参数验证
  19892. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19893. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19894. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19895. #region 页面操作权限验证
  19896. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19897. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19898. #endregion
  19899. #endregion
  19900. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19901. }
  19902. /// <summary>
  19903. /// 接团客户名单
  19904. /// 根据 Id查询 Details
  19905. /// </summary>
  19906. /// <param name="_dto"></param>
  19907. /// <returns></returns>
  19908. [HttpPost]
  19909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19910. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19911. {
  19912. #region 参数验证
  19913. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19914. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19915. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19916. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19917. #region 页面操作权限验证
  19918. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19919. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19920. #endregion
  19921. #endregion
  19922. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19923. if (viewData.Code != 0)
  19924. {
  19925. return Ok(JsonView(false, viewData.Msg));
  19926. }
  19927. return Ok(JsonView(viewData.Data));
  19928. }
  19929. /// <summary>
  19930. /// 接团客户名单
  19931. /// Add Or Edit
  19932. /// </summary>
  19933. /// <param name="_dto"></param>
  19934. /// <returns></returns>
  19935. [HttpPost]
  19936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19937. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19938. {
  19939. #region 参数验证
  19940. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19941. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19942. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19943. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19944. #region 页面操作权限验证
  19945. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19946. if (_dto.Id == 0) //添加
  19947. {
  19948. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19949. }
  19950. else if (_dto.Id >= 0) //修改
  19951. {
  19952. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19953. }
  19954. #endregion
  19955. #endregion
  19956. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19957. if (viewData.Code != 0)
  19958. {
  19959. return Ok(JsonView(false, viewData.Msg));
  19960. }
  19961. return Ok(JsonView(true));
  19962. }
  19963. /// <summary>
  19964. /// 接团客户名单
  19965. /// json字符串 AddMultiple(添加多个)
  19966. /// </summary>
  19967. /// <param name="_dto"></param>
  19968. /// <returns></returns>
  19969. [HttpPost]
  19970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19971. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19972. {
  19973. #region 参数验证
  19974. string jsonLabel = _dto.JsonLabel;
  19975. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19976. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19977. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19978. #region 页面操作权限验证
  19979. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19980. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19981. #endregion
  19982. #endregion
  19983. var request = new TourClientListAddMultipleDto();
  19984. request.DiId = _dto.DiId;
  19985. request.UserId = _dto.UserId;
  19986. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19987. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19988. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19989. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19990. var infos = new List<TourClientListInfo>();
  19991. foreach (var data in datas)
  19992. {
  19993. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19994. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19995. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19996. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19997. {
  19998. continue;
  19999. }
  20000. infos.Add(new TourClientListInfo()
  20001. {
  20002. IsAccompany = 1,
  20003. LastName = lastName,
  20004. FirstName = firstName,
  20005. Pinyin = lastNameEn + @"/" + firstNameEn,
  20006. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20007. CompanyFullName = data.CompanyFullName,
  20008. Job = data.Job
  20009. });
  20010. }
  20011. if (infos.Any())
  20012. {
  20013. var viewData = await _tourClientListRep._AddMultiple(request);
  20014. if (viewData.Code != 0)
  20015. {
  20016. return Ok(JsonView(false, viewData.Msg));
  20017. }
  20018. return Ok(JsonView(true));
  20019. }
  20020. return Ok(JsonView(false));
  20021. }
  20022. /// <summary>
  20023. /// 接团客户名单
  20024. /// AddMultiple(添加多个)
  20025. /// </summary>
  20026. /// <param name="_dto"></param>
  20027. /// <returns></returns>
  20028. [HttpPost]
  20029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20030. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20031. {
  20032. #region 参数验证
  20033. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20034. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20035. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20036. #region 页面操作权限验证
  20037. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20038. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20039. #endregion
  20040. #endregion
  20041. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20042. if (viewData.Code != 0)
  20043. {
  20044. return Ok(JsonView(false, viewData.Msg));
  20045. }
  20046. return Ok(JsonView(true));
  20047. }
  20048. /// <summary>
  20049. /// 接团客户名单
  20050. /// Del
  20051. /// </summary>
  20052. /// <param name="_dto"></param>
  20053. /// <returns></returns>
  20054. [HttpPost]
  20055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20056. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20057. {
  20058. #region 参数验证
  20059. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20060. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20061. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20062. #region 页面操作权限验证
  20063. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20064. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20065. #endregion
  20066. #endregion
  20067. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20068. if (viewData.Code != 0)
  20069. {
  20070. return Ok(JsonView(false, viewData.Msg));
  20071. }
  20072. return Ok(JsonView(true));
  20073. }
  20074. /// <summary>
  20075. /// 接团客户名单
  20076. /// 文件下载 客户名单
  20077. /// </summary>
  20078. /// <param name="_dto"></param>
  20079. /// <returns></returns>
  20080. [HttpPost]
  20081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20082. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20083. {
  20084. #region 参数验证
  20085. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20086. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20087. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20088. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20089. #region 页面操作权限验证
  20090. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20091. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20092. #endregion
  20093. #endregion
  20094. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20095. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20096. From Grp_TourClientList tcl
  20097. Left Join
  20098. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20099. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20100. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20101. From Crm_DeleClient dc
  20102. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20103. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20104. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20105. Where dc.IsDel = 0) temp
  20106. On temp.DcId =tcl.ClientId
  20107. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20108. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20109. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20110. //载入模板
  20111. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20112. if (_dto.Language == 1)
  20113. {
  20114. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20115. }
  20116. //载入模板
  20117. var doc = new Document(tempPath);
  20118. DocumentBuilder builder = new DocumentBuilder(doc);
  20119. //获取word里所有表格
  20120. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20121. //获取所填表格的序数
  20122. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20123. var rowStart = tableOne.Rows[0]; //获取第1行
  20124. if (_dto.Language == 0)
  20125. {
  20126. //循环赋值
  20127. for (int i = 0; i < DcList.Count; i++)
  20128. {
  20129. EncryptionProcessor.DecryptProperties(DcList[i]);
  20130. builder.MoveToCell(0, i + 1, 0, 0);
  20131. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  20132. builder.MoveToCell(0, i + 1, 1, 0);
  20133. int sex = DcList[i].Sex;
  20134. string sexStr = string.Empty;
  20135. if (sex == 0) sexStr = "男";
  20136. else if (sex == 1) sexStr = "女";
  20137. else sexStr = "未设置";
  20138. builder.Write(sexStr);
  20139. builder.MoveToCell(0, i + 1, 2, 0);
  20140. string birthDay = DcList[i].BirthDay;
  20141. string birthDayStr = string.Empty;
  20142. if (!string.IsNullOrEmpty(birthDay))
  20143. {
  20144. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  20145. }
  20146. builder.Write(birthDayStr);
  20147. builder.MoveToCell(0, i + 1, 3, 0);
  20148. string company = "";
  20149. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20150. {
  20151. company = DcList[i].CompanyFullName.ToString();
  20152. }
  20153. builder.Write(company);
  20154. builder.MoveToCell(0, i + 1, 4, 0);
  20155. builder.Write(DcList[i].Job);
  20156. }
  20157. }
  20158. else if (_dto.Language == 1)
  20159. {
  20160. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  20161. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  20162. List<string> transArrayStr = new List<string>();
  20163. string transStrRes1 = "";
  20164. for (int i = 0; i < DcList.Count; i++)
  20165. {
  20166. var dc = DcList[i];
  20167. EncryptionProcessor.DecryptProperties(dc);
  20168. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  20169. if (dc.Job.Equals("暂无")) dc.Job = "-";
  20170. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  20171. if (DcList.Count - 1 == i) transStrRes1 += str1;
  20172. else transStrRes1 += $"{str1}|";
  20173. }
  20174. #region AI转英文
  20175. string jsonValue = JsonConvert.SerializeObject(DcList);
  20176. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  20177. List<SeedMessages> messages = new List<SeedMessages>()
  20178. {
  20179. new SeedMessages
  20180. {
  20181. Role = KimiRole.user,
  20182. Content = jsonValue + text
  20183. }
  20184. };
  20185. KiMiApiClient client = new KiMiApiClient();
  20186. var kimiApiResult = await client.SeedMessage(messages);
  20187. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20188. string clients = kimiApiResult_JObject["content"].ToString();
  20189. string startStr = "```json", endStr = "```";
  20190. // 判断并清除开头部分
  20191. if (clients.StartsWith(startStr))
  20192. {
  20193. clients = clients.Remove(0, startStr.Length);
  20194. }
  20195. // 判断并清除结尾部分
  20196. if (clients.EndsWith(endStr))
  20197. {
  20198. clients = clients.Remove(clients.Length - endStr.Length);
  20199. }
  20200. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  20201. //循环赋值
  20202. for (int i = 0; i < en_Json.Count; i++)
  20203. {
  20204. var dc = en_Json[i];
  20205. var dc1 = DcList.Find(x => x.Id == dc.Id);
  20206. string PYName = dc.FirstName + " " + dc.LastName;
  20207. builder.MoveToCell(0, i + 1, 0, 0);
  20208. builder.Write(PYName);
  20209. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  20210. builder.MoveToCell(0, i + 1, 1, 0);
  20211. builder.Write(sex);
  20212. DateTime birthDt;
  20213. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  20214. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20215. builder.MoveToCell(0, i + 1, 2, 0);
  20216. builder.Write(birthday);
  20217. string company = string.Empty, job = string.Empty;
  20218. company = dc.CompanyFullName;
  20219. job = dc.Job;
  20220. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  20221. {
  20222. //查询对照表
  20223. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  20224. if (tempCec != null)
  20225. {
  20226. company = tempCec.enName;
  20227. }
  20228. }
  20229. builder.MoveToCell(0, i + 1, 3, 0);
  20230. builder.Write(company);
  20231. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  20232. {
  20233. //查询对照表
  20234. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  20235. if (tempPec != null)
  20236. {
  20237. job = tempPec.enName;
  20238. }
  20239. }
  20240. builder.MoveToCell(0, i + 1, 4, 0);
  20241. builder.Write(job);
  20242. }
  20243. #endregion
  20244. #region 旧翻译英文处理
  20245. ////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";
  20246. //string transStrRes = "";
  20247. //if (transStrRes1.Length > 0)
  20248. //{
  20249. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  20250. //}
  20251. ////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
  20252. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  20253. ////List<string> transArray = new List<string> { };
  20254. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  20255. //if (transStrRes.Contains("|"))
  20256. //{
  20257. // string[] transArray1 = transStrRes.Split('|');
  20258. // if (transArray1.Length > 0)
  20259. // {
  20260. // foreach (var item in transArray1)
  20261. // {
  20262. // if (item.Contains("&"))
  20263. // {
  20264. // string[] transArray2 = item.Split('&');
  20265. // int index = 0;
  20266. // string companyName = "", job = "";
  20267. // if (transArray2.Length > 0)
  20268. // {
  20269. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  20270. // if (1 < transArray2.Length) companyName = transArray2[1];
  20271. // if (2 < transArray2.Length) job = transArray2[2];
  20272. // }
  20273. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  20274. // }
  20275. // }
  20276. // }
  20277. //}
  20278. ////循环赋值
  20279. //for (int i = 0; i < DcList.Count; i++)
  20280. //{
  20281. // string PYName = "";
  20282. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  20283. // {
  20284. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  20285. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  20286. // PYName = PY_First + " " + PY_Last;
  20287. // }
  20288. // else
  20289. // {
  20290. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  20291. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  20292. // PYName = PY_First + " " + PY_Last;
  20293. // }
  20294. // builder.MoveToCell(0, i + 1, 0, 0);
  20295. // builder.Write(PYName);
  20296. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  20297. // builder.MoveToCell(0, i + 1, 1, 0);
  20298. // builder.Write(sex);
  20299. // DateTime birthDt;
  20300. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  20301. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20302. // builder.MoveToCell(0, i + 1, 2, 0);
  20303. // builder.Write(birthday);
  20304. // string company = string.Empty, job = string.Empty;
  20305. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  20306. // if (dcTransInfo != null)
  20307. // {
  20308. // company = dcTransInfo.CompanyName;
  20309. // job = dcTransInfo.Job;
  20310. // }
  20311. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20312. // {
  20313. // //查询对照表
  20314. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  20315. // if (tempCec != null)
  20316. // {
  20317. // company = tempCec.enName;
  20318. // }
  20319. // //翻译
  20320. // else
  20321. // {
  20322. // }
  20323. // }
  20324. // builder.MoveToCell(0, i + 1, 3, 0);
  20325. // builder.Write(company);
  20326. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  20327. // {
  20328. // //查询对照表
  20329. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  20330. // if (tempPec != null)
  20331. // {
  20332. // job = tempPec.enName;
  20333. // }
  20334. // //翻译
  20335. // else
  20336. // {
  20337. // }
  20338. // }
  20339. // builder.MoveToCell(0, i + 1, 4, 0);
  20340. // builder.Write(job);
  20341. //}
  20342. #endregion
  20343. }
  20344. //删除多余行
  20345. while (tableOne.Rows.Count > DcList.Count + 1)
  20346. {
  20347. tableOne.Rows.RemoveAt(DcList.Count + 1);
  20348. }
  20349. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  20350. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  20351. doc.Save(fileDir);
  20352. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  20353. return Ok(JsonView(true, "操作成功!", Url));
  20354. }
  20355. private class TranslateInfo
  20356. {
  20357. public int Index { get; set; }
  20358. public string CompanyName { get; set; }
  20359. public string Job { get; set; }
  20360. }
  20361. [HttpPost]
  20362. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  20363. {
  20364. if (files.Count == 0)
  20365. {
  20366. return Ok(JsonView(false, "文件为空"));
  20367. }
  20368. KiMiApiClient KiMiApi = new KiMiApiClient();
  20369. var seedConter = await KiMiApi.UploadFilesAsync(files);
  20370. if (seedConter.Count == 0)
  20371. {
  20372. return Ok(JsonView(false, "上传结果为空!"));
  20373. }
  20374. var messages = new List<SeedMessages>
  20375. {
  20376. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  20377. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  20378. };
  20379. messages.InsertRange(1, seedConter);
  20380. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  20381. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20382. string clients = kimiApiResult_JObject["content"].ToString();
  20383. string startStr = "```json", endStr = "```";
  20384. // 判断并清除开头部分
  20385. if (clients.StartsWith(startStr))
  20386. {
  20387. clients = clients.Remove(0, startStr.Length);
  20388. }
  20389. // 判断并清除结尾部分
  20390. if (clients.EndsWith(endStr))
  20391. {
  20392. clients = clients.Remove(clients.Length - endStr.Length);
  20393. }
  20394. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  20395. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  20396. {
  20397. {"姓", "LastName" },
  20398. {"名", "FirstName" },
  20399. {"姓名拼音", "Pinyin" },
  20400. {"性别", "Sex" },
  20401. {"单位", "CompanyFullName" },
  20402. {"职务", "Job" },
  20403. {"出生日期", "Birthday" },
  20404. };
  20405. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  20406. foreach (var item in clients_JObject)
  20407. {
  20408. BaiduClientOCRView cdc = new BaiduClientOCRView();
  20409. foreach (var field in clientFieldMap.Keys)
  20410. {
  20411. if (item.TryGetValue(field, out JToken value))
  20412. {
  20413. var getValue = value.ToString();
  20414. System.Type type = cdc.GetType();
  20415. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  20416. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  20417. propertyInfo.SetValue(cdc, propertyValue);
  20418. }
  20419. }
  20420. crmClients.Add(cdc);
  20421. }
  20422. return Ok(JsonView(new
  20423. {
  20424. fileCount = files.Count,
  20425. UploadCount = seedConter.Count,
  20426. ApiResult = clients,
  20427. CrmClients = crmClients
  20428. }));
  20429. }
  20430. #endregion
  20431. #region 团组倒推表
  20432. /// <summary>
  20433. /// 倒推表基础数据
  20434. /// Init
  20435. /// </summary>
  20436. /// <returns></returns>
  20437. [HttpPost]
  20438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20439. public async Task<IActionResult> PostInvertedListInit()
  20440. {
  20441. var viewData = await _invertedListRep._Init();
  20442. if (viewData.Code != 0)
  20443. {
  20444. return Ok(JsonView(false, viewData.Msg));
  20445. }
  20446. return Ok(JsonView(viewData.Data));
  20447. }
  20448. /// <summary>
  20449. /// 倒推表
  20450. /// Info
  20451. /// </summary>
  20452. /// <param name="dto"></param>
  20453. /// <returns></returns>
  20454. [HttpPost]
  20455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20456. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20457. {
  20458. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20459. if (viewData.Code != 0)
  20460. {
  20461. return Ok(JsonView(false, viewData.Msg));
  20462. }
  20463. return Ok(JsonView(viewData.Data));
  20464. }
  20465. /// <summary>
  20466. /// 倒推表
  20467. /// Create
  20468. /// </summary>
  20469. /// <param name="dto"></param>
  20470. /// <returns></returns>
  20471. [HttpPost]
  20472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20473. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20474. {
  20475. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20476. if (viewData.Code != 0)
  20477. {
  20478. return Ok(JsonView(false, viewData.Msg));
  20479. }
  20480. return Ok(JsonView(viewData.Data));
  20481. }
  20482. /// <summary>
  20483. /// 倒推表
  20484. /// Update
  20485. /// </summary>
  20486. /// <param name="dto"></param>
  20487. /// <returns></returns>
  20488. [HttpPost]
  20489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20490. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20491. {
  20492. var viewData = await _invertedListRep._Update(dto);
  20493. if (viewData.Code != 0)
  20494. {
  20495. return Ok(JsonView(false, viewData.Msg));
  20496. }
  20497. return Ok(JsonView(viewData.Data));
  20498. }
  20499. /// <summary>
  20500. /// 倒推表
  20501. /// File Download
  20502. /// </summary>
  20503. /// <param name="dto"></param>
  20504. /// <returns></returns>
  20505. [HttpPost]
  20506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20507. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20508. {
  20509. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20510. if (info2.Code != 0)
  20511. {
  20512. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20513. }
  20514. var info1 = info2.Data as InvertedListInfoView;
  20515. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20516. string teamName = "";
  20517. if (info != null) teamName = info.TeamName;
  20518. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20519. var doc = new Document();
  20520. var builder = new DocumentBuilder(doc);
  20521. #region old insert
  20522. ////载入模板
  20523. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20524. //Document doc = new Document(tempPath);
  20525. //DocumentBuilder builder = new DocumentBuilder(doc);
  20526. //利用键值对存放数据
  20527. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20528. //dic.Add("TeamName", teamName);
  20529. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20530. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20531. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20532. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20533. //dic.Add("SQRemark", info1.ApprovalRemark);
  20534. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20535. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20536. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20537. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20538. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20539. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20540. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20541. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20542. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20543. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20544. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20545. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20546. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20547. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20548. //#region 填充word模板书签内容
  20549. //foreach (var key in dic.Keys)
  20550. //{
  20551. // builder.MoveToBookmark(key);
  20552. // builder.Write(dic[key]);
  20553. //}
  20554. //#endregion
  20555. #endregion
  20556. #region New Insert
  20557. string titleFont = $"仿宋",
  20558. contentFont = $"仿宋";
  20559. var fontColor = Color.FromArgb(64, 64, 64);
  20560. //设置标题 团组名称
  20561. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20562. builder.Font.Name = titleFont;
  20563. builder.Font.Color = fontColor;
  20564. builder.Font.Size = 12;
  20565. builder.Font.Bold = true;
  20566. builder.Writeln(teamName);
  20567. //设置副标题 团组出访时间
  20568. builder.Font.Size = 12;
  20569. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20570. builder.Writeln();
  20571. var backgroundColor = Color.FromArgb(199, 199, 199);
  20572. var table = builder.StartTable();
  20573. builder.InsertCell();
  20574. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20575. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20576. builder.CellFormat.Borders.LineWidth = 1;
  20577. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20578. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20579. builder.RowFormat.Height = 40;
  20580. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20581. builder.Font.Name = contentFont;
  20582. builder.Font.Size = 12;
  20583. builder.Font.Bold = true;
  20584. builder.Font.Color = fontColor;
  20585. builder.Write("时间");
  20586. builder.InsertCell();
  20587. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20588. builder.Write("流程");
  20589. builder.InsertCell();
  20590. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20591. builder.Write("说明");
  20592. builder.EndRow();
  20593. //报批资料准备
  20594. if (info1.IsSelectedAirportd)
  20595. {
  20596. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20597. }
  20598. //报批/提供送签资料
  20599. if (info1.IsSelectedApprovalData)
  20600. {
  20601. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20602. }
  20603. //出批件护照办理
  20604. if (info1.IsSelectedIssueApproval)
  20605. {
  20606. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20607. }
  20608. //签证资料准备
  20609. if (info1.IsSelectedVisaInfo)
  20610. {
  20611. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20612. }
  20613. //送签
  20614. if (info1.IsSelectedSendVisa)
  20615. {
  20616. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20617. }
  20618. //出签
  20619. if (info1.IsSelectedIssueVisa)
  20620. {
  20621. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20622. }
  20623. //机票
  20624. if (info1.IsSelectedAirTicket)
  20625. {
  20626. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20627. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20628. }
  20629. //酒店
  20630. if (info1.IsSelectedHotel)
  20631. {
  20632. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20633. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20634. }
  20635. //开行前会
  20636. if (info1.IsSelectedPreTripMeeting)
  20637. {
  20638. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20639. }
  20640. //送机
  20641. if (info1.IsSelectedAirportdDropOff)
  20642. {
  20643. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20644. }
  20645. builder.EndTable();
  20646. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20647. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20648. for (int i = 0; i < table.Rows.Count; i++)
  20649. {
  20650. var row = table.Rows[i];
  20651. //设置宽度
  20652. row.Cells[0].CellFormat.Width = 20.00;
  20653. row.Cells[1].CellFormat.Width = 30.00;
  20654. row.Cells[2].CellFormat.Width = 50.00;
  20655. if (i != 0)
  20656. {
  20657. //边框设置
  20658. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20659. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20660. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20661. }
  20662. }
  20663. #region 页脚插入图片
  20664. // 创建页脚
  20665. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20666. doc.FirstSection.HeadersFooters.Add(footer);
  20667. Paragraph para = new Paragraph(doc);
  20668. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20669. footer.AppendChild(para);
  20670. builder.MoveTo(para);
  20671. string imagePath = "./Images/FMGJ_Log.png";
  20672. builder.InsertImage(imagePath);
  20673. #endregion
  20674. #endregion
  20675. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20676. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20677. string filePath = fileDir + $@"InvertedList/{fileName}";
  20678. doc.Save(filePath);
  20679. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20680. return Ok(JsonView(true, "操作成功!", Url));
  20681. }
  20682. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20683. {
  20684. var fontColor = Color.FromArgb(64, 64, 64);
  20685. builder.InsertCell();
  20686. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20687. builder.RowFormat.Height = 40;
  20688. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20689. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20690. builder.Font.Name = fontName;
  20691. builder.Font.Size = 8;
  20692. builder.Font.Bold = true;
  20693. builder.Font.Color = fontColor;
  20694. builder.Write(dateTime);
  20695. builder.InsertCell();
  20696. builder.Font.Size = 9;
  20697. builder.Font.Bold = true;
  20698. builder.Font.Color = fontColor;
  20699. builder.Write(content);
  20700. builder.InsertCell();
  20701. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20702. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20703. builder.Font.Size = 9;
  20704. builder.Font.Bold = false;
  20705. builder.Font.Color = fontColor;
  20706. builder.Write(reamrk);
  20707. builder.EndRow();
  20708. }
  20709. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20710. {
  20711. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20712. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20713. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20714. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20715. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20716. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20717. }
  20718. #endregion
  20719. #region 会务倒推表
  20720. /// <summary>
  20721. /// 会务倒推表
  20722. /// Init
  20723. /// </summary>
  20724. /// <returns></returns>
  20725. [HttpPost]
  20726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20727. public async Task<IActionResult> InforRetrogressTableInit()
  20728. {
  20729. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20730. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20731. return Ok(JsonView(false, groupData.Msg));
  20732. }
  20733. /// <summary>
  20734. /// 会务倒推表
  20735. /// ExcelDownload
  20736. /// </summary>
  20737. /// <param name="dto"></param>
  20738. /// <returns></returns>
  20739. [HttpPost]
  20740. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20742. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20743. {
  20744. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20745. var validatorRes = await validator.ValidateAsync(dto);
  20746. if (!validatorRes.IsValid)
  20747. {
  20748. StringBuilder sb = new StringBuilder();
  20749. foreach (var item in validatorRes.Errors)
  20750. {
  20751. sb.AppendLine(item.ErrorMessage);
  20752. }
  20753. return Ok(JsonView(false, sb.ToString()));
  20754. }
  20755. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20756. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20757. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20758. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20759. #region Excel
  20760. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20761. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20762. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20763. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20764. var fileNamePrefix = string.Empty;
  20765. if (days >= 30)
  20766. {
  20767. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20768. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20769. }
  20770. else if (days < 30 && days > 7)
  20771. {
  20772. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20773. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20774. }
  20775. else if (days <= 7)
  20776. {
  20777. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20778. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20779. }
  20780. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20781. fileName = CommonFun.ValidFileName(fileName);
  20782. //载入模板
  20783. WorkbookDesigner designer = new WorkbookDesigner();
  20784. designer.Workbook = new Workbook(tempPath);
  20785. designer.Process();
  20786. if (!Directory.Exists(savePath))
  20787. {
  20788. Directory.CreateDirectory(savePath);
  20789. }
  20790. string serverPath = $"{savePath}{fileName}";
  20791. designer.Workbook.Save(serverPath);
  20792. string rst = $"{servicePath}{ftpPath}{fileName}";
  20793. #endregion
  20794. return Ok(JsonView(new { url = rst }));
  20795. }
  20796. #endregion
  20797. #region 三公签证费用(签证费、代办费)
  20798. /// <summary>
  20799. /// 三公签证费用(签证费、代办费)
  20800. /// List
  20801. /// </summary>
  20802. /// <returns></returns>
  20803. [HttpPost]
  20804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20805. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20806. {
  20807. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  20808. }
  20809. /// <summary>
  20810. /// 三公签证费用(签证费、代办费)
  20811. /// Add Or Update
  20812. /// </summary>
  20813. /// <returns></returns>
  20814. [HttpPost]
  20815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20816. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20817. {
  20818. var _view = await _visaFeeInfoRep.Update(_dto);
  20819. if (_view.Code != 0)
  20820. {
  20821. return Ok(JsonView(false, _view.Msg));
  20822. }
  20823. return Ok(JsonView(true, _view.Msg));
  20824. }
  20825. #endregion
  20826. #region 酒店询价
  20827. /// <summary>
  20828. /// 酒店询价
  20829. /// Init
  20830. /// </summary>
  20831. /// <returns></returns>
  20832. [HttpPost]
  20833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20834. public async Task<IActionResult> PostHotelInquiryInit()
  20835. {
  20836. var res = await _hotelInquiryRep._Init();
  20837. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20838. return Ok(JsonView(true, res.Msg, res.Data));
  20839. }
  20840. /// <summary>
  20841. /// 酒店询价
  20842. /// page Item
  20843. /// </summary>
  20844. /// <param name="_dto"></param>
  20845. /// <returns></returns>
  20846. [HttpPost]
  20847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20848. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20849. {
  20850. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20851. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20852. var view = res.Data as PageDataViewBase;
  20853. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20854. }
  20855. /// <summary>
  20856. /// 酒店询价
  20857. /// info
  20858. /// </summary>
  20859. /// <param name="_dto"></param>
  20860. /// <returns></returns>
  20861. [HttpPost]
  20862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20863. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20864. {
  20865. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20866. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20867. return Ok(JsonView(true, res.Msg, res.Data));
  20868. }
  20869. /// <summary>
  20870. /// 酒店询价
  20871. /// Add Or Edit
  20872. /// </summary>
  20873. /// <param name="_dto"></param>
  20874. /// <returns></returns>
  20875. [HttpPost]
  20876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20877. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20878. {
  20879. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20880. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20881. return Ok(JsonView(true, res.Msg, res.Data));
  20882. }
  20883. /// <summary>
  20884. /// 酒店询价
  20885. /// Del
  20886. /// </summary>
  20887. /// <param name="_dto"></param>
  20888. /// <returns></returns>
  20889. [HttpPost]
  20890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20891. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20892. {
  20893. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20894. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20895. return Ok(JsonView(true, res.Msg, res.Data));
  20896. }
  20897. #endregion
  20898. #region 下载匹配op行程单
  20899. /// <summary>
  20900. /// 匹配op行程单
  20901. /// Init
  20902. /// </summary>
  20903. /// <param name="dto">团组列表请求dto</param>
  20904. /// <returns></returns>
  20905. [HttpPost]
  20906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20907. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20908. {
  20909. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20910. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20911. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20912. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20913. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20914. .Where(it => it.IsDel == 0)
  20915. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20916. .OrderByDescending(it => it.VisitStartDate)
  20917. .ToList();
  20918. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20919. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20920. var diids = groupInfos.Select(it => it.Id).ToList();
  20921. List<string> countrys = new List<string>();
  20922. foreach (var item in country)
  20923. {
  20924. var data = _groupRepository.FormartTeamName(item);
  20925. var dataArray = _groupRepository.GroupSplitCountry(data);
  20926. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20927. }
  20928. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20929. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20930. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20931. foreach (var item in areaItem)
  20932. {
  20933. string areaStr = item.Value;
  20934. if (!string.IsNullOrEmpty(areaStr))
  20935. {
  20936. string[] str1 = areaStr.Split("-");
  20937. if (str1.Length > 0)
  20938. {
  20939. areaArray.AddRange(str1);
  20940. }
  20941. }
  20942. }
  20943. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20944. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20945. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20946. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20947. .ToList();
  20948. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20949. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20950. .Where(it => countriesIds.Contains(it.Id))
  20951. .Select(it => new { it.Id, Name = it.Name_CN })
  20952. .ToList();
  20953. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20954. .Select(it => it.TeamName).ToList();
  20955. stopwatch.Stop();
  20956. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20957. }
  20958. ///// <summary>
  20959. ///// 匹配op行程单
  20960. ///// Init 查询区域数据
  20961. ///// </summary>
  20962. ///// <param name="dto">团组列表请求dto</param>
  20963. ///// <returns></returns>
  20964. //[HttpPost]
  20965. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20966. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20967. //{
  20968. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20969. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20970. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20971. // if (string.IsNullOrEmpty(countriesDataStr))
  20972. // {
  20973. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20974. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20975. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20976. // }
  20977. // else
  20978. // {
  20979. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20980. // }
  20981. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20982. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20983. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20984. // List<dynamic> childList = new List<dynamic>();
  20985. // int parentId = dto.CountriesId;
  20986. // if (provinceData.Count > 1)
  20987. // {
  20988. // foreach (var item1 in provinceData)
  20989. // {
  20990. // List<dynamic> childList1 = new List<dynamic>();
  20991. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20992. // foreach (var item2 in citiesData1)
  20993. // {
  20994. // List<dynamic> childList2 = new List<dynamic>();
  20995. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20996. // foreach (var item3 in countiesData1)
  20997. // {
  20998. // childList2.Add(new
  20999. // {
  21000. // id = item3.Id,
  21001. // parentId = item2.Id,
  21002. // level = "district",
  21003. // name = item3.Name_CN,
  21004. // });
  21005. // }
  21006. // childList1.Add(new
  21007. // {
  21008. // id = item2.Id,
  21009. // parentId = item1.Id,
  21010. // level = "city",
  21011. // name = item2.Name_CN,
  21012. // childList = childList2
  21013. // });
  21014. // }
  21015. // childList.Add(new
  21016. // {
  21017. // id = item1.Id,
  21018. // parentId = parentId,
  21019. // level = "province",
  21020. // name = item1.Name_CN,
  21021. // childList = childList1
  21022. // });
  21023. // }
  21024. // //城市
  21025. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  21026. // foreach (var item2 in citiesData2)
  21027. // {
  21028. // List<dynamic> childList22 = new List<dynamic>();
  21029. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21030. // foreach (var item3 in countiesData1)
  21031. // {
  21032. // childList22.Add(new
  21033. // {
  21034. // id = item3.Id,
  21035. // parentId = item2.Id,
  21036. // level = "district",
  21037. // name = item3.Name_CN,
  21038. // });
  21039. // }
  21040. // childList.Add(new
  21041. // {
  21042. // id = item2.Id,
  21043. // parentId = parentId,
  21044. // level = "city",
  21045. // name = item2.Name_CN,
  21046. // childList = childList22
  21047. // });
  21048. // }
  21049. // }
  21050. // else
  21051. // {
  21052. // foreach (var item2 in citiesData)
  21053. // {
  21054. // string cname = item2.Name_CN;
  21055. // List<dynamic> childList1 = new List<dynamic>();
  21056. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21057. // foreach (var item3 in countiesData1)
  21058. // {
  21059. // childList1.Add(new
  21060. // {
  21061. // Id = item3.Id,
  21062. // parentId = item2.Id,
  21063. // level = "district",
  21064. // name = item3.Name_CN
  21065. // });
  21066. // }
  21067. // childList.Add(new
  21068. // {
  21069. // id = item2.Id,
  21070. // parentId = parentId,
  21071. // level = "city",
  21072. // name = item2.Name_CN,
  21073. // childList = childList1
  21074. // });
  21075. // }
  21076. // }
  21077. // stopwatch.Stop();
  21078. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21079. //}
  21080. /// <summary>
  21081. /// 匹配op行程单
  21082. /// 接团信息列表 Page
  21083. /// </summary>
  21084. /// <param name="dto">团组列表请求dto</param>
  21085. /// <returns></returns>
  21086. [HttpPost]
  21087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21088. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21089. {
  21090. var swatch = new Stopwatch();
  21091. swatch.Start();
  21092. #region 参数验证
  21093. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21094. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21095. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21096. #region 页面操作权限验证
  21097. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21098. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21099. #endregion
  21100. #endregion
  21101. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21102. {
  21103. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21104. //string sqlWhere = "";
  21105. if (!string.IsNullOrEmpty(dto.Country))
  21106. {
  21107. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  21108. }
  21109. if (!string.IsNullOrEmpty(dto.Area))
  21110. {
  21111. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  21112. }
  21113. if (!string.IsNullOrEmpty(dto.TeamName))
  21114. {
  21115. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  21116. }
  21117. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  21118. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  21119. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  21120. swatch.Stop();
  21121. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  21122. }
  21123. else
  21124. {
  21125. return Ok(JsonView(false, "查询失败"));
  21126. }
  21127. }
  21128. /// <summary>
  21129. /// 匹配op行程单
  21130. /// 行程单下载
  21131. /// </summary>
  21132. /// <param name="dto">团组列表请求dto</param>
  21133. /// <returns></returns>
  21134. [HttpPost]
  21135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21136. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  21137. {
  21138. #region 参数验证
  21139. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21140. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21141. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21142. #region 页面操作权限验证
  21143. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21144. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  21145. #endregion
  21146. #endregion
  21147. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21148. {
  21149. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  21150. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  21151. }
  21152. else
  21153. {
  21154. return Ok(JsonView(false, "下载失败!"));
  21155. }
  21156. }
  21157. #endregion
  21158. #region 国家信息 数据 注释
  21159. //[HttpPost]
  21160. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  21161. //{
  21162. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  21163. // foreach (var item in dto)
  21164. // {
  21165. // infos.Add(new Grp_GroupsTaskAssignment()
  21166. // {
  21167. // DIId = item,
  21168. // CTId = 82,
  21169. // UId = 248,
  21170. // IsEnable = 1,
  21171. // CreateUserId = 233,
  21172. // CreateTime = DateTime.Now,
  21173. // IsDel = 0
  21174. // });
  21175. // infos.Add(new Grp_GroupsTaskAssignment()
  21176. // {
  21177. // DIId = item,
  21178. // CTId = 82,
  21179. // UId = 286,
  21180. // IsEnable = 1,
  21181. // CreateUserId = 233,
  21182. // CreateTime = DateTime.Now,
  21183. // IsDel = 0
  21184. // });
  21185. // }
  21186. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  21187. // return Ok("操作成功");
  21188. //}
  21189. //public class paramJsonDto
  21190. //{
  21191. // public List<CountriesInfo> str { get; set; }
  21192. //}
  21193. //[HttpPost]
  21194. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  21195. //{
  21196. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  21197. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  21198. // List<Sys_Cities> cities = new List<Sys_Cities>();
  21199. // List<Sys_Cities> districts = new List<Sys_Cities>();
  21200. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21201. // _sqlSugar.BeginTran();
  21202. // int countitiesIndex = 0;
  21203. // foreach (var item in dto.str)
  21204. // {
  21205. // dynamic data = item.c;
  21206. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  21207. // if (data != null)
  21208. // {
  21209. // countitiesIndex++;
  21210. // foreach (var item1 in data)
  21211. // {
  21212. // string cnname = item1.cn;
  21213. // string enname = item1.en;
  21214. // Sys_Cities provinceInfo = new Sys_Cities()
  21215. // {
  21216. // CountriesId = countriesId,
  21217. // Name_CN = cnname,
  21218. // Name_EN = enname,
  21219. // ParentId = 0,
  21220. // IsCapital = 1,
  21221. // CreateUserId = 208,
  21222. // CreateTime = DateTime.Now,
  21223. // IsDel = 0
  21224. // };
  21225. // if (item1.lv == "province") //省份
  21226. // {
  21227. // provinceInfo.Level = 1;
  21228. // int provinceId = 0;
  21229. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  21230. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  21231. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21232. // var data1 = item1.c;
  21233. // foreach (var item2 in data1)
  21234. // {
  21235. // if (item2.lv == "city")
  21236. // {
  21237. // string citycnname = item2.cn;
  21238. // string cityenname = item2.en;
  21239. // Sys_Cities cityInfo = new Sys_Cities()
  21240. // {
  21241. // CountriesId = countriesId,
  21242. // ParentId = provinceId,
  21243. // Level = 2,
  21244. // Name_CN = citycnname,
  21245. // Name_EN = cityenname,
  21246. // IsCapital = 1,
  21247. // CreateUserId = 208,
  21248. // CreateTime = DateTime.Now,
  21249. // IsDel = 0
  21250. // };
  21251. // if (item2.c != null)
  21252. // {
  21253. // int cityId = 0;
  21254. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  21255. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21256. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  21257. // foreach (var item3 in item2.c)
  21258. // {
  21259. // if (item3.lv == "district")
  21260. // {
  21261. // var districtInfo = new Sys_Cities()
  21262. // {
  21263. // CountriesId = countriesId,
  21264. // Name_CN = item3.cn,
  21265. // Name_EN = item3.en,
  21266. // Level = 3,
  21267. // ParentId = cityId,
  21268. // IsCapital = 1,
  21269. // CreateUserId = 208,
  21270. // CreateTime = DateTime.Now,
  21271. // IsDel = 0
  21272. // };
  21273. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21274. // //{
  21275. // districts.Add(districtInfo);
  21276. // //}
  21277. // }
  21278. // }
  21279. // }
  21280. // else
  21281. // {
  21282. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  21283. // //{
  21284. // cities.Add(cityInfo);
  21285. // //}
  21286. // }
  21287. // }
  21288. // }
  21289. // }
  21290. // else if (item1.lv == "city")//城市
  21291. // {
  21292. // provinceInfo.Level = 2;
  21293. // if (item1.c != null)
  21294. // {
  21295. // int cityId = 0;
  21296. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  21297. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21298. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21299. // foreach (var item3 in item1.c)
  21300. // {
  21301. // if (item3.lv == "district")
  21302. // {
  21303. // var districtInfo = new Sys_Cities()
  21304. // {
  21305. // CountriesId = countriesId,
  21306. // Name_CN = item3.cn,
  21307. // Name_EN = item3.en,
  21308. // Level = 3,
  21309. // ParentId = cityId,
  21310. // IsCapital = 1,
  21311. // CreateUserId = 208,
  21312. // CreateTime = DateTime.Now,
  21313. // IsDel = 0
  21314. // };
  21315. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21316. // //{
  21317. // districts.Add(districtInfo);
  21318. // //}
  21319. // }
  21320. // }
  21321. // }
  21322. // else
  21323. // {
  21324. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  21325. // //{
  21326. // cities.Add(provinceInfo);
  21327. // //}
  21328. // }
  21329. // }
  21330. // }
  21331. // }
  21332. // }
  21333. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  21334. // cities = cities.Distinct().ToList();
  21335. // districts = districts.Distinct().ToList();
  21336. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  21337. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  21338. // cities.AddRange(districts);
  21339. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  21340. // //_sqlSugar.RollbackTran();
  21341. // _sqlSugar.CommitTran();
  21342. // return Ok(JsonView(false, "操作成功!"));
  21343. //}
  21344. //[HttpPost]
  21345. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  21346. //{
  21347. // List<CountitiesInfo> infos = dto.MyProperty;
  21348. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  21349. // _sqlSugar.BeginTran();
  21350. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21351. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  21352. // foreach (var item in infos)
  21353. // {
  21354. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  21355. // if (countryInfo != null)
  21356. // {
  21357. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  21358. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  21359. // if (cityInfo1 != null)
  21360. // {
  21361. // cityInfo1.IsCapital = 0;
  21362. // cityInfos.Add(cityInfo1);
  21363. // }
  21364. // }
  21365. // }
  21366. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  21367. // .UpdateColumns(it => it.IsCapital)
  21368. // .WhereColumns(it => it.Id)
  21369. // .ExecuteCommand();
  21370. // //_sqlSugar.RollbackTran();
  21371. // _sqlSugar.CommitTran();
  21372. // return Ok(JsonView(false, "操作成功!"));
  21373. //}
  21374. //public class CounrtiesDto
  21375. //{
  21376. // public List<CountitiesInfo> MyProperty { get; set; }
  21377. //}
  21378. //public class CountitiesInfo
  21379. //{
  21380. // /// <summary>
  21381. // /// 圣约翰
  21382. // /// </summary>
  21383. // public string capital_name_chinese { get; set; }
  21384. // /// <summary>
  21385. // ///
  21386. // /// </summary>
  21387. // public string capital_name { get; set; }
  21388. // /// <summary>
  21389. // ///
  21390. // /// </summary>
  21391. // public string country_type { get; set; }
  21392. // /// <summary>
  21393. // /// 安提瓜和巴布达
  21394. // /// </summary>
  21395. // public string country_name_chinese { get; set; }
  21396. // /// <summary>
  21397. // /// 安提瓜和巴布达
  21398. // /// </summary>
  21399. // public string country_name_chinese_short { get; set; }
  21400. // /// <summary>
  21401. // /// 安提瓜和巴布达
  21402. // /// </summary>
  21403. // public string country_name_chinese_UN { get; set; }
  21404. // /// <summary>
  21405. // ///
  21406. // /// </summary>
  21407. // public string country_name_english_abbreviation { get; set; }
  21408. // /// <summary>
  21409. // ///
  21410. // /// </summary>
  21411. // public string country_name_english_formal { get; set; }
  21412. // /// <summary>
  21413. // ///
  21414. // /// </summary>
  21415. // public string country_name_english_UN { get; set; }
  21416. // /// <summary>
  21417. // ///
  21418. // /// </summary>
  21419. // public string continent_name { get; set; }
  21420. // /// <summary>
  21421. // ///
  21422. // /// </summary>
  21423. // public string subregion_name { get; set; }
  21424. // /// <summary>
  21425. // ///
  21426. // /// </summary>
  21427. // public string country_code2 { get; set; }
  21428. // /// <summary>
  21429. // ///
  21430. // /// </summary>
  21431. // public string country_code3 { get; set; }
  21432. // /// <summary>
  21433. // ///
  21434. // /// </summary>
  21435. // public string phone_code { get; set; }
  21436. //}
  21437. //public class CountriesInfo : BasicInfo
  21438. //{
  21439. // public List<CitiesInfo> c { get; set; }
  21440. //}
  21441. //public class CitiesInfo : BasicInfo
  21442. //{
  21443. // public List<AreaInfo> c { get; set; }
  21444. //}
  21445. //public class AreaInfo : BasicInfo
  21446. //{
  21447. // public List<AreaInfo> c { get; set; }
  21448. //}
  21449. //public class BasicInfo
  21450. //{
  21451. // public string code { get; set; }
  21452. // public string cn { get; set; }
  21453. // public string lv { get; set; }
  21454. // public string en { get; set; }
  21455. //}
  21456. #endregion
  21457. #region 查看邀请方
  21458. /// <summary>
  21459. /// 查看邀请方
  21460. /// 邀请方信息 Init
  21461. /// </summary>
  21462. /// <param name="dto"></param>
  21463. /// <returns></returns>
  21464. [HttpPost]
  21465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21466. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21467. {
  21468. string sqlWhere = string.Empty;
  21469. if (!string.IsNullOrEmpty(dto.Search))
  21470. {
  21471. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21472. }
  21473. string sql = string.Format($@"Select
  21474. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21475. Id,
  21476. UnitName
  21477. From Res_InvitationOfficialActivityData
  21478. Where IsDel = 0
  21479. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21480. RefAsync<int> total = 0;
  21481. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21482. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21483. }
  21484. /// <summary>
  21485. /// 查看邀请方
  21486. /// 国家信息 Init
  21487. /// </summary>
  21488. /// <param name="dto"></param>
  21489. /// <returns></returns>
  21490. [HttpPost]
  21491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21492. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21493. {
  21494. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21495. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21496. var diids = groupInfos.Select(it => it.Id).ToList();
  21497. List<string> countrys = new List<string>();
  21498. foreach (var item in country)
  21499. {
  21500. var data = _groupRepository.FormartTeamName(item);
  21501. var dataArray = _groupRepository.GroupSplitCountry(data);
  21502. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21503. }
  21504. countrys = countrys.Distinct().ToList();
  21505. for (int i = 0; i < countrys.Count; i++)
  21506. {
  21507. string item = countrys[i];
  21508. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21509. {
  21510. countrys.Remove(item);
  21511. i--;
  21512. }
  21513. }
  21514. RefAsync<int> total = 0;
  21515. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21516. .Where(it => countrys.Contains(it.Name_CN))
  21517. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21518. .Select(it => new { id = it.Id, name = it.Name_CN })
  21519. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21520. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21521. }
  21522. /// <summary>
  21523. /// 查看邀请方
  21524. /// 城市信息 Init
  21525. /// </summary>
  21526. /// <param name="dto"></param>
  21527. /// <returns></returns>
  21528. [HttpPost]
  21529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21530. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21531. {
  21532. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21533. RefAsync<int> total = 0;
  21534. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21535. .Where(it => it.CountriesId == dto.CountiesId)
  21536. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21537. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21538. .Select(it => new { id = it.Id, name = it.Name_CN })
  21539. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21540. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21541. }
  21542. /// <summary>
  21543. /// 查看邀请方
  21544. /// 团组名称 Init
  21545. /// </summary>
  21546. /// <param name="dto"></param>
  21547. /// <returns></returns>
  21548. [HttpPost]
  21549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21550. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21551. {
  21552. var watch = new Stopwatch();
  21553. watch.Start();
  21554. RefAsync<int> total = 0;
  21555. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21556. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21557. .Where((oa, di) => oa.IsDel == 0)
  21558. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21559. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21560. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21561. .Distinct()
  21562. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21563. watch.Stop();
  21564. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21565. }
  21566. /// <summary>
  21567. /// 查看邀请方
  21568. /// 团组 & 邀请方信息
  21569. /// </summary>
  21570. /// <param name="dto"></param>
  21571. /// <returns></returns>
  21572. [HttpPost]
  21573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21574. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21575. {
  21576. var watch = new Stopwatch();
  21577. watch.Start();
  21578. RefAsync<int> total = 0;
  21579. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21580. .AS("Grp_DelegationInfo")
  21581. .Includes(x => x.InvitingInfos)
  21582. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21583. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21584. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21585. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21586. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21587. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21588. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21589. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21590. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21591. infos.ForEach(x =>
  21592. {
  21593. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21594. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21595. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21596. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21597. });
  21598. watch.Stop();
  21599. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21600. }
  21601. #endregion
  21602. #region 报批行程
  21603. /// <summary>
  21604. /// 报批行程初始化
  21605. /// </summary>
  21606. /// <param name="dto"></param>
  21607. /// <returns></returns>
  21608. [HttpPost]
  21609. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21610. {
  21611. const int chiNumber = 5;
  21612. var jw = JsonView(false);
  21613. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21614. var group = groupList.First();
  21615. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21616. group = groupList.First(x => x.Id == diid);
  21617. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21618. .Where(x => x.DiId == diid && x.IsDel == 0)
  21619. .ToArray();
  21620. var count = 1;
  21621. foreach (var item in blackCodeList)
  21622. {
  21623. if (string.IsNullOrWhiteSpace(item.Title))
  21624. {
  21625. item.Title = "未设置名称数据" + count;
  21626. }
  21627. count++;
  21628. }
  21629. ;
  21630. if (group == null)
  21631. {
  21632. jw.Msg = "暂无团组!";
  21633. return Ok(jw);
  21634. }
  21635. var data = new
  21636. {
  21637. groupList = groupList.Select(x => new
  21638. {
  21639. x.TeamName,
  21640. x.Id
  21641. }),
  21642. content = new ArrayList(),
  21643. groupInfo = new
  21644. {
  21645. group.VisitDays,
  21646. group.TourCode,
  21647. group.VisitPNumber,
  21648. group.TeamName,
  21649. group.Id,
  21650. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21651. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21652. group.ClientUnit
  21653. },
  21654. blackCodeList = blackCodeList.Select(x => new
  21655. {
  21656. x.Title,
  21657. x.Id
  21658. }),
  21659. FileTempList = new ArrayList()
  21660. {
  21661. new { Index = 1,FileName = "旧模板" },
  21662. new { Index = 2,FileName = "省外办" },
  21663. new { Index = 3,FileName = "市外办" },
  21664. }
  21665. };
  21666. var resultArr = new ArrayList();
  21667. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21668. #region 默认不生成行程
  21669. //if (content.Count == 0)
  21670. //{
  21671. // var stay = "-";
  21672. // var cityPath = "-";
  21673. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21674. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21675. // .ToList();
  21676. // //添加城市路径以及住宿地
  21677. // //黑屏代码数据
  21678. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21679. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21680. // {
  21681. // jw = JsonView(true, "黑屏代码有误!", data);
  21682. // return Ok(jw);
  21683. // }
  21684. // data = data with
  21685. // {
  21686. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21687. // {
  21688. // x.Title,
  21689. // x.Id,
  21690. // }).ToArray())
  21691. // };
  21692. // foreach (DataRow row in dtBlack.Rows)
  21693. // {
  21694. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21695. // {
  21696. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21697. // return Ok(jw);
  21698. // }
  21699. // }
  21700. // //黑屏代码获取时间区间
  21701. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21702. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21703. // _sqlSugar.BeginTran();
  21704. // for (int i = 0; i < timeArr.Count; i++)
  21705. // {
  21706. // stay = "-";
  21707. // cityPath = "-";
  21708. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21709. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21710. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21711. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21712. // if (tbSelect.Length > 0)
  21713. // {
  21714. // List<string> threeCodeStr = new List<string>();
  21715. // foreach (var item in tbSelect)
  21716. // {
  21717. // var threeCode = item["Three"].ToString() ?? "";
  21718. // if (threeCode.Length == 6)
  21719. // {
  21720. // var start = threeCode.Substring(0, 3);
  21721. // var end = threeCode.Substring(3, 3);
  21722. // if (threeCodeStr.Count == 0)
  21723. // {
  21724. // threeCodeStr.Add(start);
  21725. // threeCodeStr.Add(end);
  21726. // }
  21727. // else
  21728. // {
  21729. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21730. // {
  21731. // threeCodeStr.Add(end);
  21732. // }
  21733. // else
  21734. // {
  21735. // threeCodeStr.Add(start);
  21736. // threeCodeStr.Add(end);
  21737. // }
  21738. // }
  21739. // }
  21740. // }
  21741. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21742. // var last = threeCodeStr.Last();
  21743. // foreach (var item in threeCodeStr)
  21744. // {
  21745. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21746. // if (item.Equals(last))
  21747. // {
  21748. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21749. // }
  21750. // }
  21751. // cityPath = cityPath.Trim('-');
  21752. // }
  21753. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21754. // appro.Diid = diid ?? -1;
  21755. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21756. // appro.Id = thisId;
  21757. // appro.CreateUserId = dto.UserId;
  21758. // appro.CreateTime = DateTime.Now;
  21759. // content.Add(appro);
  21760. // }
  21761. // _sqlSugar.CommitTran();
  21762. //}
  21763. #endregion
  21764. foreach (var x in content)
  21765. {
  21766. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21767. if (chiList.Count < chiNumber)
  21768. {
  21769. for (int i = chiList.Count; i < chiNumber; i++)
  21770. {
  21771. chiList.Add(new Grp_ApprovalTravelDetails());
  21772. }
  21773. }
  21774. resultArr.Add(new
  21775. {
  21776. x.Id,
  21777. x.Date,
  21778. x.Diid,
  21779. chiList = chiList.Select(x1 => new
  21780. {
  21781. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21782. x1.Details,
  21783. x1.ParentId,
  21784. x1.Id
  21785. })
  21786. });
  21787. }
  21788. data = data with
  21789. {
  21790. content = resultArr,
  21791. };
  21792. jw = JsonView(true, "获取成功!", data);
  21793. return Ok(jw);
  21794. }
  21795. /// <summary>
  21796. /// 报批行程删除
  21797. /// </summary>
  21798. /// <param name="dto"></param>
  21799. /// <returns></returns>
  21800. [HttpPost]
  21801. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21802. {
  21803. var jw = JsonView(false);
  21804. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21805. if (group == null)
  21806. {
  21807. jw.Msg = "团组参数有误!";
  21808. return Ok(jw);
  21809. }
  21810. try
  21811. {
  21812. _sqlSugar.BeginTran();
  21813. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21814. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21815. {
  21816. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21817. DeleteUserId = dto.uesrId,
  21818. IsDel = 1
  21819. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21820. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21821. {
  21822. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21823. DeleteUserId = dto.uesrId,
  21824. IsDel = 1
  21825. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21826. _sqlSugar.CommitTran();
  21827. jw = JsonView(true, "删除成功");
  21828. }
  21829. catch (Exception ex)
  21830. {
  21831. jw = JsonView(false, ex.Message);
  21832. }
  21833. return Ok(jw);
  21834. }
  21835. /// <summary>
  21836. /// 报批行程保存
  21837. /// </summary>
  21838. /// <param name="dto"></param>
  21839. /// <returns></returns>
  21840. [HttpPost]
  21841. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21842. {
  21843. var jw = JsonView(false);
  21844. var Find = dto.Arr.Find(x => x.id == 0);
  21845. if (Find != null)
  21846. {
  21847. jw.Msg = "生成的ID为0!";
  21848. return Ok(jw);
  21849. }
  21850. foreach (var item in dto.Arr)
  21851. {
  21852. foreach (var chi in item.chiList)
  21853. {
  21854. if (chi.parentId == 0)
  21855. {
  21856. chi.parentId = item.id;
  21857. }
  21858. }
  21859. }
  21860. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21861. _sqlSugar.BeginTran();
  21862. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21863. {
  21864. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21865. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21866. {
  21867. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21868. DeleteUserId = dto.UserId,
  21869. IsDel = 1
  21870. }).ExecuteCommand();
  21871. }
  21872. try
  21873. {
  21874. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21875. {
  21876. CreateTime = DateTime.Now,
  21877. CreateUserId = dto.UserId,
  21878. Details = x.details,
  21879. ParentId = x.parentId,
  21880. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21881. Remark = "",
  21882. IsDel = 0
  21883. }).ToList()).ExecuteCommand();
  21884. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21885. {
  21886. Id = x.id,
  21887. Details = x.details,
  21888. ParentId = x.parentId,
  21889. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21890. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21891. {
  21892. Details = x.Details,
  21893. ParentId = x.ParentId,
  21894. Time = x.Time
  21895. }).ExecuteCommand();
  21896. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21897. {
  21898. Id = x.id,
  21899. Date = x.date,
  21900. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21901. {
  21902. Date = x.Date
  21903. }).ExecuteCommand();
  21904. _sqlSugar.CommitTran();
  21905. jw = JsonView(true, "保存成功!");
  21906. }
  21907. catch (Exception ex)
  21908. {
  21909. _sqlSugar.RollbackTran();
  21910. jw = JsonView(false, "保存失败!" + ex.Message);
  21911. }
  21912. return Ok(jw);
  21913. }
  21914. /// <summary>
  21915. /// 报批行程生成
  21916. /// </summary>
  21917. /// <param name="dto"></param>
  21918. /// <returns></returns>
  21919. [HttpPost]
  21920. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21921. {
  21922. var jw = JsonView(false);
  21923. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21924. if (group == null)
  21925. {
  21926. jw.Msg = "暂无该团组!";
  21927. return Ok(jw);
  21928. }
  21929. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21930. //黑屏代码数据
  21931. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21932. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21933. {
  21934. jw.Msg = "黑屏代码有误!";
  21935. return Ok(jw);
  21936. }
  21937. foreach (DataRow row in dtBlack.Rows)
  21938. {
  21939. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21940. {
  21941. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21942. return Ok(jw);
  21943. }
  21944. }
  21945. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21946. var resultArr = new ArrayList();
  21947. //if (officialActivitiesArr.Count == 0)
  21948. //{
  21949. // jw.Msg = "暂无公务出访信息!";
  21950. // return Ok(jw);
  21951. //}
  21952. try
  21953. {
  21954. _sqlSugar.BeginTran();
  21955. DeleteApprovalJourney(new
  21956. Domain.Dtos.Groups.DeleteApprovalJourney
  21957. {
  21958. Diid = dto.Diid,
  21959. uesrId = dto.Userid
  21960. });
  21961. var stay = "-";
  21962. var cityPath = "-";
  21963. var arriveCountry = string.Empty;
  21964. //添加城市路径以及住宿地
  21965. //黑屏代码获取时间区间
  21966. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21967. var empty = "【未收入该三字码!请机票同事录入】";
  21968. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21969. #region 配置公务活动时间
  21970. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21971. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21972. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21973. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21974. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21975. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21976. {
  21977. 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" }),
  21978. 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"}),
  21979. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21980. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21981. };
  21982. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21983. {
  21984. 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" }),
  21985. 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"}),
  21986. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21987. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21988. };
  21989. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21990. {
  21991. 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" }),
  21992. 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"}),
  21993. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21994. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21995. };
  21996. #endregion
  21997. var nextDayNum = 0;
  21998. for (int i = 0; i < timeArr.Count; i++)
  21999. {
  22000. stay = "-";
  22001. cityPath = "-";
  22002. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22003. DateTime NewData = DateTime.Parse(timeArr[i]);
  22004. //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();
  22005. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22006. if (nextDayNum > 0)
  22007. {
  22008. nextDayNum--;
  22009. }
  22010. if (tbSelect.Length > 0)
  22011. {
  22012. List<string> threeCodeStr = new List<string>();
  22013. bool isTrade = false;
  22014. string trip = string.Empty;
  22015. foreach (var item in tbSelect)
  22016. {
  22017. if (nextDayNum == 0)
  22018. {
  22019. nextDayNum = Convert.ToInt32(item["Sign"]);
  22020. }
  22021. var airStartTime = item["StartTime"].ToString() ?? "0000";
  22022. var airEndTime = item["EndTime"].ToString() ?? "0000";
  22023. var takeOffTime = DateTime.Parse(timeArr[i]);
  22024. var fallToTime = DateTime.Parse(timeArr[i]);
  22025. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  22026. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  22027. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  22028. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  22029. if (nextDayNum > 0)
  22030. {
  22031. fallToTime = fallToTime.AddDays(nextDayNum);
  22032. }
  22033. trip = string.Empty;
  22034. var start = string.Empty;
  22035. var end = string.Empty;
  22036. var threeCode = item["Three"].ToString() ?? "";
  22037. if (threeCode.Length == 6)
  22038. {
  22039. start = threeCode.Substring(0, 3);
  22040. end = threeCode.Substring(3, 3);
  22041. if (threeCodeStr.Count == 0)
  22042. {
  22043. threeCodeStr.Add(start);
  22044. threeCodeStr.Add(end);
  22045. }
  22046. else
  22047. {
  22048. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22049. {
  22050. threeCodeStr.Add(end);
  22051. }
  22052. else
  22053. {
  22054. threeCodeStr.Add(start);
  22055. threeCodeStr.Add(end);
  22056. }
  22057. }
  22058. }
  22059. //处理机票信息
  22060. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22061. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22062. if (start_Object == null)
  22063. {
  22064. start_Object = new Res_ThreeCode()
  22065. {
  22066. AirPort = empty,
  22067. AirPort_En = empty,
  22068. City = empty,
  22069. Country = empty,
  22070. Four = empty,
  22071. Three = empty,
  22072. };
  22073. }
  22074. if (end_Object == null)
  22075. {
  22076. end_Object = new Res_ThreeCode()
  22077. {
  22078. AirPort = empty,
  22079. AirPort_En = empty,
  22080. City = empty,
  22081. Country = empty,
  22082. Four = empty,
  22083. Three = empty,
  22084. };
  22085. }
  22086. //机型判断
  22087. string airModel = item["AirModel"].ToString();
  22088. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22089. string flightTime = item["FlightTime"].ToString();
  22090. flightTime = ParseBlackTime(flightTime);
  22091. //航班号
  22092. string flightcode = item["Fliagtcode"].ToString();
  22093. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22094. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22095. if (aircompany == null)
  22096. {
  22097. aircompany = new Res_AirCompany
  22098. {
  22099. CnName = hsEmpty,
  22100. EnName = hsEmpty,
  22101. ShortCode = hsEmpty,
  22102. };
  22103. }
  22104. //航班前公务安排
  22105. if (tbSelect.First().Equals(item) && i != 0)
  22106. {
  22107. foreach (var takeoff in takeoffTimes)
  22108. {
  22109. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  22110. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  22111. {
  22112. foreach (var addTime in takeoff.Item2)
  22113. {
  22114. chiarr.Add(new Grp_ApprovalTravelDetails
  22115. {
  22116. Time = addTime,
  22117. CreateTime = DateTime.Now,
  22118. CreateUserId = dto.Userid,
  22119. ParentId = 0,
  22120. Details = "公务活动"
  22121. });
  22122. }
  22123. break;
  22124. }
  22125. }
  22126. }
  22127. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  22128. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  22129. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  22130. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  22131. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  22132. if (isTrade)
  22133. {
  22134. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  22135. trip += "(转机不出机场)。";
  22136. }
  22137. //else
  22138. //{
  22139. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  22140. //}
  22141. chiarr.Add(new Grp_ApprovalTravelDetails
  22142. {
  22143. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  22144. CreateTime = DateTime.Now,
  22145. CreateUserId = dto.Userid,
  22146. ParentId = 0,
  22147. Details = trip
  22148. });
  22149. //最后一条到达的时间安排公务
  22150. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  22151. {
  22152. bool isCheckCountry = false;
  22153. if (end_Object.Country != arriveCountry)
  22154. {
  22155. arriveCountry = end_Object.Country;
  22156. isCheckCountry = true;
  22157. }
  22158. if (nextDayNum == 0)
  22159. {
  22160. //需要入境的情况
  22161. if (isCheckCountry)
  22162. {
  22163. foreach (var fallTime in fallTimesCheckCountry)
  22164. {
  22165. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22166. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22167. {
  22168. foreach (var addTime in fallTime.Item2)
  22169. {
  22170. chiarr.Add(new Grp_ApprovalTravelDetails
  22171. {
  22172. Time = addTime,
  22173. CreateTime = DateTime.Now,
  22174. CreateUserId = dto.Userid,
  22175. ParentId = 0,
  22176. Details = "公务活动"
  22177. });
  22178. }
  22179. break;
  22180. }
  22181. }
  22182. }
  22183. else
  22184. {
  22185. foreach (var fallTime in fallTimesNotCheckCountry)
  22186. {
  22187. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22188. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22189. {
  22190. foreach (var addTime in fallTime.Item2)
  22191. {
  22192. chiarr.Add(new Grp_ApprovalTravelDetails
  22193. {
  22194. Time = addTime,
  22195. CreateTime = DateTime.Now,
  22196. CreateUserId = dto.Userid,
  22197. ParentId = 0,
  22198. Details = "公务活动"
  22199. });
  22200. }
  22201. break;
  22202. }
  22203. }
  22204. }
  22205. }
  22206. }
  22207. }
  22208. //添加乘车语句
  22209. //chiarr.Add(new Grp_ApprovalTravelDetails
  22210. //{
  22211. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  22212. // CreateTime = DateTime.Now,
  22213. // CreateUserId = dto.Userid,
  22214. // ParentId = 0,
  22215. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  22216. //});
  22217. //if (i != timeArr.Count - 1)
  22218. //{
  22219. // fallToTime = fallToTime.AddHours(2.5);
  22220. // foreach (var item in Times)
  22221. // {
  22222. // //排列公务时间
  22223. // if (fallToTime.Hour < item.Item1)
  22224. // {
  22225. // chiarr.Add(new Grp_ApprovalTravelDetails
  22226. // {
  22227. // Time = $"{item.Item2} - {item.Item3}",
  22228. // CreateTime = DateTime.Now,
  22229. // CreateUserId = dto.Userid,
  22230. // ParentId = 0,
  22231. // Details = "公务活动"
  22232. // });
  22233. // }
  22234. // }
  22235. //}
  22236. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22237. var last = threeCodeStr.Last();
  22238. foreach (var item in threeCodeStr)
  22239. {
  22240. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22241. if (item.Equals(last))
  22242. {
  22243. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22244. }
  22245. }
  22246. cityPath = cityPath.Trim('-');
  22247. }
  22248. else
  22249. {
  22250. foreach (var item in Times)
  22251. {
  22252. chiarr.Add(new Grp_ApprovalTravelDetails
  22253. {
  22254. Time = $"{item.Item2} - {item.Item3}",
  22255. CreateTime = DateTime.Now,
  22256. CreateUserId = dto.Userid,
  22257. ParentId = 0,
  22258. Details = "公务活动"
  22259. });
  22260. }
  22261. }
  22262. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22263. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22264. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  22265. appro.Diid = dto.Diid;
  22266. appro.CreateUserId = dto.Userid;
  22267. appro.CreateTime = DateTime.Now;
  22268. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22269. appro.Id = thisId;
  22270. //foreach (var item in gwinfo)
  22271. //{
  22272. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  22273. // chi.Details = "拜访" + item.Client;
  22274. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  22275. // {
  22276. // chi.Details += "," + item.ReqSample;
  22277. // }
  22278. // chi.ParentId = thisId;
  22279. // chi.Time = item.Time;
  22280. // chiarr.Add(chi);
  22281. //}
  22282. if (chiarr.Count < 6)
  22283. {
  22284. for (int j = chiarr.Count; j < 6; j++)
  22285. {
  22286. chiarr.Add(new
  22287. Grp_ApprovalTravelDetails());
  22288. }
  22289. }
  22290. resultArr.Add(new
  22291. {
  22292. appro.Id,
  22293. appro.Date,
  22294. appro.Diid,
  22295. chiList = chiarr.Select(x1 => new
  22296. {
  22297. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22298. x1.Details,
  22299. x1.ParentId,
  22300. x1.Id
  22301. })
  22302. });
  22303. }
  22304. _sqlSugar.CommitTran();
  22305. jw = JsonView(true, "生成成功!", resultArr);
  22306. }
  22307. catch (Exception ex)
  22308. {
  22309. jw.Code = 400;
  22310. jw.Msg = "生成失败!" + ex.Message;
  22311. }
  22312. return Ok(jw);
  22313. }
  22314. /// <summary>
  22315. /// 报批行程word导出
  22316. /// </summary>
  22317. /// <param name="dto"></param>
  22318. /// <returns></returns>
  22319. [HttpPost]
  22320. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  22321. {
  22322. var jw = JsonView(false);
  22323. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22324. if (group == null)
  22325. {
  22326. jw.Msg = "暂无该团组!";
  22327. return Ok(jw);
  22328. }
  22329. //模板路径
  22330. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  22331. var fileName = string.Empty;
  22332. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  22333. bool bold = false;
  22334. if (dto.FileIndex == 1)
  22335. {
  22336. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  22337. }
  22338. else if (dto.FileIndex == 2)
  22339. {
  22340. fileName = "省外办-报批.docx";
  22341. bold = false;
  22342. titleFont = "方正黑体简体";
  22343. timeFont = "Times New Roman";
  22344. contentFont = "方正仿宋_GBK";
  22345. }
  22346. else if (dto.FileIndex == 3)
  22347. {
  22348. fileName = "市外办-报批.docx";
  22349. titleFont = "方正黑体简体";
  22350. timeFont = "Times New Roman";
  22351. contentFont = "方正仿宋简体";
  22352. }
  22353. tempPath = tempPath + fileName;
  22354. //载入模板
  22355. Document doc = new Document(tempPath);
  22356. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22357. //获取所填表格的序数
  22358. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22359. Aspose.Words.Tables.Row titleRowClone = null;
  22360. Aspose.Words.Tables.Row CenterRowClone = null;
  22361. int index = 0;
  22362. int indexChi = 0;
  22363. int SetIndex = 0;
  22364. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  22365. //获取数据,放到datatable
  22366. foreach (var item in ApprovalTravelArr)
  22367. {
  22368. if (index > 0)
  22369. {
  22370. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  22371. tableOne.AppendChild(titleRowClone);
  22372. }
  22373. var textTime = item.Date;
  22374. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  22375. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  22376. SetIndex++;
  22377. if (ChiRep.Count > 0)
  22378. {
  22379. foreach (var itemChi in ChiRep)
  22380. {
  22381. var txtTime = itemChi.Time;
  22382. var txtDetail = itemChi.Details;
  22383. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  22384. {
  22385. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  22386. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22387. //indexChi++;
  22388. //SetIndex++;
  22389. break;
  22390. }
  22391. if (indexChi > 0)
  22392. {
  22393. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22394. tableOne.AppendChild(CenterRowClone);
  22395. }
  22396. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  22397. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  22398. indexChi++;
  22399. SetIndex++;
  22400. }
  22401. }
  22402. //else
  22403. //{
  22404. // if (indexChi > 0)
  22405. // {
  22406. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22407. // tableOne.AppendChild(CenterRowClone);
  22408. // }
  22409. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  22410. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22411. // indexChi++;
  22412. // SetIndex++;
  22413. //}
  22414. index++;
  22415. }
  22416. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  22417. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22418. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22419. jw.Code = 200;
  22420. jw.Msg = "";
  22421. return Ok(jw);
  22422. }
  22423. private string ParseBlackTime(string time)
  22424. {
  22425. // 匹配可能只有分钟的情况
  22426. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  22427. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  22428. if (match.Success)
  22429. {
  22430. string hours = match.Groups[1].Value;
  22431. string minutes = match.Groups[2].Value;
  22432. // 如果小时部分为空,则只显示分钟
  22433. if (string.IsNullOrEmpty(hours))
  22434. {
  22435. return $"{minutes}分钟";
  22436. }
  22437. // 如果分钟部分为空,则只显示小时
  22438. else if (string.IsNullOrEmpty(minutes))
  22439. {
  22440. return $"{hours}小时";
  22441. }
  22442. // 否则显示完整格式
  22443. else
  22444. {
  22445. return $"{hours}小时{minutes}分钟";
  22446. }
  22447. }
  22448. else
  22449. {
  22450. return "未知时长";
  22451. }
  22452. }
  22453. private string intToString(int numberVal)
  22454. {
  22455. string numberval = numberVal.ToString();
  22456. Dictionary<char, string> Number = new Dictionary<char, string>();
  22457. Number.Add('1', "一");
  22458. Number.Add('2', "二");
  22459. Number.Add('3', "三");
  22460. Number.Add('4', "四");
  22461. Number.Add('5', "五");
  22462. Number.Add('6', "六");
  22463. Number.Add('7', "七");
  22464. Number.Add('8', "八");
  22465. Number.Add('9', "九");
  22466. string stringNumberVal = string.Empty;
  22467. for (int i = 0; i < numberval.Length; i++)
  22468. {
  22469. if (i == 0)
  22470. {
  22471. stringNumberVal += Number[numberval[i]];
  22472. }
  22473. else if (i >= 1)
  22474. {
  22475. if (numberval[i] == '0')
  22476. {
  22477. stringNumberVal = "十";
  22478. }
  22479. else
  22480. {
  22481. stringNumberVal += "十" + Number[numberval[i]];
  22482. }
  22483. }
  22484. }
  22485. return stringNumberVal;
  22486. }
  22487. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22488. {
  22489. //获取table中的某个单元格,从0开始
  22490. Cell lshCell = table.Rows[rows].Cells[cells];
  22491. //将单元格中段落移除
  22492. foreach (Paragraph item in lshCell.Paragraphs)
  22493. {
  22494. lshCell.Paragraphs.Remove(item);
  22495. }
  22496. if (val.Contains("\r\n"))
  22497. {
  22498. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22499. foreach (var item in spArr)
  22500. {
  22501. //新建一个段落
  22502. Paragraph p = new Paragraph(doc);
  22503. var r = new Run(doc, item);
  22504. //设置字体
  22505. if (!string.IsNullOrEmpty(font))
  22506. {
  22507. r.Font.Name = font;
  22508. }
  22509. r.Font.Bold = bold;
  22510. //把设置的值赋给之前新建的段落
  22511. p.AppendChild(r);
  22512. //将此段落加到单元格内
  22513. lshCell.AppendChild(p);
  22514. }
  22515. }
  22516. else
  22517. {
  22518. //新建一个段落
  22519. Paragraph p = new Paragraph(doc);
  22520. var r = new Run(doc, val);
  22521. //设置字体
  22522. if (!string.IsNullOrEmpty(font))
  22523. {
  22524. r.Font.Name = font;
  22525. }
  22526. r.Font.Bold = bold;
  22527. //把设置的值赋给之前新建的段落
  22528. p.AppendChild(r);
  22529. //将此段落加到单元格内
  22530. lshCell.AppendChild(p);
  22531. }
  22532. }
  22533. /// <summary>
  22534. /// 报批行程AI续写
  22535. /// </summary>
  22536. /// <returns></returns>
  22537. [HttpPost]
  22538. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22539. {
  22540. var jw = JsonView(false);
  22541. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22542. {
  22543. jw.Msg = "参数有误!";
  22544. return Ok(jw);
  22545. }
  22546. KiMiApiClient kiMi = new KiMiApiClient();
  22547. List<SeedMessages> messages = new List<SeedMessages>() {
  22548. new SeedMessages
  22549. {
  22550. Role = KimiRole.system,
  22551. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22552. },
  22553. new SeedMessages
  22554. {
  22555. Role = KimiRole.user,
  22556. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22557. }
  22558. };
  22559. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22560. string data = kimi_result.Choices[0]?.Message.Content;
  22561. if (string.IsNullOrWhiteSpace(data))
  22562. {
  22563. jw.Data = "Ai续写失败!";
  22564. }
  22565. else
  22566. {
  22567. jw = JsonView(true, "success!", data);
  22568. }
  22569. return Ok(jw);
  22570. }
  22571. #endregion
  22572. #region 团组接待意见调查
  22573. /// <summary>
  22574. /// 团组接待意见调查 - 信息管理
  22575. /// 基础数据(团组)
  22576. /// </summary>
  22577. /// <returns></returns>
  22578. [HttpGet]
  22579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22580. public async Task<IActionResult> OpinionaireInit()
  22581. {
  22582. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22583. .Select(x => new
  22584. {
  22585. x.Id,
  22586. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22587. })
  22588. .OrderByDescending(x => x.Id)
  22589. .ToListAsync();
  22590. return Ok(JsonView(groupData, groupData.Count));
  22591. }
  22592. /// <summary>
  22593. /// 团组接待意见调查 - 信息管理
  22594. /// 列表
  22595. /// </summary>
  22596. /// <param name="groupId"></param>
  22597. /// <returns></returns>
  22598. [HttpGet("{groupId}")]
  22599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22600. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22601. {
  22602. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22603. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22604. .Select(x => new
  22605. {
  22606. x.Id,
  22607. x.TourGuideName,
  22608. x.CityName,
  22609. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22610. x.CreateTime
  22611. })
  22612. .OrderBy(x => x.Id)
  22613. .ToListAsync();
  22614. return Ok(JsonView(data));
  22615. }
  22616. /// <summary>
  22617. /// 团组接待意见调查 - 信息管理
  22618. /// 保存
  22619. /// </summary>
  22620. /// <param name="dto"></param>
  22621. /// <returns></returns>
  22622. [HttpPost]
  22623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22624. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22625. {
  22626. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22627. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22628. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22629. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22630. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22631. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22632. _opinionaireRep.BeginTran();
  22633. if (addData != null && addData.Count > 0)
  22634. {
  22635. foreach (var item in addData)
  22636. {
  22637. item.CreateUserId = currUserInfo.UserId;
  22638. item.DiId = dto.DiId;
  22639. }
  22640. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22641. }
  22642. if (updData != null && updData.Count > 0)
  22643. {
  22644. var upd = await _opinionaireRep._sqlSugar
  22645. .Updateable(updData)
  22646. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22647. .WhereColumns(x => new { x.Id })
  22648. .ExecuteCommandAsync();
  22649. }
  22650. _opinionaireRep.CommitTran();
  22651. return Ok(JsonView("操作成功!"));
  22652. }
  22653. /// <summary>
  22654. /// 团组接待意见调查 - 信息管理
  22655. /// 删除
  22656. /// </summary>
  22657. /// <param name="id"></param>
  22658. /// <returns></returns>
  22659. [HttpDelete("{id}")]
  22660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22661. public async Task<IActionResult> OpinionaireManageDel(int id)
  22662. {
  22663. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22664. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22665. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22666. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22667. if (!del) return Ok(JsonView("操作失败!"));
  22668. return Ok(JsonView("操作成功!"));
  22669. }
  22670. /// <summary>
  22671. /// 团组接待意见调查 - 用户
  22672. /// 列表
  22673. /// </summary>
  22674. /// <param name="diId"></param>
  22675. /// <returns></returns>
  22676. [HttpGet("{diId}")]
  22677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22678. public async Task<IActionResult> OpinionaireUserList(int diId)
  22679. {
  22680. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22681. var sql = string.Format(@"
  22682. SELECT
  22683. o.Id,
  22684. o.DiId,
  22685. di.TeamName AS 'GroupName',
  22686. di.VisitPNumber AS 'PeopleNumber',
  22687. di.ClientName AS 'LeadGroup',
  22688. di.VisitCountry AS 'Travel',
  22689. di.VisitDays AS 'Days',
  22690. o.CityName,
  22691. o.TourGuideName,
  22692. o.Catering,
  22693. o.CateringReason,
  22694. o.Stay,
  22695. o.StayReason,
  22696. o.[Route],
  22697. o.RouteReason,
  22698. o.OfficialActivity,
  22699. o.OfficialActivityReason,
  22700. o.TourGuide,
  22701. o.TourGuideReason,
  22702. o.[Translate],
  22703. o.TranslateReason,
  22704. o.Trip,
  22705. o.TripReason,
  22706. o.ESFileName,
  22707. o.SignatureDate,
  22708. o.Remark
  22709. FROM
  22710. Grp_Opinionaire o
  22711. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22712. WHERE
  22713. o.IsDel = 0
  22714. AND o.DiId = {0}
  22715. ORDER BY
  22716. o.Id ASC", diId);
  22717. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22718. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22719. return Ok(JsonView(data));
  22720. }
  22721. /// <summary>
  22722. /// 团组接待意见调查 - 用户
  22723. /// 保存
  22724. /// </summary>
  22725. /// <param name="dto"></param>
  22726. /// <returns></returns>
  22727. [HttpPost]
  22728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22729. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22730. {
  22731. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22732. foreach (var item in dto)
  22733. {
  22734. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22735. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22736. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22737. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22738. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22739. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22740. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22741. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22742. }
  22743. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22744. if (!Directory.Exists(filePathBase))
  22745. {
  22746. Directory.CreateDirectory(filePathBase);
  22747. }
  22748. #region 上传文件
  22749. var filePaths = new List<string>();
  22750. foreach (var item in dto)
  22751. {
  22752. var file = item.File;
  22753. // 将文件保存到指定位置
  22754. var filePath = Path.Combine(filePathBase, file.FileName);
  22755. using (var stream = new FileStream(filePath, FileMode.Create))
  22756. {
  22757. await file.CopyToAsync(stream);
  22758. }
  22759. //验证文件是否上传成功
  22760. if (!System.IO.File.Exists(filePath))
  22761. {
  22762. foreach (var filePathStr in filePaths)
  22763. {
  22764. System.IO.File.Delete(filePathStr);
  22765. }
  22766. return Ok(JsonView(false, "文件上传失败!"));
  22767. }
  22768. item.ESFileName = file.FileName;
  22769. }
  22770. #endregion
  22771. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22772. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22773. .UpdateColumns(x => new
  22774. {
  22775. x.Catering,
  22776. x.CateringReason,
  22777. x.Stay,
  22778. x.StayReason,
  22779. x.Route,
  22780. x.RouteReason,
  22781. x.OfficialActivity,
  22782. x.OfficialActivityReason,
  22783. x.TourGuide,
  22784. x.TourGuideReason,
  22785. x.Translate,
  22786. x.TranslateReason,
  22787. x.Trip,
  22788. x.TripReason,
  22789. x.ESFileName,
  22790. x.SignatureDate,
  22791. x.Remark
  22792. })
  22793. .WhereColumns(x => new { x.Id })
  22794. .ExecuteCommandAsync();
  22795. if (upd < 1)
  22796. {
  22797. foreach (var filePathStr in filePaths)
  22798. {
  22799. System.IO.File.Delete(filePathStr);
  22800. }
  22801. return Ok(JsonView(false));
  22802. }
  22803. return Ok(JsonView(true));
  22804. }
  22805. #endregion
  22806. #region 团组餐厅相关信息
  22807. /// <summary>
  22808. /// 团组相关餐厅信息
  22809. /// 基础数据(团组)
  22810. /// </summary>
  22811. /// <returns></returns>
  22812. [HttpGet]
  22813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22814. public async Task<IActionResult> RestaurantInit()
  22815. {
  22816. return Ok(await _restaurantRep.InitAsync());
  22817. }
  22818. /// <summary>
  22819. /// 团组相关餐厅信息
  22820. /// Item
  22821. /// </summary>
  22822. /// <param name="dto"></param>
  22823. /// <returns></returns>
  22824. [HttpPost]
  22825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22826. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22827. {
  22828. int portType = dto.PortType,
  22829. groupId = dto.GroupId;
  22830. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22831. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22832. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22833. }
  22834. /// <summary>
  22835. /// 团组相关餐厅信息
  22836. /// List
  22837. /// </summary>
  22838. /// <param name="dto"></param>
  22839. /// <returns></returns>
  22840. [HttpPost]
  22841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22842. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22843. {
  22844. int portType = dto.PortType,
  22845. groupId = dto.GroupId;
  22846. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22847. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22848. var sql = string.Format(@" SELECT
  22849. ri.Id,
  22850. ri.GroupId,
  22851. ri.Date,
  22852. ri.StartTime,
  22853. ri.EndTime,
  22854. CASE WHEN ri.Type = 1 THEN '早餐'
  22855. WHEN ri.Type = 2 THEN '午餐'
  22856. WHEN ri.Type = 3 THEN '晚餐'
  22857. ELSE '其他'
  22858. END AS 'Type',
  22859. ri.Name,
  22860. ri.Address,
  22861. ri.Tel,
  22862. ri.Remark,
  22863. ri.CreateTime,
  22864. u.CnName AS CreateUserName
  22865. FROM
  22866. Grp_RestaurantInfo ri
  22867. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22868. WHERE
  22869. ri.IsDel = 0
  22870. AND ri.GroupId = {0}
  22871. ORDER BY
  22872. ri.Date ASC
  22873. ", groupId);
  22874. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22875. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22876. return Ok(JsonView(infos));
  22877. }
  22878. /// <summary>
  22879. /// 团组相关餐厅信息
  22880. /// Info
  22881. /// </summary>
  22882. /// <param name="dto"></param>
  22883. /// <returns></returns>
  22884. [HttpPost]
  22885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22886. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22887. {
  22888. int portType = dto.PortType,
  22889. id = dto.Id;
  22890. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22891. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22892. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22893. }
  22894. /// <summary>
  22895. /// 团组相关餐厅信息
  22896. /// Op
  22897. /// </summary>
  22898. /// <param name="dto"></param>
  22899. /// <returns></returns>
  22900. [HttpPost]
  22901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22902. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22903. {
  22904. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22905. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22906. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22907. return Ok(await _restaurantRep.OpAsync(dto));
  22908. }
  22909. /// <summary>
  22910. /// 团组相关餐厅信息
  22911. /// Del
  22912. /// </summary>
  22913. /// <param name="dto"></param>
  22914. /// <returns></returns>
  22915. [HttpPost]
  22916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22917. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22918. {
  22919. int userId = dto.DeleteUserId;
  22920. var id = dto.Id;
  22921. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22922. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22923. return Ok(await _restaurantRep.DelAsync(dto));
  22924. }
  22925. #endregion
  22926. #region 团组会务成本
  22927. /// <summary>
  22928. /// 团组会务成本数据初始化
  22929. /// </summary>
  22930. /// <returns></returns>
  22931. [HttpPost]
  22932. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  22933. {
  22934. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  22935. .OrderByDescending(x => x.CreateTime)
  22936. .Where(x => x.IsDel == 0)
  22937. .Select<DelegationEasyView>();
  22938. DelegationEasyView di = Dto.GroupId == 0 ?
  22939. expr.First() :
  22940. expr.First(x => x.Id == Dto.GroupId);
  22941. if (di == null)
  22942. {
  22943. return Ok(JsonView(false, "团组信息不存在!"));
  22944. }
  22945. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  22946. .Where(x => x.IsDel == 0 && x.STid == 21)
  22947. .Select(x => new { x.Id, Text = x.Name })
  22948. .ToListAsync();
  22949. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  22950. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  22951. .Select(x => x.Id)
  22952. .ToList();
  22953. //仅检索会务团组
  22954. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  22955. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  22956. .OrderByDescending(x => x.VisitDate)
  22957. .Select(x => new { x.Id, x.TeamName })
  22958. .ToListAsync();
  22959. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  22960. var userList = await _sqlSugar.Queryable<Sys_Users>()
  22961. .Where(x => x.IsDel == 0)
  22962. .Select(x => new { x.Id, x.CnName })
  22963. .ToListAsync();
  22964. var units = await _sqlSugar.Queryable<Sys_SetData>()
  22965. .Where(x => x.IsDel == 0 && x.STid == 119)
  22966. .Select(x => new { x.Id, Text = x.Name })
  22967. .ToListAsync();
  22968. var FileType = new[]
  22969. {
  22970. new { Id = 0 , Name = "成本下载" },
  22971. new { Id = 1 , Name = "报价下载" },
  22972. new { Id = 2 , Name = "总表下载" },
  22973. };
  22974. var GM = new List<int>();
  22975. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  22976. try
  22977. {
  22978. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  22979. }
  22980. catch (Exception ex)
  22981. {
  22982. GM = new List<int>() { 21 };
  22983. }
  22984. var isReview = Dto.UserId == 21;
  22985. var isGM = GM.Contains(Dto.UserId);
  22986. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  22987. .Where(x => x.IsDel == 0)
  22988. .Select<ConferenceAffairsCostView>()
  22989. .First(x=> x.Diid == di.Id);
  22990. if (ConferenceAffairsCost == null)
  22991. {
  22992. ConferenceAffairsCost = new ConferenceAffairsCostView();
  22993. ConferenceAffairsCost.Diid = di.Id;
  22994. }
  22995. #region 权限校验
  22996. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  22997. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  22998. .Select(x=> x.UserId)
  22999. .Distinct()
  23000. .ToList();
  23001. if (!ids.Contains(Dto.UserId) && !isGM )
  23002. {
  23003. return Ok(JsonView(201, "暂无权限!", new
  23004. {
  23005. typeData,
  23006. groupList,
  23007. currenyList,
  23008. isGM,
  23009. userList,
  23010. units,
  23011. isReview,
  23012. operatorUser = ids,
  23013. di,
  23014. FileType
  23015. }));
  23016. }
  23017. #endregion
  23018. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23019. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23020. .Select<ConferenceAffairsCostChildView>()
  23021. .OrderBy(x=>x.Index)
  23022. .ToList();
  23023. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  23024. {
  23025. ConferenceAffairsCostChi[i - 1].Index = i;
  23026. }
  23027. var backData = new
  23028. {
  23029. ConferenceAffairsCost,
  23030. ConferenceAffairsCostChi,
  23031. typeData,
  23032. groupList,
  23033. currenyList,
  23034. isGM,
  23035. userList,
  23036. units,
  23037. isReview,
  23038. operatorUser = ids,
  23039. di,
  23040. FileType
  23041. };
  23042. return Ok(JsonView(true, "SUCCESS", backData));
  23043. }
  23044. /// <summary>
  23045. /// 会务成本保存
  23046. /// </summary>
  23047. /// <returns></returns>
  23048. [HttpPost]
  23049. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23050. {
  23051. _sqlSugar.BeginTran();
  23052. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23053. var childResult = new
  23054. {
  23055. success = 0,
  23056. error = 0
  23057. };
  23058. try
  23059. {
  23060. if (data.Id == 0)
  23061. {
  23062. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23063. .Where(x => x.Diid == Dto.GroupId)
  23064. .SetColumns(x => new Grp_ConferenceAffairsCost
  23065. {
  23066. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23067. DeleteUserId = Dto.UserId
  23068. })
  23069. .ExecuteCommand();
  23070. data.Diid = Dto.GroupId;
  23071. data.CreateTime = DateTime.Now;
  23072. data.CreateUserId = Dto.UserId;
  23073. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23074. .ExecuteReturnIdentity();
  23075. }
  23076. else
  23077. {
  23078. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23079. .ExecuteCommand();
  23080. data.Id = data.Id;
  23081. }
  23082. if (Dto.ConferenceAffairsCostChild.Any())
  23083. {
  23084. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23085. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23086. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  23087. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  23088. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23089. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23090. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23091. .IgnoreColumns(x=> new { x.ConferenceAffairsCostId })
  23092. .ExecuteCommand() : 0;
  23093. childResult = childResult with
  23094. {
  23095. error = notUpdateArr.Count(),
  23096. success = inrsetCount + updateCount
  23097. };
  23098. }
  23099. _sqlSugar.CommitTran();
  23100. }
  23101. catch (Exception ex)
  23102. {
  23103. _sqlSugar.RollbackTran();
  23104. return Ok(JsonView(false, "失败!" + ex.Message));
  23105. }
  23106. return Ok(JsonView(true,"操作成功!", childResult));
  23107. }
  23108. [HttpPost]
  23109. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  23110. {
  23111. var count = 0;
  23112. if (Dto.ConferenceAffairsCostChildids.Any())
  23113. {
  23114. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  23115. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  23116. SetColumns(x => new Grp_ConferenceAffairsCostChild
  23117. {
  23118. ReviewStatus = Dto.ReviewStatus
  23119. }).
  23120. ExecuteCommand();
  23121. }
  23122. return Ok(JsonView(true, "操作成功!",count));
  23123. }
  23124. /// <summary>
  23125. /// 会务成本所有数据清除
  23126. /// </summary>
  23127. /// <param name="Dto"></param>
  23128. /// <returns></returns>
  23129. [HttpPost]
  23130. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  23131. {
  23132. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23133. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  23134. _sqlSugar.BeginTran();
  23135. try
  23136. {
  23137. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23138. .Where(x => x.Diid == Dto.GroupId)
  23139. .SetColumns(x => new Grp_ConferenceAffairsCost
  23140. {
  23141. IsDel = 1,
  23142. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23143. DeleteUserId = Dto.UserId
  23144. })
  23145. .ExecuteCommand();
  23146. if (delCount > 0)
  23147. {
  23148. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23149. .Where(x => x.Diid == Dto.GroupId)
  23150. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23151. {
  23152. IsDel = 1,
  23153. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23154. DeleteUserId = Dto.UserId
  23155. })
  23156. .ExecuteCommand();
  23157. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23158. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23159. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23160. {
  23161. IsDel = 1,
  23162. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23163. DeleteUserId = Dto.UserId
  23164. })
  23165. .ExecuteCommand();
  23166. }
  23167. _sqlSugar.CommitTran();
  23168. }
  23169. catch (Exception ex)
  23170. {
  23171. _sqlSugar.RollbackTran();
  23172. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23173. }
  23174. return Ok(JsonView(true, "操作成功!"));
  23175. }
  23176. /// <summary>
  23177. /// 子项数据删除
  23178. /// </summary>
  23179. /// <param name="Dto"></param>
  23180. /// <returns></returns>
  23181. [HttpPost]
  23182. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  23183. {
  23184. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  23185. .Any(x => x.ReviewStatus == 1);
  23186. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  23187. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23188. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  23189. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23190. {
  23191. IsDel = 1,
  23192. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23193. DeleteUserId = Dto.UserId
  23194. })
  23195. .ExecuteCommand();
  23196. return Ok(JsonView(true, "SUCCESS!", count));
  23197. }
  23198. /// <summary>
  23199. /// 会务成本权限分配
  23200. /// </summary>
  23201. /// <param name="Dto"></param>
  23202. /// <returns></returns>
  23203. [HttpPost]
  23204. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  23205. {
  23206. _sqlSugar.BeginTran();
  23207. var count = 0;
  23208. try
  23209. {
  23210. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23211. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23212. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23213. {
  23214. IsDel = 1,
  23215. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23216. DeleteUserId = Dto.CreateUserId
  23217. })
  23218. .ExecuteCommand();
  23219. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  23220. {
  23221. CreateTime = DateTime.Now,
  23222. CreateUserId = Dto.CreateUserId,
  23223. UserId = x,
  23224. Diid = Dto.GroupId,
  23225. }).ToList()).ExecuteCommand();
  23226. _sqlSugar.CommitTran();
  23227. }
  23228. catch (Exception ex)
  23229. {
  23230. _sqlSugar.RollbackTran();
  23231. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23232. }
  23233. return Ok(JsonView(true, "操作成功!", count));
  23234. }
  23235. /// <summary>
  23236. /// 团组会务成本文件下载
  23237. /// </summary>
  23238. /// <returns></returns>
  23239. [HttpPost]
  23240. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  23241. {
  23242. var FileType = new[]
  23243. {
  23244. new { Id = 0 , Name = "成本下载" },
  23245. new { Id = 1 , Name = "报价下载" },
  23246. new { Id = 2 , Name = "总表下载" },
  23247. };
  23248. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23249. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  23250. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23251. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  23252. .Select<DelegationEasyView>()
  23253. .First();
  23254. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23255. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  23256. if (main == null)
  23257. {
  23258. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  23259. }
  23260. JsonView jw = JsonView(false);
  23261. //总表下载
  23262. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  23263. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  23264. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  23265. var field = string.Empty;
  23266. var fileTypeName = string.Empty;
  23267. field = @$"
  23268. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  23269. b.Name as PriceTypeStr ,
  23270. c.Name as CurrencyStr ,
  23271. d.Name as UnitStr ,
  23272. case a.ReviewStatus
  23273. WHEN 1 THEN '已通过'
  23274. WHEN 0 THEN '未审核'
  23275. WHEN -1 THEN '未通过'
  23276. ELSE '未审核'
  23277. END AS ReviewStatusStr
  23278. ";
  23279. if (Dto.FileTypeId == 0)
  23280. {
  23281. fileTypeName = "会务成本成本表";
  23282. loadPath += $"{fileTypeName}.xlsx";
  23283. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23284. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23285. }
  23286. else if (Dto.FileTypeId == 1)
  23287. {
  23288. fileTypeName = "会务成本报价表";
  23289. loadPath += $"{fileTypeName}.xlsx";
  23290. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23291. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23292. }
  23293. else if (Dto.FileTypeId == 2)
  23294. {
  23295. fileTypeName = "会务成本总表";
  23296. loadPath += $"{fileTypeName}.xlsx";
  23297. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23298. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23299. }
  23300. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  23301. SELECT
  23302. {field}
  23303. FROM Grp_ConferenceAffairsCostChild a
  23304. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  23305. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  23306. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  23307. WHERE a.isdel = 0
  23308. AND a.Diid = {main.Diid}
  23309. AND a.ConferenceAffairsCostId = {main.Id}
  23310. ").ToList();
  23311. var currLists = chiExcelContent.Select(x => new CurrList
  23312. {
  23313. CurrName = x.CurrencyStr,
  23314. CurrRate = x.Rate
  23315. })
  23316. .Distinct()
  23317. .ToList();
  23318. var designer = new WorkbookDesigner
  23319. {
  23320. Workbook = new Workbook(loadPath)
  23321. };
  23322. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x=>x.IsDel == 0 && x.Id == main.MostCurr);
  23323. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  23324. designer.SetDataSource("TeamName", di.TeamName);
  23325. designer.SetDataSource("City", main.City);
  23326. designer.SetDataSource("AllCost", main.CostAll);
  23327. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  23328. designer.SetDataSource("Curr", MostCurr.Name);
  23329. designer.SetDataSource("Curr1", MostCurr.Name);
  23330. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  23331. dt.TableName = "TB";
  23332. designer.SetDataSource(dt);
  23333. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  23334. dt1.TableName = "currTb";
  23335. designer.SetDataSource(dt1);
  23336. designer.Process();
  23337. designer.Workbook.Save(outputPath);
  23338. jw = JsonView(true, "操作成功!", new
  23339. {
  23340. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  23341. FilePath = networkPath
  23342. });
  23343. return Ok(jw);
  23344. }
  23345. [HttpPost]
  23346. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  23347. {
  23348. return Ok(JsonView(true,"SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  23349. .Select(x=>x.PriceName).ToList()));
  23350. }
  23351. #endregion
  23352. #region 团组签证流程
  23353. #endregion
  23354. /// <summary>
  23355. /// 123132123
  23356. /// </summary>
  23357. /// <param name="_dto"></param>
  23358. /// <returns></returns>
  23359. [HttpPost]
  23360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23361. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  23362. {
  23363. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  23364. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  23365. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  23366. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  23367. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  23368. dicDetail.Add(789, 1034);
  23369. dicDetail.Add(790, 1035);
  23370. dicDetail.Add(791, 1036);
  23371. dicDetail.Add(792, 1037);
  23372. dicDetail.Add(793, 1038);
  23373. dicDetail.Add(794, 1039);
  23374. dicDetail.Add(795, 1040);
  23375. dicDetail.Add(796, 1041);
  23376. dicDetail.Add(797, 1042);
  23377. dicDetail.Add(798, 1043);
  23378. dicDetail.Add(801, 1044);
  23379. dicDetail.Add(802, 1045);
  23380. dicDetail.Add(803, 1046);
  23381. Dictionary<int, int> dic = new Dictionary<int, int>();
  23382. dic.Add(806, 1027);
  23383. dic.Add(807, 1028);
  23384. dic.Add(808, 1029);
  23385. dic.Add(809, 1030);
  23386. dic.Add(810, 1031);
  23387. dic.Add(811, 1032);
  23388. dic.Add(812, 1033);
  23389. foreach (var item in list_visa)
  23390. {
  23391. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  23392. temp.Coefficient = item.coefficient;
  23393. DateTime dtCrt;
  23394. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  23395. if (b1)
  23396. {
  23397. temp.CreateTime = dtCrt;
  23398. }
  23399. else
  23400. {
  23401. temp.CreateTime = DateTime.Now;
  23402. }
  23403. temp.CreateUserId = item.Operators;
  23404. temp.DeleteTime = "";
  23405. temp.DeleteUserId = 0;
  23406. temp.DiId = int.Parse(item.DIID);
  23407. temp.FilePath = item.FilePath;
  23408. temp.IsDel = item.IsDel;
  23409. temp.Price = item.Price;
  23410. temp.PriceCount = 1;
  23411. temp.PriceCurrency = item.Currency;
  23412. int detailId = 0;
  23413. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  23414. {
  23415. detailId = dicDetail[item.PriceTypeDetail];
  23416. }
  23417. temp.PriceDetailType = detailId;
  23418. temp.PriceDt = DateTime.Now;
  23419. temp.PriceName = item.PriceName;
  23420. temp.PriceSum = item.Price;
  23421. int tid = 0;
  23422. if (dic.ContainsKey(item.PriceType))
  23423. {
  23424. tid = dic[item.PriceType];
  23425. }
  23426. temp.PriceType = tid;
  23427. temp.Remark = item.Remark;
  23428. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  23429. }
  23430. return Ok(JsonView(true, "操作成功!"));
  23431. }
  23432. [HttpPost]
  23433. public IActionResult TimeTest()
  23434. {
  23435. var jw = JsonView(false, "error");
  23436. _sqlSugar.BeginTran();
  23437. try
  23438. {
  23439. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  23440. .Select(x => new Crm_NewClientData
  23441. {
  23442. Id = x.Id,
  23443. Client = x.Client,
  23444. Contact = x.Contact,
  23445. Location = x.Location,
  23446. })
  23447. .ToList();
  23448. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  23449. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  23450. Stopwatch stopwatch = new Stopwatch();
  23451. // 开始计时
  23452. stopwatch.Start();
  23453. foreach (var item in clientList)
  23454. {
  23455. EncryptionProcessor.DecryptProperties(item);
  23456. }
  23457. stopwatch.Stop();
  23458. jw.Code = 200;
  23459. jw.Data = stopwatch.ElapsedMilliseconds;
  23460. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  23461. }
  23462. catch (Exception ex)
  23463. {
  23464. jw.Code = 400;
  23465. jw.Msg = ex.Message;
  23466. }
  23467. return Ok(jw);
  23468. }
  23469. }
  23470. }