GroupsController.cs 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048
  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.Compression;
  44. using System.Text.Json;
  45. using System.Text.RegularExpressions;
  46. using System.Web;
  47. using static OASystem.API.OAMethodLib.JWTHelper;
  48. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  49. using Bookmark = Aspose.Words.Bookmark;
  50. using Cell = Aspose.Words.Tables.Cell;
  51. using Table = Aspose.Words.Tables.Table;
  52. namespace OASystem.API.Controllers
  53. {
  54. /// <summary>
  55. /// 团组相关
  56. /// </summary>
  57. //[Authorize]
  58. [Route("api/[controller]/[action]")]
  59. public class GroupsController : ControllerBase
  60. {
  61. private readonly ILogger<GroupsController> _logger;
  62. private readonly ITextFileLogger _eec_textLogger;
  63. private readonly GrpScheduleRepository _grpScheduleRep;
  64. private readonly IMapper _mapper;
  65. private readonly DelegationInfoRepository _groupRepository;
  66. private readonly TaskAssignmentRepository _taskAssignmentRep;
  67. private readonly AirTicketResRepository _airTicketResRep;
  68. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  69. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  70. private readonly DelegationEnDataRepository _delegationEnDataRep;
  71. private readonly DelegationVisaRepository _delegationVisaRep;
  72. private readonly VisaPriceRepository _visaPriceRep;
  73. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  74. private readonly HotelPriceRepository _hotelPriceRep;
  75. private readonly CustomersRepository _customersRep;
  76. private readonly MessageRepository _message;
  77. private readonly SqlSugarClient _sqlSugar;
  78. private readonly TourClientListRepository _tourClientListRep;
  79. private readonly TeamRateRepository _teamRateRep;
  80. #region 成本相关
  81. private readonly CheckBoxsRepository _checkBoxs;
  82. private readonly GroupCostRepository _GroupCostRepository;
  83. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  84. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  85. #endregion
  86. private readonly SetDataRepository _setDataRep;
  87. private string url;
  88. private string path;
  89. private readonly EnterExitCostRepository _enterExitCostRep;
  90. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  91. private readonly UsersRepository _usersRep;
  92. private readonly IJuHeApiService _juHeApi;
  93. private readonly InvertedListRepository _invertedListRep;
  94. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  95. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  96. private readonly ThreeCodeRepository _threeCodeRepository;
  97. private readonly HotelInquiryRepository _hotelInquiryRep;
  98. private readonly FeeAuditRepository _feeAuditRep;
  99. private readonly VisaCommissionRepository _visaCommissionRep;
  100. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  101. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  102. private readonly List<CurrencyInfo> _currencyInit;
  103. private readonly List<int> _portTypeData;
  104. private readonly TableOperationRecordRepository _tableorRep;
  105. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  106. private readonly RestaurantRepository _restaurantRep;
  107. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  108. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  109. /// <summary>
  110. /// 构造函数
  111. /// </summary>
  112. /// <param name="logger"></param>
  113. /// <param name="eec_textLogger"></param>
  114. /// <param name="mapper"></param>
  115. /// <param name="hubContext"></param>
  116. /// <param name="sqlSugar"></param>
  117. /// <param name="grpScheduleRep"></param>
  118. /// <param name="groupRepository"></param>
  119. /// <param name="taskAssignmentRep"></param>
  120. /// <param name="airTicketResRep"></param>
  121. /// <param name="decreasePaymentsRep"></param>
  122. /// <param name="InvitationOfficialActivitiesRep"></param>
  123. /// <param name="delegationEnDataRep"></param>
  124. /// <param name="enterExitCostRep"></param>
  125. /// <param name="delegationVisaRep"></param>
  126. /// <param name="message"></param>
  127. /// <param name="visaPriceRep"></param>
  128. /// <param name="carTouristGuideGroundRep"></param>
  129. /// <param name="checkBoxs"></param>
  130. /// <param name="GroupCostRepository"></param>
  131. /// <param name="CostTypeHotelNumberRepository"></param>
  132. /// <param name="GroupCostParameterRepository"></param>
  133. /// <param name="hotelPriceRep"></param>
  134. /// <param name="customersRep"></param>
  135. /// <param name="setDataRep"></param>
  136. /// <param name="tourClientListRep"></param>
  137. /// <param name="teamRateRep"></param>
  138. /// <param name="usersRep"></param>
  139. /// <param name="juHeApi"></param>
  140. /// <param name="invertedListRep"></param>
  141. /// <param name="visaFeeInfoRep"></param>
  142. /// <param name="ticketBlackCodeRep"></param>
  143. /// <param name="hotelInquiryRep"></param>
  144. /// <param name="threeCodeRepository"></param>
  145. /// <param name="feeAuditRep"></param>
  146. /// <param name="visaCommissionRep"></param>
  147. /// <param name="ffrRep"></param>
  148. /// <param name="opinionaireRep"></param>
  149. /// <param name="tableorRep"></param>
  150. /// <param name="enterExitCostDraftRep"></param>
  151. /// <param name="restaurantRep"></param>
  152. /// <param name="enterExitCostQuoteRep"></param>
  153. /// <param name="grpOrderPreInfoRep"></param>
  154. public GroupsController(
  155. ILogger<GroupsController> logger,
  156. ITextFileLogger eec_textLogger,
  157. IMapper mapper,
  158. IHubContext<ChatHub, IChatClient> hubContext,
  159. SqlSugarClient sqlSugar,
  160. GrpScheduleRepository grpScheduleRep,
  161. DelegationInfoRepository groupRepository,
  162. TaskAssignmentRepository taskAssignmentRep,
  163. AirTicketResRepository airTicketResRep,
  164. DecreasePaymentsRepository decreasePaymentsRep,
  165. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  166. DelegationEnDataRepository delegationEnDataRep,
  167. EnterExitCostRepository enterExitCostRep,
  168. DelegationVisaRepository delegationVisaRep,
  169. MessageRepository message,
  170. VisaPriceRepository visaPriceRep,
  171. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  172. CheckBoxsRepository checkBoxs,
  173. GroupCostRepository GroupCostRepository,
  174. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  175. GroupCostParameterRepository GroupCostParameterRepository,
  176. HotelPriceRepository hotelPriceRep,
  177. CustomersRepository customersRep,
  178. SetDataRepository setDataRep,
  179. TourClientListRepository tourClientListRep,
  180. TeamRateRepository teamRateRep,
  181. UsersRepository usersRep,
  182. IJuHeApiService juHeApi,
  183. InvertedListRepository invertedListRep,
  184. VisaFeeInfoRepository visaFeeInfoRep,
  185. TicketBlackCodeRepository ticketBlackCodeRep,
  186. HotelInquiryRepository hotelInquiryRep,
  187. ThreeCodeRepository threeCodeRepository,
  188. FeeAuditRepository feeAuditRep,
  189. VisaCommissionRepository visaCommissionRep,
  190. ForeignReceivablesRepository ffrRep,
  191. OpinionaireRepository opinionaireRep,
  192. TableOperationRecordRepository tableorRep,
  193. EnterExitCostDraftRepository enterExitCostDraftRep,
  194. RestaurantRepository restaurantRep,
  195. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  196. GroupOrderPreInfoRepository grpOrderPreInfoRep
  197. )
  198. {
  199. _logger = logger;
  200. _eec_textLogger = eec_textLogger;
  201. _mapper = mapper;
  202. _grpScheduleRep = grpScheduleRep;
  203. _groupRepository = groupRepository;
  204. _taskAssignmentRep = taskAssignmentRep;
  205. _airTicketResRep = airTicketResRep;
  206. _sqlSugar = sqlSugar;
  207. url = AppSettingsHelper.Get("ExcelBaseUrl");
  208. path = AppSettingsHelper.Get("ExcelBasePath");
  209. if (!System.IO.Directory.Exists(path))
  210. {
  211. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  212. }
  213. _decreasePaymentsRep = decreasePaymentsRep;
  214. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  215. _delegationEnDataRep = delegationEnDataRep;
  216. _enterExitCostRep = enterExitCostRep;
  217. _delegationVisaRep = delegationVisaRep;
  218. _message = message;
  219. _visaPriceRep = visaPriceRep;
  220. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  221. _checkBoxs = checkBoxs;
  222. _GroupCostRepository = GroupCostRepository;
  223. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  224. _GroupCostParameterRepository = GroupCostParameterRepository;
  225. _hotelPriceRep = hotelPriceRep;
  226. _customersRep = customersRep;
  227. _setDataRep = setDataRep;
  228. _tourClientListRep = tourClientListRep;
  229. _teamRateRep = teamRateRep;
  230. _hubContext = hubContext;
  231. _usersRep = usersRep;
  232. _juHeApi = juHeApi;
  233. _invertedListRep = invertedListRep;
  234. _visaFeeInfoRep = visaFeeInfoRep;
  235. _ticketBlackCodeRep = ticketBlackCodeRep;
  236. _hotelInquiryRep = hotelInquiryRep;
  237. _threeCodeRepository = threeCodeRepository;
  238. _feeAuditRep = feeAuditRep;
  239. _visaCommissionRep = visaCommissionRep;
  240. _ffrRep = ffrRep;
  241. _opinionaireRep = opinionaireRep;
  242. _currencyInit = new List<CurrencyInfo>()
  243. {
  244. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  245. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  246. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  247. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  248. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  249. };
  250. _portTypeData = new List<int>() { 2, 3 };
  251. _tableorRep = tableorRep;
  252. _enterExitCostDraftRep = enterExitCostDraftRep;
  253. _restaurantRep = restaurantRep;
  254. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  255. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  256. }
  257. #region 流程管控
  258. /// <summary>
  259. /// 获取团组流程管控信息
  260. /// </summary>
  261. /// <param name="_jsonDto">查询参数</param>
  262. /// <returns></returns>
  263. [HttpPost]
  264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  265. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  266. {
  267. if (string.IsNullOrEmpty(_jsonDto.Paras))
  268. {
  269. return Ok(JsonView(false, "参数为空"));
  270. }
  271. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  272. if (_ScheduleDto != null)
  273. {
  274. if (_ScheduleDto.SearchType == 2)//获取列表
  275. {
  276. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  277. return Ok(JsonView(_grpScheduleViewList));
  278. }
  279. else//获取对象
  280. {
  281. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  282. if (_grpScheduleView != null)
  283. {
  284. return Ok(JsonView(_grpScheduleView));
  285. }
  286. }
  287. }
  288. else
  289. {
  290. return Ok(JsonView(false, "参数反序列化失败"));
  291. }
  292. return Ok(JsonView(false, "暂无数据!"));
  293. }
  294. /// <summary>
  295. /// 修改团组流程管控详细表数据
  296. /// </summary>
  297. /// <param name="dto"></param>
  298. /// <returns></returns>
  299. [HttpPost]
  300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  301. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  302. {
  303. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  304. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  305. .SetColumns(it => it.Duty == _detail.Duty)
  306. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  307. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  308. .SetColumns(it => it.JobContent == _detail.JobContent)
  309. .SetColumns(it => it.Remark == _detail.Remark)
  310. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  311. .Where(s => s.Id == dto.Id)
  312. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  313. .ExecuteCommandAsync();
  314. if (result > 0)
  315. {
  316. return Ok(JsonView(true, "保存成功!"));
  317. }
  318. return Ok(JsonView(false, "保存失败!"));
  319. }
  320. /// <summary>
  321. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  322. /// </summary>
  323. /// <param name="dto"></param>
  324. /// <returns></returns>
  325. [HttpPost]
  326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  327. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  328. {
  329. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  330. _detail.IsDel = 1;
  331. _detail.DeleteUserId = dto.Duty;
  332. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  333. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  334. .SetColumns(it => it.IsDel == _detail.IsDel)
  335. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  336. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  337. .Where(it => it.Id == dto.Id)
  338. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  339. //.WhereColumns(s => s.Id == dto.Id)
  340. .ExecuteCommandAsync();
  341. if (result > 0)
  342. {
  343. return Ok(JsonView(true, "删除成功!"));
  344. }
  345. return Ok(JsonView(false, "删除失败!"));
  346. }
  347. /// <summary>
  348. /// 增加团组流程管控详细表数据
  349. /// </summary>
  350. /// <param name="dto"></param>
  351. /// <returns></returns>
  352. [HttpPost]
  353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  354. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  355. {
  356. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  357. if (DateTime.Now < _detail.ExpectBeginDt)
  358. {
  359. _detail.StepStatus = 0;
  360. }
  361. else
  362. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  363. _detail.StepStatus = 1;
  364. }
  365. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  366. if (result > 0)
  367. {
  368. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  369. return Ok(JsonView(true, "添加成功!", _result));
  370. }
  371. return Ok(JsonView(false, "添加失败!"));
  372. }
  373. #endregion
  374. #region 团组前期信息
  375. /// <summary>
  376. /// 团组前期信息H5-URL(员工对应地址)
  377. /// </summary>
  378. /// <param name="name">用户名称</param>
  379. /// <returns></returns>
  380. [HttpGet]
  381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  382. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  383. {
  384. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  385. .Where(x => x.IsDel == 0)
  386. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  387. .OrderBy(x => x.Id)
  388. .Select(x => new
  389. {
  390. name = x.CnName,
  391. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  392. })
  393. .ToListAsync();
  394. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  395. }
  396. /// <summary>
  397. /// 团组前期信息 List
  398. /// </summary>
  399. /// <returns></returns>
  400. [HttpPost]
  401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  402. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  403. {
  404. var search = dto.Search;
  405. int[] nameTempIds = new int[] { 1, 12, 28 },
  406. countryTempIds = new int[] { 2, 13, 29 },
  407. daysTempIds = new int[] { 4, 15, 31 },
  408. ppNumTempIds = new int[] { 6 };
  409. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  410. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  411. .Where((opi, u) => opi.IsDel == 0)
  412. .OrderByDescending((opi, u) => opi.CreateTime)
  413. .Select((opi, u) => new GroupOrderPreInfoListView()
  414. {
  415. Id = opi.Id,
  416. Name = opi.Name,
  417. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  418. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  419. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  420. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  421. Operator = u.CnName,
  422. OperationTime = opi.CreateTime
  423. })
  424. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  425. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  426. .ToListAsync();
  427. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  428. int total = list.Count;
  429. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  430. var listPageData1 = listPageData
  431. .Skip((dto.PageIndex - 1) * dto.PageSize)
  432. .Take(dto.PageSize)
  433. .ToList();
  434. var infoIds = listPageData1.Select(x => x.Id).ToList();
  435. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  436. .Where(x => x.IsDel == 0 && x.STid == 109)
  437. .ToArrayAsync();
  438. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  439. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  440. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  441. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  442. .ToListAsync();
  443. foreach (var item in listPageData1)
  444. {
  445. var typeDatas1 = typeDatas.Select(x => new
  446. {
  447. x.Id,
  448. x.Name,
  449. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  450. }).ToArray();
  451. item.VersionDetails = typeDatas1;
  452. }
  453. return Ok(JsonView(listPageData1, listPageData1.Count));
  454. }
  455. /// <summary>
  456. /// 团组前期信息 Init
  457. /// </summary>
  458. /// <returns></returns>
  459. [HttpGet("{userId}")]
  460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  461. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  462. {
  463. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  464. }
  465. /// <summary>
  466. /// 国家数据源
  467. /// </summary>
  468. /// <param name="pageIndex">当前页码</param>
  469. /// <param name="pageSize">每页条数</param>
  470. /// <param name="search">查询条件</param>
  471. /// <returns></returns>
  472. [HttpGet]
  473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  474. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  475. {
  476. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  477. if (pageIndex == 0 && pageSize == 0)
  478. {
  479. //所有数据
  480. return Ok(JsonView(countrys, countrys.Count));
  481. }
  482. //分页
  483. int skip = (pageIndex - 1) * pageSize;
  484. int take = pageSize;
  485. if (!string.IsNullOrEmpty(search))
  486. {
  487. IEnumerable<char> charSequence = search.Select(c => c);
  488. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  489. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  490. return Ok(JsonView(pageData, pageResult1.Count));
  491. }
  492. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  493. return Ok(JsonView(pageResult2, countrys.Count));
  494. }
  495. /// <summary>
  496. /// 城市数据源
  497. /// </summary>
  498. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  499. /// <param name="pageIndex">当前页码</param>
  500. /// <param name="pageSize">每页条数</param>
  501. /// <param name="search">查询条件</param>
  502. /// <returns></returns>
  503. [HttpGet("{countryLabel}")]
  504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  505. public async Task<IActionResult> CityByCountry(
  506. string countryLabel,
  507. [FromQuery] int pageIndex,
  508. [FromQuery] int pageSize,
  509. [FromQuery] string search)
  510. {
  511. countryLabel = HttpUtility.UrlDecode(countryLabel);
  512. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  513. var citys = Array.Empty<string?>();
  514. if (countryList.Any())
  515. {
  516. var cityDatas = await _sqlSugar
  517. .Queryable<Grp_NationalTravelFee>()
  518. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  519. .ToArrayAsync();
  520. foreach (var item in cityDatas)
  521. {
  522. if (item.City.Contains("城市"))
  523. {
  524. item.City = item.Country + "-所有城市";
  525. }
  526. }
  527. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  528. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  529. }
  530. if (pageIndex == 0 && pageSize == 0)
  531. {
  532. //所有数据
  533. return Ok(JsonView(citys, citys?.Length ?? 0));
  534. }
  535. //分页
  536. int skip = (pageIndex - 1) * pageSize;
  537. int take = pageSize;
  538. if (!string.IsNullOrEmpty(search))
  539. {
  540. IEnumerable<char> charSequence = search.Select(c => c);
  541. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  542. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  543. return Ok(JsonView(pageData, pageResult1.Count));
  544. }
  545. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  546. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  547. }
  548. /// <summary>
  549. /// 团组前期信息 Info
  550. /// </summary>
  551. /// <param name="dto">Id</param>
  552. /// <returns></returns>
  553. [HttpGet("{Id}/{TempId}")]
  554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  555. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  556. {
  557. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  558. }
  559. /// <summary>
  560. /// 团组前期信息 移动端 Info
  561. /// </summary>
  562. /// <param name="dto">Id</param>
  563. /// <returns></returns>
  564. [HttpGet("{Id}/{TempId}")]
  565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  566. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  567. {
  568. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  569. }
  570. /// <summary>
  571. /// 团组前期信息 Save
  572. /// </summary>
  573. /// <param name="dto">Id</param>
  574. /// <returns></returns>
  575. [HttpPost]
  576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  577. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  578. {
  579. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  580. }
  581. /// <summary>
  582. /// 团组前期信息 Del
  583. /// </summary>
  584. /// <param name="dto">Id</param>
  585. /// <returns></returns>
  586. [HttpPost]
  587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  588. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  589. {
  590. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  591. }
  592. /// <summary>
  593. /// 团组前期信息 文件下载
  594. /// </summary>
  595. /// <param name="dto">Id</param>
  596. /// <returns></returns>
  597. [HttpGet("{Id}/{TempId}")]
  598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  599. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  600. {
  601. int id = dto.Id, tempId = dto.TempId;
  602. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  603. var data = view.Data as GrpOrderPreInfoView;
  604. #region Excel
  605. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  606. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  607. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  608. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  609. var fileNamePrefix = string.Empty;
  610. if (tempId == 1405)
  611. {
  612. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  613. fileNamePrefix = $"{data.Name}_无商邀版";
  614. }
  615. else if (tempId == 1406)
  616. {
  617. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  618. fileNamePrefix = $"{data.Name}_有商邀版";
  619. }
  620. else
  621. {
  622. //tempId == 1404 默认下载
  623. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  624. fileNamePrefix = $"{data.Name}_单接送机";
  625. }
  626. foreach (var item in data.Items)
  627. {
  628. var obj = item.NewValue;
  629. if (obj == null) item.OriginVal = "";
  630. else if (obj.Equals("有") || obj.Equals("无"))
  631. {
  632. item.OriginVal = obj.ToString();
  633. }
  634. else if (obj is object[] objArray)
  635. {
  636. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  637. item.OriginVal = string.Join("、", stringArray);
  638. }
  639. else if (obj is string[] stringArray)
  640. {
  641. item.OriginVal = string.Join("、", stringArray);
  642. }
  643. else if (obj.Equals("-"))
  644. {
  645. item.OriginVal = "";
  646. }
  647. }
  648. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  649. fileName = CommonFun.ValidFileName(fileName);
  650. //载入模板
  651. var designer = new WorkbookDesigner
  652. {
  653. Workbook = new Workbook(tempPath)
  654. };
  655. if (tempId == 1406)
  656. {
  657. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  658. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  659. for (int i = 1; i <= view2.Length; i++)
  660. {
  661. view2[i - 1].Index = i;
  662. }
  663. designer.SetDataSource("View1", view1);
  664. designer.SetDataSource("View2", view2);
  665. }
  666. else
  667. {
  668. designer.SetDataSource("View", data.Items);
  669. }
  670. designer.Process();
  671. if (!Directory.Exists(savePath))
  672. {
  673. Directory.CreateDirectory(savePath);
  674. }
  675. string serverPath = $"{savePath}{fileName}";
  676. designer.Workbook.Save(serverPath);
  677. string rst = $"{servicePath}{ftpPath}{fileName}";
  678. #endregion
  679. return Ok(JsonView(new { url = rst }));
  680. }
  681. #endregion
  682. #region 团组基本信息
  683. /// <summary>
  684. /// 接团信息列表
  685. /// </summary>
  686. /// <param name="dto">团组列表请求dto</param>
  687. /// <returns></returns>
  688. [HttpPost]
  689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  690. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  691. {
  692. var groupData = await _groupRepository.GetGroupList(dto);
  693. if (groupData.Code != 0)
  694. {
  695. return Ok(JsonView(false, groupData.Msg));
  696. }
  697. return Ok(JsonView(groupData.Data));
  698. }
  699. /// <summary>
  700. /// 分页查询团组列表
  701. /// </summary>
  702. /// <param name="dto"></param>
  703. /// <returns></returns>
  704. [HttpPost]
  705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  706. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  707. {
  708. var watch = new Stopwatch();
  709. watch.Start();
  710. RefAsync<int> total = 0;
  711. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  712. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  713. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  714. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  715. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  716. .Distinct()
  717. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  718. watch.Stop();
  719. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  720. }
  721. /// <summary>
  722. /// 接团信息列表 Page Init
  723. /// </summary>
  724. /// <returns></returns>
  725. [HttpPost]
  726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  727. public async Task<IActionResult> PostGroupPageListInit()
  728. {
  729. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  730. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  731. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  732. var _view = new
  733. {
  734. depData = depDatas,
  735. rankData = rankDatas
  736. };
  737. return Ok(JsonView(true, "查询成功!", _view));
  738. }
  739. /// <summary>
  740. /// 接团信息列表 Page
  741. /// </summary>
  742. /// <param name="dto">团组列表请求dto</param>
  743. /// <returns></returns>
  744. [HttpPost]
  745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  746. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  747. {
  748. #region 参数验证
  749. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  750. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  751. #region 页面操作权限验证
  752. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  753. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  754. #endregion
  755. #endregion
  756. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  757. {
  758. string sqlWhere = string.Empty;
  759. if (dto.IsSure == 0) //未完成
  760. {
  761. sqlWhere += string.Format(@" And IsSure = 0");
  762. }
  763. else if (dto.IsSure == 1) //已完成
  764. {
  765. sqlWhere += string.Format(@" And IsSure = 1");
  766. }
  767. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  768. {
  769. string tj = dto.SearchCriteria;
  770. 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}%')",
  771. tj, tj, tj, tj, tj);
  772. }
  773. if (int.TryParse(dto.Rank, out int rankId))
  774. {
  775. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  776. }
  777. string sqlWhere1 = string.Empty;
  778. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  779. {
  780. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  781. }
  782. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  783. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  784. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  785. JietuanOperator,IsSure,CreateTime,IsBid
  786. From (
  787. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  788. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  789. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  790. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  791. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  792. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  793. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  794. From Grp_DelegationInfo gdi
  795. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  796. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  797. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  798. Where gdi.IsDel = 0 {0}
  799. ) temp {1}", sqlWhere, sqlWhere1);
  800. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  801. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  802. //处理 团组模块实际操作人
  803. _DelegationList.ForEach(async x =>
  804. {
  805. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  806. var operatorNames = new StringBuilder();
  807. //operatorNames.AppendLine("各模块实际操作人:");
  808. if (operators.Any())
  809. {
  810. operators.ForEach(y =>
  811. {
  812. string label = string.Empty;
  813. if (y.OperationUsers.Any())
  814. {
  815. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  816. label = string.Join('、', users);
  817. }
  818. else label = "暂未指定";
  819. operatorNames.AppendLine($"{y.CTableName}:{label}");
  820. operatorNames.AppendLine();
  821. });
  822. }
  823. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  824. });
  825. var _view = new
  826. {
  827. PageFuncAuth = pageFunAuthView,
  828. Data = _DelegationList
  829. };
  830. return Ok(JsonView(true, "查询成功!", _view, total));
  831. }
  832. else
  833. {
  834. return Ok(JsonView(false, "查询失败"));
  835. }
  836. }
  837. /// <summary>
  838. /// 团组列表
  839. /// </summary>
  840. /// <returns></returns>
  841. [HttpPost]
  842. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  843. {
  844. #region 参数验证
  845. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  846. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  847. #region 页面操作权限验证
  848. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  849. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  850. #endregion
  851. #endregion
  852. if (dto.PortType != 1 && dto.PortType != 2)
  853. {
  854. return Ok(JsonView(false, "查询失败!"));
  855. }
  856. string orderbyStr = "order by gdi.CreateTime Desc";
  857. string sqlWhere = string.Empty;
  858. if (dto.IsSure == 0) //未完成
  859. {
  860. sqlWhere += string.Format(@" And IsSure = 0");
  861. }
  862. else if (dto.IsSure == 1) //已完成
  863. {
  864. sqlWhere += string.Format(@" And IsSure = 1");
  865. }
  866. //团组类型
  867. if (dto.TeamDid > 0)
  868. {
  869. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  870. }
  871. //团组名称
  872. if (!string.IsNullOrEmpty(dto.TeamName))
  873. {
  874. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  875. }
  876. //客户名称
  877. if (!string.IsNullOrEmpty(dto.ClientName))
  878. {
  879. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  880. }
  881. //客户单位
  882. if (!string.IsNullOrEmpty(dto.ClientUnit))
  883. {
  884. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  885. }
  886. //出访时间
  887. if (!string.IsNullOrEmpty(dto.visitDataTime))
  888. {
  889. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  890. orderbyStr = "order by gdi.VisitDate";
  891. }
  892. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  893. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  894. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  895. JietuanOperator,IsSure,CreateTime
  896. From (
  897. Select row_number() over({0}) as Row_Number,
  898. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  899. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  900. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  901. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  902. From Grp_DelegationInfo gdi
  903. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  904. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  905. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  906. Where gdi.IsDel = 0 {1}
  907. ) temp ", orderbyStr, sqlWhere);
  908. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  909. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  910. #region 处理所属部门
  911. /*
  912. * 1.sq 和 gyy 等显示 市场部
  913. * 2.王鸽和主管及张总还有管理员号统一国交部
  914. * 2-1. 4 管理员 ,21 张海麟
  915. */
  916. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  917. var userIds1 = new List<int>() { 4, 21 };
  918. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  919. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  920. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  921. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  922. .ToList();
  923. foreach (var item in _DelegationList)
  924. {
  925. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  926. }
  927. #endregion
  928. var _view = new
  929. {
  930. PageFuncAuth = pageFunAuthView,
  931. Data = _DelegationList
  932. };
  933. return Ok(JsonView(true, "查询成功!", _view, total));
  934. }
  935. /// <summary>
  936. /// 接团信息详情
  937. /// </summary>
  938. /// <param name="dto">团组info请求dto</param>
  939. /// <returns></returns>
  940. [HttpPost]
  941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  942. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  943. {
  944. var groupData = await _groupRepository.GetGroupInfo(dto);
  945. if (groupData.Code != 0)
  946. {
  947. return Ok(JsonView(false, groupData.Msg));
  948. }
  949. return Ok(JsonView(groupData.Data));
  950. }
  951. /// <summary>
  952. /// 接团信息 编辑添加
  953. /// 基础信息数据源
  954. /// </summary>
  955. /// <param name="dto"></param>
  956. /// <returns></returns>
  957. [HttpPost]
  958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  959. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  960. {
  961. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  962. if (groupData.Code != 0)
  963. {
  964. return Ok(JsonView(false, groupData.Msg));
  965. }
  966. return Ok(JsonView(groupData.Data));
  967. }
  968. /// <summary>
  969. /// 成本修改团组信息
  970. /// </summary>
  971. /// <param name="dto"></param>
  972. /// <returns></returns>
  973. [HttpPost]
  974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  975. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  976. {
  977. var jw = JsonView(false, "操作失败");
  978. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  979. if (di == null)
  980. {
  981. jw.Msg = "参数有误!";
  982. return Ok(jw);
  983. }
  984. #region 添加出访起止时间
  985. var startTime = new DateTime();
  986. var endTime = new DateTime();
  987. if (DateTime.TryParse(dto.VisitDate, out startTime))
  988. {
  989. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  990. }
  991. else
  992. {
  993. jw.Msg = "参数有误!";
  994. return Ok(jw);
  995. }
  996. #endregion
  997. di.VisitDate = startTime;
  998. di.VisitPNumber = dto.VisitPNumber;
  999. di.VisitDays = dto.VisitDays;
  1000. di.VisitStartDate = startTime;
  1001. di.VisitEndDate = endTime;
  1002. var count = _sqlSugar.Updateable(di)
  1003. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1004. .ExecuteCommand();
  1005. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1006. }
  1007. /// <summary>
  1008. /// 接团信息 编辑添加
  1009. /// 省份-城市 基础信息数据源
  1010. /// </summary>
  1011. /// <param name="dto"></param>
  1012. /// <returns></returns>
  1013. [HttpPost]
  1014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1015. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1016. {
  1017. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1018. string search = dto.Search;
  1019. var data = await _groupRepository.CityBasicSource();
  1020. int total = data.Length;
  1021. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1022. .Skip((pageIndex - 1) * pageSize)
  1023. .Take(pageSize)
  1024. .ToArray();
  1025. return Ok(JsonView(data, total));
  1026. }
  1027. /// <summary>
  1028. /// 接团信息 操作(增改)
  1029. /// </summary>
  1030. /// <param name="dto"></param>
  1031. /// <returns></returns>
  1032. [HttpPost]
  1033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1034. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1035. {
  1036. // 创建 Stopwatch 实例
  1037. Stopwatch stopwatch = Stopwatch.StartNew();
  1038. decimal ffrPrice = 0.00M;
  1039. DateTime? visitDt = null;
  1040. if (dto.Status == 2)
  1041. {
  1042. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1043. if (groupInfo != null)
  1044. {
  1045. ffrPrice = groupInfo.PaymentMoney;
  1046. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1047. }
  1048. }
  1049. var groupData = await _groupRepository.GroupOperation(dto);
  1050. if (groupData.Code != 0)
  1051. {
  1052. return Ok(JsonView(false, groupData.Msg));
  1053. }
  1054. int diId = 0;
  1055. try
  1056. {
  1057. //添加时 默认加入团组汇率
  1058. if (dto.Status == 1) //添加
  1059. {
  1060. diId = groupData.Data;
  1061. //添加默认币种
  1062. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1063. //默认分配权限
  1064. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1065. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1066. var _managerIds = new List<int>() { 22, 32, 21 };
  1067. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1068. if (userIds.Count > 0)
  1069. {
  1070. userIds.Add(208);
  1071. //创建团组管控
  1072. GroupStepForDelegation.CreateWorkStep(diId);
  1073. //发送消息
  1074. string groupName = dto.TeamName;
  1075. string createGroupUser = string.Empty;
  1076. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1077. if (userInfo != null) createGroupUser = userInfo.CnName;
  1078. string title = $"系统通知";
  1079. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1080. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1081. }
  1082. //默认创建倒推表
  1083. await _invertedListRep._Create(dto.UserId, diId);
  1084. }
  1085. else if (dto.Status == 2)
  1086. {
  1087. diId = dto.Id;
  1088. }
  1089. #region 签证人员团组时间通知
  1090. #region 计算出访起止时间
  1091. var startTime = new DateTime();
  1092. var endTime = new DateTime();
  1093. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1094. {
  1095. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1096. }
  1097. #endregion
  1098. #endregion
  1099. #region 团组操作默认添加/修改收款账单
  1100. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1101. {
  1102. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1103. .Where(x => x.IsDel == 0 &&
  1104. x.Diid == diId &&
  1105. x.Remark.Equals("预付款")
  1106. )
  1107. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1108. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1109. .FirstAsync();
  1110. ffrInfo = new Fin_ForeignReceivables()
  1111. {
  1112. Diid = diId,
  1113. PriceName = dto.ClientUnit,
  1114. Price = dto.PaymentMoney,
  1115. Count = 1,
  1116. Unit = $"元",
  1117. ItemSumPrice = dto.PaymentMoney,
  1118. Rate = 1.0000M,
  1119. Currency = 836,
  1120. AddingWay = 0,
  1121. CreateUserId = dto.UserId,
  1122. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1123. Remark = $"预付款"
  1124. };
  1125. if (ffrInfo == null) //Add
  1126. {
  1127. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1128. }
  1129. else //修改
  1130. {
  1131. await _sqlSugar.Updateable(ffrInfo)
  1132. .UpdateColumns(x => new
  1133. {
  1134. x.PriceName,
  1135. x.Price,
  1136. x.ItemSumPrice,
  1137. x.CreateTime,
  1138. x.CreateUserId
  1139. })
  1140. .WhereColumns(x => x.Id)
  1141. .ExecuteCommandAsync();
  1142. }
  1143. }
  1144. #endregion
  1145. if (diId > 0)
  1146. {
  1147. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1148. }
  1149. // 停止计时
  1150. stopwatch.Stop();
  1151. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1152. }
  1153. catch (Exception ex)
  1154. {
  1155. // 停止计时
  1156. stopwatch.Stop();
  1157. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1158. Logs(ex.Message);
  1159. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1160. }
  1161. // 停止计时
  1162. stopwatch.Stop();
  1163. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1164. }
  1165. /// <summary>
  1166. /// 接团流程操作(增改)
  1167. /// 安卓端使用 建团时添加客户名单
  1168. /// </summary>
  1169. /// <param name="dto"></param>
  1170. /// <returns></returns>
  1171. [HttpPost]
  1172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1173. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1174. {
  1175. #region 参数验证
  1176. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1177. #region 页面操作权限验证
  1178. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1179. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1180. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1181. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1182. #endregion
  1183. #endregion
  1184. try
  1185. {
  1186. //_sqlSugar.BeginTran();
  1187. decimal ffrPrice = 0.00M;
  1188. DateTime? visitDt = null;
  1189. if (dto.Status == 2)
  1190. {
  1191. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1192. if (groupInfo != null)
  1193. {
  1194. ffrPrice = groupInfo.PaymentMoney;
  1195. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1196. }
  1197. }
  1198. var _dto = new GroupOperationDto();
  1199. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1200. var groupData = await _groupRepository.GroupOperation(_dto);
  1201. if (groupData.Code != 0)
  1202. {
  1203. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1204. }
  1205. int diId = 0;
  1206. //添加时 默认加入团组汇率
  1207. if (dto.Status == 1) //添加
  1208. {
  1209. diId = groupData.Data;
  1210. //添加默认币种
  1211. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1212. //默认分配权限
  1213. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1214. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1215. var _managerIds = new List<int>() { 21, 22, 32 };
  1216. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1217. if (userIds.Count > 0)
  1218. {
  1219. userIds.Add(208);
  1220. //创建团组管控
  1221. GroupStepForDelegation.CreateWorkStep(diId);
  1222. //发送消息
  1223. string groupName = dto.TeamName;
  1224. string createGroupUser = string.Empty;
  1225. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1226. if (userInfo != null) createGroupUser = userInfo.CnName;
  1227. string title = $"系统通知";
  1228. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1229. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1230. }
  1231. #region 应用推送
  1232. try
  1233. {
  1234. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1235. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1236. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1237. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1238. {
  1239. var userList = new List<string>() { users.QiyeChatUserId };
  1240. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1241. }
  1242. }
  1243. catch (Exception ex)
  1244. {
  1245. }
  1246. #endregion
  1247. //默认创建倒推表
  1248. await _invertedListRep._Create(dto.UserId, diId);
  1249. }
  1250. if (dto.Status == 2)
  1251. {
  1252. diId = dto.Id;
  1253. if (diId == 0)
  1254. {
  1255. //_sqlSugar.RollbackTran();
  1256. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1257. }
  1258. }
  1259. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1260. if (viewData.Code != 0)
  1261. {
  1262. //_sqlSugar.RollbackTran();
  1263. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1264. }
  1265. #region 团组操作默认添加/修改收款账单
  1266. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1267. {
  1268. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1269. .Where(x => x.IsDel == 0 &&
  1270. x.Diid == diId &&
  1271. x.Remark.Equals("预付款")
  1272. )
  1273. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1274. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1275. .FirstAsync();
  1276. ffrInfo = new Fin_ForeignReceivables()
  1277. {
  1278. Diid = diId,
  1279. PriceName = dto.ClientUnit,
  1280. Price = dto.PaymentMoney,
  1281. Count = 1,
  1282. Unit = $"元",
  1283. ItemSumPrice = dto.PaymentMoney,
  1284. Rate = 1.0000M,
  1285. Currency = 836,
  1286. AddingWay = 0,
  1287. CreateUserId = dto.UserId,
  1288. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1289. Remark = $"预付款"
  1290. };
  1291. if (ffrInfo == null) //Add
  1292. {
  1293. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1294. }
  1295. else //修改
  1296. {
  1297. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1298. .UpdateColumns(x => new
  1299. {
  1300. x.PriceName,
  1301. x.Price,
  1302. x.ItemSumPrice,
  1303. x.CreateTime,
  1304. x.CreateUserId
  1305. })
  1306. .WhereColumns(x => x.Id)
  1307. .ExecuteCommandAsync();
  1308. }
  1309. }
  1310. #endregion
  1311. #region 签证人员团组时间通知
  1312. #region 计算出访起止时间
  1313. var startTime = new DateTime();
  1314. var endTime = new DateTime();
  1315. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1316. {
  1317. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1318. }
  1319. #endregion
  1320. if (diId > 0)
  1321. {
  1322. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1323. }
  1324. #endregion
  1325. //_sqlSugar.CommitTran();
  1326. return Ok(JsonView(true, "添加成功"));
  1327. }
  1328. catch (Exception ex)
  1329. {
  1330. _sqlSugar.RollbackTran();
  1331. return Ok(JsonView(false, ex.Message));
  1332. }
  1333. }
  1334. /// <summary>
  1335. /// 接团流程操作(增改)
  1336. /// 安卓端使用 建团时添加客户名单
  1337. /// </summary>
  1338. /// <param name="dto"></param>
  1339. /// <returns></returns>
  1340. [HttpPost]
  1341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1342. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1343. {
  1344. #region 参数验证
  1345. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1346. #region 页面操作权限验证
  1347. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1348. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1349. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1350. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1351. #endregion
  1352. #endregion
  1353. _sqlSugar.BeginTran();
  1354. decimal ffrPrice = 0.00M;
  1355. DateTime? visitDt = null;
  1356. if (dto.Status == 2)
  1357. {
  1358. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1359. if (groupInfo != null)
  1360. {
  1361. ffrPrice = groupInfo.PaymentMoney;
  1362. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1363. }
  1364. }
  1365. var _dto = new GroupOperationDto();
  1366. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1367. var groupData = await _groupRepository.GroupOperation(_dto);
  1368. if (groupData.Code != 0)
  1369. {
  1370. _sqlSugar.RollbackTran();
  1371. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1372. }
  1373. try
  1374. {
  1375. int diId = 0;
  1376. //添加时 默认加入团组汇率
  1377. if (dto.Status == 1) //添加
  1378. {
  1379. diId = groupData.Data;
  1380. //添加默认币种
  1381. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1382. //默认分配权限
  1383. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1384. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1385. var _managerIds = new List<int>() { 21, 22, 32 };
  1386. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1387. if (userIds.Count > 0)
  1388. {
  1389. userIds.Add(208);
  1390. //创建团组管控
  1391. GroupStepForDelegation.CreateWorkStep(diId);
  1392. //发送消息
  1393. string groupName = dto.TeamName;
  1394. string createGroupUser = string.Empty;
  1395. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1396. if (userInfo != null) createGroupUser = userInfo.CnName;
  1397. string title = $"系统通知";
  1398. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1399. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1400. }
  1401. #region 应用推送
  1402. try
  1403. {
  1404. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1405. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1406. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1407. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1408. {
  1409. var userList = new List<string>() { users.QiyeChatUserId };
  1410. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1411. }
  1412. }
  1413. catch (Exception ex)
  1414. {
  1415. _sqlSugar.CommitTran();
  1416. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1417. }
  1418. #endregion
  1419. //默认创建倒推表
  1420. await _invertedListRep._Create(dto.UserId, diId);
  1421. }
  1422. else if (dto.Status == 2)
  1423. {
  1424. diId = dto.Id;
  1425. if (diId == 0)
  1426. {
  1427. _sqlSugar.RollbackTran();
  1428. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1429. }
  1430. }
  1431. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1432. if (viewData.Code != 0)
  1433. {
  1434. _sqlSugar.RollbackTran();
  1435. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1436. }
  1437. #region 团组操作默认添加/修改收款账单
  1438. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1439. {
  1440. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1441. .Where(x => x.IsDel == 0 &&
  1442. x.Diid == diId &&
  1443. x.Remark.Equals("预付款")
  1444. )
  1445. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1446. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1447. .FirstAsync();
  1448. ffrInfo = new Fin_ForeignReceivables()
  1449. {
  1450. Diid = diId,
  1451. PriceName = dto.ClientUnit,
  1452. Price = dto.PaymentMoney,
  1453. Count = 1,
  1454. Unit = $"元",
  1455. ItemSumPrice = dto.PaymentMoney,
  1456. Rate = 1.0000M,
  1457. Currency = 836,
  1458. AddingWay = 0,
  1459. CreateUserId = dto.UserId,
  1460. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1461. Remark = $"预付款"
  1462. };
  1463. if (ffrInfo == null) //Add
  1464. {
  1465. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1466. }
  1467. else //修改
  1468. {
  1469. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1470. .UpdateColumns(x => new
  1471. {
  1472. x.PriceName,
  1473. x.Price,
  1474. x.ItemSumPrice,
  1475. x.CreateTime,
  1476. x.CreateUserId
  1477. })
  1478. .WhereColumns(x => x.Id)
  1479. .ExecuteCommandAsync();
  1480. }
  1481. }
  1482. #endregion
  1483. #region 签证人员团组时间通知
  1484. #region 计算出访起止时间
  1485. var startTime = new DateTime();
  1486. var endTime = new DateTime();
  1487. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1488. {
  1489. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1490. }
  1491. #endregion
  1492. if (diId > 0)
  1493. {
  1494. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1495. }
  1496. #endregion
  1497. _sqlSugar.CommitTran();
  1498. return Ok(JsonView(true));
  1499. }
  1500. catch (Exception ex)
  1501. {
  1502. _sqlSugar.RollbackTran();
  1503. return Ok(JsonView(false, ex.Message));
  1504. }
  1505. }
  1506. /// <summary>
  1507. /// 接团信息 操作(删除)
  1508. /// </summary>
  1509. /// <param name="dto"></param>
  1510. /// <returns></returns>
  1511. [HttpPost]
  1512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1513. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1514. {
  1515. var diId = dto.Id;
  1516. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1517. #region 删除 验证
  1518. /*
  1519. * 1、收款账单数据:0 条
  1520. * 2、收款退还数据:0 条
  1521. * 3、机票费用数据:0 条
  1522. * 4、签证费用数据:0 条
  1523. * 5、保险费用数据:0 条
  1524. * 6、酒店费用数据:0 条
  1525. * 7、公务出访数据:1 条
  1526. * 8、邀请公务活动费用数据:1 条
  1527. * 9、OP费用数据:5 条
  1528. * 10、其他费用数据:0 条
  1529. * 11、团组日付报销费用数据:0 条
  1530. *
  1531. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1532. */
  1533. //收款账单
  1534. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1535. //收款退还
  1536. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1537. //机票费用
  1538. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1539. //签证费用
  1540. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1541. //保险费用
  1542. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1543. //酒店费用
  1544. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1545. //公务出访
  1546. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1547. //邀请公务活动费用
  1548. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1549. //OP费用
  1550. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1551. //其他费用
  1552. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1553. //团组日付报销费用
  1554. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1555. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1556. if (feeCount > 0)
  1557. {
  1558. var delMsgTips = new StringBuilder();
  1559. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1560. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1561. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1562. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1563. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1564. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1565. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1566. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1567. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1568. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1569. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1570. delMsgTips.AppendLine($"");
  1571. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1572. return Ok(JsonView(false, delMsgTips.ToString()));
  1573. }
  1574. #endregion
  1575. var groupData = await _groupRepository.GroupDel(dto);
  1576. if (groupData.Code != 0)
  1577. {
  1578. return Ok(JsonView(false, groupData.Msg));
  1579. }
  1580. return Ok(JsonView(true));
  1581. }
  1582. /// <summary>
  1583. /// 获取团组销售报价号
  1584. /// 团组添加时 使用
  1585. /// </summary>
  1586. /// <returns></returns>
  1587. [HttpPost]
  1588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1589. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1590. {
  1591. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1592. if (groupData.Code != 0)
  1593. {
  1594. return Ok(JsonView(false, groupData.Msg));
  1595. }
  1596. object salesQuoteNo = new
  1597. {
  1598. SalesQuoteNo = groupData.Data
  1599. };
  1600. return Ok(JsonView(salesQuoteNo));
  1601. }
  1602. /// <summary>
  1603. /// 设置确认出团
  1604. /// </summary>
  1605. /// <param name="dto"></param>
  1606. /// <returns></returns>
  1607. [HttpPost]
  1608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1609. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1610. {
  1611. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1612. if (groupData.Code != 0)
  1613. {
  1614. return Ok(JsonView(false, groupData.Msg));
  1615. }
  1616. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1617. #region OA消息推送
  1618. try
  1619. {
  1620. string groupName = groupInfo.TeamName;
  1621. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1622. string title = $"系统通知";
  1623. string content = $"团组[{groupName}]已确认出团!";
  1624. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1625. }
  1626. catch (Exception ex)
  1627. {
  1628. }
  1629. #endregion
  1630. #region 应用推送
  1631. try
  1632. {
  1633. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1634. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1635. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1636. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1637. {
  1638. var userList = new List<string>() { users.QiyeChatUserId };
  1639. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1640. }
  1641. }
  1642. catch (Exception ex)
  1643. {
  1644. }
  1645. #endregion
  1646. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1647. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1648. }
  1649. /// <summary>
  1650. /// 获取团组名称data And 签证国别Data
  1651. /// </summary>
  1652. /// <param name="dto"></param>
  1653. /// <returns></returns>
  1654. [HttpPost]
  1655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1656. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1657. {
  1658. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1659. if (groupData.Code != 0)
  1660. {
  1661. return Ok(JsonView(false, groupData.Msg));
  1662. }
  1663. return Ok(JsonView(groupData.Data));
  1664. }
  1665. /// <summary>
  1666. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1667. /// </summary>
  1668. /// <returns></returns>
  1669. [HttpPost]
  1670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1671. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1672. {
  1673. try
  1674. {
  1675. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1676. if (groupData.Code != 0)
  1677. {
  1678. return Ok(JsonView(false, groupData.Msg));
  1679. }
  1680. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1681. }
  1682. catch (Exception ex)
  1683. {
  1684. return Ok(JsonView(false, ex.Message));
  1685. throw;
  1686. }
  1687. }
  1688. /// <summary>
  1689. /// 团组清单 Excel
  1690. /// </summary>
  1691. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1692. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1693. /// <returns></returns>
  1694. [HttpGet]
  1695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1696. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1697. {
  1698. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1699. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1700. if (!beginBool && !endBool)
  1701. {
  1702. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1703. }
  1704. string sql = string.Format(@"
  1705. SELECT
  1706. ROW_NUMBER,
  1707. Id,
  1708. SalesQuoteNo,
  1709. TourCode,
  1710. TeamTypeId,
  1711. TeamType,
  1712. TeamLevId,
  1713. TeamLev,
  1714. TeamName,
  1715. ClientName,
  1716. ClientUnit,
  1717. VisitDate,
  1718. VisitDays,
  1719. VisitPNumber,
  1720. JietuanOperatorId,
  1721. JietuanOperator,
  1722. IsSure,
  1723. CreateUserName,
  1724. IsBid
  1725. FROM
  1726. (
  1727. SELECT
  1728. ROW_NUMBER() OVER(
  1729. ORDER BY
  1730. gdi.VisitDate Desc
  1731. ) AS ROW_NUMBER,
  1732. gdi.Id,
  1733. SalesQuoteNo,
  1734. TourCode,
  1735. ssd.Id TeamTypeId,
  1736. ssd.Name TeamType,
  1737. ssd1.Id TeamLevId,
  1738. ssd1.Name TeamLev,
  1739. TeamName,
  1740. ClientName,
  1741. ClientUnit,
  1742. VisitDate,
  1743. VisitDays,
  1744. VisitPNumber,
  1745. JietuanOperator JietuanOperatorId,
  1746. su.CnName JietuanOperator,
  1747. IsSure,
  1748. gdi.CreateTime,
  1749. su1.CnName As CreateUserName,
  1750. gdi.IsBid
  1751. FROM
  1752. Grp_DelegationInfo gdi
  1753. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1754. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1755. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1756. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1757. WHERE
  1758. gdi.IsDel = 0
  1759. AND gdi.IsBid = 0
  1760. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1761. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1762. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1763. #region 处理所属部门
  1764. /*
  1765. * 1.sq 和 gyy 等显示 市场部
  1766. * 2.王鸽和主管及张总还有管理员号统一国交部
  1767. * 2-1. 4 管理员 ,21 张海麟
  1768. */
  1769. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1770. var userIds1 = new List<int>() { 4, 21 };
  1771. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1772. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1773. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1774. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1775. .ToListAsync();
  1776. var droupIds = groupList.Select(it => it.Id).ToList();
  1777. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1778. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1779. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1780. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1781. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1782. {
  1783. DiId = tcl.DiId,
  1784. LastName = dc.LastName,
  1785. FirstName = dc.FirstName,
  1786. Sex = dc.Sex,
  1787. Birthday = dc.BirthDay,
  1788. Company = cc.CompanyFullName,
  1789. Job = dc.Job,
  1790. CreateTime = tcl.CreateTime,
  1791. })
  1792. .ToList();
  1793. foreach (var item in groupList)
  1794. {
  1795. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1796. string groupFirstName = "";
  1797. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1798. if (currDatas.Any())
  1799. {
  1800. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1801. }
  1802. item.GroupFirst = groupFirstName;
  1803. }
  1804. #endregion
  1805. #region Excel
  1806. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1807. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1808. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1809. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1810. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1811. //载入模板
  1812. var designer = new WorkbookDesigner
  1813. {
  1814. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1815. };
  1816. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1817. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1818. dt.TableName = "GroupList";
  1819. designer.SetDataSource(dt);
  1820. designer.Process();
  1821. if (!Directory.Exists(savePath))
  1822. {
  1823. Directory.CreateDirectory(savePath);
  1824. }
  1825. string serverPath = $"{savePath}{fileName}";
  1826. designer.Workbook.Save(serverPath);
  1827. string rst = $"{servicePath}{ftpPath}{fileName}";
  1828. #endregion
  1829. return Ok(JsonView(true, "操作成功!", rst));
  1830. }
  1831. /// <summary>
  1832. /// 团组合同下载(1.付款80% 2.付全款)
  1833. /// </summary>
  1834. /// <param name="dto"></param>
  1835. /// <returns></returns>
  1836. /// <exception cref="Exception"></exception>
  1837. [HttpPost]
  1838. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1839. {
  1840. var jw = JsonView(false);
  1841. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1842. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1843. if (di == null)
  1844. {
  1845. jw.Msg = "团组Id有误!";
  1846. return Ok(jw);
  1847. }
  1848. #region 权限校验
  1849. var allDownFile = new List<int>() { 21 };
  1850. try
  1851. {
  1852. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1853. .First(x => x.Id == 1418 && x.IsDel == 0);
  1854. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1855. }
  1856. catch (Exception)
  1857. { }
  1858. var guojiaoDownFile = new List<int>() { 330,383};
  1859. var shichangDownFile = new List<int>() { 95 };
  1860. if (allDownFile.Contains(dto.UserId))
  1861. {
  1862. }
  1863. else if (guojiaoDownFile.Contains(dto.UserId))
  1864. {
  1865. var guojiaobuDi = new List<int>() { 4, 21 };
  1866. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1867. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1868. .Where((d, u) => u.Id == di.JietuanOperator)
  1869. .Select((d, u) => d.DepName)
  1870. .First();
  1871. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1872. {
  1873. jw.Msg = "暂无下载权限!";
  1874. return Ok(jw);
  1875. }
  1876. }
  1877. else if (shichangDownFile.Contains(dto.UserId))
  1878. {
  1879. var dic = new Dictionary<int, int[]>()
  1880. {
  1881. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1882. };
  1883. try
  1884. {
  1885. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1886. if (sqSetting != null)
  1887. {
  1888. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1889. foreach (var item in result.Keys)
  1890. {
  1891. if (dic.ContainsKey(item))
  1892. {
  1893. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1894. Array.Copy(dic[item], dilatation, dic[item].Length);
  1895. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1896. dic[item] = dilatation;
  1897. }
  1898. else
  1899. {
  1900. dic.Add(item, result[item]);
  1901. }
  1902. }
  1903. }
  1904. if (!dic[95].Contains(di.CreateUserId))
  1905. {
  1906. jw.Msg = "暂无下载权限!";
  1907. return Ok(jw);
  1908. }
  1909. }
  1910. catch (Exception)
  1911. { }
  1912. }
  1913. else if (dto.UserId == di.CreateUserId)
  1914. {
  1915. }
  1916. else
  1917. {
  1918. jw.Msg = "暂无下载权限!";
  1919. return Ok(jw);
  1920. }
  1921. #endregion
  1922. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1923. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1924. .ToListAsync();
  1925. if (!blackCodeList.Any())
  1926. {
  1927. jw.Msg = "该团无机票行程代码!";
  1928. return Ok(jw);
  1929. }
  1930. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1931. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1932. if (groupEnterExitCost == null)
  1933. {
  1934. jw.Msg = "暂无三公费用信息!";
  1935. return Ok(jw);
  1936. }
  1937. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1938. rateList ??= new List<CurrencyInfo>();
  1939. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1940. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1941. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1942. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1943. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1944. .Select((x, a, b) => new
  1945. {
  1946. x.Index,
  1947. itemName = a.Name,
  1948. CurrencyStr = b.Name,
  1949. x.Cost,
  1950. x.SubTotal,
  1951. x.Remark
  1952. })
  1953. .OrderBy((x) => x.Index)
  1954. .ToList();
  1955. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1956. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1957. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1958. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1959. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1960. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1961. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1962. decimal subJJC = 0.00M,
  1963. subGWC = 0.00M,
  1964. subTDC = 0.00M;
  1965. //经济舱
  1966. if (groupEnterExitCost.SumJJC == 1)
  1967. {
  1968. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1969. }
  1970. //公务舱
  1971. if (groupEnterExitCost.SumGWC == 1)
  1972. {
  1973. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1974. }
  1975. //头等舱
  1976. if (groupEnterExitCost.SumTDC == 1)
  1977. {
  1978. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1979. }
  1980. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1981. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1982. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1983. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1984. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1985. .Select((x, s, dc, cc) => new GroupClints
  1986. {
  1987. Id = x.Id,
  1988. Name = s.Name,
  1989. IsAccompany = x.IsAccompany,
  1990. CompanyFullName = cc.CompanyFullName
  1991. })
  1992. .ToListAsync();
  1993. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1994. //获取舱位人数
  1995. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1996. .GroupBy(x => x.Name)
  1997. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1998. .ToList();
  1999. string cityPath = string.Empty;
  2000. string startCity = string.Empty;
  2001. string endCity = string.Empty;
  2002. foreach (var item in blackCodeList)
  2003. {
  2004. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2005. cityPath += city + "\r\n";
  2006. if (item.Equals(blackCodeList.First()))
  2007. {
  2008. var sp = city.Split('-');
  2009. startCity = sp[0];
  2010. endCity = sp[^1];
  2011. }
  2012. }
  2013. var bookMarkDic = new Dictionary<string, string>
  2014. {
  2015. { "ClientUnit", di.ClientUnit },
  2016. { "VisitCountry", di.VisitCountry },
  2017. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2018. { "VisitPNumber", di.VisitPNumber.ToString() },
  2019. { "CityPath", cityPath },
  2020. { "StartCity", startCity },
  2021. { "EndCity", endCity },
  2022. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2023. };
  2024. Document doc = null;
  2025. var percentage = 0.8M;
  2026. var fileNameadd = "预付";
  2027. if (dto.FileType == 1)
  2028. {
  2029. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2030. }
  2031. else if (dto.FileType == 2)
  2032. {
  2033. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2034. percentage = 1;
  2035. fileNameadd = "全款";
  2036. }
  2037. else
  2038. {
  2039. throw new Exception("FileType有误!");
  2040. }
  2041. var builder = new DocumentBuilder(doc);
  2042. decimal totalPrice = 0.00M;
  2043. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2044. if (firstTable != null)
  2045. {
  2046. // 遍历表格的行和单元格
  2047. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2048. {
  2049. for (int i = 0; i < row.Cells.Count; i++)
  2050. {
  2051. var cell = row.Cells[i];
  2052. // 读取单元格内容
  2053. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2054. if (cellTextFirst.Contains("舱位"))
  2055. {
  2056. break;
  2057. }
  2058. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2059. {
  2060. if (i == 2)
  2061. {
  2062. if (cellTextFirst == "经济舱")
  2063. {
  2064. // 设置单元格内容
  2065. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2066. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2067. }
  2068. else
  2069. {
  2070. // 设置单元格内容
  2071. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2072. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2073. }
  2074. }
  2075. if (i == 3)
  2076. {
  2077. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2078. if (count != null)
  2079. {
  2080. // 设置单元格内容
  2081. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2082. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2083. }
  2084. }
  2085. if (i == 4)
  2086. {
  2087. var rowPrice = 0.00M;
  2088. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2089. count ??= 0;
  2090. if (cellTextFirst == "经济舱")
  2091. {
  2092. rowPrice = subJJC * (int)count;
  2093. }
  2094. else
  2095. {
  2096. rowPrice = subGWC * (int)count;
  2097. }
  2098. totalPrice += rowPrice;
  2099. // 设置单元格内容
  2100. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2101. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2102. }
  2103. }
  2104. }
  2105. }
  2106. }
  2107. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2108. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2109. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2110. //--合同表格部分
  2111. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2112. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2113. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2114. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2115. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2116. bookMarkDic.Add("CityPath1", cityPath);
  2117. bookMarkDic.Add("CityPath2", cityPath);
  2118. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2119. if (contractTable != null)
  2120. {
  2121. //数据源
  2122. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2123. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2124. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2125. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2126. .Select((it, y, s) => new
  2127. {
  2128. it.Cost,
  2129. it.SubTotal,
  2130. it.Type,
  2131. y.Id,
  2132. y.City,
  2133. s.Name,
  2134. CurrencyCodeCn = s.Remark
  2135. })
  2136. .ToList()
  2137. .Select(x => new
  2138. {
  2139. CurrencyCode = x.Name,
  2140. CityId = x.Id,
  2141. x.City,
  2142. di.VisitPNumber,
  2143. x.Type,
  2144. x.Cost,
  2145. x.SubTotal,
  2146. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2147. x.CurrencyCodeCn,
  2148. });
  2149. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2150. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2151. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2152. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2153. var tableSettings = new List<tableSetting>()
  2154. {
  2155. new(){ Index = 1 , Property = "City"},
  2156. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2157. new(){ Index = 3 , Property = "Cost"},
  2158. new(){ Index = 4 , Property = "VisitPNumber"},
  2159. //new tableSetting{ Index = 5 , Property = ""},
  2160. //new tableSetting{ Index = 6 , Property = ""},
  2161. new(){ Index = 7 , Property = "Rate"},
  2162. //new tableSetting{ Index = 8 , Property = ""},
  2163. };
  2164. //1.住宿费
  2165. int cloneRow = 8;
  2166. int startDayPrice = 8; //写入index
  2167. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2168. foreach (var dac in dac1)
  2169. {
  2170. var first = dac.First();
  2171. var dayCount = dac.Count();
  2172. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2173. for (int i = 1; i < row.Cells.Count; i++)
  2174. {
  2175. var cell = row.Cells[i];
  2176. var findProperty = tableSettings.Find(x => x.Index == i);
  2177. if (findProperty != null)
  2178. {
  2179. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2180. // 设置单元格内容
  2181. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2182. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2183. }
  2184. else
  2185. {
  2186. switch (i)
  2187. {
  2188. case 5:
  2189. cell.FirstParagraph.Runs.Clear();
  2190. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2191. break;
  2192. case 6:
  2193. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2194. cell.FirstParagraph.Runs.Clear();
  2195. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2196. break;
  2197. case 8:
  2198. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2199. cell.FirstParagraph.Runs.Clear();
  2200. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2201. ZSPriceSum += xiaojiRMB;
  2202. break;
  2203. default:
  2204. break;
  2205. }
  2206. }
  2207. }
  2208. startDayPrice++;
  2209. if (!dac1.Last().Equals(dac))
  2210. {
  2211. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2212. // 将克隆的行追加到原行后面
  2213. contractTable.Rows.Insert(startDayPrice, newRow);
  2214. }
  2215. else
  2216. {
  2217. cloneRow += dac1.Count + 1;
  2218. startDayPrice = cloneRow;
  2219. }
  2220. }
  2221. //2.伙食费
  2222. foreach (var dac in dac2)
  2223. {
  2224. var first = dac.First();
  2225. var dayCount = dac.Count();
  2226. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2227. for (int i = 1; i < row.Cells.Count; i++)
  2228. {
  2229. var cell = row.Cells[i];
  2230. var findProperty = tableSettings.Find(x => x.Index == i);
  2231. if (findProperty != null)
  2232. {
  2233. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2234. // 设置单元格内容
  2235. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2236. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2237. }
  2238. else
  2239. {
  2240. switch (i)
  2241. {
  2242. case 5:
  2243. cell.FirstParagraph.Runs.Clear();
  2244. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2245. break;
  2246. case 6:
  2247. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2248. cell.FirstParagraph.Runs.Clear();
  2249. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2250. break;
  2251. case 8:
  2252. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2253. cell.FirstParagraph.Runs.Clear();
  2254. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2255. HSPriceSum += xiaojiRMB;
  2256. break;
  2257. default:
  2258. break;
  2259. }
  2260. }
  2261. }
  2262. startDayPrice++;
  2263. if (!dac2.Last().Equals(dac))
  2264. {
  2265. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2266. // 将克隆的行追加到原行后面
  2267. contractTable.Rows.Insert(startDayPrice, newRow);
  2268. }
  2269. else
  2270. {
  2271. cloneRow += dac2.Count + 1;
  2272. startDayPrice = cloneRow;
  2273. }
  2274. }
  2275. //3.公杂费
  2276. foreach (var dac in dac3)
  2277. {
  2278. var first = dac.First();
  2279. var dayCount = dac.Count();
  2280. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2281. for (int i = 1; i < row.Cells.Count; i++)
  2282. {
  2283. var cell = row.Cells[i];
  2284. var findProperty = tableSettings.Find(x => x.Index == i);
  2285. if (findProperty != null)
  2286. {
  2287. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2288. // 设置单元格内容
  2289. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2290. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2291. }
  2292. else
  2293. {
  2294. switch (i)
  2295. {
  2296. case 5:
  2297. cell.FirstParagraph.Runs.Clear();
  2298. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2299. break;
  2300. case 6:
  2301. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2302. cell.FirstParagraph.Runs.Clear();
  2303. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2304. break;
  2305. case 8:
  2306. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2307. cell.FirstParagraph.Runs.Clear();
  2308. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2309. GZPriceSum += xiaojiRMB;
  2310. break;
  2311. default:
  2312. break;
  2313. }
  2314. }
  2315. }
  2316. startDayPrice++;
  2317. if (!dac3.Last().Equals(dac))
  2318. {
  2319. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2320. // 将克隆的行追加到原行后面
  2321. contractTable.Rows.Insert(startDayPrice, newRow);
  2322. }
  2323. else
  2324. {
  2325. cloneRow += dac3.Count + 1;
  2326. startDayPrice = cloneRow;
  2327. }
  2328. }
  2329. //合并单元格
  2330. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2331. {
  2332. var currentRow = contractTable.Rows[i];
  2333. var nextRow = contractTable.Rows[i + 1];
  2334. // 获取当前行和下一行的第一个单元格
  2335. Cell currentCell = currentRow.Cells[0];
  2336. Cell nextCell = nextRow.Cells[0];
  2337. // 检查单元格内容是否一致(去除尾部的换行符)
  2338. string currentText = currentCell.GetText().Trim();
  2339. string nextText = nextCell.GetText().Trim();
  2340. if (currentText == nextText)
  2341. {
  2342. // 如果当前单元格已经被合并,找到合并的起始单元格
  2343. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2344. {
  2345. // 找到合并的起始单元格
  2346. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2347. // 将下一行的单元格设置为合并的后续单元格
  2348. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2349. }
  2350. else
  2351. {
  2352. // 如果当前单元格是合并的起始单元格
  2353. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2354. // 将下一行的单元格设置为合并的后续单元格
  2355. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2356. }
  2357. }
  2358. else
  2359. {
  2360. // 如果内容不一致,重置当前单元格的合并属性
  2361. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2362. {
  2363. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2364. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2365. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2366. }
  2367. else
  2368. {
  2369. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2370. }
  2371. }
  2372. }
  2373. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2374. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2375. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2376. }
  2377. foreach (var bookmarkName in bookMarkDic.Keys)
  2378. {
  2379. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2380. if (bookmark != null)
  2381. {
  2382. if (bookmarkName == "ClientUnit")
  2383. {
  2384. // 移动到书签位置
  2385. builder.MoveTo(bookmark.BookmarkStart);
  2386. // 设置字体样式为下划线
  2387. builder.Font.Underline = Aspose.Words.Underline.Single;
  2388. // 插入书签值
  2389. builder.Write(bookMarkDic[bookmarkName]);
  2390. // 清除字体格式,避免影响后续文本
  2391. builder.Font.ClearFormatting();
  2392. }
  2393. else
  2394. {
  2395. builder.MoveToBookmark(bookmarkName);
  2396. builder.Write(bookMarkDic[bookmarkName]);
  2397. }
  2398. }
  2399. }
  2400. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2401. doc.Save(savePaht);
  2402. jw.Msg = "生成成功!";
  2403. jw.Code = 200;
  2404. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2405. return Ok(jw);
  2406. }
  2407. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2408. {
  2409. int index = rowIndex;
  2410. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2411. {
  2412. index--;
  2413. }
  2414. return index;
  2415. }
  2416. #endregion
  2417. #region 团组&签证
  2418. #region 团组&签证 New
  2419. /// <summary>
  2420. /// 团组&签证 New
  2421. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2422. /// </summary>
  2423. /// <param name="file">请求dto</param>
  2424. /// <returns></returns>
  2425. [HttpPost]
  2426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2427. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile file, int fileTypeId)
  2428. {
  2429. //文件验证
  2430. if (file.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2431. //var visaFiles = new VisaUploadFileTypeView();
  2432. var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2433. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2434. //服务器存储文件
  2435. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2436. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2437. var filePath = Path.Combine(fileServerPath, file.FileName);
  2438. using (var stream = new FileStream(filePath, FileMode.Create))
  2439. {
  2440. await file.CopyToAsync(stream);
  2441. }
  2442. //日志记录-上传文件
  2443. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, file.FileName);
  2444. //kimi AI 识别文档返回json结果
  2445. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2446. var KiMiApi = new KiMiApiClient();
  2447. var files = new List<IFormFile>() { file };
  2448. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2449. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2450. var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2451. var messages = new List<SeedMessages>
  2452. {
  2453. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2454. new() { Role = KimiRole.user, Content = seedMessage }
  2455. };
  2456. messages.InsertRange(1, seedConter);
  2457. string jsonString = string.Empty;
  2458. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2459. while (!isJson)
  2460. {
  2461. kimiAI_API_Index++;
  2462. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2463. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2464. jsonString += kimiApiResult_JObject["content"].ToString();
  2465. string startStr = "```json", endStr = "```";
  2466. // 判断并清除开头部分
  2467. if (jsonString.StartsWith(startStr))
  2468. {
  2469. jsonString = jsonString.Replace(startStr, "");
  2470. }
  2471. // 判断并清除结尾部分
  2472. if (jsonString.EndsWith(endStr))
  2473. {
  2474. jsonString = jsonString.Replace(endStr, "");
  2475. }
  2476. //验证json格式是否正确
  2477. try
  2478. {
  2479. JsonDocument.Parse(jsonString);
  2480. isJson = true; // 如果解析成功,则是json格式
  2481. }
  2482. catch (Exception)
  2483. {
  2484. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2485. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2486. }
  2487. }
  2488. var clientInfo = new Crm_DeleClient(); //客户资料表
  2489. var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2490. var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2491. var clientCert = new Crm_CustomerCert(); //客户证件表
  2492. var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2493. //按照表格类型分别进行参数处理
  2494. switch (fileTypeId)
  2495. {
  2496. //澳新签证个人申请表
  2497. case 1:
  2498. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2499. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2500. break;
  2501. default:
  2502. break;
  2503. }
  2504. return Ok(JsonView(true, jsonString));
  2505. }
  2506. #endregion
  2507. /// <summary>
  2508. /// 根据团组Id获取签证客户信息List
  2509. /// </summary>
  2510. /// <param name="dto">请求dto</param>
  2511. /// <returns></returns>
  2512. [HttpPost]
  2513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2514. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2515. {
  2516. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2517. if (groupData.Code != 0)
  2518. {
  2519. return Ok(JsonView(false, groupData.Msg));
  2520. }
  2521. return Ok(JsonView(groupData.Data));
  2522. }
  2523. /// <summary>
  2524. /// IOS获取团组签证拍照上传进度01(团组列表)
  2525. /// </summary>
  2526. /// <param name="dto">请求dto</param>
  2527. /// <returns></returns>
  2528. [HttpPost]
  2529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2530. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2531. {
  2532. if (dto == null)
  2533. {
  2534. return Ok(JsonView(false, "参数为空"));
  2535. }
  2536. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2537. return Ok(JsonView(visaList));
  2538. }
  2539. /// <summary>
  2540. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2541. /// </summary>
  2542. /// <returns></returns>
  2543. [HttpPost]
  2544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2545. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2546. {
  2547. if (dto == null)
  2548. {
  2549. return Ok(JsonView(false, "请求错误:"));
  2550. }
  2551. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2552. return Ok(JsonView(list));
  2553. }
  2554. /// <summary>
  2555. /// IOS获取团组签证拍照上传进度03(相册)
  2556. /// </summary>
  2557. /// <returns></returns>
  2558. [HttpPost]
  2559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2560. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2561. {
  2562. if (dto == null)
  2563. {
  2564. return Ok(JsonView(false, "请求错误:"));
  2565. }
  2566. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2567. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2568. list.ForEach(s => s.url = url);
  2569. return Ok(JsonView(list));
  2570. }
  2571. /// <summary>
  2572. /// IOS获取团组签证拍照上传进度04(图片上传)
  2573. /// </summary>
  2574. /// <param name="dto"></param>
  2575. /// <returns></returns>
  2576. [HttpPost]
  2577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2578. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2579. {
  2580. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2581. //if (!string.IsNullOrEmpty(result))
  2582. //{
  2583. //}
  2584. //else {
  2585. // return Ok(JsonView(false, "上传失败"));
  2586. //}
  2587. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2588. int sucNum = 0;
  2589. try
  2590. {
  2591. foreach (var item in dto.base64DataList)
  2592. {
  2593. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2594. string result = DecodeBase64ToImage(item, imageName);
  2595. if (!string.IsNullOrEmpty(result))
  2596. {
  2597. var pic = new Grp_VisaProgressCustomerPicture
  2598. {
  2599. CreateUserId = dto.CreateUserId,
  2600. PicName = imageName,
  2601. PicPath = result,
  2602. VisaProgressCustomerId = dto.visaProgressCustomerId
  2603. };
  2604. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2605. if (insertResult > 0)
  2606. {
  2607. sucNum++;
  2608. }
  2609. }
  2610. }
  2611. }
  2612. catch (Exception ex)
  2613. {
  2614. return Ok(JsonView(false, ex.Message));
  2615. }
  2616. string msg = string.Format(@"成功上传{0}张", sucNum);
  2617. return Ok(JsonView(true, msg));
  2618. }
  2619. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2620. {
  2621. string filename = "";//声明一个string类型的相对路径
  2622. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2623. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2624. try//会有异常抛出,try,catch一下
  2625. {
  2626. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2627. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2628. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2629. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2630. //文件名称
  2631. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2632. //上传的文件的路径
  2633. string filePath = "";
  2634. if (!Directory.Exists(fileDir))
  2635. {
  2636. Directory.CreateDirectory(fileDir);
  2637. }
  2638. //上传的文件的路径
  2639. filePath = fileDir + filename;
  2640. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2641. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2642. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2643. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2644. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2645. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2646. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2647. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2648. bitmap.Dispose();
  2649. }
  2650. catch (Exception e)
  2651. {
  2652. string massage = e.Message;
  2653. Logs("IOS图片上传Error:" + massage);
  2654. //filename = e.Message;
  2655. }
  2656. return filename;//返回相对路径
  2657. }
  2658. /// <summary>
  2659. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2660. /// </summary>
  2661. /// <param name="dto"></param>
  2662. /// <returns></returns>
  2663. [HttpPost]
  2664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2665. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2666. {
  2667. if (dto == null)
  2668. {
  2669. return Ok(JsonView(false, "请求错误:"));
  2670. }
  2671. string msg = "参数错误";
  2672. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2673. {
  2674. try
  2675. {
  2676. //_delegationVisaRep.BeginTran();
  2677. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2678. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2679. .Where(s => s.Id == dto.visaProgressCustomerId)
  2680. .ExecuteCommandAsync();
  2681. if (updCount > 0 && dto.publishCode == 1)
  2682. {
  2683. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2684. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2685. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2686. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2687. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2688. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2689. if (groupData == null)
  2690. {
  2691. _delegationVisaRep.RollbackTran();
  2692. }
  2693. string title = string.Format(@"[签证进度更新]");
  2694. string content = string.Format(@"测试文本");
  2695. bool rst = await _message.AddMsg(new MessageDto()
  2696. {
  2697. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2698. IssuerId = dto.publisher,
  2699. Title = title,
  2700. Content = content,
  2701. ReleaseTime = DateTime.Now,
  2702. UIdList = new List<int> {
  2703. 234
  2704. }
  2705. });
  2706. if (rst)
  2707. {
  2708. return Ok(JsonView(true, "发送通知成功"));
  2709. }
  2710. }
  2711. //_delegationVisaRep.CommitTran();
  2712. }
  2713. catch (Exception)
  2714. {
  2715. //_delegationVisaRep.RollbackTran();
  2716. }
  2717. }
  2718. return Ok(JsonView(true, msg));
  2719. }
  2720. #endregion
  2721. #region 团组任务分配
  2722. /// <summary>
  2723. /// 团组任务分配初始化
  2724. /// </summary>
  2725. /// <returns></returns>
  2726. [HttpPost]
  2727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2728. public async Task<IActionResult> GetTaskAssignmen()
  2729. {
  2730. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2731. if (groupData.Code != 0)
  2732. {
  2733. return Ok(JsonView(false, groupData.Msg));
  2734. }
  2735. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2736. }
  2737. /// <summary>
  2738. /// 团组任务分配查询
  2739. /// </summary>
  2740. /// <param name="dto"></param>
  2741. /// <returns></returns>
  2742. [HttpPost]
  2743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2744. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2745. {
  2746. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2747. if (groupData.Code != 0)
  2748. {
  2749. return Ok(JsonView(false, groupData.Msg));
  2750. }
  2751. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2752. }
  2753. /// <summary>
  2754. /// 团组任务分配操作
  2755. /// </summary>
  2756. /// <param name="dto"></param>
  2757. /// <returns></returns>
  2758. [HttpPost]
  2759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2760. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2761. {
  2762. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2763. if (groupData.Code != 0)
  2764. {
  2765. return Ok(JsonView(false, groupData.Msg));
  2766. }
  2767. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2768. }
  2769. /// <summary>
  2770. /// 团组任务分配
  2771. /// 批量分配
  2772. /// 查询团组
  2773. /// </summary>
  2774. /// <param name="dto"></param>
  2775. /// <returns></returns>
  2776. [HttpPost]
  2777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2778. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2779. {
  2780. //参数验证
  2781. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2782. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2783. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2784. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2785. }
  2786. /// <summary>
  2787. /// 团组任务分配
  2788. /// 批量分配
  2789. /// </summary>
  2790. /// <param name="dto"></param>
  2791. /// <returns></returns>
  2792. [HttpPost]
  2793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2794. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2795. {
  2796. //参数验证
  2797. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2798. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2799. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2800. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2801. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2802. }
  2803. #endregion
  2804. #region 团组费用审核
  2805. /// <summary>
  2806. /// 费用审核
  2807. /// 团组列表 Page
  2808. /// </summary>
  2809. /// <param name="_dto">团组列表请求dto</param>
  2810. /// <returns></returns>
  2811. [HttpPost]
  2812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2813. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2814. {
  2815. #region 参数验证
  2816. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2817. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2818. #region 页面操作权限验证
  2819. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2820. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2821. #endregion
  2822. #endregion
  2823. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2824. {
  2825. string sqlWhere = string.Empty;
  2826. if (_dto.IsSure == 0) //未完成
  2827. {
  2828. sqlWhere += string.Format(@" And IsSure = 0");
  2829. }
  2830. else if (_dto.IsSure == 1) //已完成
  2831. {
  2832. sqlWhere += string.Format(@" And IsSure = 1");
  2833. }
  2834. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2835. {
  2836. string tj = _dto.SearchCriteria;
  2837. 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}%')",
  2838. tj, tj, tj, tj, tj);
  2839. }
  2840. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2841. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2842. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2843. From (
  2844. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2845. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2846. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2847. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2848. From Grp_DelegationInfo gdi
  2849. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2850. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2851. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2852. Where gdi.IsDel = 0 {0}
  2853. ) temp ", sqlWhere);
  2854. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2855. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2856. var _view = new
  2857. {
  2858. PageFuncAuth = pageFunAuthView,
  2859. Data = _DelegationList
  2860. };
  2861. return Ok(JsonView(true, "查询成功!", _view, total));
  2862. }
  2863. else
  2864. {
  2865. return Ok(JsonView(false, "查询失败"));
  2866. }
  2867. }
  2868. /// <summary>
  2869. /// 获取团组费用审核
  2870. /// </summary>
  2871. /// <param name="_dto"></param>
  2872. /// <returns></returns>
  2873. [HttpPost]
  2874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2875. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2876. {
  2877. try
  2878. {
  2879. #region 参数验证
  2880. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2881. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2882. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2883. #region 页面操作权限验证
  2884. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2885. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2886. #endregion
  2887. #endregion
  2888. var _view = new Grp_CreditCardPaymentView();
  2889. var clientNameList = GetSimplClientList(_dto.DiId);
  2890. #region 费用清单
  2891. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2892. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2893. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2894. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2895. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2896. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2897. /*
  2898. * 76://酒店预订
  2899. */
  2900. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2901. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2902. /*
  2903. * 79://车/导游地接
  2904. */
  2905. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2906. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2907. /*
  2908. * 80: //签证
  2909. */
  2910. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2911. /*
  2912. *81: //邀请/公务活动
  2913. */
  2914. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2915. /*
  2916. * 82: //团组客户保险
  2917. */
  2918. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2919. /*
  2920. * Lable = 85 机票预订
  2921. */
  2922. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2923. /*
  2924. * 85 机票预定
  2925. */
  2926. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2927. /*
  2928. * 98 其他款项
  2929. */
  2930. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2931. /*
  2932. * 285:收款退还
  2933. */
  2934. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2935. /*
  2936. * 1015: //超支费用
  2937. */
  2938. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2939. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2940. /*
  2941. * 币种信息
  2942. */
  2943. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2944. /*
  2945. * 车/导游地接 费用类型
  2946. */
  2947. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2948. /*
  2949. * 车/导游地接 费用类型
  2950. */
  2951. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2952. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2953. /*
  2954. * 用户信息
  2955. */
  2956. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2957. /*
  2958. * 费用模块
  2959. */
  2960. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2961. string priceModule = string.Empty;
  2962. if (sdPriceName != null)
  2963. {
  2964. priceModule = sdPriceName.Name;
  2965. }
  2966. /*
  2967. * 成本信息
  2968. */
  2969. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2970. decimal _groupRate = 0.0000M;
  2971. string _groupCurrencyCode = "-";
  2972. if (groupCost != null)
  2973. {
  2974. _groupRate = groupCost.Rate;
  2975. if (int.TryParse(groupCost.Currency, out int _currency))
  2976. {
  2977. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2978. }
  2979. else _groupCurrencyCode = groupCost.Currency;
  2980. }
  2981. string costContentSql = $"Select * From Grp_GroupCost";
  2982. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2983. //处理日期为空的天数
  2984. for (int i = 0; i < groupCostDetails.Count; i++)
  2985. if (i != 0)
  2986. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2987. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2988. /*
  2989. * 处理详情数据
  2990. */
  2991. foreach (var entity in entityList)
  2992. {
  2993. var _detail = new Grp_CreditCardPaymentDetailView
  2994. {
  2995. Id = entity.Id,
  2996. PriceName = priceModule,
  2997. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  2998. };
  2999. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3000. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3001. //处理金额
  3002. if (entity.CTable == 1015)
  3003. {
  3004. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3005. if (czInfo != null)
  3006. {
  3007. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3008. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3009. }
  3010. }
  3011. /*
  3012. * 应付款金额
  3013. */
  3014. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3015. string PaymentCurrency_WaitPay = "Unknown";
  3016. string hotelCurrncyCode = "Unknown";
  3017. string hotelCurrncyName = "Unknown";
  3018. if (sdPaymentCurrency_WaitPay != null)
  3019. {
  3020. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3021. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3022. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3023. if (hotelCurrncyCode.Equals("CNY"))
  3024. {
  3025. entity.DayRate = 1.0000M;
  3026. }
  3027. }
  3028. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3029. /*
  3030. * 此次付款金额
  3031. */
  3032. decimal CurrPayStr = 0.00M,
  3033. OriginalCurrPay = 0.00M;
  3034. if (entity.PayPercentage == 0)
  3035. {
  3036. if (entity.PayThenMoney != 0)
  3037. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3038. }
  3039. else
  3040. {
  3041. if (entity.PayMoney != 0)
  3042. {
  3043. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3044. }
  3045. }
  3046. //if (_dto.Label == 79)
  3047. //{
  3048. // string original = string.Empty;
  3049. // if (hotelCurrncyCode.Equals("CNY"))
  3050. // {
  3051. // OriginalCurrPay = CurrPayStr;
  3052. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3053. // }
  3054. // else
  3055. // {
  3056. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3057. // //760 EUR(7600.00 CNY)
  3058. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3059. // }
  3060. //}
  3061. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3062. string original = string.Empty;
  3063. if (hotelCurrncyCode.Equals("CNY"))
  3064. {
  3065. OriginalCurrPay = CurrPayStr;
  3066. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3067. }
  3068. else
  3069. {
  3070. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3071. //760 EUR(7600.00 CNY)
  3072. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3073. }
  3074. /*
  3075. * 剩余尾款
  3076. */
  3077. decimal BalanceStr = 0;
  3078. if (CurrPayStr != 0)
  3079. {
  3080. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3081. BalanceStr = 0;
  3082. else
  3083. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3084. }
  3085. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3086. /*
  3087. * Bus名称
  3088. */
  3089. _detail.BusName = "待增加";
  3090. /*
  3091. *费用所属
  3092. */
  3093. switch (entity.CTable)
  3094. {
  3095. case 76://酒店预订
  3096. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3097. if (hotelReservations != null)
  3098. {
  3099. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3100. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3101. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3102. string roomFeeStr = "", roomFeestr1 = "";
  3103. //是否比较房型价格
  3104. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3105. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3106. roomFeeStr += $"<br/>";
  3107. var roomTotal = 0.00M;
  3108. if (hotelReservations.SingleRoomPrice > 0)
  3109. {
  3110. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3111. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3112. //__isSingle = true;
  3113. roomTotal += fee;
  3114. }
  3115. if (hotelReservations.DoubleRoomPrice > 0)
  3116. {
  3117. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3118. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3119. // __isDouble = true;
  3120. roomTotal += fee;
  3121. }
  3122. if (hotelReservations.SuiteRoomPrice > 0)
  3123. {
  3124. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3125. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3126. //__isSuite = true;
  3127. roomTotal += fee;
  3128. }
  3129. if (hotelReservations.OtherRoomPrice > 0)
  3130. {
  3131. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3132. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3133. //__isOther = true;
  3134. roomTotal += fee;
  3135. }
  3136. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3137. else roomFeeStr += " 0.00 * 0";
  3138. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3139. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3140. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3141. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3142. /*
  3143. * 费用类型
  3144. * 1:房费
  3145. * 2:早餐
  3146. * 3:地税
  3147. * 4:城市税
  3148. * </summary>
  3149. */
  3150. //地税
  3151. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3152. if (governmentRentData != null)
  3153. {
  3154. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3155. governmentRentFee = governmentRentData.Price;
  3156. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3157. if (governmentRentCurrData != null)
  3158. {
  3159. governmentRentCode = governmentRentCurrData.Name;
  3160. governmentRentName = $"({governmentRentCurrData.Remark})";
  3161. }
  3162. }
  3163. //城市税
  3164. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3165. if (cityTaxData != null)
  3166. {
  3167. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3168. cityTaxFee = cityTaxData.Price;
  3169. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3170. if (cityTaxCurrData != null)
  3171. {
  3172. cityTaxCode = cityTaxCurrData.Name;
  3173. cityTaxName = $"({cityTaxCurrData.Remark})";
  3174. }
  3175. }
  3176. //酒店早餐
  3177. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3178. if (breakfastData != null)
  3179. {
  3180. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3181. breakfastFee = breakfastData.Price;
  3182. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3183. if (breakfastCurrData != null)
  3184. {
  3185. breakfastCode = breakfastCurrData.Name;
  3186. breakfastName = $"({breakfastCurrData.Remark})";
  3187. }
  3188. }
  3189. //房间费用
  3190. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3191. if (roomData != null)
  3192. {
  3193. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3194. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3195. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3196. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3197. roomFee = roomData.Price;
  3198. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3199. if (roomCurrData != null)
  3200. {
  3201. roomCode = roomCurrData.Name;
  3202. roomName = $"({roomCurrData.Remark})";
  3203. }
  3204. }
  3205. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3206. string hotelCostStr = "";
  3207. decimal hotelCsotTotal = 0.00M;
  3208. if (groupCost != null)
  3209. {
  3210. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3211. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3212. }
  3213. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3214. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3215. string hotelCost_day = "";
  3216. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3217. foreach (var item in hotelCostDetails1)
  3218. {
  3219. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3220. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3221. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3222. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3223. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3224. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3225. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3226. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3227. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3228. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3229. hotelCost_day += @$"<br/>";
  3230. }
  3231. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3232. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3233. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3234. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3235. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3236. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3237. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3238. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3239. $"房间说明: {hotelReservations.Remark} <br/>" +
  3240. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3241. $"{hotelBreakfastStr}" +
  3242. $"{hotelGovernmentRentStr}" +
  3243. $"{hotelCityTaxStr}";
  3244. _detail.PriceNameContent = hotelReservations.HotelName;
  3245. }
  3246. break;
  3247. case 79://车/导游地接
  3248. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3249. if (touristGuideGroundReservations != null)
  3250. {
  3251. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3252. {
  3253. _detail.BusName = touristGuideGroundReservations.BusName;
  3254. }
  3255. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3256. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3257. //if (isInt)
  3258. //{
  3259. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3260. // if (cityInfo != null)
  3261. // {
  3262. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3263. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3264. // if (carFeeItem != null)
  3265. // {
  3266. // nameContent += $@"({carFeeItem.Name})";
  3267. // }
  3268. // _detail.PriceNameContent = nameContent;
  3269. // }
  3270. //}
  3271. //else
  3272. //{
  3273. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3274. //}
  3275. var touristGuideGroundReservationsContents =
  3276. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3277. var opContent_sb = new StringBuilder();
  3278. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3279. opContent_sb.AppendLine(contetTitle);
  3280. foreach (var item in touristGuideGroundReservationsContents)
  3281. {
  3282. string typeName = "Unknown";
  3283. string carCurrencyCode = "Unknown";
  3284. string carCurrencyName = "Unknown";
  3285. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3286. if (carTypeData != null) typeName = carTypeData.Name;
  3287. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3288. if (currencyData != null)
  3289. {
  3290. carCurrencyCode = currencyData.Name;
  3291. carCurrencyName = currencyData.Remark;
  3292. }
  3293. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3294. bool IsCurrencyAgreement = false;
  3295. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3296. string opCostStr = string.Empty;
  3297. decimal opCostTypePrice = 0.00M;
  3298. #region 处理成本各项费用
  3299. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3300. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3301. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3302. costOPFeeCNY = 0.00M, //团组成本 op费用
  3303. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3304. if (opCost.Count > 0)
  3305. {
  3306. switch (item.SId)
  3307. {
  3308. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3309. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3310. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3311. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3312. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3313. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3314. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3315. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3316. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3317. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3318. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3319. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3320. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3321. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3322. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3323. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3324. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3325. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3326. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3327. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3328. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3329. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3330. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3331. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3332. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3333. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3334. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3335. }
  3336. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3337. costOPFeeCNY = opCostTypePrice * _groupRate;
  3338. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3339. }
  3340. #endregion
  3341. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3342. aduitOPFeeCNY = item.Price * entity.DayRate;
  3343. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3344. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3345. $"{opTypeStr} {opCostStr}<br/>" +
  3346. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3347. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3348. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3349. {
  3350. if (IsCurrencyAgreement)
  3351. {
  3352. if (item.Price > opCostTypePrice)
  3353. {
  3354. opContent_sb.Append("<span style='color:red;'>");
  3355. opContent_sb.Append(opContent);
  3356. opContent_sb.Append("</span>");
  3357. opContent_sb.AppendLine();
  3358. }
  3359. else
  3360. {
  3361. opContent_sb.Append(opContent);
  3362. opContent_sb.AppendLine();
  3363. }
  3364. }
  3365. else
  3366. {
  3367. //验证是否超成本 按付款比例计算
  3368. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3369. {
  3370. opContent_sb.Append("<span style='color:red;'>");
  3371. opContent_sb.Append(opContent);
  3372. opContent_sb.Append("</span>");
  3373. opContent_sb.AppendLine();
  3374. }
  3375. else
  3376. {
  3377. opContent_sb.Append(opContent);
  3378. opContent_sb.AppendLine();
  3379. }
  3380. }
  3381. }
  3382. else
  3383. {
  3384. opContent_sb.Append(opContent);
  3385. opContent_sb.AppendLine();
  3386. }
  3387. }
  3388. _detail.PriceMsgContent = opContent_sb.ToString();
  3389. }
  3390. break;
  3391. case 80: //签证
  3392. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3393. if (visaInfo != null)
  3394. {
  3395. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3396. _detail.PriceNameContent = visaInfo.VisaDescription;
  3397. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3398. }
  3399. break;
  3400. case 81: //邀请/公务活动
  3401. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3402. if (_ioa != null)
  3403. {
  3404. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3405. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3406. sendCurrName = "Unknown", //快递费用币种 Name
  3407. sendCurrCode = "Unknown", //快递费用币种 Code
  3408. eventsCurrName = "Unknown", //公务活动费币种 Name
  3409. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3410. translateCurrName = "Unknown", //公务翻译费 Name
  3411. translateCurrCode = "Unknown"; //公务翻译费 Code
  3412. #region 处理费用币种
  3413. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3414. if (inviteCurrData != null)
  3415. {
  3416. inviteCurrName = inviteCurrData.Remark;
  3417. inviteCurrCode = inviteCurrData.Name;
  3418. }
  3419. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3420. if (sendCurrData != null)
  3421. {
  3422. sendCurrName = sendCurrData.Remark;
  3423. sendCurrCode = sendCurrData.Name;
  3424. }
  3425. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3426. if (eventsCurrData != null)
  3427. {
  3428. eventsCurrName = eventsCurrData.Remark;
  3429. eventsCurrCode = eventsCurrData.Name;
  3430. }
  3431. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3432. if (translateCurrData != null)
  3433. {
  3434. translateCurrName = translateCurrData.Remark;
  3435. translateCurrCode = translateCurrData.Name;
  3436. }
  3437. #endregion
  3438. _detail.PriceNameContent = _ioa.InviterArea;
  3439. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3440. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3441. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3442. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3443. $@"备注:" + _ioa.Remark + "<br/>";
  3444. }
  3445. break;
  3446. case 82: //团组客户保险
  3447. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3448. if (customers != null)
  3449. {
  3450. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3451. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3452. }
  3453. break;
  3454. case 85: //机票预订
  3455. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3456. if (jpRes != null)
  3457. {
  3458. string FlightsDescription = jpRes.FlightsDescription;
  3459. string PriceDescription = jpRes.PriceDescription;
  3460. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3461. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3462. }
  3463. break;
  3464. case 98://其他款项
  3465. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3466. if (gdpRes != null)
  3467. {
  3468. //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/";
  3469. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  3470. //{
  3471. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  3472. //}
  3473. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3474. _detail.PriceNameContent = gdpRes.PriceName;
  3475. }
  3476. break;
  3477. case 285://收款退还
  3478. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3479. if (refundAndOtherMoney != null)
  3480. {
  3481. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3482. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3483. }
  3484. break;
  3485. case 751://酒店早餐
  3486. break;
  3487. case 1015://超支费用
  3488. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3489. if (groupExtraCost != null)
  3490. {
  3491. _detail.PriceNameContent = groupExtraCost.PriceName;
  3492. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3493. }
  3494. break;
  3495. default:
  3496. break;
  3497. }
  3498. /*
  3499. * 申请人
  3500. */
  3501. string operatorName = " - ";
  3502. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3503. if (_opUser != null)
  3504. {
  3505. operatorName = _opUser.CnName;
  3506. }
  3507. _detail.OperatorName = operatorName;
  3508. /*
  3509. * 审核人
  3510. */
  3511. string auditOperatorName = " - ";
  3512. if (entity.IsAuditGM != 0)
  3513. {
  3514. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3515. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3516. else
  3517. {
  3518. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3519. if (_adUser != null)
  3520. {
  3521. auditOperatorName = _adUser.CnName;
  3522. }
  3523. }
  3524. }
  3525. _detail.AuditOperatorName = auditOperatorName;
  3526. /*
  3527. * 超预算比例
  3528. */
  3529. string overBudgetStr = "";
  3530. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3531. else if (entity.ExceedBudget == 0)
  3532. {
  3533. if (entity.CTable == 76 || entity.CTable == 79)
  3534. {
  3535. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3536. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3537. }
  3538. else
  3539. {
  3540. overBudgetStr = "未超预算";
  3541. }
  3542. }
  3543. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3544. _detail.OverBudget = overBudgetStr;
  3545. decimal auditFee = 0.00M; //已审核金额 人名币
  3546. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3547. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3548. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3549. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3550. {
  3551. auditedFeeOriginal = entity.PayMoney;
  3552. auditFee = CurrPayStr;
  3553. }
  3554. else if (entity.IsAuditGM == 0)
  3555. {
  3556. unAuditFeeCNY = CurrPayStr;
  3557. unAuditFeeOriginal = OriginalCurrPay;
  3558. OriginalCurrPay = 0.00M;
  3559. }
  3560. /*
  3561. * 费用总计
  3562. */
  3563. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3564. {
  3565. CurrencyId = entity.PaymentCurrency,
  3566. CurrencyName = PaymentCurrency_WaitPay,
  3567. AmountPayable = entity.PayMoney,
  3568. ThisPayment = OriginalCurrPay,
  3569. BalancePayment = BalanceStr,
  3570. AuditedFunds = auditFee,
  3571. AuditedFundsOriginal = auditedFeeOriginal,
  3572. UnAuditFundsCNY = unAuditFeeCNY,
  3573. UnAuditFundsOriginal = unAuditFeeOriginal
  3574. });
  3575. _detail.IsAuditGM = entity.IsAuditGM;
  3576. detailList.Add(_detail);
  3577. }
  3578. #endregion
  3579. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3580. /*
  3581. * 下方描述处理
  3582. */
  3583. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3584. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3585. if (ccpCurrencyPrice != null)
  3586. {
  3587. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3588. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3589. }
  3590. else
  3591. {
  3592. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3593. }
  3594. string amountPayableStr = string.Format(@"应付款总金额: ");
  3595. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3596. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3597. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3598. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3599. foreach (var item in nonDuplicat)
  3600. {
  3601. var currencyName = item.CurrencyName;
  3602. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3603. if (strs.Count > 0)
  3604. {
  3605. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3606. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3607. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3608. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3609. //单独处理此次付款金额
  3610. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3611. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3612. //单独处理已审核费用
  3613. //if (item.CurrencyId == 836) //人民币
  3614. //{
  3615. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3616. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3617. //}
  3618. //else
  3619. //{
  3620. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3621. //}
  3622. if (currencyName.Equals("CNY"))
  3623. {
  3624. //已审核费用
  3625. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3626. //未审核费用
  3627. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3628. }
  3629. else
  3630. {
  3631. //已审核费用
  3632. 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"));
  3633. //未审核费用
  3634. 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"));
  3635. }
  3636. }
  3637. }
  3638. _view.TotalStr1 = amountPayableStr[..^1];
  3639. _view.TotalStr2 = thisPaymentStr[..^1];
  3640. _view.TotalStr3 = balancePaymentStr[..^1];
  3641. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3642. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3643. var _view1 = new
  3644. {
  3645. PageFuncAuth = pageFunAuthView,
  3646. Data = _view
  3647. };
  3648. return Ok(JsonView(_view1));
  3649. }
  3650. catch (Exception ex)
  3651. {
  3652. return Ok(JsonView(false, ex.Message));
  3653. }
  3654. }
  3655. /// <summary>
  3656. /// 费用审核
  3657. /// 修改团组费用审核状态
  3658. /// </summary>
  3659. /// <param name="_dto">参数Json字符串</param>
  3660. /// <returns></returns>
  3661. [HttpPost]
  3662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3663. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3664. {
  3665. #region 参数验证
  3666. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3667. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3668. #endregion
  3669. #region 页面操作权限验证
  3670. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3671. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3672. #endregion
  3673. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3674. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3675. DateTime dtNow = DateTime.Now;
  3676. _groupRepository.BeginTran();
  3677. int rst = 0;
  3678. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3679. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3680. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3681. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3682. var msgDatas = new List<dynamic>();
  3683. var dic_ccp_user = new Dictionary<int, int>() { };
  3684. foreach (var item in idList)
  3685. {
  3686. int CreditId = int.Parse(item);
  3687. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3688. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3689. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3690. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3691. .Where(s => s.Id == CreditId)
  3692. .ExecuteCommandAsync();
  3693. if (result < 1)
  3694. {
  3695. rst = -1;
  3696. _groupRepository.RollbackTran();
  3697. return Ok(JsonView(false, "操作失败并回滚!"));
  3698. }
  3699. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3700. if (creditData != null)
  3701. {
  3702. #region 应用通知配置
  3703. try
  3704. {
  3705. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3706. }
  3707. catch (Exception ex)
  3708. {
  3709. }
  3710. #endregion
  3711. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3712. string groupNameStr = string.Empty;
  3713. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3714. if (groupData != null) groupNameStr = groupData.TeamName;
  3715. string creditTypeStr = string.Empty;
  3716. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3717. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3718. string creditCurrency = string.Empty;
  3719. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3720. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3721. if (creditCurrency.Equals("CNY"))
  3722. {
  3723. creditData.DayRate = 1.0000M;
  3724. }
  3725. if (creditData.PayPercentage == 0.00M)
  3726. {
  3727. creditData.PayPercentage = 100M;
  3728. }
  3729. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3730. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3731. string msgContent = "";
  3732. if (creditCurrency.Equals("CNY"))
  3733. {
  3734. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3735. }
  3736. else
  3737. {
  3738. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3739. }
  3740. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3741. }
  3742. }
  3743. if (rst == 0)
  3744. {
  3745. _groupRepository.CommitTran();
  3746. foreach (var item in msgDatas)
  3747. {
  3748. //发送消息
  3749. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3750. }
  3751. #region 应用推送
  3752. try
  3753. {
  3754. foreach (var ccpId in dic_ccp_user.Keys)
  3755. {
  3756. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3757. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3758. }
  3759. }
  3760. catch (Exception)
  3761. {
  3762. }
  3763. #endregion
  3764. return Ok(JsonView(true, "操作成功!"));
  3765. }
  3766. return Ok(JsonView(false, "操作失败!"));
  3767. }
  3768. /// <summary>
  3769. /// 费用审核
  3770. /// 其他款项 文件下载
  3771. /// </summary>
  3772. /// <param name="id">其他款项 主键编号</param>
  3773. /// <returns></returns>
  3774. [HttpGet("{id}")]
  3775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3776. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1,int.MaxValue,ErrorMessage ="请传入有效的ID")]int id)
  3777. {
  3778. //网站域名
  3779. 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/";
  3780. var otherInfo = await _decreasePaymentsRep._sqlSugar
  3781. .Queryable<Grp_DecreasePayments>()
  3782. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  3783. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  3784. .Select((x, y) => new
  3785. {
  3786. x.Id,
  3787. x.FilePath
  3788. })
  3789. .FirstAsync();
  3790. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  3791. {
  3792. var url = $"{baseUrl}{otherInfo.FilePath}";
  3793. return Ok(JsonView(true, "操作成功!", url));
  3794. }
  3795. return Ok(JsonView(false, "暂无附件"));
  3796. }
  3797. #endregion
  3798. #region 机票费用录入
  3799. /// <summary>
  3800. /// 机票录入当前登录人可操作团组
  3801. /// </summary>
  3802. /// <param name="dto"></param>
  3803. /// <returns></returns>
  3804. [HttpPost]
  3805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3806. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3807. {
  3808. try
  3809. {
  3810. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3811. if (groupData.Code != 0)
  3812. {
  3813. return Ok(JsonView(false, groupData.Msg));
  3814. }
  3815. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3816. }
  3817. catch (Exception ex)
  3818. {
  3819. return Ok(JsonView(false, ex.Message));
  3820. }
  3821. }
  3822. /// <summary>
  3823. /// 机票费用录入列表
  3824. /// </summary>
  3825. /// <param name="dto"></param>
  3826. /// <returns></returns>
  3827. [HttpPost]
  3828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3829. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3830. {
  3831. try
  3832. {
  3833. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3834. if (groupData.Code != 0)
  3835. {
  3836. return Ok(JsonView(false, groupData.Msg));
  3837. }
  3838. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3839. }
  3840. catch (Exception ex)
  3841. {
  3842. return Ok(JsonView(false, ex.Message));
  3843. throw;
  3844. }
  3845. }
  3846. /// <summary>
  3847. /// 根据id查询费用录入信息
  3848. /// </summary>
  3849. /// <param name="dto"></param>
  3850. /// <returns></returns>
  3851. [HttpPost]
  3852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3853. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3854. {
  3855. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3856. if (groupData.Code != 0)
  3857. {
  3858. return Ok(JsonView(false, groupData.Msg));
  3859. }
  3860. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3861. }
  3862. /// <summary>
  3863. /// 机票费用录入操作(Status:1.新增,2.修改)
  3864. /// </summary>
  3865. /// <param name="dto"></param>
  3866. /// <returns></returns>
  3867. [HttpPost]
  3868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3869. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3870. {
  3871. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3872. if (groupData.Code != 0)
  3873. {
  3874. return Ok(JsonView(false, groupData.Msg));
  3875. }
  3876. #region 应用推送
  3877. try
  3878. {
  3879. var diId = dto.AirTicketResOpData.DiId;
  3880. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3881. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3882. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3883. //自动审核
  3884. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3885. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3886. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3887. $"GroupId:{diId};airId:{dataId};",
  3888. status,
  3889. auditMsg);
  3890. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3891. //2024-10-21 新增LZ UID
  3892. var userIds = new List<int>() { 21 };
  3893. string title = $"系统通知";
  3894. string content = "";
  3895. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3896. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3897. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3898. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3899. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3900. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3901. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3902. }
  3903. catch (Exception ex)
  3904. {
  3905. }
  3906. #endregion
  3907. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3908. }
  3909. /// <summary>
  3910. /// 机票费用自动审核 AI识别方式
  3911. /// </summary>
  3912. /// <returns></returns>
  3913. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3914. {
  3915. var ecoTypeIds = new List<int>() {
  3916. 459, //超经舱
  3917. 460, //经济舱
  3918. 1430, //公务舱(实际经济舱)
  3919. 1432, //头等舱(实际经济舱)
  3920. };
  3921. var bizTypeIds = new List<int>() {
  3922. 457, //头等舱
  3923. 458, //公务舱
  3924. 1431, //头等舱(实际公务舱)
  3925. };
  3926. var auditFeeTypeIds = new List<int>() { };
  3927. auditFeeTypeIds.AddRange(ecoTypeIds);
  3928. auditFeeTypeIds.AddRange(bizTypeIds);
  3929. int currModule = 85;
  3930. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3931. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3932. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3933. .Select((x, y) => new
  3934. {
  3935. x.Id,
  3936. CcpId = y.Id,
  3937. x.FlightsDate,
  3938. x.PrePrice,
  3939. x.CType,
  3940. x.ClientNum,
  3941. x.DIId
  3942. })
  3943. .FirstAsync();
  3944. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3945. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3946. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3947. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3948. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3949. var groupCostContents = await _sqlSugar
  3950. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3951. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3952. .ToListAsync();
  3953. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3954. //处理 成本详细信息日期为空 填装费用信息
  3955. var airFeeLabel = new StringBuilder();
  3956. airFeeLabel.AppendLine("费用成本:");
  3957. for (int i = 0; i < groupCostContents.Count; i++)
  3958. {
  3959. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3960. {
  3961. int index = i - 1;
  3962. if (index >= 0)
  3963. {
  3964. groupCostContents[i].Date = groupCostContents[index].Date;
  3965. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3966. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3967. }
  3968. }
  3969. else
  3970. {
  3971. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3972. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3973. }
  3974. var item = groupCostContents[i];
  3975. airFeeLabel.AppendLine($"{item.Date}");
  3976. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3977. }
  3978. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3979. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3980. //访问Kimi AI 返回价格结果
  3981. var msgs = new List<SeedMessages>()
  3982. {
  3983. new ()
  3984. {
  3985. Role = KimiRole.user,
  3986. Content = airFeeLabel.ToString()
  3987. }
  3988. };
  3989. var client = new KiMiApiClient();
  3990. var kimiApiResult = await client.SeedMessage(msgs);
  3991. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3992. string clients = kimiApiResult_JObject["content"].ToString();
  3993. decimal ecoPri_kimiAI = 0.00M,
  3994. bizPri_kimiAI = 0.00M;
  3995. //单个价格: 经济舱价格
  3996. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3997. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3998. if (clients.Contains('/'))
  3999. {
  4000. var priArray = clients.Split('/');
  4001. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4002. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4003. }
  4004. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4005. var isAutoAudit = false;
  4006. //价格验证处理
  4007. //经济舱
  4008. if (ecoTypeIds.Contains(airInfo.CType))
  4009. {
  4010. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4011. }
  4012. //公务舱
  4013. else if (bizTypeIds.Contains(airInfo.CType))
  4014. {
  4015. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4016. }
  4017. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4018. //是否执行自动审核
  4019. if (isAutoAudit)
  4020. {
  4021. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4022. .SetColumns(x => x.IsAuditGM == 3)
  4023. .SetColumns(x => x.AuditGMOperate == 4)
  4024. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4025. .Where(x => x.Id == airInfo.CcpId)
  4026. .ExecuteCommandAsync();
  4027. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4028. }
  4029. return (false, "当前费用超过成本费用,不可自动审核!");
  4030. }
  4031. /// <summary>
  4032. /// 机票费用录入
  4033. /// 自动审核测试 - AI 识别
  4034. /// </summary>
  4035. /// <param name="groupId"></param>
  4036. /// <param name="Id"></param>
  4037. /// <returns></returns>
  4038. [HttpPost]
  4039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4040. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4041. {
  4042. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4043. return Ok(JsonView(status, msg));
  4044. }
  4045. /// <summary>
  4046. /// 根据舱位类型查询接团客户名单信息
  4047. /// </summary>
  4048. /// <param name="dto"></param>
  4049. /// <returns></returns>
  4050. [HttpPost]
  4051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4052. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4053. {
  4054. try
  4055. {
  4056. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4057. if (crm_Groups.Count != 0)
  4058. {
  4059. var Customer = new List<dynamic>();
  4060. foreach (var item in crm_Groups)
  4061. {
  4062. var data = new
  4063. {
  4064. item.Id,
  4065. item.Pinyin,
  4066. Name = item.LastName + item.FirstName
  4067. };
  4068. Customer.Add(data);
  4069. }
  4070. return Ok(JsonView(true, "查询成功!", Customer));
  4071. }
  4072. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4073. }
  4074. catch (Exception ex)
  4075. {
  4076. return Ok(JsonView(false, "程序错误!"));
  4077. throw;
  4078. }
  4079. }
  4080. /// <summary>
  4081. /// 根据团号获取客户信息
  4082. /// </summary>
  4083. /// <param name="dto"></param>
  4084. /// <returns></returns>
  4085. [HttpPost]
  4086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4087. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4088. {
  4089. var jw = JsonView(false);
  4090. if (dto.DIID < 1)
  4091. {
  4092. jw.Msg += "请输入正确的diid";
  4093. return Ok(jw);
  4094. }
  4095. var arr = GetSimplClientList(dto.DIID);
  4096. jw = JsonView(true, "获取成功!", arr);
  4097. return Ok(jw);
  4098. }
  4099. private List<SimplClientInfo> GetSimplClientList(int diId)
  4100. {
  4101. 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);
  4102. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4103. foreach (var item in arr)
  4104. {
  4105. EncryptionProcessor.DecryptProperties(item);
  4106. }
  4107. return arr;
  4108. }
  4109. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4110. {
  4111. string result = origin;
  4112. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4113. {
  4114. string[] temparr = origin.Split(',');
  4115. string fistrStr = temparr[0];
  4116. int count = temparr.Length;
  4117. bool success = int.TryParse(fistrStr, out int tempId);
  4118. if (success)
  4119. {
  4120. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4121. if (tempInfo != null)
  4122. {
  4123. if (count > 1)
  4124. {
  4125. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4126. }
  4127. else
  4128. {
  4129. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4130. }
  4131. }
  4132. }
  4133. }
  4134. return result;
  4135. }
  4136. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4137. {
  4138. string result = origin;
  4139. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4140. {
  4141. string[] temparr = origin.Split(',');
  4142. result = "";
  4143. foreach (var item in temparr)
  4144. {
  4145. bool success = int.TryParse(item, out int tempId);
  4146. if (success)
  4147. {
  4148. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4149. if (tempInfo != null)
  4150. {
  4151. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4152. }
  4153. }
  4154. }
  4155. }
  4156. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4157. return result;
  4158. }
  4159. /// <summary>
  4160. /// 机票费用录入,删除
  4161. /// </summary>
  4162. /// <param name="dto"></param>
  4163. /// <returns></returns>
  4164. [HttpPost]
  4165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4166. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4167. {
  4168. try
  4169. {
  4170. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4171. if (res)
  4172. {
  4173. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4174. {
  4175. IsDel = 1,
  4176. DeleteUserId = dto.DeleteUserId,
  4177. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4178. }).ExecuteCommandAsync();
  4179. return Ok(JsonView(true, "删除成功!"));
  4180. }
  4181. return Ok(JsonView(false, "删除失败!"));
  4182. }
  4183. catch (Exception ex)
  4184. {
  4185. return Ok(JsonView(false, "程序错误!"));
  4186. throw;
  4187. }
  4188. }
  4189. /// <summary>
  4190. /// 导出机票录入报表
  4191. /// </summary>
  4192. /// <param name="dto"></param>
  4193. /// <returns></returns>
  4194. [HttpPost]
  4195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4196. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4197. {
  4198. try
  4199. {
  4200. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4201. if (groupData.Code != 0)
  4202. {
  4203. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4204. }
  4205. else
  4206. {
  4207. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4208. if (AirTicketReservations.Count != 0)
  4209. {
  4210. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4211. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4212. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4213. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4214. var designer = new WorkbookDesigner
  4215. {
  4216. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4217. };
  4218. decimal countCost = 0;
  4219. foreach (var item in AirTicketReservations)
  4220. {
  4221. #region 处理客人姓名
  4222. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4223. item.ClientName = clientNames;
  4224. #endregion
  4225. if (item.BankType == "其他")
  4226. {
  4227. item.BankNo = "--";
  4228. }
  4229. else
  4230. {
  4231. if (!string.IsNullOrEmpty(item.BankType))
  4232. {
  4233. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  4234. }
  4235. }
  4236. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4237. item.Price = System.Decimal.Round(item.Price, 2);
  4238. countCost += Convert.ToDecimal(item.Price);
  4239. }
  4240. designer.SetDataSource("Export", AirTicketReservations);
  4241. designer.SetDataSource("ExportDiCode", diCode);
  4242. designer.SetDataSource("ExportDiName", diName);
  4243. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4244. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4245. designer.Process();
  4246. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4247. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4248. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4249. return Ok(JsonView(true, "成功", url = rst));
  4250. }
  4251. else
  4252. {
  4253. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4254. }
  4255. }
  4256. }
  4257. catch (Exception ex)
  4258. {
  4259. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4260. throw;
  4261. }
  4262. }
  4263. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  4264. /// <summary>
  4265. /// 行程单导出
  4266. /// </summary>
  4267. /// <param name="dto"></param>
  4268. /// <returns></returns>
  4269. [HttpPost]
  4270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4271. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4272. {
  4273. try
  4274. {
  4275. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4276. if (groupData.Code != 0)
  4277. {
  4278. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4279. }
  4280. else
  4281. {
  4282. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4283. if (dto.Language == "CN")
  4284. {
  4285. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4286. var builder = new DocumentBuilder(doc);
  4287. int tableIndex = 0;//表格索引
  4288. //得到文档中的第一个表格
  4289. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4290. foreach (var item in _AirTicketReservations)
  4291. {
  4292. #region 处理固定数据
  4293. string[] FlightsCode = item.FlightsCode.Split('/');
  4294. if (FlightsCode.Length != 0)
  4295. {
  4296. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4297. if (_AirCompany != null)
  4298. {
  4299. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4300. }
  4301. else
  4302. {
  4303. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4304. }
  4305. }
  4306. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4307. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4308. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4309. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4310. string name = "";
  4311. foreach (string clientName in nameArray)
  4312. {
  4313. if (!name.Contains(clientName))
  4314. {
  4315. name += clientName + ",";
  4316. }
  4317. }
  4318. if (!string.IsNullOrWhiteSpace(name))
  4319. {
  4320. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4321. }
  4322. else
  4323. {
  4324. table.Range.Bookmarks["ClientName"].Text = "--";
  4325. }
  4326. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4327. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4328. table.Range.Bookmarks["JointTicket"].Text = "--";
  4329. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4330. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4331. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4332. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4333. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4334. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4335. #endregion
  4336. #region 循环数据处理
  4337. var airs = new List<AirInfo>();
  4338. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4339. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4340. for (int i = 0; i < FlightsCode.Length; i++)
  4341. {
  4342. var air = new AirInfo();
  4343. string[] tempstr = DayArray[i]
  4344. .Replace("\r\n", string.Empty)
  4345. .Replace("\\r\\n", string.Empty)
  4346. .TrimStart().TrimEnd()
  4347. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4348. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4349. string starCity = "";
  4350. if (star_Three != null)
  4351. {
  4352. starCity = star_Three.AirPort;
  4353. }
  4354. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4355. string EndCity = "";
  4356. if (End_Three != null)
  4357. {
  4358. EndCity = End_Three.AirPort;
  4359. }
  4360. air.Destination = starCity + "/" + EndCity;
  4361. air.Flight = FlightsCode[i];
  4362. air.SeatingClass = item.CTypeName;
  4363. string dateTime = tempstr[2];
  4364. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4365. air.FlightDate = DateTemp;
  4366. air.DepartureTime = tempstr[5];
  4367. air.LandingTime = tempstr[6];
  4368. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4369. air.TicketStatus = "--";
  4370. air.Luggage = "--";
  4371. air.DepartureTerminal = "--";
  4372. air.LandingTerminal = "--";
  4373. airs.Add(air);
  4374. }
  4375. int row = 13;
  4376. for (int i = 0; i < airs.Count; i++)
  4377. {
  4378. if (airs.Count > 2)
  4379. {
  4380. for (int j = 0; j < airs.Count - 2; j++)
  4381. {
  4382. var CopyRow = table.Rows[12].Clone(true);
  4383. table.Rows.Add(CopyRow);
  4384. }
  4385. }
  4386. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4387. int index = 0;
  4388. foreach (PropertyInfo property in properties)
  4389. {
  4390. string value = property.GetValue(airs[i]).ToString();
  4391. Cell ishcel0 = table.Rows[row].Cells[index];
  4392. var p = new Paragraph(doc);
  4393. string s = value;
  4394. p.AppendChild(new Run(doc, s));
  4395. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4396. ishcel0.AppendChild(p);
  4397. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4398. index++;
  4399. }
  4400. row++;
  4401. }
  4402. #endregion
  4403. var lastParagraph = new Paragraph(doc);
  4404. //第一个表格末尾加段落
  4405. table.ParentNode.InsertAfter(lastParagraph, table);
  4406. //复制第一个表格
  4407. Table cloneTable = (Table)table.Clone(true);
  4408. //在文档末尾段落后面加入复制的表格
  4409. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4410. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4411. {
  4412. int rownewsIndex = 13;
  4413. for (int i = 0; i < 2; i++)
  4414. {
  4415. var CopyRow = table.Rows[12].Clone(true);
  4416. table.Rows.RemoveAt(13);
  4417. table.Rows.Add(CopyRow);
  4418. rownewsIndex++;
  4419. }
  4420. }
  4421. else
  4422. {
  4423. table.Rows.RemoveAt(12);
  4424. }
  4425. cloneTable.Rows.RemoveAt(12);
  4426. }
  4427. if (_AirTicketReservations.Count != 0)
  4428. {
  4429. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4430. if (FlightsCode.Length != 0)
  4431. {
  4432. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4433. if (_AirCompany != null)
  4434. {
  4435. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4436. }
  4437. else
  4438. {
  4439. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4440. }
  4441. }
  4442. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4443. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4444. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4445. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4446. string name = "";
  4447. foreach (string clientName in nameArray)
  4448. {
  4449. if (!name.Contains(clientName))
  4450. {
  4451. name += clientName + ",";
  4452. }
  4453. }
  4454. if (!string.IsNullOrWhiteSpace(name))
  4455. {
  4456. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4457. }
  4458. else
  4459. {
  4460. table.Range.Bookmarks["ClientName"].Text = "--";
  4461. }
  4462. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4463. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4464. table.Range.Bookmarks["JointTicket"].Text = "--";
  4465. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4466. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4467. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4468. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4469. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4470. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4471. }
  4472. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4473. //保存合并后的文档
  4474. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4475. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4476. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4477. return Ok(JsonView(true, "成功!", rst));
  4478. }
  4479. else
  4480. {
  4481. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4482. var builder = new DocumentBuilder(doc);
  4483. int tableIndex = 0;//表格索引
  4484. //得到文档中的第一个表格
  4485. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4486. var texts = new List<string>();
  4487. foreach (var item in _AirTicketReservations)
  4488. {
  4489. string[] FlightsCode = item.FlightsCode.Split('/');
  4490. if (FlightsCode.Length != 0)
  4491. {
  4492. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4493. if (_AirCompany != null)
  4494. {
  4495. if (!transDic.ContainsKey(_AirCompany.CnName))
  4496. {
  4497. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4498. }
  4499. }
  4500. else
  4501. {
  4502. if (!transDic.ContainsKey("--"))
  4503. {
  4504. transDic.Add("--", "--");
  4505. }
  4506. }
  4507. }
  4508. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4509. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4510. string name = "";
  4511. foreach (string clientName in nameArray)
  4512. {
  4513. name += clientName + ",";
  4514. }
  4515. if (!texts.Contains(name))
  4516. {
  4517. texts.Add(name);
  4518. }
  4519. var airs = new List<AirInfo>();
  4520. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4521. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4522. for (int i = 0; i < FlightsCode.Length; i++)
  4523. {
  4524. var air = new AirInfo();
  4525. string[] tempstr = DayArray[i]
  4526. .Replace("\r\n", string.Empty)
  4527. .Replace("\\r\\n", string.Empty)
  4528. .TrimStart().TrimEnd()
  4529. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4530. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4531. if (star_Three != null)
  4532. {
  4533. if (!transDic.ContainsKey(star_Three.AirPort))
  4534. {
  4535. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4536. }
  4537. }
  4538. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4539. if (End_Three != null)
  4540. {
  4541. if (!transDic.ContainsKey(End_Three.AirPort))
  4542. {
  4543. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4544. }
  4545. }
  4546. if (!texts.Contains(item.CTypeName))
  4547. {
  4548. texts.Add(item.CTypeName);
  4549. }
  4550. }
  4551. }
  4552. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4553. if (transData.Count > 0)
  4554. {
  4555. foreach (TranslateResult item in transData)
  4556. {
  4557. if (!transDic.ContainsKey(item.Query))
  4558. {
  4559. transDic.Add(item.Query, item.Translation);
  4560. }
  4561. }
  4562. }
  4563. foreach (var item in _AirTicketReservations)
  4564. {
  4565. #region 处理固定数据
  4566. string[] FlightsCode = item.FlightsCode.Split('/');
  4567. if (FlightsCode.Length != 0)
  4568. {
  4569. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4570. if (_AirCompany != null)
  4571. {
  4572. string str = "--";
  4573. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4574. if (!string.IsNullOrEmpty(translateResult))
  4575. {
  4576. str = translateResult;
  4577. str = _airTicketResRep.Processing(str);
  4578. }
  4579. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4580. }
  4581. else
  4582. {
  4583. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4584. }
  4585. }
  4586. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4587. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4588. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4589. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4590. string names = "";
  4591. foreach (string clientName in nameArray)
  4592. {
  4593. names += clientName + ",";
  4594. }
  4595. if (!string.IsNullOrWhiteSpace(names))
  4596. {
  4597. string str = "--";
  4598. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4599. if (!string.IsNullOrEmpty(translateResult))
  4600. {
  4601. str = translateResult;
  4602. str = _airTicketResRep.Processing(str);
  4603. }
  4604. table.Range.Bookmarks["ClientName"].Text = str;
  4605. }
  4606. else
  4607. {
  4608. table.Range.Bookmarks["ClientName"].Text = "--";
  4609. }
  4610. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4611. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4612. table.Range.Bookmarks["JointTicket"].Text = "--";
  4613. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4614. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4615. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4616. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4617. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4618. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4619. #endregion
  4620. #region 循环数据处理
  4621. var airs = new List<AirInfo>();
  4622. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4623. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4624. for (int i = 0; i < FlightsCode.Length; i++)
  4625. {
  4626. var air = new AirInfo();
  4627. string[] tempstr = DayArray[i]
  4628. .Replace("\r\n", string.Empty)
  4629. .Replace("\\r\\n", string.Empty)
  4630. .TrimStart().TrimEnd()
  4631. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4632. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4633. string starCity = "";
  4634. if (star_Three != null)
  4635. {
  4636. string str2 = "--";
  4637. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4638. if (!string.IsNullOrEmpty(translateResult2))
  4639. {
  4640. str2 = translateResult2;
  4641. str2 = _airTicketResRep.Processing(str2);
  4642. }
  4643. starCity = str2;
  4644. }
  4645. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4646. string EndCity = "";
  4647. if (End_Three != null)
  4648. {
  4649. string str1 = "--";
  4650. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4651. if (!string.IsNullOrEmpty(translateResult1))
  4652. {
  4653. str1 = translateResult1;
  4654. str1 = _airTicketResRep.Processing(str1);
  4655. }
  4656. EndCity = str1;
  4657. }
  4658. air.Destination = starCity + "/" + EndCity;
  4659. air.Flight = FlightsCode[i];
  4660. string str = "--";
  4661. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4662. if (!string.IsNullOrEmpty(translateResult))
  4663. {
  4664. str = translateResult;
  4665. str = _airTicketResRep.Processing(str);
  4666. }
  4667. air.SeatingClass = str;
  4668. string dateTime = tempstr[2];
  4669. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4670. air.FlightDate = DateTemp;
  4671. air.DepartureTime = tempstr[5];
  4672. air.LandingTime = tempstr[6];
  4673. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4674. air.TicketStatus = "--";
  4675. air.Luggage = "--";
  4676. air.DepartureTerminal = "--";
  4677. air.LandingTerminal = "--";
  4678. airs.Add(air);
  4679. }
  4680. int row = 13;
  4681. for (int i = 0; i < airs.Count; i++)
  4682. {
  4683. if (airs.Count > 2)
  4684. {
  4685. for (int j = 0; j < airs.Count - 2; j++)
  4686. {
  4687. var CopyRow = table.Rows[12].Clone(true);
  4688. table.Rows.Add(CopyRow);
  4689. }
  4690. }
  4691. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4692. int index = 0;
  4693. foreach (PropertyInfo property in properties)
  4694. {
  4695. string value = property.GetValue(airs[i]).ToString();
  4696. Cell ishcel0 = table.Rows[row].Cells[index];
  4697. var p = new Paragraph(doc);
  4698. string s = value;
  4699. p.AppendChild(new Run(doc, s));
  4700. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4701. ishcel0.AppendChild(p);
  4702. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4703. //ishcel0.CellFormat.VerticalAlignment=
  4704. index++;
  4705. }
  4706. row++;
  4707. }
  4708. #endregion
  4709. var lastParagraph = new Paragraph(doc);
  4710. //第一个表格末尾加段落
  4711. table.ParentNode.InsertAfter(lastParagraph, table);
  4712. //复制第一个表格
  4713. Table cloneTable = (Table)table.Clone(true);
  4714. //在文档末尾段落后面加入复制的表格
  4715. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4716. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4717. {
  4718. int rownewsIndex = 13;
  4719. for (int i = 0; i < 2; i++)
  4720. {
  4721. var CopyRow = table.Rows[12].Clone(true);
  4722. table.Rows.RemoveAt(13);
  4723. table.Rows.Add(CopyRow);
  4724. rownewsIndex++;
  4725. }
  4726. }
  4727. else
  4728. {
  4729. table.Rows.RemoveAt(12);
  4730. }
  4731. cloneTable.Rows.RemoveAt(12);
  4732. }
  4733. if (_AirTicketReservations.Count != 0)
  4734. {
  4735. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4736. if (FlightsCode.Length != 0)
  4737. {
  4738. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4739. if (_AirCompany != null)
  4740. {
  4741. string str = "--";
  4742. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4743. if (!string.IsNullOrEmpty(translateResult))
  4744. {
  4745. str = translateResult;
  4746. str = _airTicketResRep.Processing(str);
  4747. }
  4748. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4749. }
  4750. else
  4751. {
  4752. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4753. }
  4754. }
  4755. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4756. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4757. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4758. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4759. string names = "";
  4760. foreach (string clientName in nameArray)
  4761. {
  4762. names += clientName + ",";
  4763. }
  4764. if (!string.IsNullOrWhiteSpace(names))
  4765. {
  4766. string str = "--";
  4767. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4768. if (!string.IsNullOrEmpty(translateResult))
  4769. {
  4770. str = translateResult;
  4771. str = _airTicketResRep.Processing(str);
  4772. }
  4773. table.Range.Bookmarks["ClientName"].Text = str;
  4774. }
  4775. else
  4776. {
  4777. table.Range.Bookmarks["ClientName"].Text = "--";
  4778. }
  4779. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4780. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4781. table.Range.Bookmarks["JointTicket"].Text = "--";
  4782. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4783. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4784. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4785. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4786. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4787. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4788. }
  4789. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4790. //保存合并后的文档
  4791. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4792. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4793. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4794. return Ok(JsonView(true, "成功!", rst));
  4795. }
  4796. }
  4797. }
  4798. catch (Exception ex)
  4799. {
  4800. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4801. throw;
  4802. }
  4803. }
  4804. #endregion
  4805. #region 团组增减款项 --> 其他款项
  4806. /// <summary>
  4807. /// 团组增减款项下拉框绑定
  4808. /// </summary>
  4809. /// <param name="dto"></param>
  4810. /// <returns></returns>
  4811. [HttpPost]
  4812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4813. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4814. {
  4815. #region 参数验证
  4816. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4817. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4818. #endregion
  4819. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4820. }
  4821. /// <summary>
  4822. /// 根据团组Id查询团组增减款项
  4823. /// </summary>
  4824. /// <param name="dto"></param>
  4825. /// <returns></returns>
  4826. [HttpPost]
  4827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4828. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4829. {
  4830. #region 参数验证
  4831. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4832. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4833. #endregion
  4834. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4835. }
  4836. /// <summary>
  4837. /// 团组增减款项操作(Status:1.新增,2.修改)
  4838. /// </summary>
  4839. /// <param name="dto"></param>
  4840. /// <returns></returns>
  4841. [HttpPost]
  4842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4843. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4844. {
  4845. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4846. if (groupData.Code != 200)
  4847. {
  4848. return Ok(JsonView(false, groupData.Msg));
  4849. }
  4850. #region 应用推送
  4851. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4852. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4853. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4854. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4855. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4856. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4857. //自动审核
  4858. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4859. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4860. //2024-10-21 新增LZ UID
  4861. var userIds = new List<int>() { 21 };
  4862. string title = $"系统通知";
  4863. string content = "";
  4864. var diId = dto.DiId;
  4865. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4866. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4867. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4868. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4869. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4870. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4871. #endregion
  4872. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4873. }
  4874. /// <summary>
  4875. /// 团组增减款项操作 删除
  4876. /// </summary>
  4877. /// <param name="dto"></param>
  4878. /// <returns></returns>
  4879. [HttpPost]
  4880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4881. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4882. {
  4883. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4884. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4885. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4886. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4887. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4888. }
  4889. /// <summary>
  4890. /// 根据团组增减款项Id查询
  4891. /// </summary>
  4892. /// <param name="dto"></param>
  4893. /// <returns></returns>
  4894. [HttpPost]
  4895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4896. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4897. {
  4898. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4899. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4900. }
  4901. /// <summary>
  4902. /// 查询供应商名称
  4903. /// </summary>
  4904. /// <param name="dto"></param>
  4905. /// <returns></returns>
  4906. [HttpPost]
  4907. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4908. {
  4909. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4910. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4911. ?? new List<Grp_DecreasePayments>();
  4912. dbResult = dbResult.Distinct(new
  4913. ProductComparer()).ToList();
  4914. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4915. {
  4916. x.Id,
  4917. x.SupplierAddress,
  4918. x.SupplierArea,
  4919. x.SupplierContact,
  4920. x.SupplierContactNumber,
  4921. x.SupplierEmail,
  4922. x.SupplierName,
  4923. x.SupplierSocialAccount,
  4924. x.SupplierTypeId,
  4925. }).ToList());
  4926. return Ok(jw);
  4927. }
  4928. /// <summary>
  4929. /// 团组增减款项 OTA匹配
  4930. /// </summary>
  4931. /// <param name="file"></param>
  4932. /// <returns></returns>
  4933. [HttpPost]
  4934. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4935. {
  4936. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4937. string fileName = file.FileName;
  4938. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4939. {
  4940. return Ok(JsonView(false, "请上传Excel文件!"));
  4941. }
  4942. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4943. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4944. if (!Directory.Exists(path))
  4945. {
  4946. Directory.CreateDirectory(path);
  4947. }
  4948. var filePath = @$"{path}/{fileName}";
  4949. //保存文件
  4950. using (FileStream fs = System.IO.File.Create(filePath))
  4951. {
  4952. file.CopyTo(fs);
  4953. fs.Flush();
  4954. }
  4955. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4956. //读取ExcelFile
  4957. DataTable dt = ConvertExcelToDataTable(filePath);
  4958. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4959. dt.TableName = "TB";
  4960. //修改table列名
  4961. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4962. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4963. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4964. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4965. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4966. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4967. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4968. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4969. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4970. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4971. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4972. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4973. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4974. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4975. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4976. var otaOrderNos = new List<string>();
  4977. foreach (DataRow item in dt.Rows)
  4978. {
  4979. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4980. }
  4981. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4982. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4983. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4984. .Select((dp, di) => new
  4985. {
  4986. dp.PriceName,
  4987. dp.OTAOrderNo,
  4988. dp.FeeTotal,
  4989. di.TeamName,
  4990. })
  4991. .ToListAsync();
  4992. foreach (DataRow item in dt.Rows)
  4993. {
  4994. var otaOrderNo = item["OTAOrderNo"].ToString();
  4995. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4996. if (oaData == null) continue;
  4997. item["GroupName"] = oaData.TeamName;
  4998. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4999. }
  5000. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5001. var pairs = new Dictionary<string, object>();
  5002. var datas = new List<DataTable>
  5003. {
  5004. dt
  5005. };
  5006. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5007. return Ok(JsonView(true, "操作成功", new { url }));
  5008. }
  5009. #region
  5010. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5011. {
  5012. // 创建Workbook对象
  5013. var workbook = new Workbook(excelFilePath);
  5014. // 获取第一个工作表
  5015. var worksheet = workbook.Worksheets[0];
  5016. // 将工作表转换为DataTable
  5017. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5018. return dataTable;
  5019. }
  5020. #endregion
  5021. /// <summary>
  5022. /// 世运会数据
  5023. /// </summary>
  5024. /// <returns></returns>
  5025. [HttpGet]
  5026. public IActionResult WorldGamesData()
  5027. {
  5028. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5029. var groupMenu = setData.GroupBy(x => x.T0);
  5030. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5031. foreach (var item in groupMenu)
  5032. {
  5033. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5034. {
  5035. Data = new SetDataView
  5036. {
  5037. Name = item.Key
  5038. },
  5039. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5040. });
  5041. }
  5042. return Ok(JsonView(true, "success", resultArr));
  5043. }
  5044. #endregion
  5045. #region 文件上传、删除
  5046. /// <summary>
  5047. /// region 文件上传 可以带参数
  5048. /// </summary>
  5049. /// <param name="file"></param>
  5050. /// <returns></returns>
  5051. [HttpPost]
  5052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5053. public async Task<IActionResult> UploadProject(IFormFile file)
  5054. {
  5055. //var TypeName = Request.Headers["TypeName"].ToString();
  5056. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5057. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5058. ////文件名称
  5059. //string projectFileName = file.FileName;
  5060. ////上传的文件的路径
  5061. //string filePath = $"{fileDir}/{projectFileName}";
  5062. //if (TypeName == "A")//A代表团组增减款项
  5063. //{
  5064. // filePath = fileDir + $@"\团组增减款项相关文件";
  5065. // if (!Directory.Exists(filePath))
  5066. // {
  5067. // Directory.CreateDirectory(filePath);
  5068. // }
  5069. // //上传的文件的路径
  5070. // filePath += $@"\{projectFileName}";
  5071. //}
  5072. //else if (TypeName == "B")//B代表商邀相关文件
  5073. //{
  5074. // //上传的文件的路径
  5075. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5076. // if (!Directory.Exists(filePath))
  5077. // {
  5078. // Directory.CreateDirectory(filePath);
  5079. // }
  5080. // //上传的文件的路径
  5081. // filePath = $@"\{projectFileName}";
  5082. //}
  5083. //try
  5084. //{
  5085. // using (FileStream fs = System.IO.File.Create(filePath))
  5086. // {
  5087. // file.CopyTo(fs);
  5088. // fs.Flush();
  5089. // }
  5090. //}
  5091. //catch (Exception ex)
  5092. //{
  5093. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5094. //}
  5095. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5096. try
  5097. {
  5098. var TypeName = Request.Headers["TypeName"].ToString();
  5099. if (file != null)
  5100. {
  5101. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5102. //文件名称
  5103. string projectFileName = file.FileName;
  5104. //上传的文件的路径
  5105. string filePath = $"{fileDir}/{projectFileName}";
  5106. if (TypeName == "A")//A代表团组增减款项
  5107. {
  5108. if (!Directory.Exists(fileDir))
  5109. {
  5110. Directory.CreateDirectory(fileDir);
  5111. }
  5112. //上传的文件的路径
  5113. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5114. }
  5115. else if (TypeName == "B")//B代表商邀相关文件
  5116. {
  5117. if (!Directory.Exists(fileDir))
  5118. {
  5119. Directory.CreateDirectory(fileDir);
  5120. }
  5121. //上传的文件的路径
  5122. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5123. }
  5124. using (FileStream fs = System.IO.File.Create(filePath))
  5125. {
  5126. file.CopyTo(fs);
  5127. fs.Flush();
  5128. }
  5129. return Ok(JsonView(true, "上传成功!", projectFileName));
  5130. }
  5131. else
  5132. {
  5133. return Ok(JsonView(false, "上传失败!"));
  5134. }
  5135. }
  5136. catch (Exception ex)
  5137. {
  5138. return Ok(JsonView(false, ex.Message));
  5139. }
  5140. }
  5141. /// <summary>
  5142. /// 删除指定文件
  5143. /// </summary>
  5144. /// <param name="dto"></param>
  5145. /// <returns></returns>
  5146. [HttpPost]
  5147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5148. public async Task<IActionResult> DelFile(DelFileDto dto)
  5149. {
  5150. try
  5151. {
  5152. var TypeName = Request.Headers["TypeName"].ToString();
  5153. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5154. string filePath = "";
  5155. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5156. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5157. int id = 0;
  5158. if (TypeName == "A")
  5159. {
  5160. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5161. // 删除该文件
  5162. System.IO.File.Delete(filePath);
  5163. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5164. .Where(a => a.Id == dto.Id)
  5165. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5166. .ExecuteCommandAsync();
  5167. }
  5168. else if (TypeName == "B")
  5169. {
  5170. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5171. // 删除该文件
  5172. System.IO.File.Delete(filePath);
  5173. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5174. if (info != null)
  5175. {
  5176. string[] files = Array.Empty<string>();
  5177. if (!string.IsNullOrEmpty(info.Attachment))
  5178. {
  5179. try
  5180. {
  5181. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5182. }
  5183. catch (Exception)
  5184. {
  5185. files = new List<string>() { info.Attachment }.ToArray();
  5186. }
  5187. }
  5188. if (files.Length > 0)
  5189. {
  5190. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5191. string filePath2 = string.Empty;
  5192. if (files1.Length > 0)
  5193. {
  5194. filePath2 = JsonConvert.SerializeObject(files1);
  5195. }
  5196. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5197. .Where(a => a.Id == dto.Id)
  5198. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5199. .ExecuteCommandAsync();
  5200. }
  5201. }
  5202. }
  5203. if (id != 0)
  5204. {
  5205. return Ok(JsonView(true, "成功!"));
  5206. }
  5207. else
  5208. {
  5209. return Ok(JsonView(false, "失败!"));
  5210. }
  5211. }
  5212. catch (Exception ex)
  5213. {
  5214. return Ok(JsonView(false, "程序错误!"));
  5215. throw;
  5216. }
  5217. }
  5218. /// <summary>
  5219. /// 文件上传多个文件 可以带参数
  5220. /// </summary>
  5221. /// <param name="files"></param>
  5222. /// <returns></returns>
  5223. [HttpPost]
  5224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5225. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5226. {
  5227. try
  5228. {
  5229. var TypeName = Request.Headers["TypeName"].ToString();
  5230. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5231. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5232. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5233. var filePahts = new List<string>();
  5234. foreach (var file in files)
  5235. {
  5236. //文件名称
  5237. string projectFileName = file.FileName;
  5238. //上传的文件的路径
  5239. string filePath = $"{fileDir}/{projectFileName}";
  5240. if (TypeName == "A")//A代表团组增减款项
  5241. {
  5242. if (!Directory.Exists(fileDir))
  5243. {
  5244. Directory.CreateDirectory(fileDir);
  5245. }
  5246. //上传的文件的路径
  5247. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5248. }
  5249. else if (TypeName == "B")//B代表商邀相关文件
  5250. {
  5251. if (!Directory.Exists(fileDir))
  5252. {
  5253. Directory.CreateDirectory(fileDir);
  5254. }
  5255. //上传的文件的路径
  5256. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5257. }
  5258. using (FileStream fs = System.IO.File.Create(filePath))
  5259. {
  5260. file.CopyTo(fs);
  5261. fs.Flush();
  5262. }
  5263. filePahts.Add(projectFileName);
  5264. }
  5265. return Ok(JsonView(true, "上传成功!", filePahts));
  5266. }
  5267. catch (Exception ex)
  5268. {
  5269. return Ok(JsonView(false, ex.Message));
  5270. }
  5271. }
  5272. #endregion
  5273. #region 商邀费用录入
  5274. /// <summary>
  5275. /// 根据团组Id查询商邀费用列表
  5276. /// </summary>
  5277. /// <param name="dto"></param>
  5278. /// <returns></returns>
  5279. [HttpPost]
  5280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5281. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5282. {
  5283. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5284. if (groupData.Code != 0)
  5285. {
  5286. return Ok(JsonView(false, groupData.Msg));
  5287. }
  5288. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5289. }
  5290. /// <summary>
  5291. /// 商邀费用列表
  5292. /// 下载文件
  5293. /// </summary>
  5294. /// <param name="id"></param>
  5295. /// <returns></returns>
  5296. [HttpGet("{id}")]
  5297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5298. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5299. {
  5300. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5301. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5302. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5303. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5304. var filePaths = new List<string>();
  5305. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5306. try
  5307. {
  5308. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5309. }
  5310. catch (Exception ex)
  5311. {
  5312. filePaths.Add(info.Attachment);
  5313. }
  5314. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5315. for (int i = 0; i < filePaths.Count; i++)
  5316. {
  5317. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5318. }
  5319. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5320. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5321. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5322. {
  5323. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5324. {
  5325. foreach (string filePath in filePaths)
  5326. {
  5327. if (System.IO.File.Exists(filePath))
  5328. {
  5329. // 获取文件名
  5330. string fileName = Path.GetFileName(filePath);
  5331. // 将文件添加到ZIP归档中
  5332. zipArchive.CreateEntryFromFile(filePath, fileName);
  5333. }
  5334. }
  5335. }
  5336. }
  5337. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5338. }
  5339. /// <summary>
  5340. /// 商邀费用 Info Page 基础数据源
  5341. /// </summary>
  5342. /// <returns></returns>
  5343. [HttpPost]
  5344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5345. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5346. {
  5347. try
  5348. {
  5349. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5350. if (groupData.Code != 0)
  5351. {
  5352. return Ok(JsonView(false, groupData.Msg));
  5353. }
  5354. return Ok(JsonView(true, "操作成功", groupData.Data));
  5355. }
  5356. catch (Exception ex)
  5357. {
  5358. return Ok(JsonView(false, ex.Message));
  5359. throw;
  5360. }
  5361. }
  5362. /// <summary>
  5363. /// 根据商邀费用ID查询C表和商邀费用数据
  5364. /// </summary>
  5365. /// <param name="dto"></param>
  5366. /// <returns></returns>
  5367. [HttpPost]
  5368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5369. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5370. {
  5371. try
  5372. {
  5373. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5374. if (groupData.Code != 0)
  5375. {
  5376. return Ok(JsonView(false, groupData.Msg));
  5377. }
  5378. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5379. }
  5380. catch (Exception ex)
  5381. {
  5382. return Ok(JsonView(false, ex.Message));
  5383. throw;
  5384. }
  5385. }
  5386. /// <summary>
  5387. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5388. /// </summary>
  5389. /// <param name="dto"></param>
  5390. /// <returns></returns>
  5391. [HttpPost]
  5392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5393. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5394. {
  5395. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5396. if (groupData.Code != 0)
  5397. {
  5398. return Ok(JsonView(false, groupData.Msg));
  5399. }
  5400. #region 应用推送
  5401. try
  5402. {
  5403. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5404. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5405. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5406. //2024-10-21 新增LZ UID
  5407. var userIds = new List<int>() { 21 };
  5408. string title = $"系统通知";
  5409. string content = "";
  5410. var diId = dto.DiId;
  5411. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5412. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5413. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5414. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5415. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5416. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5417. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5418. }
  5419. catch (Exception ex)
  5420. {
  5421. }
  5422. #endregion
  5423. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5424. }
  5425. /// <summary>
  5426. /// 商邀删除
  5427. /// </summary>
  5428. /// <param name="dto"></param>
  5429. /// <returns></returns>
  5430. [HttpPost]
  5431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5432. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5433. {
  5434. try
  5435. {
  5436. _sqlSugar.BeginTran();
  5437. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5438. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5439. {
  5440. IsDel = 1,
  5441. DeleteUserId = dto.DeleteUserId,
  5442. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5443. })
  5444. .Where(it => it.Id == dto.Id)
  5445. .ExecuteCommand();
  5446. if (res1 > 0)
  5447. {
  5448. int _diId = 0;
  5449. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5450. if (_ioaInfo != null)
  5451. {
  5452. _diId = _ioaInfo.DiId;
  5453. }
  5454. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5455. .SetColumns(a => new Grp_CreditCardPayment()
  5456. {
  5457. IsDel = 1,
  5458. DeleteUserId = dto.DeleteUserId,
  5459. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5460. })
  5461. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5462. .ExecuteCommand();
  5463. if (res2 > 0)
  5464. {
  5465. _sqlSugar.CommitTran();
  5466. return Ok(JsonView(true, "删除成功!"));
  5467. }
  5468. }
  5469. _sqlSugar.RollbackTran();
  5470. return Ok(JsonView(false, "删除失败"));
  5471. }
  5472. catch (Exception ex)
  5473. {
  5474. _sqlSugar.RollbackTran();
  5475. return Ok(JsonView(false, ex.Message));
  5476. }
  5477. }
  5478. #endregion
  5479. #region 票据上传
  5480. /// <summary>
  5481. /// 团组模块文件上传
  5482. /// </summary>
  5483. /// <param name="dto"></param>
  5484. /// <returns></returns>
  5485. [HttpPost]
  5486. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5487. {
  5488. var jw = JsonView(false);
  5489. long M = 1024 * 1024;
  5490. if (dto.Files == null || dto.Files.Count == 0)
  5491. {
  5492. jw.Msg = "无文件信息!";
  5493. return Ok(jw);
  5494. }
  5495. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5496. {
  5497. jw.Msg = "文件大小超过20M!";
  5498. return Ok(jw);
  5499. }
  5500. //var nameSp = dto.File.FileName.Split(".");
  5501. //if (nameSp.Length < 2)
  5502. //{
  5503. // jw.Msg = "拓展名称有误!";
  5504. // return Ok(jw);
  5505. //}
  5506. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5507. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5508. //{
  5509. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5510. // return Ok(jw);
  5511. //}
  5512. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5513. if (Ctable == null)
  5514. {
  5515. jw.Msg = "Ctable指向有误!";
  5516. return Ok(jw);
  5517. }
  5518. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5519. if (groupInfo == null)
  5520. {
  5521. jw.Msg = "团组信息不存在!";
  5522. return Ok(jw);
  5523. }
  5524. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5525. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5526. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5527. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5528. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5529. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5530. try
  5531. {
  5532. if (!Directory.Exists(fileBase))
  5533. {
  5534. Directory.CreateDirectory(fileBase);
  5535. }
  5536. var saveArr = new List<Grp_GroupModelFile>();
  5537. foreach (var fileStream in dto.Files)
  5538. {
  5539. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5540. var file = new Grp_GroupModelFile()
  5541. {
  5542. Cid = dto.Cid,
  5543. CreateTime = DateTime.Now,
  5544. CreateUserId = dto.Userid,
  5545. Ctable = dto.Ctable,
  5546. Diid = dto.Diid,
  5547. IsDel = 0,
  5548. FilePath = saveFilePath,
  5549. FileName = fileStream.FileName
  5550. };
  5551. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5552. {
  5553. fileStream.CopyTo(fs);
  5554. fs.Flush();
  5555. }
  5556. saveArr.Add(file);
  5557. }
  5558. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5559. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5560. jw = JsonView(true, "保存成功!", new
  5561. {
  5562. count = addResult,
  5563. filesName = saveArr.Select(x => x.FileName)
  5564. });
  5565. }
  5566. catch (Exception ex)
  5567. {
  5568. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5569. {
  5570. count = 0,
  5571. filesName = Array.Empty<string>(),
  5572. });
  5573. }
  5574. return Ok(jw);
  5575. }
  5576. /// <summary>
  5577. /// 查询各模块已保存文件
  5578. /// </summary>
  5579. /// <param name="dto"></param>
  5580. /// <returns></returns>
  5581. [HttpPost]
  5582. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5583. {
  5584. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5585. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5586. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5587. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5588. {
  5589. expression = Expressionable.Create<Grp_GroupModelFile>()
  5590. .And(x => visaIds.Contains(x.CreateUserId));
  5591. }
  5592. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5593. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5594. .Where(expression.ToExpression())
  5595. .ToList();
  5596. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5597. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5598. {
  5599. x.FileName,
  5600. x.Id,
  5601. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5602. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5603. })));
  5604. }
  5605. /// <summary>
  5606. /// 下载该团组下的所有文件
  5607. /// </summary>
  5608. /// <param name="dto"></param>
  5609. /// <returns></returns>
  5610. [HttpPost]
  5611. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5612. {
  5613. var jw = JsonView(false);
  5614. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5615. if (groupInfo == null)
  5616. {
  5617. jw.Msg = "团组信息不存在!";
  5618. return Ok(jw);
  5619. }
  5620. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5621. var isModule = Convert.ToBoolean(dto.isModule);
  5622. var Zips = new Dictionary<string, Stream>();
  5623. var io = new IOOperatorHelper();
  5624. if (isModule)
  5625. {
  5626. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5627. foreach (var moduleArr in moduleGroup)
  5628. {
  5629. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5630. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5631. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5632. var chiZips = new Dictionary<string, Stream>();
  5633. foreach (var item in moduleArr)
  5634. {
  5635. if (System.IO.File.Exists(item.FilePath))
  5636. {
  5637. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5638. {
  5639. byte[] bytes = new byte[fileStream.Length];
  5640. fileStream.Read(bytes, 0, bytes.Length);
  5641. fileStream.Close();
  5642. Stream stream = new MemoryStream(bytes);
  5643. chiZips.Add(item.FileName, stream);
  5644. }
  5645. }
  5646. }
  5647. if (chiZips.Count > 0)
  5648. {
  5649. var byts = io.ConvertZipStream(chiZips);
  5650. Stream stream = new MemoryStream(byts);
  5651. Zips.Add(key.Name + "_.zip", stream);
  5652. }
  5653. }
  5654. }
  5655. else
  5656. {
  5657. foreach (var item in dbQuery)
  5658. {
  5659. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5660. {
  5661. byte[] bytes = new byte[fileStream.Length];
  5662. fileStream.Read(bytes, 0, bytes.Length);
  5663. fileStream.Close();
  5664. var stream = new MemoryStream(bytes);
  5665. while (Zips.ContainsKey(item.FileName))
  5666. {
  5667. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5668. }
  5669. Zips.Add(item.FileName, stream);
  5670. }
  5671. }
  5672. }
  5673. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5674. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5675. if (Zips.Count > 0)
  5676. {
  5677. var byts = io.ConvertZipStream(Zips);
  5678. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5679. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5680. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5681. }
  5682. else
  5683. {
  5684. jw.Msg = "暂无生成文件!";
  5685. }
  5686. return Ok(jw);
  5687. }
  5688. /// <summary>
  5689. /// 下载该团组下此模块的所有文件
  5690. /// </summary>
  5691. /// <param name="dto"></param>
  5692. /// <returns></returns>
  5693. [HttpPost]
  5694. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5695. {
  5696. var jw = JsonView(false);
  5697. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5698. if (groupInfo == null)
  5699. {
  5700. jw.Msg = "团组信息不存在!";
  5701. return Ok(jw);
  5702. }
  5703. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5704. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5705. && x.IsDel == 0);
  5706. if (key == null)
  5707. {
  5708. jw.Msg = "Ctable指向错误!";
  5709. return Ok(jw);
  5710. }
  5711. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5712. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5713. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5714. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5715. var io = new IOOperatorHelper();
  5716. var Zips = new Dictionary<string, Stream>();
  5717. foreach (var item in dbQuery)
  5718. {
  5719. if (System.IO.File.Exists(item.FilePath))
  5720. {
  5721. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5722. {
  5723. byte[] bytes = new byte[fileStream.Length];
  5724. fileStream.Read(bytes, 0, bytes.Length);
  5725. fileStream.Close();
  5726. var stream = new MemoryStream(bytes);
  5727. while (Zips.ContainsKey(item.FileName))
  5728. {
  5729. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5730. }
  5731. Zips.Add(item.FileName, stream);
  5732. }
  5733. }
  5734. }
  5735. if (Zips.Count > 0)
  5736. {
  5737. var byts = io.ConvertZipStream(Zips);
  5738. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5739. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5740. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5741. }
  5742. else
  5743. {
  5744. jw.Msg = "暂无生成文件!";
  5745. }
  5746. return Ok(jw);
  5747. }
  5748. /// <summary>
  5749. /// 删除该团组下的指定文件
  5750. /// </summary>
  5751. /// <param name="dto"></param>
  5752. /// <returns></returns>
  5753. [HttpPost]
  5754. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5755. {
  5756. var jw = JsonView(false);
  5757. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5758. if (sing == null)
  5759. {
  5760. jw.Msg = "暂无";
  5761. return Ok(jw);
  5762. }
  5763. if (System.IO.File.Exists(sing.FilePath))
  5764. {
  5765. try
  5766. {
  5767. System.IO.File.Delete(sing.FilePath);
  5768. }
  5769. catch (Exception ex)
  5770. {
  5771. jw.Msg = "删除失败!" + ex.Message;
  5772. return Ok(jw);
  5773. }
  5774. }
  5775. sing.IsDel = 1;
  5776. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5777. sing.DeleteUserId = dto.UserId;
  5778. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5779. jw = JsonView(true, "删除成功!");
  5780. return Ok(jw);
  5781. }
  5782. #endregion
  5783. #region 共享文件上传
  5784. /// <summary>
  5785. /// 共享文件数据初始化
  5786. /// </summary>
  5787. /// <returns></returns>
  5788. [HttpGet]
  5789. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5790. {
  5791. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5792. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5793. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5794. .Select(x => x.Id)
  5795. .ToList()
  5796. .Contains(userid);
  5797. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5798. .Where(x => x.STid == 111 && x.IsDel == 0)
  5799. .Select(x => new
  5800. {
  5801. x.Name,
  5802. x.Id,
  5803. }).ToList();
  5804. if (isMarketingDepartment)
  5805. {
  5806. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5807. }
  5808. if (portType == 1)
  5809. {
  5810. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5811. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5812. .Where(x => x.IsDel == 0)
  5813. .OrderByDescending(x => x.VisitDate)
  5814. .Select(x => new
  5815. {
  5816. x.TeamName,
  5817. x.Id,
  5818. x.CityId,
  5819. })
  5820. .ToList()
  5821. .Select(x =>
  5822. {
  5823. var provinceId = x.CityId;
  5824. var isDefualtVal = true;
  5825. if (provinceId > 0)
  5826. {
  5827. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5828. if (parentId != null)
  5829. {
  5830. isDefualtVal = false;
  5831. provinceId = (int)parentId;
  5832. }
  5833. }
  5834. if (isDefualtVal)
  5835. {
  5836. provinceId = 122; //默认四川
  5837. }
  5838. return new
  5839. {
  5840. x.TeamName,
  5841. x.Id,
  5842. provinceId,
  5843. };
  5844. })
  5845. .ToList();
  5846. return Ok(JsonView(true, "SUCCESS!", new
  5847. {
  5848. dropDownType,
  5849. dropDownGroupList,
  5850. isMarketingDepartment
  5851. }));
  5852. }
  5853. else if (portType == 2 || portType == 3)
  5854. {
  5855. return Ok(JsonView(true, "SUCCESS!", new
  5856. {
  5857. dropDownType,
  5858. isMarketingDepartment
  5859. }));
  5860. }
  5861. else
  5862. {
  5863. return Ok(JsonView(false, "portType有误!"));
  5864. }
  5865. }
  5866. /// <summary>
  5867. /// 共享文件上传
  5868. /// </summary>
  5869. /// <param name="dto"></param>
  5870. /// <returns></returns>
  5871. [HttpPost]
  5872. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5873. {
  5874. var isGroup = new List<int> { 1412 };
  5875. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5876. {
  5877. return Ok(JsonView(false, "该文件需要关联团组!"));
  5878. }
  5879. if (dto.Files == null || dto.Files.Count == 0)
  5880. {
  5881. return Ok(JsonView(false, "无文件信息!"));
  5882. }
  5883. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5884. {
  5885. return Ok(JsonView(false, "文件大小超过20M!"));
  5886. }
  5887. if (dto.Userid < 1)
  5888. {
  5889. return Ok(JsonView(false, "请传入有效的Userid!"));
  5890. }
  5891. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5892. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5893. .Select((u, j) => new
  5894. {
  5895. u.CnName,
  5896. UserId = u.Id,
  5897. j.JobName,
  5898. })
  5899. .First();
  5900. if (jobInfo == null)
  5901. {
  5902. return Ok(JsonView(false, "请传入有效的Userid!"));
  5903. }
  5904. var commonFileExtensions = new List<string>
  5905. {
  5906. // 文本文件
  5907. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5908. // 图片文件
  5909. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5910. // 视频文件
  5911. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5912. // 音频文件
  5913. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5914. // 压缩文件
  5915. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5916. // 数据文件
  5917. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5918. };
  5919. try
  5920. {
  5921. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5922. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5923. commonFileExtensions.AddRange(settingExtend);
  5924. }
  5925. catch (Exception)
  5926. { }
  5927. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5928. if (setdata == null)
  5929. {
  5930. return Ok(JsonView(false, "请传入有效的FileType!"));
  5931. }
  5932. var insertList = new List<Grp_GroupShareFile>();
  5933. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5934. if (!Directory.Exists(winPath))
  5935. {
  5936. Directory.CreateDirectory(winPath);
  5937. }
  5938. foreach (var item in dto.Files)
  5939. {
  5940. var houzui = Path.GetExtension(item.FileName);
  5941. if (!commonFileExtensions.Contains(houzui))
  5942. {
  5943. return Ok(JsonView(false, "未知后缀名称!"));
  5944. }
  5945. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5946. var saveFilePath = winPath + fileName;
  5947. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5948. {
  5949. item.CopyTo(fs);
  5950. fs.Flush();
  5951. }
  5952. var fileDetail = new Grp_GroupShareFile()
  5953. {
  5954. CreateUserId = dto.Userid,
  5955. CreateTime = DateTime.Now,
  5956. UploadJob = jobInfo.JobName,
  5957. FileName = fileName,
  5958. FileType = dto.FileType,
  5959. Diid = dto.Diid,
  5960. FilePath = winPath + fileName,
  5961. };
  5962. insertList.Add(fileDetail);
  5963. }
  5964. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5965. return Ok(JsonView(true, "保存成功!"));
  5966. }
  5967. /// <summary>
  5968. /// 查询共享文件列表
  5969. /// </summary>
  5970. /// <param name="dto"></param>
  5971. /// <returns></returns>
  5972. [HttpPost]
  5973. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5974. {
  5975. var isGroup = new List<int> { 1412 };
  5976. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5977. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5978. .And(x => x.Diid == dto.Diid)
  5979. .And(x => x.FileType == dto.FileType)
  5980. .And(x => x.IsDel == 0)
  5981. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5982. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5983. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5984. int totalCount = 0;
  5985. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5986. .Where(queryExpression.ToExpression())
  5987. .OrderBy(x => x.UploadJob)
  5988. .Select(x => new
  5989. {
  5990. x.Id,
  5991. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5992. x.FileName,
  5993. x.FileType,
  5994. x.CreateTime,
  5995. })
  5996. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5997. return Ok(JsonView(true, "SUCCESS!", new
  5998. {
  5999. FileList = dbQuery,
  6000. dto.PageSize,
  6001. dto.PageIndex,
  6002. totalCount
  6003. }));
  6004. }
  6005. /// <summary>
  6006. /// 删除共享文件模块下的指定文件
  6007. /// </summary>
  6008. /// <param name="dto"></param>
  6009. /// <returns></returns>
  6010. [HttpPost]
  6011. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6012. {
  6013. var jw = JsonView(false);
  6014. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6015. if (sing == null)
  6016. {
  6017. jw.Msg = "暂无文件信息!";
  6018. return Ok(jw);
  6019. }
  6020. if (sing.CreateUserId != dto.UserId)
  6021. {
  6022. jw.Msg = "只能删除自己上传的文件!";
  6023. return Ok(jw);
  6024. }
  6025. if (System.IO.File.Exists(sing.FilePath))
  6026. {
  6027. try
  6028. {
  6029. System.IO.File.Delete(sing.FilePath);
  6030. }
  6031. catch (Exception ex)
  6032. {
  6033. jw.Msg = "删除失败!" + ex.Message;
  6034. return Ok(jw);
  6035. }
  6036. }
  6037. sing.IsDel = 1;
  6038. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6039. sing.DeleteUserId = dto.UserId;
  6040. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6041. jw = JsonView(true, "删除成功!");
  6042. return Ok(jw);
  6043. }
  6044. #endregion
  6045. #region 团组英文资料
  6046. /// <summary>
  6047. /// 查询团组英文所有资料
  6048. /// </summary>
  6049. /// <param name="dto"></param>
  6050. /// <returns></returns>
  6051. [HttpPost]
  6052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6053. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6054. {
  6055. try
  6056. {
  6057. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6058. if (groupData.Code != 0)
  6059. {
  6060. return Ok(JsonView(false, groupData.Msg));
  6061. }
  6062. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6063. }
  6064. catch (Exception ex)
  6065. {
  6066. return Ok(JsonView(false, ex.Message));
  6067. throw;
  6068. }
  6069. }
  6070. /// <summary>
  6071. /// 团组英文资料操作(Status:1.新增,2.修改)
  6072. /// </summary>
  6073. /// <param name="dto"></param>
  6074. /// <returns></returns>
  6075. [HttpPost]
  6076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6077. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6078. {
  6079. try
  6080. {
  6081. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6082. if (groupData.Code != 0)
  6083. {
  6084. return Ok(JsonView(false, groupData.Msg));
  6085. }
  6086. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6087. }
  6088. catch (Exception ex)
  6089. {
  6090. return Ok(JsonView(false, ex.Message));
  6091. throw;
  6092. }
  6093. }
  6094. /// <summary>
  6095. /// 团组英文资料Id查询数据
  6096. /// </summary>
  6097. /// <param name="dto"></param>
  6098. /// <returns></returns>
  6099. [HttpPost]
  6100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6101. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6102. {
  6103. try
  6104. {
  6105. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6106. if (_DelegationEnData != null)
  6107. {
  6108. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6109. }
  6110. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6111. }
  6112. catch (Exception ex)
  6113. {
  6114. return Ok(JsonView(false, "程序错误!"));
  6115. throw;
  6116. }
  6117. }
  6118. /// <summary>
  6119. /// 团组英文资料删除
  6120. /// </summary>
  6121. /// <param name="dto"></param>
  6122. /// <returns></returns>
  6123. [HttpPost]
  6124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6125. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6126. {
  6127. try
  6128. {
  6129. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6130. if (!res)
  6131. {
  6132. return Ok(JsonView(false, "删除失败"));
  6133. }
  6134. return Ok(JsonView(true, "删除成功!"));
  6135. }
  6136. catch (Exception ex)
  6137. {
  6138. return Ok(JsonView(false, ex.Message));
  6139. throw;
  6140. }
  6141. }
  6142. #endregion
  6143. #region 导出邀请函
  6144. /// <summary>
  6145. /// 导出邀请函页面初始化
  6146. /// </summary>
  6147. /// <param name="dto"></param>
  6148. /// <returns></returns>
  6149. [HttpPost]
  6150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6151. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6152. {
  6153. try
  6154. {
  6155. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6156. var crm_Deles = new List<Crm_DeleClient>();
  6157. if (dto.DiId == 0)
  6158. {
  6159. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6160. }
  6161. else
  6162. {
  6163. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6164. }
  6165. return Ok(JsonView(true, "查询成功!", new
  6166. {
  6167. deleClient = crm_Deles,
  6168. delegations = grp_Delegations
  6169. }));
  6170. }
  6171. catch (Exception ex)
  6172. {
  6173. return Ok(JsonView(false, "程序错误!"));
  6174. throw;
  6175. }
  6176. }
  6177. /// <summary>
  6178. /// 导出邀请函
  6179. /// </summary>
  6180. /// <param name="dto"></param>
  6181. /// <returns></returns>
  6182. [HttpPost]
  6183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6184. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6185. {
  6186. #region 参数验证
  6187. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6188. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6189. #endregion
  6190. try
  6191. {
  6192. var transDic = new Dictionary<string, string>();
  6193. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6194. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6195. From Grp_TourClientList tcl
  6196. Left Join
  6197. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6198. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6199. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6200. From Crm_DeleClient dc
  6201. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6202. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6203. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6204. Where dc.IsDel = 0) temp
  6205. On temp.DcId =tcl.ClientId
  6206. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6207. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6208. var texts = new List<string>();
  6209. if (datas.Count != 0)
  6210. {
  6211. foreach (TourClientListDetailsView item in datas)
  6212. {
  6213. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6214. {
  6215. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6216. }
  6217. else
  6218. {
  6219. string name = item.LastName + item.FirstName;
  6220. texts.Add(name);
  6221. }
  6222. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6223. {
  6224. if (!transDic.ContainsKey(item.Job))
  6225. {
  6226. texts.Add(item.Job);
  6227. }
  6228. }
  6229. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6230. {
  6231. texts.Add(item.CompanyFullName);
  6232. }
  6233. }
  6234. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6235. if (transData.Count > 0)
  6236. {
  6237. foreach (TranslateResult item in transData)
  6238. {
  6239. if (!transDic.ContainsKey(item.Query))
  6240. {
  6241. transDic.Add(item.Query, item.Translation);
  6242. }
  6243. }
  6244. }
  6245. var list = new List<GuestList>();
  6246. foreach (var dele in datas)
  6247. {
  6248. var guestList = new GuestList();
  6249. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6250. {
  6251. guestList.Name = dele.Pinyin;
  6252. }
  6253. else
  6254. {
  6255. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6256. guestList.Name = Name;
  6257. }
  6258. if (dele.Sex == 0)
  6259. {
  6260. guestList.Sex = "Male";
  6261. }
  6262. else if (dele.Sex == 1)
  6263. {
  6264. guestList.Sex = "Female";
  6265. }
  6266. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6267. if (!string.IsNullOrEmpty(dele.Job))
  6268. {
  6269. guestList.Job = dele.Job;
  6270. }
  6271. list.Add(guestList);
  6272. }
  6273. //载入模板
  6274. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6275. var builder = new DocumentBuilder(doc);
  6276. //获取word里所有表格
  6277. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6278. //获取所填表格的序数
  6279. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6280. var rowStart = tableOne.Rows[0]; //获取第1行
  6281. //循环赋值
  6282. for (int i = 0; i < list.Count; i++)
  6283. {
  6284. builder.MoveToCell(0, i + 1, 0, 0);
  6285. builder.Write(list[i].Name.ToString());
  6286. builder.MoveToCell(0, i + 1, 1, 0);
  6287. builder.Write(list[i].Sex.ToString());
  6288. builder.MoveToCell(0, i + 1, 2, 0);
  6289. builder.Write(list[i].DOB.ToString());
  6290. builder.MoveToCell(0, i + 1, 3, 0);
  6291. builder.Write(list[i].Job.ToString());
  6292. }
  6293. //删除多余行
  6294. while (tableOne.Rows.Count > list.Count + 1)
  6295. {
  6296. tableOne.Rows.RemoveAt(list.Count + 1);
  6297. }
  6298. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6299. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6300. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6301. doc.Save(filePath);
  6302. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6303. return Ok(JsonView(true, "操作成功!", Url));
  6304. }
  6305. else
  6306. {
  6307. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6308. }
  6309. }
  6310. catch (Exception ex)
  6311. {
  6312. return Ok(JsonView(false, ex.Message));
  6313. throw;
  6314. }
  6315. }
  6316. #endregion
  6317. #region 团组经理模块 出入境费用
  6318. /// <summary>
  6319. /// 团组模块 - 出入境费用 - 省份基础数据源
  6320. /// </summary>
  6321. /// <returns></returns>
  6322. [HttpGet]
  6323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6324. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6325. {
  6326. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6327. }
  6328. /// <summary>
  6329. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6330. /// </summary>
  6331. /// <param name="dto"></param>
  6332. /// <returns></returns>
  6333. [HttpPost]
  6334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6335. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6336. {
  6337. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6338. var groupNamFirst = groupNameData.FirstOrDefault();
  6339. //SetDataInfoView
  6340. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6341. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6342. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6343. //验证城市归属并给默认值
  6344. int provinceId = 122;
  6345. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6346. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6347. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6348. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6349. return Ok(JsonView(true, "查询成功!", new
  6350. {
  6351. GroupNameData = groupNameData,
  6352. CurrencyData = _CurrencyData,
  6353. WordTypeData = wordTypeData,
  6354. ExcelTypeData = excelTypeData,
  6355. CurrencyInit = _currencyInfos,
  6356. ViewPermissionData = viewPermissionData
  6357. }));
  6358. }
  6359. /// <summary>
  6360. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6361. /// </summary>
  6362. /// <returns></returns>
  6363. [HttpGet("{provinceId}")]
  6364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6365. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6366. {
  6367. //验证城市归属并给默认值
  6368. if (provinceId < 1) provinceId = 122;
  6369. /*
  6370. * 122 四川
  6371. * 108 贵州
  6372. * 103 重庆
  6373. * 132 云南
  6374. */
  6375. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6376. return Ok(JsonView(true, "查询成功!", new
  6377. {
  6378. WordTypeData = wordTypeData,
  6379. ExcelTypeData = excelTypeData,
  6380. }));
  6381. }
  6382. /// <summary>
  6383. /// 团组模块 - 出入境费用
  6384. /// 实时汇率 tips
  6385. /// 签证费用 tips
  6386. /// 机票费用 tips
  6387. /// </summary>
  6388. /// <returns></returns>
  6389. [HttpPost]
  6390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6391. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6392. {
  6393. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6394. //默认币种显示
  6395. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6396. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6397. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6398. return Ok(JsonView(true, "查询成功!", new
  6399. {
  6400. //GroupNameData = groupNameData.Data,
  6401. visaData = visaData.Data,
  6402. airData,
  6403. reteInfos
  6404. }));
  6405. }
  6406. /// <summary>
  6407. /// 团组模块 - 出入境费用 - Info
  6408. /// </summary>
  6409. /// <param name="dto"></param>
  6410. /// <returns></returns>
  6411. [HttpPost]
  6412. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6414. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6415. {
  6416. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6417. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6418. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6419. }
  6420. /// <summary>
  6421. /// 团组模块 - 出入境费用 - 设置view权限
  6422. /// </summary>
  6423. /// <returns></returns>
  6424. [HttpPost]
  6425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6426. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6427. {
  6428. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6429. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6430. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6431. var permissions = new List<Grp_EnterExitCostPermission>();
  6432. foreach (var userId in dto.UserIds)
  6433. {
  6434. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6435. }
  6436. if (permissions.Any())
  6437. {
  6438. _sqlSugar.BeginTran();
  6439. try
  6440. {
  6441. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6442. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6443. if (result < 1)
  6444. {
  6445. _sqlSugar.RollbackTran();
  6446. return Ok(JsonView(false));
  6447. }
  6448. }
  6449. catch (Exception ex)
  6450. {
  6451. _sqlSugar.RollbackTran();
  6452. return Ok(JsonView(false, ex.Message));
  6453. }
  6454. _sqlSugar.CommitTran();
  6455. return Ok(JsonView(true));
  6456. }
  6457. return Ok(JsonView(false));
  6458. }
  6459. /// <summary>
  6460. /// 团组模块 - 出入境费用 - Add And Update
  6461. /// </summary>
  6462. /// <returns></returns>
  6463. [HttpPost]
  6464. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6466. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6467. {
  6468. try
  6469. {
  6470. var rateRecords = new List<RateRecordInfo>();
  6471. #region 汇率保存前存储
  6472. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  6473. if (info != null)
  6474. {
  6475. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  6476. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  6477. {
  6478. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  6479. {
  6480. CurrencyCode = x.CurrencyCode,
  6481. CurrencyName = x.CurrencyName,
  6482. UpdatePreRate = x.Rate,
  6483. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  6484. }).ToList();
  6485. }
  6486. else
  6487. {
  6488. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6489. {
  6490. CurrencyCode = x.CurrencyCode,
  6491. CurrencyName = x.CurrencyName,
  6492. UpdatePreRate = 0.00M,
  6493. UpdateBreRate = x.Rate
  6494. }).ToList();
  6495. }
  6496. }
  6497. else
  6498. {
  6499. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6500. {
  6501. CurrencyCode = x.CurrencyCode,
  6502. CurrencyName = x.CurrencyName,
  6503. UpdatePreRate = 0.00M,
  6504. UpdateBreRate = x.Rate
  6505. }).ToList();
  6506. }
  6507. #endregion
  6508. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6509. if (dto.DayOtherPriceData.Any())
  6510. {
  6511. var inserList = dto.DayOtherPriceData
  6512. .Where(x => x.Id == 0)
  6513. .Select(x => new Grp_DayOtherPrice
  6514. {
  6515. Cost = x.Cost,
  6516. Id = x.Id,
  6517. CreateTime = DateTime.Now,
  6518. CreateUserId = dto.UserId,
  6519. Currency = x.Currency,
  6520. Diid = x.DiId,
  6521. Index = x.Index,
  6522. IsDel = 0,
  6523. SetDataId = x.SetDataId,
  6524. SubTotal = x.SubTotal,
  6525. Remark = x.Remark
  6526. })
  6527. .ToList();
  6528. var updateList = dto.DayOtherPriceData
  6529. .Where(x => x.Id != 0)
  6530. .Select(x => new Grp_DayOtherPrice
  6531. {
  6532. Cost = x.Cost,
  6533. Id = x.Id,
  6534. CreateTime = DateTime.Now,
  6535. CreateUserId = dto.UserId,
  6536. Currency = x.Currency,
  6537. Diid = x.DiId,
  6538. Index = x.Index,
  6539. IsDel = 0,
  6540. SetDataId = x.SetDataId,
  6541. SubTotal = x.SubTotal,
  6542. Remark = x.Remark
  6543. })
  6544. .ToList();
  6545. //添加
  6546. _sqlSugar.BeginTran();
  6547. if (inserList.Any())
  6548. {
  6549. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6550. }
  6551. if (updateList.Any())
  6552. {
  6553. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6554. }
  6555. _sqlSugar.CommitTran();
  6556. }
  6557. if (data.Code != 0)
  6558. {
  6559. return Ok(JsonView(false, data.Msg));
  6560. }
  6561. //生成默认文件pdf并且通知人员
  6562. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6563. {
  6564. DiId = dto.DiId,
  6565. ExportType = 1,
  6566. SubTypeId = 1005
  6567. }, "pdf");
  6568. //发送通知
  6569. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6570. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6571. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6572. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6573. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6574. //汇率信息记录
  6575. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6576. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  6577. //汇率验证、反推
  6578. (bool isSendMsg,string msgContent,List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  6579. if (isSendMsg)
  6580. {
  6581. //消息推送
  6582. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId,dto.UserId,msgContent);
  6583. }
  6584. #region //日志汇率记录
  6585. //按照已使用币种记录
  6586. if (checkCurrencys != null && checkCurrencys.Count > 0)
  6587. {
  6588. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  6589. //汇率记录中加入实时汇率
  6590. if (liveRates != null && liveRates.Count > 0)
  6591. {
  6592. foreach (var item in rateRecords)
  6593. {
  6594. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  6595. }
  6596. }
  6597. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  6598. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  6599. var logContent = new StringBuilder();
  6600. foreach (var item in rateRecords)
  6601. {
  6602. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  6603. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  6604. logContent.AppendLine(msg);
  6605. }
  6606. _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());
  6607. }
  6608. #endregion
  6609. return Ok(JsonView(true, data.Msg, data.Data));
  6610. }
  6611. catch (Exception ex)
  6612. {
  6613. return Ok(JsonView(false, ex.Message));
  6614. }
  6615. }
  6616. /// <summary>
  6617. /// 团组模块 - 出入境费用 - Confirm 费用
  6618. /// </summary>
  6619. /// <returns></returns>
  6620. [HttpPost]
  6621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6622. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6623. {
  6624. //TODO:测试完毕需把对应的用户ID更改
  6625. //1、数据表添加字段
  6626. //2、更改字段接口()
  6627. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6628. //3、确认成功 给财务发送消息
  6629. if (_view.Code == 200)
  6630. {
  6631. if (dto.Type == 1)
  6632. {
  6633. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6634. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6635. }
  6636. }
  6637. return Ok(_view);
  6638. }
  6639. /// <summary>
  6640. /// 团组模块 - 出入境费用 - File download
  6641. /// </summary>
  6642. /// <param name="dto"></param>
  6643. /// <returns></returns>
  6644. [HttpPost]
  6645. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6647. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6648. {
  6649. try
  6650. {
  6651. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6652. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6653. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6654. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6655. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6656. 3 团组成员名单 1 团组成员名单", ""));
  6657. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6658. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6659. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6660. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6661. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6662. //数据源
  6663. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6664. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6665. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6666. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6667. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6668. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6669. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6670. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6671. .Select((x, a, b) => new
  6672. {
  6673. x.Index,
  6674. itemName = a.Name,
  6675. CurrencyStr = b.Name,
  6676. x.Cost,
  6677. x.SubTotal,
  6678. x.Remark
  6679. })
  6680. .OrderBy((x) => x.Index)
  6681. .ToList(); //其他款项费用
  6682. var peiceItemCurrencys = new List<string>();
  6683. if (_DayAndCosts.Any())
  6684. {
  6685. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6686. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6687. }
  6688. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6689. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6690. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6691. {
  6692. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6693. }
  6694. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6695. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6696. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6697. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6698. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6699. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6700. .Select((tcl, dc, cc) => new ClientInfo
  6701. {
  6702. LastName = dc.LastName,
  6703. FirstName = dc.FirstName,
  6704. Sex = dc.Sex,
  6705. Birthday = dc.BirthDay,
  6706. Company = cc.CompanyFullName,
  6707. Job = dc.Job
  6708. })
  6709. .ToList();
  6710. foreach (var item in DeleClientList)
  6711. {
  6712. EncryptionProcessor.DecryptProperties(item);
  6713. }
  6714. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6715. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6716. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6717. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6718. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6719. if (dto.ExportType == 1) //明细表
  6720. {
  6721. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6722. {
  6723. //获取模板
  6724. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6725. //载入模板
  6726. var doc = new Document(tempPath);
  6727. var builder = new DocumentBuilder(doc);
  6728. var dic = new Dictionary<string, string>();
  6729. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6730. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6731. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6732. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6733. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6734. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6735. //境内费用(其他费用)
  6736. if (_EnterExitCosts.ChoiceOne == 1)
  6737. {
  6738. string row1_1 = "";
  6739. if (_EnterExitCosts.Visa > 0)
  6740. {
  6741. //insidePayTotal += _EnterExitCosts.Visa;
  6742. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 人民币/人";
  6743. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6744. //{
  6745. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6746. //}
  6747. }
  6748. string row1_2 = "";
  6749. if (_EnterExitCosts.YiMiao > 0)
  6750. {
  6751. //insidePayTotal += _EnterExitCosts.YiMiao;
  6752. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 人民币/人";
  6753. }
  6754. if (_EnterExitCosts.HeSuan > 0)
  6755. {
  6756. //insidePayTotal += _EnterExitCosts.HeSuan;
  6757. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 人民币/人";
  6758. }
  6759. if (_EnterExitCosts.Service > 0)
  6760. {
  6761. //insidePayTotal += _EnterExitCosts.Service;
  6762. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 人民币/人";
  6763. }
  6764. string row1_3 = "";
  6765. if (_EnterExitCosts.Safe > 0)
  6766. {
  6767. //insidePayTotal += _EnterExitCosts.Safe;
  6768. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 人民币/人";
  6769. }
  6770. if (_EnterExitCosts.Ticket > 0)
  6771. {
  6772. //insidePayTotal += _EnterExitCosts.Ticket;
  6773. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 人民币/人";
  6774. }
  6775. string row1 = "";
  6776. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6777. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6778. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6779. row1 += $"备注:{_EnterExitCosts.Remark}";
  6780. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6781. dic.Add("Row1Str", row1);
  6782. }
  6783. string airTotalStr = string.Empty,
  6784. airPriceStr = string.Empty;
  6785. //经济舱
  6786. if (_EnterExitCosts.SumJJC == 1)
  6787. {
  6788. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6789. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6790. }
  6791. //公务舱
  6792. if (_EnterExitCosts.SumGWC == 1)
  6793. {
  6794. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6795. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6796. }
  6797. //头等舱
  6798. if (_EnterExitCosts.SumTDC == 1)
  6799. {
  6800. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6801. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6802. }
  6803. //汇率描述
  6804. string rateStr = "";
  6805. if (peiceItemCurrencyInfos.Any())
  6806. {
  6807. rateStr = "\r\n汇率描述:";
  6808. foreach (var item in peiceItemCurrencyInfos)
  6809. {
  6810. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  6811. }
  6812. }
  6813. string twoItemRemark = "备注:";
  6814. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6815. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6816. dic.Add("AirTotalStr", airTotalStr);
  6817. dic.Add("AirPriceStr", airPriceStr);
  6818. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6819. dic.Add("TwoItemRemark", twoItemRemark);
  6820. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6821. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6822. int table1Row = 0,
  6823. table2Row = 0,
  6824. table3Row = 0,
  6825. table4Row = 0,
  6826. table5Row = 0;
  6827. //住宿费
  6828. if (_EnterExitCosts.ChoiceThree == 1)
  6829. {
  6830. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6831. table1Row = dac1.Count;
  6832. #region 填充word表格内容
  6833. for (int i = 0; i < dac1.Count; i++)
  6834. {
  6835. Grp_DayAndCost dac = dac1[i];
  6836. if (dac == null) continue;
  6837. builder.MoveToCell(0, i, 0, 0);
  6838. builder.Write("第" + dac.Days.ToString() + "晚:");
  6839. builder.MoveToCell(0, i, 1, 0);
  6840. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6841. //builder.Write(dac.Place == null ? "" : dac.Place);
  6842. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6843. builder.MoveToCell(0, i, 2, 0);
  6844. builder.Write("费用标准:");
  6845. string curr = "";
  6846. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6847. if (currData != null)
  6848. {
  6849. curr = currData.Name;
  6850. }
  6851. builder.MoveToCell(0, i, 3, 0);
  6852. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6853. builder.MoveToCell(0, i, 4, 0);
  6854. builder.Write("费用小计:");
  6855. builder.MoveToCell(0, i, 5, 0);
  6856. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6857. }
  6858. #endregion
  6859. }
  6860. else dic.Add("SubZS", "0.00");
  6861. //删除多余行
  6862. while (table1.Rows.Count > table1Row)
  6863. {
  6864. table1.Rows.RemoveAt(table1Row);
  6865. }
  6866. //伙食费
  6867. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6868. if (_EnterExitCosts.ChoiceFour == 1)
  6869. {
  6870. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6871. table2Row = dac2.Count;
  6872. #region 填充word表格内容
  6873. for (int i = 0; i < dac2.Count; i++)
  6874. {
  6875. Grp_DayAndCost dac = dac2[i];
  6876. if (dac == null) continue;
  6877. builder.MoveToCell(1, i, 0, 0);
  6878. builder.Write("第" + dac.Days.ToString() + "天:");
  6879. builder.MoveToCell(1, i, 1, 0);
  6880. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6881. builder.MoveToCell(1, i, 2, 0);
  6882. builder.Write("费用标准:");
  6883. string curr = "";
  6884. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6885. if (currData != null)
  6886. {
  6887. curr = currData.Name;
  6888. }
  6889. builder.MoveToCell(1, i, 3, 0);
  6890. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6891. builder.MoveToCell(1, i, 4, 0);
  6892. builder.Write("费用小计:");
  6893. builder.MoveToCell(1, i, 5, 0);
  6894. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6895. }
  6896. #endregion
  6897. }
  6898. else dic.Add("SubHS", "0.00");
  6899. //删除多余行
  6900. while (table2.Rows.Count > table2Row)
  6901. {
  6902. table2.Rows.RemoveAt(table2Row);
  6903. }
  6904. //公杂费
  6905. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6906. if (_EnterExitCosts.ChoiceFive == 1)
  6907. {
  6908. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6909. table3Row = dac3.Count;
  6910. #region 填充word表格内容
  6911. for (int i = 0; i < dac3.Count; i++)
  6912. {
  6913. Grp_DayAndCost dac = dac3[i];
  6914. if (dac == null) continue;
  6915. builder.MoveToCell(2, i, 0, 0);
  6916. builder.Write("第" + dac.Days.ToString() + "天:");
  6917. builder.MoveToCell(2, i, 1, 0);
  6918. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6919. builder.MoveToCell(2, i, 2, 0);
  6920. builder.Write("费用标准:");
  6921. string curr = "";
  6922. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6923. if (currData != null)
  6924. {
  6925. curr = currData.Name;
  6926. }
  6927. builder.MoveToCell(2, i, 3, 0);
  6928. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6929. builder.MoveToCell(2, i, 4, 0);
  6930. builder.Write("费用小计:");
  6931. builder.MoveToCell(2, i, 5, 0);
  6932. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6933. }
  6934. //删除多余行
  6935. while (table3.Rows.Count > table3Row)
  6936. {
  6937. table3.Rows.RemoveAt(table3Row);
  6938. }
  6939. #endregion
  6940. }
  6941. else dic.Add("SubGZF", "0.00");
  6942. //删除多余行
  6943. while (table3.Rows.Count > table3Row)
  6944. {
  6945. table3.Rows.RemoveAt(table3Row);
  6946. }
  6947. //培训费
  6948. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6949. if (_EnterExitCosts.ChoiceSix == 1)
  6950. {
  6951. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  6952. dic.Add("SubPX", pxStr);
  6953. table4Row = dac4.Count;
  6954. #region 填充word表格内容
  6955. for (int i = 0; i < dac4.Count; i++)
  6956. {
  6957. Grp_DayAndCost dac = dac4[i];
  6958. if (dac == null) continue;
  6959. builder.MoveToCell(3, i, 0, 0);
  6960. builder.Write("第" + dac.Days.ToString() + "天:");
  6961. builder.MoveToCell(3, i, 1, 0);
  6962. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6963. builder.MoveToCell(3, i, 2, 0);
  6964. builder.Write("费用标准:");
  6965. string curr = "";
  6966. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6967. if (currData != null)
  6968. {
  6969. curr = currData.Name;
  6970. }
  6971. builder.MoveToCell(3, i, 3, 0);
  6972. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6973. builder.MoveToCell(3, i, 4, 0);
  6974. builder.Write("费用小计:");
  6975. builder.MoveToCell(3, i, 5, 0);
  6976. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6977. }
  6978. #endregion
  6979. }
  6980. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6981. //删除多余行
  6982. while (table4.Rows.Count > table4Row)
  6983. {
  6984. table4.Rows.RemoveAt(table4Row);
  6985. }
  6986. //其他费用
  6987. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6988. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6989. {
  6990. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  6991. dic.Add("titleQi", qtStr);
  6992. table5Row = dac5.Count;
  6993. #region 填充word表格内容
  6994. for (int i = 0; i < dac5.Count; i++)
  6995. {
  6996. var dac = dac5[i];
  6997. if (dac == null) continue;
  6998. builder.MoveToCell(4, i, 0, 0);
  6999. builder.Write("第" + dac.Index.ToString() + "项:");
  7000. builder.MoveToCell(4, i, 1, 0);
  7001. builder.Write(dac.itemName);
  7002. builder.MoveToCell(4, i, 2, 0);
  7003. builder.Write("费用标准:");
  7004. builder.MoveToCell(4, i, 3, 0);
  7005. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7006. builder.MoveToCell(4, i, 4, 0);
  7007. builder.Write("费用小计:");
  7008. builder.MoveToCell(4, i, 5, 0);
  7009. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7010. builder.MoveToCell(4, i, 6, 0);
  7011. builder.Write("备注:");
  7012. builder.MoveToCell(4, i, 7, 0);
  7013. builder.Write(dac.Remark);
  7014. }
  7015. #endregion
  7016. }
  7017. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7018. //删除多余行
  7019. while (table5.Rows.Count > table5Row)
  7020. {
  7021. table5.Rows.RemoveAt(table5Row);
  7022. }
  7023. //加上其他费用
  7024. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7025. decimal subJJC = 0.00M,
  7026. subGWC = 0.00M,
  7027. subTDC = 0.00M;
  7028. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7029. string totalLabel = string.Format("全部费用总计:");
  7030. //经济舱
  7031. if (_EnterExitCosts.SumJJC == 1)
  7032. {
  7033. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7034. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7035. }
  7036. //公务舱
  7037. if (_EnterExitCosts.SumGWC == 1)
  7038. {
  7039. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7040. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7041. }
  7042. //头等舱
  7043. if (_EnterExitCosts.SumTDC == 1)
  7044. {
  7045. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7046. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7047. }
  7048. //TotalLabel
  7049. dic.Add("TotalLabel", totalLabel);
  7050. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7051. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7052. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7053. #region 填充word模板书签内容
  7054. foreach (var key in dic.Keys)
  7055. {
  7056. Bookmark bookmark = doc.Range.Bookmarks[key];
  7057. if (bookmark != null)
  7058. {
  7059. builder.MoveToBookmark(key);
  7060. builder.Write(dic[key]);
  7061. }
  7062. }
  7063. #endregion
  7064. #region 设置页眉
  7065. string userLabel = string.Empty;
  7066. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7067. if (currUserInfo != null)
  7068. {
  7069. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7070. if (userInfo != null)
  7071. {
  7072. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7073. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7074. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7075. }
  7076. }
  7077. //设置页脚
  7078. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7079. #endregion
  7080. //文件名
  7081. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  7082. AsposeHelper.removewatermark_v2180();
  7083. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7084. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7085. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7086. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7087. }
  7088. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7089. {
  7090. //获取模板
  7091. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7092. //载入模板
  7093. var doc = new Document(tempPath);
  7094. var builder = new DocumentBuilder(doc);
  7095. var dic = new Dictionary<string, string>();
  7096. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7097. {
  7098. var list = new List<string>();
  7099. try
  7100. {
  7101. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7102. foreach (var item in spilitArr)
  7103. {
  7104. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7105. var depCode = spDotandEmpty[2].Substring(0, 3);
  7106. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7107. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7108. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7109. list.Add(depName);
  7110. list.Add(arrName);
  7111. }
  7112. list = list.Distinct().ToList();
  7113. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7114. }
  7115. catch (Exception)
  7116. {
  7117. dic.Add("ReturnCode", "行程录入不正确!");
  7118. }
  7119. }
  7120. else
  7121. {
  7122. dic.Add("ReturnCode", "未录入行程!");
  7123. }
  7124. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7125. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7126. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7127. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7128. {
  7129. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7130. dic.Add("Day", sp.Days.ToString());
  7131. }
  7132. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7133. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7134. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7135. //dic.Add("Names", Names);
  7136. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7137. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7138. decimal dac1totalPrice = 0.00M;
  7139. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7140. foreach (var dac in dac1)
  7141. {
  7142. if (dac.SubTotal == 0.00M)
  7143. {
  7144. continue;
  7145. }
  7146. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7147. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7148. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7149. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7150. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7151. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7152. builder.Write(currency);//币种
  7153. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7154. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7155. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7156. builder.Write("");//人数
  7157. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7158. builder.Write("");//天数
  7159. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7160. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7161. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7162. decimal rate = 0.00M;
  7163. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7164. builder.Write(rate.ToString("#0.0000"));//汇率
  7165. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7166. decimal rbmPrice = dac.SubTotal;
  7167. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7168. accommodationStartIndex++;
  7169. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7170. }
  7171. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7172. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7173. {
  7174. table1.Rows.RemoveAt(i - 1);
  7175. foodandotherStartIndex--;
  7176. }
  7177. if (dac2.Count == dac3.Count)//国家 币种 金额
  7178. {
  7179. for (int i = 0; i < dac2.Count; i++)
  7180. {
  7181. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7182. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7183. }
  7184. }
  7185. decimal dac2totalPrice = 0.00M;
  7186. foreach (var dac in dac2)
  7187. {
  7188. if (dac.SubTotal == 0)
  7189. {
  7190. continue;
  7191. }
  7192. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7193. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7194. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7195. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7196. builder.Write(currency);//币种
  7197. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7198. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7199. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7200. builder.Write("");//人数
  7201. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7202. builder.Write("");//天数
  7203. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7204. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7205. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7206. decimal rate = 0.00M;
  7207. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7208. builder.Write(rate.ToString("#0.0000"));//汇率
  7209. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7210. decimal rbmPrice = dac.SubTotal;
  7211. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7212. foodandotherStartIndex++;
  7213. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7214. }
  7215. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7216. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7217. {
  7218. table1.Rows.RemoveAt(i - 1);
  7219. }
  7220. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7221. string otherFeeStr = "";
  7222. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7223. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7224. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7225. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7226. foreach (var otherInfo in dac5)
  7227. {
  7228. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7229. }
  7230. #endregion
  7231. if (otherFeeStr.Length > 0)
  7232. {
  7233. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7234. otherFeeStr = $"({otherFeeStr})";
  7235. dic.Add("OtherFeeStr", otherFeeStr);
  7236. }
  7237. //总计
  7238. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7239. //国际旅费
  7240. string outsideAir = string.Empty;
  7241. string allPriceAir = string.Empty;
  7242. if (_EnterExitCosts.SumJJC == 1)
  7243. {
  7244. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7245. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7246. }
  7247. if (_EnterExitCosts.SumGWC == 1)
  7248. {
  7249. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7250. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7251. }
  7252. if (_EnterExitCosts.SumTDC == 1)
  7253. {
  7254. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7255. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7256. }
  7257. dic.Add("InTravelPrice", $"({outsideAir})");
  7258. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7259. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7260. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7261. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7262. foreach (var key in dic.Keys)
  7263. {
  7264. builder.MoveToBookmark(key);
  7265. builder.Write(dic[key]);
  7266. }
  7267. //模板文件名
  7268. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7269. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7270. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7271. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7272. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7273. }
  7274. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7275. {
  7276. //获取模板
  7277. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7278. //载入模板
  7279. var designer = new WorkbookDesigner
  7280. {
  7281. Workbook = new Workbook(tempPath)
  7282. };
  7283. var dic = new Dictionary<string, string>();
  7284. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7285. {
  7286. var list = new List<string>();
  7287. try
  7288. {
  7289. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7290. foreach (var item in spilitArr)
  7291. {
  7292. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7293. var depCode = spDotandEmpty[2].Substring(0, 3);
  7294. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7295. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7296. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7297. list.Add(depName);
  7298. list.Add(arrName);
  7299. }
  7300. list = list.Distinct().ToList();
  7301. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7302. }
  7303. catch (Exception)
  7304. {
  7305. dic.Add("ReturnCode", "行程录入不正确!");
  7306. }
  7307. }
  7308. else
  7309. {
  7310. dic.Add("ReturnCode", "未录入行程!");
  7311. }
  7312. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7313. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7314. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7315. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7316. {
  7317. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7318. dic.Add("Day", sp.Days.ToString());
  7319. }
  7320. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7321. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7322. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7323. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7324. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7325. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7326. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7327. designer.SetDataSource("Name", Names);
  7328. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7329. designer.SetDataSource("Day", dic["Day"] + "天");
  7330. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7331. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7332. int startIndex = 10;
  7333. const int startIndexcopy = 10;
  7334. if (dac2.Count == dac3.Count)//国家 币种 金额
  7335. {
  7336. for (int i = 0; i < dac2.Count; i++)
  7337. {
  7338. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7339. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7340. }
  7341. }
  7342. var dtdac1 = new DataTable();
  7343. var place = new List<string>();
  7344. dtdac1.Columns.AddRange(new DataColumn[] {
  7345. new(){ ColumnName = "city"},
  7346. new(){ ColumnName = "curr"},
  7347. new(){ ColumnName = "criterion"},
  7348. new(){ ColumnName = "number",DataType = typeof(int)},
  7349. new(){ ColumnName = "day",DataType = typeof(int)},
  7350. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7351. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7352. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7353. });
  7354. var dtdac2 = new DataTable();
  7355. dtdac2.Columns.AddRange(new DataColumn[] {
  7356. new(){ ColumnName = "city"},
  7357. new(){ ColumnName = "curr"},
  7358. new(){ ColumnName = "criterion"},
  7359. new(){ ColumnName = "number",DataType = typeof(int)},
  7360. new(){ ColumnName = "day",DataType = typeof(int)},
  7361. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7362. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7363. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7364. });
  7365. dtdac1.TableName = "tb1";
  7366. dtdac2.TableName = "tb2";
  7367. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7368. foreach (var item in dac1)
  7369. {
  7370. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7371. if (place.Contains(item.Place))
  7372. {
  7373. continue;
  7374. }
  7375. DataRow row = dtdac1.NewRow();
  7376. row["city"] = item.Place;
  7377. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7378. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7379. row["curr"] = currency;
  7380. row["rate"] = rate.ToString("#0.0000");
  7381. row["criterion"] = item.Cost.ToString("#0.00");
  7382. row["number"] = 1;
  7383. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7384. //row["costRMB"] = rbmPrice;
  7385. dtdac1.Rows.Add(row);
  7386. place.Add(item.Place);
  7387. }
  7388. place = new List<string>();
  7389. foreach (var item in dac2)
  7390. {
  7391. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7392. if (place.Contains(item.Place))
  7393. {
  7394. continue;
  7395. }
  7396. DataRow row = dtdac2.NewRow();
  7397. row["city"] = item.Place;
  7398. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7399. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7400. row["curr"] = currency;
  7401. row["rate"] = rate.ToString("#0.0000");
  7402. row["criterion"] = item.Cost.ToString("#0.00");
  7403. row["number"] = 1;
  7404. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7405. //row["cost"] = item.SubTotal;
  7406. //row["costRMB"] = rbmPrice;
  7407. dtdac2.Rows.Add(row);
  7408. place.Add(item.Place);
  7409. //dac2totalPrice += rbmPrice;
  7410. }
  7411. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7412. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7413. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7414. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7415. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7416. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7417. string cell4Str1 = string.Empty;
  7418. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7419. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7420. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7421. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7422. string cellStr = $" 5.其他费用(";
  7423. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7424. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7425. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7426. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7427. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7428. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7429. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7430. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7431. foreach (var otherInfo in dac5)
  7432. {
  7433. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7434. }
  7435. #endregion
  7436. if (cellStr.Length > 8)
  7437. {
  7438. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7439. }
  7440. cellStr += ")";
  7441. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7442. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7443. decimal pxFee = dac4.Sum(it => it.Cost);
  7444. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7445. string celllastStr1 = "";
  7446. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7447. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7448. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7449. celllastStr1 += $",国际旅费 元";
  7450. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7451. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7452. designer.SetDataSource("cell4Str", cell4Str);
  7453. designer.SetDataSource("cellStr", cellStr);
  7454. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7455. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7456. designer.SetDataSource("celllastStr", celllastStr);
  7457. Workbook wb = designer.Workbook;
  7458. var sheet = wb.Worksheets[0];
  7459. //绑定datatable数据集
  7460. designer.SetDataSource(dtdac1);
  7461. designer.SetDataSource(dtdac2);
  7462. designer.Process();
  7463. var rowStart = dtdac1.Rows.Count;
  7464. while (rowStart > 0)
  7465. {
  7466. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7467. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7468. startIndex++;
  7469. rowStart--;
  7470. }
  7471. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7472. startIndex += 1; //总计行
  7473. rowStart = dtdac2.Rows.Count;
  7474. while (rowStart > 0)
  7475. {
  7476. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7477. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7478. startIndex++;
  7479. rowStart--;
  7480. }
  7481. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7482. wb.CalculateFormula(true);
  7483. //模板文件名
  7484. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7485. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7486. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7487. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7488. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7489. }
  7490. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7491. {
  7492. //获取模板
  7493. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7494. //载入模板
  7495. var doc = new Document(tempPath);
  7496. var builder = new DocumentBuilder(doc);
  7497. var dic = new Dictionary<string, string>
  7498. {
  7499. { "GroupName", _DelegationInfo.TeamName },
  7500. { "ClientUnit", _DelegationInfo.ClientUnit }
  7501. };
  7502. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7503. string missionLeaderJob = "";//负责人job
  7504. //int groupNumber = 0; //团人数
  7505. if (DeleClientList.Count > 0)
  7506. {
  7507. missionLeader = DeleClientList[0]?.Name ?? "";
  7508. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7509. }
  7510. dic.Add("MissionLeader", missionLeader); //团负责人
  7511. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7512. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7513. #region MyRegion
  7514. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7515. //{
  7516. // List<string> list = new List<string>();
  7517. // try
  7518. // {
  7519. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7520. // foreach (var item in spilitArr)
  7521. // {
  7522. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7523. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7524. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7525. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7526. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7527. // list.Add(depName);
  7528. // list.Add(arrName);
  7529. // }
  7530. // list = list.Distinct().ToList();
  7531. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7532. // }
  7533. // catch (Exception)
  7534. // {
  7535. // dic.Add("ReturnCode", "行程录入不正确!");
  7536. // }
  7537. //}
  7538. //else
  7539. //{
  7540. // dic.Add("ReturnCode", "未录入行程!");
  7541. //}
  7542. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7543. dic.Add("ReturnCode", string.Join("、", countrys));
  7544. #endregion
  7545. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7546. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7547. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7548. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7549. //{
  7550. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7551. // dic.Add("Day", sp.Days.ToString());
  7552. //}
  7553. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7554. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7555. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7556. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7557. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7558. //培训人员名单
  7559. int cultivateRowIndex = 7;
  7560. foreach (var item in DeleClientList)
  7561. {
  7562. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7563. builder.Write(item.Name);
  7564. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7565. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7566. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7567. string birthDay = "";
  7568. if (item.Birthday != null)
  7569. {
  7570. DateTime dt = Convert.ToDateTime(item.Birthday);
  7571. birthDay = $"{dt.Year}.{dt.Month}";
  7572. }
  7573. builder.Write(birthDay);
  7574. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7575. builder.Write(item.Company);
  7576. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7577. builder.Write(item.Job);
  7578. cultivateRowIndex++;
  7579. }
  7580. //删除多余行
  7581. //cultivateRowIndex -= 2;
  7582. int delRows = 10 + 7 - cultivateRowIndex;
  7583. if (delRows > 0)
  7584. {
  7585. for (int i = 0; i < delRows; i++)
  7586. {
  7587. table1.Rows.RemoveAt(cultivateRowIndex);
  7588. //cultivateRowIndex++;
  7589. }
  7590. }
  7591. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7592. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7593. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7594. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7595. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7596. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7597. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7598. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7599. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7600. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7601. //其他费用
  7602. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7603. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7604. //其他费用合计
  7605. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7606. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7607. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7608. //公务舱合计
  7609. //国际旅费
  7610. //string outsideJJ = "";
  7611. //string allPriceJJ = "";
  7612. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7613. {
  7614. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7615. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7616. }
  7617. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7618. {
  7619. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7620. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7621. }
  7622. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7623. {
  7624. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7625. dic.Add("AirFeeTotal", airFeeTotalStr);
  7626. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7627. dic.Add("FeeTotal", feeTotalStr);
  7628. }
  7629. foreach (var key in dic.Keys)
  7630. {
  7631. builder.MoveToBookmark(key);
  7632. builder.Write(dic[key]);
  7633. }
  7634. //模板文件名
  7635. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7636. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7637. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7638. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7639. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7640. }
  7641. }
  7642. else if (dto.ExportType == 2) //表格
  7643. {
  7644. //利用键值对存放数据
  7645. Dictionary<string, string> dic = new Dictionary<string, string>();
  7646. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7647. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7648. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7649. dic.Add("Day", sp.Days.ToString());
  7650. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7651. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7652. {
  7653. //获取模板
  7654. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7655. //载入模板
  7656. var doc = new Document(tempPath);
  7657. var builder = new DocumentBuilder(doc);
  7658. dic.Add("TeamName", _DelegationInfo.TeamName);
  7659. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7660. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7661. string missionLeaderName = "",
  7662. missionLeaderJob = "";
  7663. if (DeleClientList.Count > 0)
  7664. {
  7665. missionLeaderName = DeleClientList[0].Name;
  7666. missionLeaderJob = DeleClientList[0].Job;
  7667. }
  7668. dic.Add("MissionLeaderName", missionLeaderName);
  7669. dic.Add("MissionLeaderJob", missionLeaderJob);
  7670. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7671. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7672. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7673. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7674. int rowCount = 10;//总人数行
  7675. int startRowIndex = 7; //起始行
  7676. for (int i = 0; i < DeleClientList.Count; i++)
  7677. {
  7678. builder.MoveToCell(0, startRowIndex, 0, 0);
  7679. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7680. builder.MoveToCell(0, startRowIndex, 1, 0);
  7681. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7682. builder.Write(sex);//性别
  7683. builder.MoveToCell(0, startRowIndex, 2, 0);
  7684. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7685. builder.MoveToCell(0, startRowIndex, 3, 0);
  7686. builder.Write(DeleClientList[i].Company);//工作单位
  7687. builder.MoveToCell(0, startRowIndex, 4, 0);
  7688. builder.Write(DeleClientList[i].Job);//职务及级别
  7689. builder.MoveToCell(0, startRowIndex, 5, 0);
  7690. builder.Write("");//人员属性
  7691. builder.MoveToCell(0, startRowIndex, 6, 0);
  7692. builder.Write("");//上次出国时间
  7693. startRowIndex++;
  7694. }
  7695. int nullRow = rowCount - DeleClientList.Count;//空行
  7696. for (int i = 0; i < nullRow; i++)
  7697. {
  7698. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7699. }
  7700. foreach (var key in dic.Keys)
  7701. {
  7702. builder.MoveToBookmark(key);
  7703. builder.Write(dic[key]);
  7704. }
  7705. //模板文件名
  7706. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7707. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7708. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7709. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7710. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7711. }
  7712. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7713. {
  7714. //获取模板
  7715. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7716. //载入模板
  7717. var doc = new Document(tempPath);
  7718. var builder = new DocumentBuilder(doc);
  7719. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7720. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7721. dic.Add("Names", Names);
  7722. int accommodationRows = 12;
  7723. //int foodandotherRows = 12;
  7724. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7725. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7726. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7727. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7728. int accommodationStartIndex = 6;
  7729. decimal dac1totalPrice = 0.00M;
  7730. foreach (var dac in dac1)
  7731. {
  7732. if (dac.SubTotal == 0)
  7733. {
  7734. continue;
  7735. }
  7736. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7737. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7738. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7739. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7740. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7741. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7742. builder.Write(currency);//币种
  7743. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7744. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7745. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7746. builder.Write("");//人数
  7747. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7748. builder.Write("");//天数
  7749. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7750. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7751. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7752. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7753. builder.Write(rate.ToString("#0.0000"));//汇率
  7754. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7755. decimal rbmPrice = rate * dac.SubTotal;
  7756. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7757. accommodationStartIndex++;
  7758. dac1totalPrice += rbmPrice;
  7759. }
  7760. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7761. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7762. builder.Write("小计");
  7763. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7764. builder.Write(dac1totalPrice.ToString("#0.00"));
  7765. accommodationStartIndex++;
  7766. int nullRow = accommodationRows - dac1.Count;
  7767. //删除空行
  7768. //if (nullRow > 0)
  7769. //{
  7770. // int rowIndex = accommodationStartIndex;
  7771. // for (int i = 0; i < nullRow; i++)
  7772. // {
  7773. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7774. // row.Remove();
  7775. // rowIndex++;
  7776. // }
  7777. //}
  7778. if (dac2.Count == dac3.Count)//国家 币种 金额
  7779. {
  7780. for (int i = 0; i < dac2.Count; i++)
  7781. {
  7782. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7783. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7784. }
  7785. }
  7786. int foodandotherStartIndex = 19;//
  7787. decimal dac2totalPrice = 0.00M;
  7788. foreach (var dac in dac2)
  7789. {
  7790. if (dac.SubTotal == 0)
  7791. {
  7792. continue;
  7793. }
  7794. //foodandotherStartIndex = 12;
  7795. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7796. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7797. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7798. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7799. builder.Write(currency);//币种
  7800. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7801. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7802. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7803. builder.Write("");//人数
  7804. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7805. builder.Write("");//天数
  7806. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7807. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7808. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7809. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7810. builder.Write(rate.ToString("#0.0000"));//汇率
  7811. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7812. decimal rbmPrice = rate * dac.SubTotal;
  7813. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7814. foodandotherStartIndex++;
  7815. dac2totalPrice += rbmPrice;
  7816. }
  7817. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7818. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7819. //删除空行
  7820. //if (dac2.Count < foodandotherRows)
  7821. //{
  7822. // while (table2.Rows.Count > dac2.Count)
  7823. // {
  7824. // table2.Rows.RemoveAt(dac2.Count);
  7825. // }
  7826. //}
  7827. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7828. string otherFeeStr = "";
  7829. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7830. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7831. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7832. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7833. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7834. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7835. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7836. foreach (var otherInfo in dac5)
  7837. {
  7838. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7839. }
  7840. #endregion
  7841. if (otherFeeStr.Length > 0)
  7842. {
  7843. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7844. otherFeeStr = $"({otherFeeStr})";
  7845. dic.Add("OtherFeeStr", otherFeeStr);
  7846. }
  7847. foreach (var key in dic.Keys)
  7848. {
  7849. builder.MoveToBookmark(key);
  7850. builder.Write(dic[key]);
  7851. }
  7852. //模板文件名
  7853. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7854. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7855. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7856. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7857. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7858. }
  7859. }
  7860. else if (dto.ExportType == 3)
  7861. {
  7862. if (dto.SubTypeId == 1) //团组成员名单
  7863. {
  7864. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7865. //获取模板
  7866. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7867. //载入模板
  7868. var doc = new Document(tempPath);
  7869. var builder = new DocumentBuilder(doc);
  7870. //获取word里所有表格
  7871. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7872. //获取所填表格的序数
  7873. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7874. var rowStart = tableOne.Rows[0]; //获取第1行
  7875. //循环赋值
  7876. for (int i = 0; i < DeleClientList.Count; i++)
  7877. {
  7878. builder.MoveToCell(0, i + 1, 0, 0);
  7879. builder.Write(DeleClientList[i].Name);
  7880. builder.MoveToCell(0, i + 1, 1, 0);
  7881. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7882. builder.Write(sex);
  7883. builder.MoveToCell(0, i + 1, 2, 0);
  7884. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7885. builder.MoveToCell(0, i + 1, 3, 0);
  7886. builder.Write(DeleClientList[i].Company);
  7887. builder.MoveToCell(0, i + 1, 4, 0);
  7888. builder.Write(DeleClientList[i].Job);
  7889. }
  7890. //删除多余行
  7891. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7892. {
  7893. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7894. }
  7895. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7896. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7897. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7898. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7899. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7900. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7901. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7902. }
  7903. }
  7904. return Ok(JsonView(400, "操作失败!", ""));
  7905. }
  7906. catch (Exception ex)
  7907. {
  7908. return Ok(JsonView(400, ex.Message, ""));
  7909. }
  7910. }
  7911. /// <summary>
  7912. /// 获取三公费用标准city
  7913. /// </summary>
  7914. /// <param name="placeData"></param>
  7915. /// <param name="nationalTravelFeeId"></param>
  7916. /// <returns></returns>
  7917. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7918. {
  7919. string _city = string.Empty;
  7920. if (placeData.Count < 1) return _city;
  7921. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7922. if (data == null) return _city;
  7923. string country = data.Country;
  7924. string city = data.City;
  7925. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7926. else _city = city;
  7927. return _city;
  7928. }
  7929. ///// <summary>
  7930. ///// 团组模块 - 出入境费用 - 明细表导出
  7931. ///// </summary>
  7932. ///// <returns></returns>
  7933. //[HttpPost]
  7934. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7935. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7936. //{
  7937. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7938. // if (data.Code != 0)
  7939. // {
  7940. // return Ok(JsonView(false, data.Msg));
  7941. // }
  7942. // return Ok(JsonView(true, data.Msg, data.Data));
  7943. //}
  7944. /// <summary>
  7945. /// 团组模块 - 出入境费用 - 一键清空
  7946. /// </summary>
  7947. /// <returns></returns>
  7948. [HttpPost]
  7949. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7951. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7952. {
  7953. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7954. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7955. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7956. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7957. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7958. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7959. .SetColumns(x => new Grp_DayOtherPrice
  7960. {
  7961. IsDel = 1,
  7962. DeleteUserId = dto.UserId,
  7963. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7964. })
  7965. .ExecuteCommandAsync();
  7966. if (_view.Code == 0)
  7967. {
  7968. return Ok(JsonView(true, "操作成功"));
  7969. }
  7970. return Ok(JsonView(false, "操作失败"));
  7971. }
  7972. /// <summary>
  7973. /// 团组模块 - 出入境费用 - 子项删除
  7974. /// </summary>
  7975. /// <returns></returns>
  7976. [HttpPost]
  7977. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7979. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7980. {
  7981. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7982. if (data.Code != 0)
  7983. {
  7984. return Ok(JsonView(false, data.Msg));
  7985. }
  7986. return Ok(JsonView(true, "操作成功!", data.Data));
  7987. }
  7988. /// <summary>
  7989. /// 删除三公其他费用
  7990. /// </summary>
  7991. /// <param name="dto"></param>
  7992. /// <returns></returns>
  7993. [HttpPost]
  7994. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7995. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7996. {
  7997. var jw = JsonView(false, "删除失败!");
  7998. var data = new Grp_DayOtherPrice()
  7999. {
  8000. Id = dto.Id,
  8001. IsDel = 1,
  8002. DeleteUserId = dto.DeleteUserId,
  8003. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8004. };
  8005. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8006. if (del > 0)
  8007. {
  8008. jw.Code = 200;
  8009. jw.Msg = "删除成功!";
  8010. }
  8011. return Ok(jw);
  8012. }
  8013. /// <summary>
  8014. /// 团组模块 - 出入境国家费用标准 List
  8015. /// </summary>
  8016. /// <returns></returns>
  8017. [HttpPost]
  8018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8019. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8020. {
  8021. int provinceId = dto.ProvinceId;
  8022. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8023. var nftData = await _sqlSugar
  8024. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8025. JoinType.Left, ntf.Currency == sd1.Id,
  8026. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8027. JoinType.Left, ntf.ProvinceId == c.Id
  8028. ))
  8029. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8030. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8031. {
  8032. Id = ntf.Id,
  8033. ProvinceId = ntf.ProvinceId,
  8034. ProvinceName = c.Name_CN,
  8035. Continent = ntf.Continent,
  8036. Country = ntf.Country,
  8037. City = ntf.City,
  8038. Currency = ntf.Currency,
  8039. CurrencyCode = sd1.Name,
  8040. CurrencyName = sd1.Remark,
  8041. RoomCost = ntf.RoomCost,
  8042. FoodCost = ntf.FoodCost,
  8043. PublicCost = ntf.PublicCost,
  8044. LastUpdateUserId = ntf.LastUpdateUserId,
  8045. LastUpdateUserName = u.CnName,
  8046. LastUpdateTime = ntf.LastUpdateTime
  8047. })
  8048. .ToListAsync();
  8049. return Ok(JsonView(true, "查询成功!", nftData));
  8050. }
  8051. /// <summary>
  8052. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8053. /// </summary>
  8054. /// <returns></returns>
  8055. [HttpPost]
  8056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8057. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8058. {
  8059. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8060. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8061. List<string> countryData = new List<string>();
  8062. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8063. countryData = countryData.Distinct().ToList();
  8064. List<dynamic> dataSource = new List<dynamic>();
  8065. foreach (var item in countryData)
  8066. {
  8067. var cityData1 = new List<string>();
  8068. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8069. var countryData2 = new
  8070. {
  8071. CountryName = item,
  8072. CityData = cityData1
  8073. };
  8074. if (!dataSource.Contains(countryData2))
  8075. {
  8076. dataSource.Add(countryData2);
  8077. }
  8078. }
  8079. return Ok(JsonView(true, "查询成功!", dataSource));
  8080. }
  8081. /// <summary>
  8082. /// 团组模块 - 出入境国家费用标准 Page List
  8083. /// </summary>
  8084. /// <returns></returns>
  8085. [HttpPost]
  8086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8087. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8088. {
  8089. int portId = dto.PortType,
  8090. pageIndex = dto.PageIndex,
  8091. pageSize = dto.PageSize;
  8092. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8093. if (pageIndex == 0) pageIndex = 1;
  8094. if (pageSize == 0) pageSize = 10;
  8095. RefAsync<int> total = 0;
  8096. var nationalTravelFeeData = await _sqlSugar
  8097. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8098. JoinType.Left, ntf.Currency == sd1.Id,
  8099. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8100. JoinType.Left, ntf.ProvinceId == sd2.Id
  8101. ))
  8102. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8103. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8104. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8105. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8106. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8107. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8108. {
  8109. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8110. Id = ntf.Id,
  8111. ProvinceId = ntf.ProvinceId,
  8112. ProvinceName = sd2.Name_CN,
  8113. Continent = ntf.Continent,
  8114. Country = ntf.Country,
  8115. City = ntf.City,
  8116. Currency = ntf.Currency,
  8117. CurrencyCode = sd1.Name,
  8118. CurrencyName = sd1.Remark,
  8119. RoomCost = ntf.RoomCost,
  8120. FoodCost = ntf.FoodCost,
  8121. PublicCost = ntf.PublicCost,
  8122. LastUpdateUserId = ntf.LastUpdateUserId,
  8123. LastUpdateUserName = u.CnName,
  8124. LastUpdateTime = ntf.LastUpdateTime,
  8125. Remark = ntf.Remark
  8126. })
  8127. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8128. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8129. }
  8130. /// <summary>
  8131. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8132. /// </summary>
  8133. /// <returns></returns>
  8134. [HttpPost]
  8135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8136. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8137. {
  8138. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8139. int portId = dto.PortType;
  8140. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8141. string whereSql = string.Empty;
  8142. if (!string.IsNullOrEmpty(dto.Country))
  8143. {
  8144. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8145. }
  8146. if (!string.IsNullOrEmpty(dto.City))
  8147. {
  8148. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8149. }
  8150. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8151. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8152. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8153. From Grp_NationalTravelFee gntf
  8154. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8155. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8156. Where gntf.Isdel = 0 {0} ", whereSql);
  8157. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8158. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8159. }
  8160. /// <summary>
  8161. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8162. /// </summary>
  8163. /// <returns></returns>
  8164. [HttpPost]
  8165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8166. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8167. {
  8168. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8169. }
  8170. /// <summary>
  8171. /// 团组模块 - 出入境国家费用标准 - Del
  8172. /// </summary>
  8173. /// <returns></returns>
  8174. [HttpPost]
  8175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8176. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8177. {
  8178. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8179. {
  8180. Id = dto.Id,
  8181. DeleteUserId = dto.DeleteUserId,
  8182. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8183. IsDel = 1
  8184. };
  8185. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8186. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8187. .WhereColumns(it => new { it.Id })
  8188. .ExecuteCommandAsync();
  8189. if (delStatus <= 0)
  8190. {
  8191. return Ok(JsonView(false, "删除失败!"));
  8192. }
  8193. return Ok(JsonView(true, "操作成功!"));
  8194. }
  8195. /// <summary>
  8196. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8197. /// 注:Get 请求Headers 加 Token
  8198. /// </summary>
  8199. /// <param name="groupId"></param>
  8200. /// <returns></returns>
  8201. [HttpGet("{groupId}")]
  8202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8203. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8204. {
  8205. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8206. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8207. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8208. data.ForEach(x =>
  8209. {
  8210. x.CreateUserId = _currUserInfo.UserId;
  8211. });
  8212. if (data.Any())
  8213. {
  8214. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8215. if (add > 0)
  8216. {
  8217. return Ok(JsonView(true, "操作成功!"));
  8218. }
  8219. }
  8220. return Ok(JsonView(false, "未操作!"));
  8221. }
  8222. #endregion
  8223. #region 团组经理模块 出入境费用-草稿
  8224. /// <summary>
  8225. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8226. /// </summary>
  8227. /// <returns></returns>
  8228. [HttpGet]
  8229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8230. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8231. {
  8232. var provData = await _groupRepository.ProvinceBasicSource();
  8233. return Ok(JsonView(true, "查询成功!", provData));
  8234. }
  8235. /// <summary>
  8236. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8237. /// </summary>
  8238. /// <returns></returns>
  8239. [HttpGet("{provinceId}")]
  8240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8241. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8242. {
  8243. //验证城市归属并给默认值
  8244. if (provinceId < 1) provinceId = 122;
  8245. /*
  8246. * 122 四川
  8247. * 108 贵州
  8248. * 103 重庆
  8249. * 132 云南
  8250. */
  8251. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8252. return Ok(JsonView(true, "查询成功!", new
  8253. {
  8254. WordTypeData = wordTypeData,
  8255. ExcelTypeData = excelTypeData,
  8256. }));
  8257. }
  8258. /// <summary>
  8259. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8260. /// </summary>
  8261. /// <returns></returns>
  8262. [HttpPost]
  8263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8264. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8265. {
  8266. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8267. .Where(x => x.IsDel == 0)
  8268. .OrderByDescending(x => x.CreateTime)
  8269. .Select(x => new { x.Id, x.DraftName })
  8270. .ToListAsync();
  8271. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8272. //SetDataInfoView
  8273. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8274. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8275. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8276. int provinceId = dto.ProvinceId;
  8277. if (provinceId < 1) provinceId = 122;
  8278. /*
  8279. * 122 四川
  8280. * 108 贵州
  8281. * 103 重庆
  8282. * 132 云南
  8283. */
  8284. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8285. //默认币种显示
  8286. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8287. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8288. return Ok(JsonView(true, "查询成功!", new
  8289. {
  8290. DraftNameDatas = draftNameDatas,
  8291. CurrencyData = _CurrencyData,
  8292. WordTypeData = wordTypeData,
  8293. ExcelTypeData = excelTypeData,
  8294. CurrencyInit = _currencyInfos,
  8295. ViewPermissionData = viewPermissionData
  8296. }));
  8297. }
  8298. /// <summary>
  8299. /// 团组模块 - 出入境费用-草稿
  8300. /// 实时汇率 tips
  8301. /// 机票费用 tips
  8302. /// </summary>
  8303. /// <returns></returns>
  8304. [HttpPost]
  8305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8306. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8307. {
  8308. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8309. return Ok(JsonView(true, "查询成功!", new
  8310. {
  8311. //GroupNameData = groupNameData.Data,
  8312. //visaData = visaData.Data,
  8313. //airData = airData.Data,
  8314. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8315. }));
  8316. }
  8317. /// <summary>
  8318. /// 团组模块 - 出入境费用-草稿
  8319. /// 签证费用 tips
  8320. /// </summary>
  8321. /// <returns></returns>
  8322. [HttpPost]
  8323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8324. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8325. {
  8326. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8327. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8328. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8329. .Select(x => x.NationalTravelFeeId)
  8330. .Distinct()
  8331. .ToListAsync();
  8332. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8333. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8334. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8335. .Select(x => x.Country)
  8336. .Distinct()
  8337. .ToArrayAsync();
  8338. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8339. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8340. return Ok(JsonView(true, "查询成功!", new
  8341. {
  8342. totalAmt,
  8343. remark
  8344. }));
  8345. }
  8346. /// <summary>
  8347. /// 团组模块 - 出入境费用-草稿 - Info
  8348. /// </summary>
  8349. /// <returns></returns>
  8350. [HttpPost]
  8351. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8353. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8354. {
  8355. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8356. }
  8357. /// <summary>
  8358. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8359. /// </summary>
  8360. /// <returns></returns>
  8361. [HttpPost]
  8362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8363. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8364. {
  8365. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8366. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8367. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8368. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8369. foreach (var userId in dto.UserIds)
  8370. {
  8371. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8372. }
  8373. if (permissions.Any())
  8374. {
  8375. _sqlSugar.BeginTran();
  8376. try
  8377. {
  8378. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8379. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8380. if (result < 1)
  8381. {
  8382. _sqlSugar.RollbackTran();
  8383. return Ok(JsonView(false));
  8384. }
  8385. }
  8386. catch (Exception ex)
  8387. {
  8388. _sqlSugar.RollbackTran();
  8389. return Ok(JsonView(false, ex.Message));
  8390. }
  8391. _sqlSugar.CommitTran();
  8392. return Ok(JsonView(true));
  8393. }
  8394. return Ok(JsonView(false));
  8395. }
  8396. /// <summary>
  8397. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8398. /// </summary>
  8399. /// <returns></returns>
  8400. [HttpPost]
  8401. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8403. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8404. {
  8405. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8406. if (data.Code != 0)
  8407. {
  8408. return Ok(JsonView(false, data.Msg));
  8409. }
  8410. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8411. //汇率信息记录
  8412. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8413. return Ok(JsonView(true, data.Msg, data.Data));
  8414. }
  8415. /// <summary>
  8416. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8417. /// </summary>
  8418. /// <param name="dto"></param>
  8419. /// <returns></returns>
  8420. [HttpPost]
  8421. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8423. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8424. {
  8425. try
  8426. {
  8427. var id = dto.Id;
  8428. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8429. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8430. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8431. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8432. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8433. 3 团组成员名单 1 团组成员名单", ""));
  8434. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8435. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8436. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8437. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8438. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8439. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8440. //数据源
  8441. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8442. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8443. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8444. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8445. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8446. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8447. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8448. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8449. .Select((x, a, b) => new
  8450. {
  8451. x.Index,
  8452. itemName = a.Name,
  8453. CurrencyStr = b.Name,
  8454. x.Cost,
  8455. x.SubTotal,
  8456. x.Remark
  8457. })
  8458. .OrderBy((x) => x.Index)
  8459. .ToList(); //其他款项费用
  8460. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8461. var peiceItemCurrencys = new List<string>();
  8462. if (_DayAndCosts.Any())
  8463. {
  8464. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8465. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8466. }
  8467. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8468. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8469. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8470. {
  8471. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8472. }
  8473. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8474. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8475. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8476. if (dto.ExportType == 1) //明细表
  8477. {
  8478. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8479. {
  8480. //获取模板
  8481. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8482. //载入模板
  8483. Document doc = new Document(tempPath);
  8484. DocumentBuilder builder = new DocumentBuilder(doc);
  8485. //利用键值对存放数据
  8486. Dictionary<string, string> dic = new Dictionary<string, string>();
  8487. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8488. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8489. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8490. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8491. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8492. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8493. //境内费用(其他费用)
  8494. if (_EnterExitCosts.ChoiceOne == 1)
  8495. {
  8496. string row1_1 = "";
  8497. if (_EnterExitCosts.Visa > 0)
  8498. {
  8499. //insidePayTotal += _EnterExitCosts.Visa;
  8500. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8501. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8502. //{
  8503. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8504. //}
  8505. }
  8506. string row1_2 = "";
  8507. if (_EnterExitCosts.YiMiao > 0)
  8508. {
  8509. //insidePayTotal += _EnterExitCosts.YiMiao;
  8510. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8511. }
  8512. if (_EnterExitCosts.HeSuan > 0)
  8513. {
  8514. //insidePayTotal += _EnterExitCosts.HeSuan;
  8515. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8516. }
  8517. if (_EnterExitCosts.Service > 0)
  8518. {
  8519. //insidePayTotal += _EnterExitCosts.Service;
  8520. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8521. }
  8522. string row1_3 = "";
  8523. if (_EnterExitCosts.Safe > 0)
  8524. {
  8525. //insidePayTotal += _EnterExitCosts.Safe;
  8526. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8527. }
  8528. if (_EnterExitCosts.Ticket > 0)
  8529. {
  8530. //insidePayTotal += _EnterExitCosts.Ticket;
  8531. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8532. }
  8533. string row1 = "";
  8534. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8535. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8536. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8537. row1 += $"备注:{_EnterExitCosts.Remark}";
  8538. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8539. dic.Add("Row1Str", row1);
  8540. }
  8541. string airTotalStr = string.Empty,
  8542. airPriceStr = string.Empty;
  8543. //经济舱
  8544. if (_EnterExitCosts.SumJJC == 1)
  8545. {
  8546. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8547. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8548. }
  8549. //公务舱
  8550. if (_EnterExitCosts.SumGWC == 1)
  8551. {
  8552. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8553. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8554. }
  8555. //头等舱
  8556. if (_EnterExitCosts.SumTDC == 1)
  8557. {
  8558. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8559. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8560. }
  8561. //汇率描述
  8562. string rateStr = "";
  8563. if (peiceItemCurrencyInfos.Any())
  8564. {
  8565. rateStr = "\r\n汇率描述:";
  8566. foreach (var item in peiceItemCurrencyInfos)
  8567. {
  8568. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8569. }
  8570. }
  8571. string twoItemRemark = "备注:";
  8572. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8573. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8574. dic.Add("AirTotalStr", airTotalStr);
  8575. dic.Add("AirPriceStr", airPriceStr);
  8576. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8577. dic.Add("TwoItemRemark", twoItemRemark);
  8578. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8579. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8580. int table1Row = 0,
  8581. table2Row = 0,
  8582. table3Row = 0,
  8583. table4Row = 0,
  8584. table5Row = 0;
  8585. //住宿费
  8586. if (_EnterExitCosts.ChoiceThree == 1)
  8587. {
  8588. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8589. table1Row = dac1.Count;
  8590. #region 填充word表格内容
  8591. for (int i = 0; i < dac1.Count; i++)
  8592. {
  8593. var dac = dac1[i];
  8594. if (dac == null) continue;
  8595. builder.MoveToCell(0, i, 0, 0);
  8596. builder.Write("第" + dac.Days.ToString() + "晚:");
  8597. builder.MoveToCell(0, i, 1, 0);
  8598. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8599. //builder.Write(dac.Place == null ? "" : dac.Place);
  8600. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8601. builder.MoveToCell(0, i, 2, 0);
  8602. builder.Write("费用标准:");
  8603. string curr = "";
  8604. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8605. if (currData != null)
  8606. {
  8607. curr = currData.Name;
  8608. }
  8609. builder.MoveToCell(0, i, 3, 0);
  8610. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8611. builder.MoveToCell(0, i, 4, 0);
  8612. builder.Write("费用小计:");
  8613. builder.MoveToCell(0, i, 5, 0);
  8614. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8615. }
  8616. #endregion
  8617. }
  8618. else dic.Add("SubZS", "0.00");
  8619. //删除多余行
  8620. while (table1.Rows.Count > table1Row)
  8621. {
  8622. table1.Rows.RemoveAt(table1Row);
  8623. }
  8624. //伙食费
  8625. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8626. if (_EnterExitCosts.ChoiceFour == 1)
  8627. {
  8628. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8629. table2Row = dac2.Count;
  8630. #region 填充word表格内容
  8631. for (int i = 0; i < dac2.Count; i++)
  8632. {
  8633. var dac = dac2[i];
  8634. if (dac == null) continue;
  8635. builder.MoveToCell(1, i, 0, 0);
  8636. builder.Write("第" + dac.Days.ToString() + "天:");
  8637. builder.MoveToCell(1, i, 1, 0);
  8638. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8639. builder.MoveToCell(1, i, 2, 0);
  8640. builder.Write("费用标准:");
  8641. string curr = "";
  8642. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8643. if (currData != null)
  8644. {
  8645. curr = currData.Name;
  8646. }
  8647. builder.MoveToCell(1, i, 3, 0);
  8648. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8649. builder.MoveToCell(1, i, 4, 0);
  8650. builder.Write("费用小计:");
  8651. builder.MoveToCell(1, i, 5, 0);
  8652. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8653. }
  8654. #endregion
  8655. }
  8656. else dic.Add("SubHS", "0.00");
  8657. //删除多余行
  8658. while (table2.Rows.Count > table2Row)
  8659. {
  8660. table2.Rows.RemoveAt(table2Row);
  8661. }
  8662. //公杂费
  8663. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8664. if (_EnterExitCosts.ChoiceFive == 1)
  8665. {
  8666. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8667. table3Row = dac3.Count;
  8668. #region 填充word表格内容
  8669. for (int i = 0; i < dac3.Count; i++)
  8670. {
  8671. var dac = dac3[i];
  8672. if (dac == null) continue;
  8673. builder.MoveToCell(2, i, 0, 0);
  8674. builder.Write("第" + dac.Days.ToString() + "天:");
  8675. builder.MoveToCell(2, i, 1, 0);
  8676. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8677. builder.MoveToCell(2, i, 2, 0);
  8678. builder.Write("费用标准:");
  8679. string curr = "";
  8680. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8681. if (currData != null)
  8682. {
  8683. curr = currData.Name;
  8684. }
  8685. builder.MoveToCell(2, i, 3, 0);
  8686. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8687. builder.MoveToCell(2, i, 4, 0);
  8688. builder.Write("费用小计:");
  8689. builder.MoveToCell(2, i, 5, 0);
  8690. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8691. }
  8692. //删除多余行
  8693. while (table3.Rows.Count > table3Row)
  8694. {
  8695. table3.Rows.RemoveAt(table3Row);
  8696. }
  8697. #endregion
  8698. }
  8699. else dic.Add("SubGZF", "0.00");
  8700. //删除多余行
  8701. while (table3.Rows.Count > table3Row)
  8702. {
  8703. table3.Rows.RemoveAt(table3Row);
  8704. }
  8705. //培训费
  8706. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8707. if (_EnterExitCosts.ChoiceSix == 1)
  8708. {
  8709. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8710. dic.Add("SubPX", pxStr);
  8711. table4Row = dac4.Count;
  8712. #region 填充word表格内容
  8713. for (int i = 0; i < dac4.Count; i++)
  8714. {
  8715. var dac = dac4[i];
  8716. if (dac == null) continue;
  8717. builder.MoveToCell(3, i, 0, 0);
  8718. builder.Write("第" + dac.Days.ToString() + "天:");
  8719. builder.MoveToCell(3, i, 1, 0);
  8720. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8721. builder.MoveToCell(3, i, 2, 0);
  8722. builder.Write("费用标准:");
  8723. string curr = "";
  8724. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8725. if (currData != null)
  8726. {
  8727. curr = currData.Name;
  8728. }
  8729. builder.MoveToCell(3, i, 3, 0);
  8730. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8731. builder.MoveToCell(3, i, 4, 0);
  8732. builder.Write("费用小计:");
  8733. builder.MoveToCell(3, i, 5, 0);
  8734. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8735. }
  8736. #endregion
  8737. }
  8738. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8739. //删除多余行
  8740. while (table4.Rows.Count > table4Row)
  8741. {
  8742. table4.Rows.RemoveAt(table4Row);
  8743. }
  8744. //其他费用
  8745. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8746. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8747. {
  8748. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8749. dic.Add("titleQi", qtStr);
  8750. table5Row = dac5.Count;
  8751. #region 填充word表格内容
  8752. for (int i = 0; i < dac5.Count; i++)
  8753. {
  8754. var dac = dac5[i];
  8755. if (dac == null) continue;
  8756. builder.MoveToCell(4, i, 0, 0);
  8757. builder.Write("第" + dac.Index.ToString() + "项:");
  8758. builder.MoveToCell(4, i, 1, 0);
  8759. builder.Write(dac.itemName);
  8760. builder.MoveToCell(4, i, 2, 0);
  8761. builder.Write("费用标准:");
  8762. builder.MoveToCell(4, i, 3, 0);
  8763. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8764. builder.MoveToCell(4, i, 4, 0);
  8765. builder.Write("费用小计:");
  8766. builder.MoveToCell(4, i, 5, 0);
  8767. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8768. builder.MoveToCell(4, i, 6, 0);
  8769. builder.Write("备注:");
  8770. builder.MoveToCell(4, i, 7, 0);
  8771. builder.Write(dac.Remark);
  8772. }
  8773. #endregion
  8774. }
  8775. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8776. //删除多余行
  8777. while (table5.Rows.Count > table5Row)
  8778. {
  8779. table5.Rows.RemoveAt(table5Row);
  8780. }
  8781. //加上其他费用
  8782. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8783. decimal subJJC = 0.00M,
  8784. subGWC = 0.00M,
  8785. subTDC = 0.00M;
  8786. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8787. string totalLabel = string.Format("全部费用总计:");
  8788. //经济舱
  8789. if (_EnterExitCosts.SumJJC == 1)
  8790. {
  8791. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8792. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8793. }
  8794. //公务舱
  8795. if (_EnterExitCosts.SumGWC == 1)
  8796. {
  8797. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8798. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8799. }
  8800. //头等舱
  8801. if (_EnterExitCosts.SumTDC == 1)
  8802. {
  8803. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8804. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8805. }
  8806. //TotalLabel
  8807. dic.Add("TotalLabel", totalLabel);
  8808. #region 填充word模板书签内容
  8809. foreach (var key in dic.Keys)
  8810. {
  8811. Bookmark bookmark = doc.Range.Bookmarks[key];
  8812. if (bookmark != null)
  8813. {
  8814. builder.MoveToBookmark(key);
  8815. builder.Write(dic[key]);
  8816. }
  8817. }
  8818. #endregion
  8819. //文件名
  8820. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8821. strFileName = CommonFun.ValidFileName(strFileName);
  8822. AsposeHelper.removewatermark_v2180();
  8823. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8824. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8825. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8826. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8827. }
  8828. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8829. {
  8830. //获取模板
  8831. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8832. //载入模板
  8833. Document doc = new Document(tempPath);
  8834. DocumentBuilder builder = new DocumentBuilder(doc);
  8835. Dictionary<string, string> dic = new Dictionary<string, string>();
  8836. string returnCodeLabel = string.Empty;
  8837. if (nationalTravelFeeData.Any())
  8838. {
  8839. List<string> list = new List<string>();
  8840. foreach (var item in nationalTravelFeeData)
  8841. {
  8842. list.Add($"{item.Country}({item.City})");
  8843. }
  8844. list = list.Distinct().ToList();
  8845. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8846. }
  8847. var countryLabel = string.Empty;
  8848. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8849. if (countryData.Any())
  8850. {
  8851. countryLabel = string.Join("、", countryData);
  8852. }
  8853. dic.Add("ReturnCodeAir", returnCodeLabel);
  8854. dic.Add("VisitStartDate", "-");
  8855. dic.Add("VisitEndDate", "-");
  8856. dic.Add("Day", "-");
  8857. dic.Add("VisitCountry", countryLabel);
  8858. dic.Add("ClientUnit", "-");
  8859. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8860. //dic.Add("Names", Names);
  8861. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8862. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8863. decimal dac1totalPrice = 0.00M;
  8864. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8865. foreach (var dac in dac1)
  8866. {
  8867. if (dac.SubTotal == 0.00M)
  8868. {
  8869. continue;
  8870. }
  8871. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8872. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8873. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8874. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8875. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8876. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8877. builder.Write(currency);//币种
  8878. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8879. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8880. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8881. builder.Write("");//人数
  8882. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8883. builder.Write("");//天数
  8884. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8885. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8886. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8887. decimal rate = 0.00M;
  8888. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8889. builder.Write(rate.ToString("#0.0000"));//汇率
  8890. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8891. decimal rbmPrice = dac.SubTotal;
  8892. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8893. accommodationStartIndex++;
  8894. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8895. }
  8896. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8897. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8898. {
  8899. table1.Rows.RemoveAt(i - 1);
  8900. foodandotherStartIndex--;
  8901. }
  8902. if (dac2.Count == dac3.Count)//国家 币种 金额
  8903. {
  8904. for (int i = 0; i < dac2.Count; i++)
  8905. {
  8906. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8907. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8908. }
  8909. }
  8910. decimal dac2totalPrice = 0.00M;
  8911. foreach (var dac in dac2)
  8912. {
  8913. if (dac.SubTotal == 0)
  8914. {
  8915. continue;
  8916. }
  8917. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8918. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8919. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8920. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8921. builder.Write(currency);//币种
  8922. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8923. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8924. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8925. builder.Write("");//人数
  8926. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8927. builder.Write("");//天数
  8928. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8929. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8930. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8931. decimal rate = 0.00M;
  8932. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8933. builder.Write(rate.ToString("#0.0000"));//汇率
  8934. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8935. decimal rbmPrice = dac.SubTotal;
  8936. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8937. foodandotherStartIndex++;
  8938. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8939. }
  8940. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8941. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8942. {
  8943. table1.Rows.RemoveAt(i - 1);
  8944. }
  8945. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8946. string otherFeeStr = "";
  8947. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8948. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8949. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8950. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8951. foreach (var otherInfo in dac5)
  8952. {
  8953. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8954. }
  8955. #endregion
  8956. if (otherFeeStr.Length > 0)
  8957. {
  8958. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8959. otherFeeStr = $"({otherFeeStr})";
  8960. dic.Add("OtherFeeStr", otherFeeStr);
  8961. }
  8962. //总计
  8963. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8964. //国际旅费
  8965. string outsideAir = string.Empty;
  8966. string allPriceAir = string.Empty;
  8967. if (_EnterExitCosts.SumJJC == 1)
  8968. {
  8969. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8970. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8971. }
  8972. if (_EnterExitCosts.SumGWC == 1)
  8973. {
  8974. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8975. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8976. }
  8977. if (_EnterExitCosts.SumTDC == 1)
  8978. {
  8979. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8980. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8981. }
  8982. dic.Add("InTravelPrice", $"({outsideAir})");
  8983. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8984. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8985. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8986. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8987. foreach (var key in dic.Keys)
  8988. {
  8989. builder.MoveToBookmark(key);
  8990. builder.Write(dic[key]);
  8991. }
  8992. //模板文件名
  8993. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8994. strFileName = CommonFun.ValidFileName(strFileName);
  8995. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8996. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8997. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8998. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8999. }
  9000. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9001. {
  9002. //获取模板
  9003. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9004. //载入模板
  9005. WorkbookDesigner designer = new WorkbookDesigner();
  9006. designer.Workbook = new Workbook(tempPath);
  9007. Dictionary<string, string> dic = new Dictionary<string, string>();
  9008. string returnCodeLabel = string.Empty;
  9009. if (nationalTravelFeeData.Any())
  9010. {
  9011. List<string> list = new List<string>();
  9012. foreach (var item in nationalTravelFeeData)
  9013. {
  9014. list.Add($"{item.Country}({item.City})");
  9015. }
  9016. list = list.Distinct().ToList();
  9017. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9018. }
  9019. var countryLabel = string.Empty;
  9020. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9021. if (countryData.Any())
  9022. {
  9023. countryLabel = string.Join("、", countryData);
  9024. }
  9025. dic.Add("ReturnCodeAir", returnCodeLabel);
  9026. dic.Add("VisitStartDate", "-");
  9027. dic.Add("VisitEndDate", "-");
  9028. dic.Add("Day", "0");
  9029. dic.Add("VisitCountry", countryLabel);
  9030. dic.Add("ClientUnit", "-");
  9031. designer.SetDataSource("ClientUnit", "-");
  9032. designer.SetDataSource("VisitCountry", countryLabel);
  9033. designer.SetDataSource("Group", "-");
  9034. designer.SetDataSource("ClientUnitTitle", "-");
  9035. designer.SetDataSource("Name", "-");
  9036. designer.SetDataSource("VisitStartDate", "-");
  9037. designer.SetDataSource("Day", "0");
  9038. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9039. designer.SetDataSource("ReturnCodeAir", "-");
  9040. int startIndex = 10;
  9041. const int startIndexcopy = 10;
  9042. if (dac2.Count == dac3.Count)//国家 币种 金额
  9043. {
  9044. for (int i = 0; i < dac2.Count; i++)
  9045. {
  9046. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9047. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9048. }
  9049. }
  9050. DataTable dtdac1 = new DataTable();
  9051. List<string> place = new List<string>();
  9052. dtdac1.Columns.AddRange(new DataColumn[] {
  9053. new DataColumn(){ ColumnName = "city"},
  9054. new DataColumn(){ ColumnName = "curr"},
  9055. new DataColumn(){ ColumnName = "criterion"},
  9056. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9057. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9058. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9059. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9060. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9061. });
  9062. DataTable dtdac2 = new DataTable();
  9063. dtdac2.Columns.AddRange(new DataColumn[] {
  9064. new DataColumn(){ ColumnName = "city"},
  9065. new DataColumn(){ ColumnName = "curr"},
  9066. new DataColumn(){ ColumnName = "criterion"},
  9067. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9068. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9069. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9070. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9071. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9072. });
  9073. dtdac1.TableName = "tb1";
  9074. dtdac2.TableName = "tb2";
  9075. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9076. foreach (var item in dac1)
  9077. {
  9078. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9079. if (place.Contains(item.Place))
  9080. {
  9081. continue;
  9082. }
  9083. DataRow row = dtdac1.NewRow();
  9084. row["city"] = item.Place;
  9085. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9086. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9087. row["curr"] = currency;
  9088. row["rate"] = rate.ToString("#0.0000");
  9089. row["criterion"] = item.Cost.ToString("#0.00");
  9090. row["number"] = 1;
  9091. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9092. //row["costRMB"] = rbmPrice;
  9093. dtdac1.Rows.Add(row);
  9094. place.Add(item.Place);
  9095. }
  9096. place = new List<string>();
  9097. foreach (var item in dac2)
  9098. {
  9099. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9100. if (place.Contains(item.Place))
  9101. {
  9102. continue;
  9103. }
  9104. DataRow row = dtdac2.NewRow();
  9105. row["city"] = item.Place;
  9106. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9107. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9108. row["curr"] = currency;
  9109. row["rate"] = rate.ToString("#0.0000");
  9110. row["criterion"] = item.Cost.ToString("#0.00");
  9111. row["number"] = 1;
  9112. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9113. //row["cost"] = item.SubTotal;
  9114. //row["costRMB"] = rbmPrice;
  9115. dtdac2.Rows.Add(row);
  9116. place.Add(item.Place);
  9117. //dac2totalPrice += rbmPrice;
  9118. }
  9119. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9120. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9121. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9122. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9123. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9124. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9125. string cell4Str1 = string.Empty;
  9126. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9127. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9128. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9129. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9130. string cellStr = $" 5.其他费用(";
  9131. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9132. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9133. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9134. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9135. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9136. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9137. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9138. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9139. foreach (var otherInfo in dac5)
  9140. {
  9141. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9142. }
  9143. #endregion
  9144. if (cellStr.Length > 8)
  9145. {
  9146. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9147. }
  9148. cellStr += ")";
  9149. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9150. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9151. decimal pxFee = dac4.Sum(it => it.Cost);
  9152. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9153. string celllastStr1 = "";
  9154. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9155. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9156. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9157. celllastStr1 += $",国际旅费 元";
  9158. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9159. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9160. designer.SetDataSource("cell4Str", cell4Str);
  9161. designer.SetDataSource("cellStr", cellStr);
  9162. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9163. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9164. designer.SetDataSource("celllastStr", celllastStr);
  9165. Workbook wb = designer.Workbook;
  9166. var sheet = wb.Worksheets[0];
  9167. //绑定datatable数据集
  9168. designer.SetDataSource(dtdac1);
  9169. designer.SetDataSource(dtdac2);
  9170. designer.Process();
  9171. var rowStart = dtdac1.Rows.Count;
  9172. while (rowStart > 0)
  9173. {
  9174. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9175. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9176. startIndex++;
  9177. rowStart--;
  9178. }
  9179. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9180. startIndex += 1; //总计行
  9181. rowStart = dtdac2.Rows.Count;
  9182. while (rowStart > 0)
  9183. {
  9184. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9185. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9186. startIndex++;
  9187. rowStart--;
  9188. }
  9189. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9190. wb.CalculateFormula(true);
  9191. //模板文件名
  9192. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9193. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9194. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9195. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9196. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9197. }
  9198. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9199. {
  9200. //获取模板
  9201. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9202. //载入模板
  9203. Document doc = new Document(tempPath);
  9204. DocumentBuilder builder = new DocumentBuilder(doc);
  9205. Dictionary<string, string> dic = new Dictionary<string, string>();
  9206. dic.Add("GroupName", "-");
  9207. dic.Add("ClientUnit", "-");
  9208. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9209. //string missionLeaderJob = "";//负责人job
  9210. //int groupNumber = 0; //团人数
  9211. dic.Add("MissionLeader", "-"); //团负责人
  9212. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9213. dic.Add("GroupNumber", "0"); //团人数
  9214. dic.Add("Day", "0");
  9215. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9216. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9217. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9218. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9219. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9220. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9221. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9222. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9223. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9224. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9225. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9226. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9227. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9228. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9229. //其他费用
  9230. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9231. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9232. //其他费用合计
  9233. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9234. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9235. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9236. //公务舱合计
  9237. //国际旅费
  9238. //string outsideJJ = "";
  9239. //string allPriceJJ = "";
  9240. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9241. {
  9242. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9243. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9244. }
  9245. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9246. {
  9247. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9248. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9249. }
  9250. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9251. {
  9252. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9253. dic.Add("AirFeeTotal", airFeeTotalStr);
  9254. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9255. dic.Add("FeeTotal", feeTotalStr);
  9256. }
  9257. foreach (var key in dic.Keys)
  9258. {
  9259. builder.MoveToBookmark(key);
  9260. builder.Write(dic[key]);
  9261. }
  9262. //模板文件名
  9263. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9264. strFileName = CommonFun.ValidFileName(strFileName);
  9265. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9266. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9267. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9268. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9269. }
  9270. }
  9271. else if (dto.ExportType == 2) //表格
  9272. {
  9273. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9274. }
  9275. else if (dto.ExportType == 3)
  9276. {
  9277. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9278. }
  9279. return Ok(JsonView(400, "只可导出明细表!", ""));
  9280. }
  9281. catch (Exception ex)
  9282. {
  9283. return Ok(JsonView(400, ex.Message, ""));
  9284. }
  9285. }
  9286. /// <summary>
  9287. /// 获取三公费用标准city
  9288. /// </summary>
  9289. /// <param name="placeData"></param>
  9290. /// <param name="nationalTravelFeeId"></param>
  9291. /// <returns></returns>
  9292. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9293. {
  9294. string _city = string.Empty;
  9295. if (!placeData.Any()) return _city;
  9296. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9297. if (data == null) return _city;
  9298. string country = data.Country;
  9299. string city = data.City;
  9300. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9301. else _city = city;
  9302. return _city;
  9303. }
  9304. /// <summary>
  9305. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9306. /// </summary>
  9307. /// <returns></returns>
  9308. [HttpPost]
  9309. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9311. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9312. {
  9313. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9314. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9315. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9316. if (_view.Code == 0)
  9317. {
  9318. return Ok(JsonView(true, "操作成功"));
  9319. }
  9320. return Ok(JsonView(false, "操作失败"));
  9321. }
  9322. /// <summary>
  9323. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9324. /// </summary>
  9325. /// <returns></returns>
  9326. [HttpPost]
  9327. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9329. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9330. {
  9331. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9332. if (data.Code != 0)
  9333. {
  9334. return Ok(JsonView(false, data.Msg));
  9335. }
  9336. return Ok(JsonView(true, "操作成功!", data.Data));
  9337. }
  9338. /// <summary>
  9339. /// 三公其他费用草稿 删除
  9340. /// </summary>
  9341. /// <param name="dto"></param>
  9342. /// <returns></returns>
  9343. [HttpPost]
  9344. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9345. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9346. {
  9347. var jw = JsonView(false, "删除失败!");
  9348. var data = new Grp_DayOtherPriceDraft()
  9349. {
  9350. Id = dto.Id,
  9351. IsDel = 1,
  9352. DeleteUserId = dto.DeleteUserId,
  9353. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9354. };
  9355. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9356. if (del > 0)
  9357. {
  9358. jw.Code = 200;
  9359. jw.Msg = "删除成功!";
  9360. }
  9361. return Ok(jw);
  9362. }
  9363. /// <summary>
  9364. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9365. /// </summary>
  9366. /// <returns></returns>
  9367. [HttpPost]
  9368. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9369. {
  9370. var jw = JsonView(false);
  9371. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9372. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9373. jw.Code = StatusCodes.Status200OK;
  9374. jw.Msg = "操作成功!";
  9375. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9376. return Ok(jw);
  9377. }
  9378. /// <summary>
  9379. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9380. /// </summary>
  9381. /// <param name="dto"></param>
  9382. /// <returns></returns>
  9383. [HttpPost]
  9384. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9385. {
  9386. int userId = dto.UserId,
  9387. portId = dto.PortType,
  9388. groupId = dto.GroupId,
  9389. draftId = dto.DraftId;
  9390. _portTypeData.Add(1);
  9391. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9392. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9393. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9394. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9395. _sqlSugar.BeginTran();
  9396. try
  9397. {
  9398. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9399. if (draftDatas == null)
  9400. {
  9401. _sqlSugar.RollbackTran();
  9402. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9403. }
  9404. //验证可覆盖已有数据 两边创建人需为同一人;
  9405. int draftCreateUserId = draftDatas.CreateUserId,
  9406. formalCreateUserId = 0;
  9407. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9408. if (formalData != null)
  9409. {
  9410. formalCreateUserId = formalData.CreateUserId;
  9411. if (draftCreateUserId != formalCreateUserId)
  9412. {
  9413. _sqlSugar.RollbackTran();
  9414. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9415. }
  9416. }
  9417. //默认添加查看、编辑权限(创建人、自己)
  9418. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9419. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9420. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9421. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9422. newExterData.DiId = groupId;
  9423. newExterData.CreateUserId = userId;
  9424. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9425. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9426. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9427. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9428. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9429. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9430. //数据如果存在执行删除
  9431. if (enterExitCostInfo != null)
  9432. {
  9433. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9434. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9435. .Where(x => x.Id == enterExitCostInfo.Id)
  9436. .ExecuteCommand();
  9437. _sqlSugar.Updateable<Grp_DayAndCost>()
  9438. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9439. .Where(x => x.DiId == groupId)
  9440. .ExecuteCommand();
  9441. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9442. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9443. .Where(x => x.Diid == groupId)
  9444. .ExecuteCommand();
  9445. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9446. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9447. .Where(x => x.GroupId == groupId)
  9448. .ExecuteCommand();
  9449. }
  9450. //执行insert
  9451. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9452. if (insertId < 1)
  9453. {
  9454. _sqlSugar.RollbackTran();
  9455. return Ok(JsonView(false, "草稿数据导入失败!"));
  9456. }
  9457. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9458. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9459. #region 默认添加权限
  9460. #endregion
  9461. _sqlSugar.CommitTran();
  9462. //执行操作之后
  9463. //生成默认文件pdf并且通知人员
  9464. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9465. {
  9466. DiId = groupId,
  9467. ExportType = 1,
  9468. SubTypeId = 1005
  9469. }, "pdf");
  9470. //发送通知
  9471. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9472. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9473. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9474. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9475. //汇率信息记录
  9476. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9477. return Ok(JsonView(true));
  9478. }
  9479. catch (Exception ex)
  9480. {
  9481. _sqlSugar.RollbackTran();
  9482. return Ok(JsonView(false, ex.Message));
  9483. }
  9484. }
  9485. #endregion
  9486. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9487. /// <summary>
  9488. /// 获取币种基础数据(含逻辑处理)
  9489. /// </summary>
  9490. /// <returns></returns>
  9491. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9492. {
  9493. return await GeneralMethod.EnterExitCostInitRate();
  9494. }
  9495. /// <summary>
  9496. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9497. /// </summary>
  9498. /// <returns></returns>
  9499. [HttpPost]
  9500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9501. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9502. {
  9503. //验证城市归属并给默认值
  9504. int provinceId = dto.ProvinceId;
  9505. if (provinceId < 1) provinceId = 122;
  9506. var dataSource = await _sqlSugar
  9507. .Queryable<Sys_SetData>()
  9508. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9509. .ToListAsync();
  9510. var fileTypes = new List<EecSetDataInfoView>();
  9511. //三公费用-Word明细类型
  9512. var wordTypeData = dataSource
  9513. .Where(it => it.STid == 72)
  9514. .Select(x => new EecSetDataInfoView
  9515. {
  9516. ParentId = 1,
  9517. Id = x.Id,
  9518. Name = x.Name
  9519. })
  9520. .ToArray();
  9521. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9522. var excelTypeData = dataSource
  9523. .Where(it => it.STid == 73)
  9524. .Select(x => new EecSetDataInfoView
  9525. {
  9526. ParentId = 2,
  9527. Id = x.Id,
  9528. Name = x.Name
  9529. })
  9530. .ToArray();
  9531. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9532. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9533. fileTypes.Add(groupNameList);
  9534. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9535. //默认币种显示
  9536. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9537. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9538. return Ok(JsonView(true, "查询成功!", new
  9539. {
  9540. FileTypeData = fileTypes,
  9541. CurrencyInit = _currencyInfos,
  9542. viewPermissionData = viewPermissionData
  9543. }));
  9544. }
  9545. /// <summary>
  9546. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9547. /// </summary>
  9548. /// <returns></returns>
  9549. [HttpPost]
  9550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9551. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9552. {
  9553. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9554. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9555. RefAsync<int> total = 0;
  9556. int diId = 0;
  9557. var status = int.TryParse(dto.GroupName, out diId);
  9558. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9559. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9560. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9561. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9562. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9563. .OrderByDescending(x => x.VisitStartDate)
  9564. .Select(x => new EnterExitCostMobileGroupView()
  9565. {
  9566. Id = x.Id,
  9567. GroupName = x.TeamName,
  9568. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9569. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9570. ProvinceId = x.CityId
  9571. })
  9572. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9573. //处理省份Id
  9574. if (data.Any())
  9575. {
  9576. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9577. if (provCityDatas.Any())
  9578. {
  9579. foreach (var item in data)
  9580. {
  9581. var provinceId = item.ProvinceId;
  9582. var isDefualtVal = true;
  9583. if (provinceId > 0)
  9584. {
  9585. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9586. if (parentId != null)
  9587. {
  9588. isDefualtVal = false;
  9589. item.ProvinceId = (int)parentId;
  9590. }
  9591. }
  9592. if (isDefualtVal)
  9593. {
  9594. item.ProvinceId = 122; //默认四川
  9595. }
  9596. }
  9597. }
  9598. }
  9599. //处理是否显示
  9600. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9601. {
  9602. foreach (var item in data)
  9603. {
  9604. item.IsView = true;
  9605. }
  9606. }
  9607. return Ok(JsonView(true, "查询成功!", data, total));
  9608. }
  9609. /// <summary>
  9610. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9611. /// </summary>
  9612. /// <returns></returns>
  9613. [HttpPost]
  9614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9615. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9616. {
  9617. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9618. RefAsync<int> total = 0;
  9619. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9620. .Where(x => x.IsDel == 0 && x.STid == 66)
  9621. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9622. .Select(x => new
  9623. {
  9624. id = x.Id,
  9625. name = x.Name,
  9626. remark = x.Remark,
  9627. })
  9628. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9629. return Ok(JsonView(true, "查询成功!", data, total));
  9630. }
  9631. /// <summary>
  9632. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9633. /// </summary>
  9634. /// <returns></returns>
  9635. [HttpPost]
  9636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9637. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9638. {
  9639. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9640. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9641. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9642. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9643. var groupOtherRateData = groupRateData.TeamRates;
  9644. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9645. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9646. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9647. groupOtherRateData = groupOtherRateData
  9648. .Select(x => new TeamRateDescAddCurrencyIdView
  9649. {
  9650. CurrencyId = x.CurrencyId,
  9651. CurrencyName = x.CurrencyName,
  9652. CurrencyCode = x.CurrencyCode,
  9653. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9654. }).ToList();
  9655. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9656. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9657. }
  9658. /// <summary>
  9659. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9660. /// </summary>
  9661. /// <returns></returns>
  9662. [HttpPost]
  9663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9664. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9665. {
  9666. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9667. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9668. var tipsData = new List<int>() { 1, 2, 3 };
  9669. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9670. if (dto.TipsType == 1)
  9671. {
  9672. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9673. }
  9674. else if (dto.TipsType == 2)
  9675. {
  9676. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9677. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9678. }
  9679. else if (dto.TipsType == 3)
  9680. {
  9681. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9682. return Ok(JsonView(true, "查询成功!", airData));
  9683. }
  9684. return Ok(JsonView(false));
  9685. }
  9686. /// <summary>
  9687. /// 团组模块 - 出入境国家费用标准-移动端 List
  9688. /// </summary>
  9689. /// <returns></returns>
  9690. [HttpPost]
  9691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9692. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9693. {
  9694. Stopwatch sw = new Stopwatch();
  9695. sw.Start();
  9696. int provinceId = dto.ProvinceId;
  9697. if (provinceId < 1) provinceId = 122; // 默认四川
  9698. RefAsync<int> total = 0;
  9699. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9700. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9701. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9702. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9703. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9704. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9705. .Select((ntf, sd, u, sd1) => new
  9706. {
  9707. Id = ntf.Id,
  9708. Area = $"{ntf.Country}-{ntf.City}",
  9709. Currency = ntf.Currency,
  9710. CurrencyCode = sd.Name,
  9711. CurrencyName = sd.Remark,
  9712. RoomCost = ntf.RoomCost,
  9713. FoodCost = ntf.FoodCost,
  9714. PublicCost = ntf.PublicCost,
  9715. TrainCost = ntf.TrainCost,
  9716. LastUpdateUserId = ntf.LastUpdateUserId,
  9717. LastUpdateUserName = u.CnName,
  9718. LastUpdateTime = ntf.LastUpdateTime
  9719. })
  9720. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9721. sw.Stop();
  9722. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9723. }
  9724. /// <summary>
  9725. /// 团组模块 - 出入境费用-移动端 - Info
  9726. /// </summary>
  9727. /// <returns></returns>
  9728. [HttpPost]
  9729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9730. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9731. {
  9732. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9733. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9734. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9735. return Ok(data);
  9736. }
  9737. /// <summary>
  9738. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9739. /// </summary>
  9740. /// <returns></returns>
  9741. [HttpPost]
  9742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9743. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9744. {
  9745. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9746. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9747. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9748. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9749. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9750. mobileInfo.DiId = dto.DiId;
  9751. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9752. if (eecInfo == null) return Ok(mobileInfo);
  9753. //验证查看权限
  9754. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9755. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9756. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9757. mobileInfo.IsAssignPerm = isSet;
  9758. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9759. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9760. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9761. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9762. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9763. {
  9764. SubId = dac.Id,
  9765. DiId = dac.DiId,
  9766. Type = dac.Type,
  9767. Days = dac.Days,
  9768. NationalTravelFeeId = dac.NationalTravelFeeId,
  9769. Arae = $"{ntf.Country}-{ntf.City}",
  9770. Cost = dac.Cost,
  9771. Currency = dac.Currency,
  9772. CurrencyName = sd.Name,
  9773. SubTotal = dac.SubTotal,
  9774. })
  9775. .ToList();
  9776. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9777. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9778. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9779. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9780. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9781. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9782. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9783. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9784. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9785. //其他款项
  9786. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9787. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9788. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9789. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9790. .OrderBy((dop, sd1, sd2) => dop.Index)
  9791. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9792. {
  9793. SubId = dop.Id,
  9794. DiId = dop.Diid,
  9795. Index = dop.Index,
  9796. SetDataId = dop.SetDataId,
  9797. SetDataName = sd1.Name,
  9798. Cost = dop.Cost,
  9799. Currency = dop.Currency,
  9800. CurrencyName = sd2.Remark,
  9801. SubTotal = dop.SubTotal,
  9802. Remark = dop.Remark,
  9803. })
  9804. .ToArray();
  9805. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9806. return Ok(mobileInfo);
  9807. }
  9808. /// <summary>
  9809. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9810. /// </summary>
  9811. /// <returns></returns>
  9812. [HttpPost]
  9813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9814. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9815. {
  9816. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9817. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9818. //验证查看权限
  9819. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9820. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9821. var userIds = await _sqlSugar
  9822. .Queryable<Grp_EnterExitCostPermission>()
  9823. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9824. .Select(x => x.UserId)
  9825. .ToArrayAsync();
  9826. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9827. var perUsersView = new List<dynamic>();
  9828. foreach (var item in perUsers)
  9829. {
  9830. bool isView1 = false;
  9831. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9832. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9833. }
  9834. return Ok(JsonView(perUsersView));
  9835. }
  9836. /// <summary>
  9837. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9838. /// </summary>
  9839. /// <returns></returns>
  9840. [HttpPost]
  9841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9842. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9843. {
  9844. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9845. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9846. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9847. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9848. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9849. //验证查看权限
  9850. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9851. //if (!isView) return Ok(JsonView(false, msg));
  9852. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9853. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9854. var subType = dto.SubType;
  9855. if (subType == 1) //1:境内费用
  9856. {
  9857. var oneData = new ChoiceOneMobileSubInfoView()
  9858. {
  9859. Id = eecInfo.Id,
  9860. ChoiceOne = eecInfo.ChoiceOne,
  9861. ChoiceOneTotalCost = eecInfo.InsidePay,
  9862. Visa = eecInfo.Visa,
  9863. VisaRemark = eecInfo.VisaRemark,
  9864. YiMiao = eecInfo.YiMiao,
  9865. HeSuan = eecInfo.HeSuan,
  9866. Service = eecInfo.Service,
  9867. Ticket = eecInfo.Ticket,
  9868. Safe = eecInfo.Safe,
  9869. FirstItemRemark = eecInfo.FirstItemRemark
  9870. };
  9871. return Ok(JsonView(oneData));
  9872. }
  9873. else if (subType == 2) //2:国际旅费
  9874. {
  9875. var twoData = new ChoiceTwoMobileSubInfoView()
  9876. {
  9877. Id = eecInfo.Id,
  9878. ChoiceTwoJJ = eecInfo.SumJJC,
  9879. OutsideJJPay = eecInfo.OutsideJJPay,
  9880. ChoiceTwoGW = eecInfo.SumGWC,
  9881. OutsideGWPay = eecInfo.OutsideGWPay,
  9882. ChoiceTwoTD = eecInfo.SumTDC,
  9883. OutsideTDPay = eecInfo.OutsideTDPay,
  9884. AirJJ = eecInfo.AirJJ,
  9885. AirGW = eecInfo.AirGW,
  9886. AirTD = eecInfo.AirTD,
  9887. CityTranffic = eecInfo.CityTranffic,
  9888. TwoItemRemark = eecInfo.TwoItemRemark
  9889. };
  9890. return Ok(JsonView(twoData));
  9891. }
  9892. else if (subType == 3) //3:住宿费
  9893. {
  9894. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9895. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9896. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9897. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9898. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9899. {
  9900. SubId = dac.Id,
  9901. DiId = dac.DiId,
  9902. Type = dac.Type,
  9903. Days = dac.Days,
  9904. NationalTravelFeeId = dac.NationalTravelFeeId,
  9905. Arae = $"{ntf.Country}-{ntf.City}",
  9906. Cost = dac.Cost,
  9907. Currency = dac.Currency,
  9908. CurrencyName = sd.Name,
  9909. SubTotal = dac.SubTotal,
  9910. })
  9911. .ToArray();
  9912. var data = new ChoiceMobileSubInfo3To6View()
  9913. {
  9914. ParentId = eecInfo.Id,
  9915. Choice = eecInfo.ChoiceThree,
  9916. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9917. Details = dayAndCostDatas
  9918. };
  9919. return Ok(JsonView(data));
  9920. }
  9921. else if (subType == 4) //4:伙食费
  9922. {
  9923. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9924. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9925. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9926. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9927. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9928. {
  9929. SubId = dac.Id,
  9930. DiId = dac.DiId,
  9931. Type = dac.Type,
  9932. Days = dac.Days,
  9933. NationalTravelFeeId = dac.NationalTravelFeeId,
  9934. Arae = $"{ntf.Country}-{ntf.City}",
  9935. Cost = dac.Cost,
  9936. Currency = dac.Currency,
  9937. CurrencyName = sd.Name,
  9938. SubTotal = dac.SubTotal,
  9939. })
  9940. .ToArray();
  9941. var data = new ChoiceMobileSubInfo3To6View()
  9942. {
  9943. ParentId = eecInfo.Id,
  9944. Choice = eecInfo.ChoiceFour,
  9945. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9946. Details = dayAndCostDatas
  9947. };
  9948. return Ok(JsonView(data));
  9949. }
  9950. else if (subType == 5) //5:公杂费
  9951. {
  9952. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9953. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9954. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9955. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9956. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9957. {
  9958. SubId = dac.Id,
  9959. DiId = dac.DiId,
  9960. Type = dac.Type,
  9961. Days = dac.Days,
  9962. NationalTravelFeeId = dac.NationalTravelFeeId,
  9963. Arae = $"{ntf.Country}-{ntf.City}",
  9964. Cost = dac.Cost,
  9965. Currency = dac.Currency,
  9966. CurrencyName = sd.Name,
  9967. SubTotal = dac.SubTotal,
  9968. })
  9969. .ToArray();
  9970. var data = new ChoiceMobileSubInfo3To6View()
  9971. {
  9972. ParentId = eecInfo.Id,
  9973. Choice = eecInfo.ChoiceFive,
  9974. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9975. Details = dayAndCostDatas
  9976. };
  9977. return Ok(JsonView(data));
  9978. }
  9979. else if (subType == 6) //6:培训费
  9980. {
  9981. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9982. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9983. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9984. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9985. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9986. {
  9987. SubId = dac.Id,
  9988. DiId = dac.DiId,
  9989. Type = dac.Type,
  9990. Days = dac.Days,
  9991. NationalTravelFeeId = dac.NationalTravelFeeId,
  9992. Arae = $"{ntf.Country}-{ntf.City}",
  9993. Cost = dac.Cost,
  9994. Currency = dac.Currency,
  9995. CurrencyName = sd.Name,
  9996. SubTotal = dac.SubTotal,
  9997. })
  9998. .ToArray();
  9999. var data = new ChoiceMobileSubInfo3To6View()
  10000. {
  10001. ParentId = eecInfo.Id,
  10002. Choice = eecInfo.ChoiceSix,
  10003. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10004. Details = dayAndCostDatas
  10005. };
  10006. return Ok(JsonView(data));
  10007. }
  10008. else if (subType == 7) //7:其他
  10009. {
  10010. //其他款项
  10011. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10012. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10013. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10014. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10015. .OrderBy((dop, sd1, sd2) => dop.Index)
  10016. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10017. {
  10018. SubId = dop.Id,
  10019. DiId = dop.Diid,
  10020. Index = dop.Index,
  10021. SetDataId = dop.SetDataId,
  10022. SetDataName = sd1.Name,
  10023. Cost = dop.Cost,
  10024. Currency = dop.Currency,
  10025. CurrencyName = sd2.Name,
  10026. SubTotal = dop.SubTotal,
  10027. Remark = dop.Remark,
  10028. })
  10029. .ToArray();
  10030. var data = new ChoiceSevenMobileSubInfoView()
  10031. {
  10032. ParentId = eecInfo.Id,
  10033. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10034. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10035. Details = otherData
  10036. };
  10037. return Ok(JsonView(data));
  10038. }
  10039. return Ok(JsonView(false));
  10040. }
  10041. #region op
  10042. ///// <summary>
  10043. ///// 移动端更新费用消息通知
  10044. ///// </summary>
  10045. ///// <param name="diid"></param>
  10046. ///// <param name="id"></param>
  10047. ///// <param name="currUserId"></param>
  10048. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10049. //{
  10050. // try
  10051. // {
  10052. // ////生成默认文件pdf并且通知人员
  10053. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10054. // //{
  10055. // // DiId = diid,
  10056. // // ExportType = 1,
  10057. // // SubTypeId = 1005
  10058. // //}, "pdf");
  10059. // ////发送通知
  10060. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10061. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10062. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10063. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10064. // ////汇率信息记录
  10065. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10066. // }
  10067. // catch (Exception ex)
  10068. // {
  10069. // //记录日志
  10070. // throw;
  10071. // }
  10072. //}
  10073. /// <summary>
  10074. /// 验证出入境费用数据是否存在
  10075. /// 不存在添加
  10076. /// </summary>
  10077. /// <param name="diId"></param>
  10078. /// <param name="currUserId"></param>
  10079. /// <returns></returns>
  10080. /// <exception cref="CustomException"></exception>
  10081. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10082. {
  10083. var parentId = 0;
  10084. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10085. if (info != null)
  10086. {
  10087. parentId = info.Id;
  10088. }
  10089. else
  10090. {
  10091. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10092. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10093. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10094. parentId = addId;
  10095. }
  10096. return parentId;
  10097. }
  10098. /// <summary>
  10099. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10100. /// </summary>
  10101. /// <returns></returns>
  10102. [HttpPost]
  10103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10104. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10105. {
  10106. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10107. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10108. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10109. //验证编辑权限
  10110. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10111. //if (!isEdit) return Ok(JsonView(false, msg));
  10112. var permissions = new List<Grp_EnterExitCostPermission>();
  10113. foreach (var userId in dto.UserIds)
  10114. {
  10115. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10116. }
  10117. if (permissions.Any())
  10118. {
  10119. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10120. {
  10121. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10122. }
  10123. _sqlSugar.BeginTran();
  10124. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10125. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10126. if (result < 1)
  10127. {
  10128. _sqlSugar.RollbackTran();
  10129. return Ok(JsonView(false));
  10130. }
  10131. _sqlSugar.CommitTran();
  10132. return Ok(JsonView(true));
  10133. }
  10134. return Ok(JsonView(false));
  10135. }
  10136. /// <summary>
  10137. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10138. /// </summary>
  10139. /// <returns></returns>
  10140. [HttpPost]
  10141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10142. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10143. {
  10144. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10145. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10146. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10147. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10148. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10149. int id = dto.Id;
  10150. if (id <= 0) //add
  10151. {
  10152. //int provinceId = dto.ProvinceId;
  10153. int groupId = dto.DiId;
  10154. //if (provinceId < 1) provinceId = 122;
  10155. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10156. info.LastUpdateUserId = dto.CurrUserId;
  10157. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10158. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10159. if (add < 1) return Ok(JsonView(false));
  10160. id = add;
  10161. }
  10162. else //update
  10163. {
  10164. ////验证编辑权限
  10165. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10166. //if (!isEdit) return Ok(JsonView(false, msg));
  10167. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  10168. {
  10169. CurrencyRemark = currencyStr,
  10170. LastUpdateUserId = dto.CurrUserId,
  10171. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10172. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10173. if (upd < 1) return Ok(JsonView(false));
  10174. }
  10175. #region 汇率变更时更改币种相关费用
  10176. var opDayCosts = new List<Grp_DayAndCost>();
  10177. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10178. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10179. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10180. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10181. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10182. .Select((dac, sd) => new
  10183. {
  10184. dac.Id,
  10185. dac.DiId,
  10186. CurrencyCode = sd.Name,
  10187. dac.Cost
  10188. })
  10189. .ToList();
  10190. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10191. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10192. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10193. .Select((dop, sd) => new
  10194. {
  10195. dop.Id,
  10196. dop.Diid,
  10197. CurrencyCode = sd.Name,
  10198. dop.Cost
  10199. })
  10200. .ToList();
  10201. if (dayCosts.Count > 0)
  10202. {
  10203. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10204. foreach (var dc in new_dayCosts)
  10205. {
  10206. var thisCurrency = dc.Key.ToUpper();
  10207. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10208. if (thisRate == 0.00M) continue;
  10209. foreach (var dcSub in dc)
  10210. {
  10211. opDayCosts.Add(new Grp_DayAndCost()
  10212. {
  10213. Id = dcSub.Id,
  10214. DiId = dcSub.DiId,
  10215. Cost = dcSub.Cost,
  10216. SubTotal = dcSub.Cost * thisRate,
  10217. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10218. });
  10219. }
  10220. }
  10221. if (opDayCosts.Count > 0)
  10222. {
  10223. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10224. }
  10225. }
  10226. if (dayOtherCosts.Count > 0)
  10227. {
  10228. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10229. foreach (var dc in new_dayOtherCosts)
  10230. {
  10231. var thisCurrency = dc.Key.ToUpper();
  10232. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10233. if (thisRate == 0.00M) continue;
  10234. foreach (var dcSub in dc)
  10235. {
  10236. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10237. {
  10238. Id = dcSub.Id,
  10239. Diid = dcSub.Diid,
  10240. Cost = dcSub.Cost,
  10241. SubTotal = dcSub.Cost * thisRate,
  10242. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10243. });
  10244. }
  10245. }
  10246. if (opDayOtherCosts.Count > 0)
  10247. {
  10248. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10249. }
  10250. }
  10251. #endregion
  10252. //消息通知
  10253. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10254. //汇率信息记录
  10255. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10256. return Ok(JsonView(new { parentId = id }));
  10257. }
  10258. /// <summary>
  10259. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10260. /// </summary>
  10261. /// <returns></returns>
  10262. [HttpPost]
  10263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10264. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10265. {
  10266. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10267. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10268. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10269. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10270. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10271. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  10272. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10273. int id = dto.Id;
  10274. if (id <= 0) //add
  10275. {
  10276. checkboxInfo.CreateUserId = dto.CurrUserId;
  10277. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10278. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10279. if (add < 1) return Ok(JsonView(false));
  10280. }
  10281. else //update
  10282. {
  10283. ////验证编辑权限
  10284. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10285. //if (!isEdit) return Ok(JsonView(false, msg));
  10286. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10287. .UpdateColumns(x => new
  10288. {
  10289. x.ChoiceOne,
  10290. x.ChoiceTwo,
  10291. x.SumJJC,
  10292. x.SumGWC,
  10293. x.SumTDC,
  10294. x.ChoiceThree,
  10295. x.ChoiceFour,
  10296. x.ChoiceFive,
  10297. x.ChoiceSix,
  10298. x.OtherExpenses_Checked
  10299. })
  10300. .Where(x => x.Id == id)
  10301. .ExecuteCommandAsync();
  10302. if (upd < 1) return Ok(JsonView(false));
  10303. }
  10304. return Ok(JsonView(new { parentId = id }));
  10305. }
  10306. /// <summary>
  10307. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10308. /// </summary>
  10309. /// <returns></returns>
  10310. [HttpPost]
  10311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10312. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10313. {
  10314. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10315. // if (provinceId < 1) provinceId = 122;
  10316. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10317. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10318. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10319. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10320. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10321. var checkboxInfo = new Grp_EnterExitCost()
  10322. {
  10323. Id = id,
  10324. //ProvinceId = provinceId,
  10325. DiId = diId,
  10326. CreateUserId = currUserId,
  10327. LastUpdateUserId = dto.CurrUserId,
  10328. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10329. };
  10330. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10331. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10332. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10333. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10334. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10335. if (id <= 0) //add
  10336. {
  10337. checkboxInfo.CreateUserId = dto.CurrUserId;
  10338. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10339. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10340. if (add < 1) return Ok(JsonView(false));
  10341. }
  10342. else //update
  10343. {
  10344. ////验证编辑权限
  10345. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10346. //if (!isEdit) return Ok(JsonView(false, msg));
  10347. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10348. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  10349. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  10350. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10351. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10352. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10353. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10354. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10355. .Where(x => x.Id == id)
  10356. .ExecuteCommandAsync();
  10357. if (upd < 1) return Ok(JsonView(false));
  10358. }
  10359. return Ok(JsonView(new { parentId = id }));
  10360. }
  10361. /// <summary>
  10362. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10363. /// </summary>
  10364. /// <returns></returns>
  10365. [HttpPost]
  10366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10367. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10368. {
  10369. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10370. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10371. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10372. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10373. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10374. info.FirstItemRemark = dto.FirstItemRemark;
  10375. info.LastUpdateUserId = dto.CurrUserId;
  10376. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10377. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10378. int id = dto.Id;
  10379. if (id <= 0) //add
  10380. {
  10381. info.CreateUserId = dto.CurrUserId;
  10382. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10383. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10384. if (add < 1) return Ok(JsonView(false));
  10385. id = add;
  10386. }
  10387. else //update
  10388. {
  10389. ////验证编辑权限
  10390. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10391. //if (!isEdit) return Ok(JsonView(false, msg));
  10392. var upd = await _sqlSugar.Updateable(info)
  10393. .UpdateColumns(x => new
  10394. {
  10395. x.ChoiceOne,
  10396. x.InsidePay,
  10397. x.VisaRemark,
  10398. x.Visa,
  10399. x.Service,
  10400. x.Safe,
  10401. x.Ticket,
  10402. x.HeSuan,
  10403. x.YiMiao,
  10404. x.FirstItemRemark,
  10405. x.LastUpdateUserId,
  10406. x.LastUpdateTime
  10407. })
  10408. .Where(x => x.Id == id)
  10409. .ExecuteCommandAsync();
  10410. if (upd < 1) return Ok(JsonView(false));
  10411. }
  10412. //消息通知
  10413. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10414. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10415. }
  10416. /// <summary>
  10417. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10418. /// </summary>
  10419. /// <returns></returns>
  10420. [HttpPost]
  10421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10422. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10423. {
  10424. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10425. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10426. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10427. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10428. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10429. info.DiId = dto.DiId;
  10430. //info.ProvinceId = dto.ProvinceId;
  10431. info.OutsideJJPay = dto.OutsideJJPay;
  10432. info.OutsideGWPay = dto.OutsideGWPay;
  10433. info.OutsideTDPay = dto.OutsideTDPay;
  10434. info.AirJJ = dto.AirJJ;
  10435. info.AirGW = dto.AirGW;
  10436. info.AirTD = dto.AirTD;
  10437. info.CityTranffic = dto.CityTranffic;
  10438. info.TwoItemRemark = dto.TwoItemRemark;
  10439. info.SumJJC = dto.ChoiceTwoJJ;
  10440. info.SumGWC = dto.ChoiceTwoGW;
  10441. info.SumTDC = dto.ChoiceTwoTD;
  10442. info.LastUpdateUserId = dto.CurrUserId;
  10443. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10444. int id = dto.Id;
  10445. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10446. if (id <= 0) //add i
  10447. {
  10448. info.CreateUserId = dto.CurrUserId;
  10449. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10450. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10451. if (addId <= 0) return Ok(JsonView(false));
  10452. id = addId;
  10453. }
  10454. else //update
  10455. {
  10456. ////验证编辑权限
  10457. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10458. //if (!isEdit) return Ok(JsonView(false, msg));
  10459. var upd = await _sqlSugar.Updateable(info)
  10460. .UpdateColumns(x => new
  10461. {
  10462. x.SumJJC,
  10463. x.OutsideJJPay,
  10464. x.SumGWC,
  10465. x.OutsideGWPay,
  10466. x.SumTDC,
  10467. x.OutsideTDPay,
  10468. x.AirJJ,
  10469. x.AirGW,
  10470. x.AirTD,
  10471. x.CityTranffic,
  10472. x.TwoItemRemark,
  10473. x.LastUpdateTime,
  10474. x.LastUpdateUserId
  10475. })
  10476. .Where(x => x.Id == id)
  10477. .ExecuteCommandAsync();
  10478. if (upd < 1) return Ok(JsonView(false));
  10479. }
  10480. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10481. gwcItemTotal = info.AirGW + info.CityTranffic;
  10482. tdcItemTotal = info.AirTD + info.CityTranffic;
  10483. //消息通知
  10484. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10485. return Ok(JsonView(new
  10486. {
  10487. parentId = id,
  10488. choiceTwoJJ = dto.ChoiceTwoJJ,
  10489. jjcItemTotal = jjcItemTotal,
  10490. choiceTwoGW = dto.ChoiceTwoGW,
  10491. gwcItemTotal = gwcItemTotal,
  10492. choiceTwoTD = dto.ChoiceTwoTD,
  10493. tdcItemTotal = tdcItemTotal
  10494. }));
  10495. }
  10496. /// <summary>
  10497. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10498. /// </summary>
  10499. /// <returns></returns>
  10500. [HttpPost]
  10501. [ApiExplorerSettings(IgnoreApi = true)]
  10502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10503. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10504. {
  10505. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10506. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10507. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10508. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10509. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10510. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10511. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10512. var infos = infos1.Select(x => new Grp_DayAndCost
  10513. {
  10514. Id = x.Id,
  10515. DiId = dto.DiId,
  10516. Type = dto.FeeType,
  10517. Days = x.Days,
  10518. NationalTravelFeeId = x.NationalTravelFeeId,
  10519. Cost = x.Cost,
  10520. Currency = x.Currency,
  10521. SubTotal = x.SubTotal,
  10522. CreateUserId = dto.CurrUserId
  10523. })
  10524. .ToList();
  10525. var adds = infos.Where(x => x.Id <= 0).ToList();
  10526. var upds = infos.Where(x => x.Id > 0).ToList();
  10527. if (adds.Count > 0)
  10528. {
  10529. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10530. if (add < 1) return Ok(JsonView(false));
  10531. }
  10532. if (upds.Count > 0)
  10533. {
  10534. var upd = await _sqlSugar.Updateable(adds)
  10535. .UpdateColumns(x => new
  10536. {
  10537. x.Days,
  10538. x.NationalTravelFeeId,
  10539. x.Cost,
  10540. x.Currency,
  10541. x.SubTotal
  10542. })
  10543. .WhereColumns(x => new { x.Id })
  10544. .ExecuteCommandAsync();
  10545. if (upd < 1) return Ok(JsonView(false));
  10546. }
  10547. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10548. //消息通知
  10549. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10550. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10551. return Ok(JsonView(new { itemTotal = itemTotal }));
  10552. }
  10553. /// <summary>
  10554. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10555. /// </summary>
  10556. /// <returns></returns>
  10557. [HttpPost]
  10558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10559. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10560. {
  10561. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10562. int subId = dto.SubId, feeType = dto.FeeType;
  10563. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10564. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10565. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10566. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10567. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10568. subInfo.Id = subId;
  10569. subInfo.DiId = dto.DiId;
  10570. if (feeType == 3) subInfo.Type = 1;
  10571. else if (feeType == 4) subInfo.Type = 2;
  10572. else if (feeType == 5) subInfo.Type = 3;
  10573. else if (feeType == 6) subInfo.Type = 4;
  10574. subInfo.CreateUserId = dto.CurrUserId;
  10575. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10576. if (parentId < 1) return Ok(JsonView(false));
  10577. //子表op
  10578. if (subId < 1)
  10579. {
  10580. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10581. if (subAdd < 1) return Ok(JsonView(false));
  10582. }
  10583. else
  10584. {
  10585. ////验证编辑权限
  10586. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10587. //if (!isEdit) return Ok(JsonView(false, msg));
  10588. var subUpd = await _sqlSugar.Updateable(subInfo)
  10589. .UpdateColumns(x => new
  10590. {
  10591. x.Days,
  10592. x.NationalTravelFeeId,
  10593. x.Cost,
  10594. x.Currency,
  10595. x.SubTotal
  10596. })
  10597. .WhereColumns(x => new { x.Id })
  10598. .ExecuteCommandAsync();
  10599. if (subUpd < 1) return Ok(JsonView(false));
  10600. }
  10601. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10602. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10603. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10604. }
  10605. /// <summary>
  10606. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10607. /// </summary>
  10608. /// <returns></returns>
  10609. [HttpPost]
  10610. [ApiExplorerSettings(IgnoreApi = true)]
  10611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10612. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10613. {
  10614. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10615. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10616. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10617. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10618. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10619. {
  10620. Id = x.Id,
  10621. Diid = dto.DiId,
  10622. SetDataId = x.SetDataId,
  10623. Index = x.Index,
  10624. Cost = x.Cost,
  10625. Currency = x.Currency,
  10626. SubTotal = x.SubTotal,
  10627. CreateUserId = dto.CurrUserId,
  10628. Remark = x.Remark
  10629. }).ToList();
  10630. var adds = infos.Where(x => x.Id <= 0).ToList();
  10631. var upds = infos.Where(x => x.Id > 0).ToList();
  10632. if (adds.Count > 0)
  10633. {
  10634. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10635. if (add < 1) return Ok(JsonView(false));
  10636. }
  10637. if (upds.Count > 0)
  10638. {
  10639. var upd = await _sqlSugar.Updateable(adds)
  10640. .UpdateColumns(x => new
  10641. {
  10642. x.Index,
  10643. x.SetDataId,
  10644. x.Cost,
  10645. x.Currency,
  10646. x.SubTotal,
  10647. x.Remark
  10648. })
  10649. .WhereColumns(x => new { x.Id })
  10650. .ExecuteCommandAsync();
  10651. if (upd < 1) return Ok(JsonView(false));
  10652. }
  10653. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10654. //消息通知
  10655. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10656. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10657. return Ok(JsonView(new { itemTotal = itemTotal }));
  10658. }
  10659. /// <summary>
  10660. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10661. /// </summary>
  10662. /// <returns></returns>
  10663. [HttpPost]
  10664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10665. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10666. {
  10667. int subId = dto.SubId;
  10668. int diId = dto.Diid;
  10669. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10670. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10671. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10672. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10673. subInfo.Id = subId;
  10674. subInfo.Diid = dto.Diid;
  10675. subInfo.CreateUserId = dto.CurrUserId;
  10676. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10677. if (parentId < 1) return Ok(JsonView(false));
  10678. #region 子表op
  10679. if (subId < 1)//add
  10680. {
  10681. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10682. if (subAdd < 1) return Ok(JsonView(false));
  10683. }
  10684. else //upd
  10685. {
  10686. ////验证编辑权限
  10687. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10688. //if (!isEdit) return Ok(JsonView(false, msg));
  10689. var subUpd = await _sqlSugar.Updateable(subInfo)
  10690. .UpdateColumns(x => new
  10691. {
  10692. x.Index,
  10693. x.SetDataId,
  10694. x.Cost,
  10695. x.Currency,
  10696. x.SubTotal,
  10697. x.Remark
  10698. })
  10699. .WhereColumns(x => new { x.Id })
  10700. .ExecuteCommandAsync();
  10701. if (subUpd < 1) return Ok(JsonView(false));
  10702. }
  10703. #endregion
  10704. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10705. //消息通知
  10706. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10707. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10708. }
  10709. /// <summary>
  10710. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10711. /// </summary>
  10712. /// <returns></returns>
  10713. [HttpPost]
  10714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10715. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10716. {
  10717. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10718. if (data.Code != 0)
  10719. {
  10720. return Ok(JsonView(false, data.Msg));
  10721. }
  10722. return Ok(JsonView(true, "操作成功!", data.Data));
  10723. }
  10724. /// <summary>
  10725. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10726. /// </summary>
  10727. /// <param name="dto"></param>
  10728. /// <returns></returns>
  10729. [HttpPost]
  10730. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10731. {
  10732. var data = new Grp_DayOtherPrice()
  10733. {
  10734. Id = dto.Id,
  10735. IsDel = 1,
  10736. DeleteUserId = dto.DeleteUserId,
  10737. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10738. };
  10739. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10740. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10741. return Ok(JsonView(false, "删除失败!"));
  10742. }
  10743. #endregion
  10744. #endregion
  10745. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10746. /// <summary>
  10747. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10748. /// </summary>
  10749. /// <returns></returns>
  10750. [HttpGet]
  10751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10752. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10753. {
  10754. var provData = await _groupRepository.ProvinceBasicSource();
  10755. return Ok(JsonView(true, "查询成功!", provData));
  10756. }
  10757. /// <summary>
  10758. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10759. /// </summary>
  10760. /// <returns></returns>
  10761. [HttpPost]
  10762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10763. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10764. {
  10765. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10766. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10767. RefAsync<int> total = 0;
  10768. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10769. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10770. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10771. .Select(x => new
  10772. {
  10773. Id = x.Id,
  10774. DraftName = x.DraftName,
  10775. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10776. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10777. .Any()
  10778. })
  10779. .OrderByDescending(x => x.Id)
  10780. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10781. return Ok(JsonView(true, "查询成功!", data, total));
  10782. }
  10783. /// <summary>
  10784. /// 出入境费用-草稿 移动端
  10785. /// 获取币种基础数据(含逻辑处理)
  10786. /// </summary>
  10787. /// <returns></returns>
  10788. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10789. {
  10790. return await GeneralMethod.EnterExitCostInitRate();
  10791. }
  10792. /// <summary>
  10793. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10794. /// </summary>
  10795. /// <returns></returns>
  10796. [HttpPost]
  10797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10798. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10799. {
  10800. //验证城市归属并给默认值
  10801. int provinceId = dto.ProvinceId;
  10802. if (provinceId < 1) provinceId = 122;
  10803. var dataSource = await _sqlSugar
  10804. .Queryable<Sys_SetData>()
  10805. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10806. .ToListAsync();
  10807. //三公费用-Word明细类型
  10808. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10809. .Select(x => new SetDataInfoView
  10810. {
  10811. Id = x.Id,
  10812. Name = x.Name,
  10813. Remark = x.Remark
  10814. })
  10815. .ToList();
  10816. //三公费用-Excel明细类型
  10817. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10818. .Select(x => new SetDataInfoView
  10819. {
  10820. Id = x.Id,
  10821. Name = x.Name,
  10822. Remark = x.Remark
  10823. })
  10824. .ToList();
  10825. //默认币种显示
  10826. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10827. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10828. return Ok(JsonView(true, "查询成功!", new
  10829. {
  10830. WordTypeData = wordTypeData,
  10831. ExcelTypeData = excelTypeData,
  10832. CurrencyInit = _currencyInfos,
  10833. viewPermissionData = viewPermissionData
  10834. }));
  10835. }
  10836. /// <summary>
  10837. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10838. /// </summary>
  10839. /// <returns></returns>
  10840. [HttpPost]
  10841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10842. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10843. {
  10844. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10845. RefAsync<int> total = 0;
  10846. int diId = 0;
  10847. var status = int.TryParse(dto.GroupName, out diId);
  10848. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10849. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10850. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10851. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10852. .OrderByDescending(x => x.VisitStartDate)
  10853. .Select(x => new
  10854. {
  10855. Id = x.Id,
  10856. GroupName = x.TeamName
  10857. })
  10858. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10859. return Ok(JsonView(true, "查询成功!", data, total));
  10860. }
  10861. /// <summary>
  10862. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10863. /// </summary>
  10864. /// <returns></returns>
  10865. [HttpPost]
  10866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10867. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10868. {
  10869. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10870. RefAsync<int> total = 0;
  10871. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10872. .Where(x => x.IsDel == 0 && x.STid == 66)
  10873. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10874. .Select(x => new
  10875. {
  10876. id = x.Id,
  10877. name = x.Name,
  10878. remark = x.Remark,
  10879. })
  10880. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10881. return Ok(JsonView(true, "查询成功!", data, total));
  10882. }
  10883. /// <summary>
  10884. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10885. /// </summary>
  10886. /// <returns></returns>
  10887. [HttpPost]
  10888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10889. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10890. {
  10891. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10892. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10893. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10894. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10895. var groupOtherRateData = groupRateData.TeamRates;
  10896. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10897. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10898. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10899. groupOtherRateData = groupOtherRateData
  10900. .Select(x => new TeamRateDescAddCurrencyIdView
  10901. {
  10902. CurrencyId = x.CurrencyId,
  10903. CurrencyName = x.CurrencyName,
  10904. CurrencyCode = x.CurrencyCode,
  10905. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10906. }).ToList();
  10907. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10908. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10909. }
  10910. /// <summary>
  10911. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10912. /// </summary>
  10913. /// <returns></returns>
  10914. [HttpPost]
  10915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10916. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10917. {
  10918. int portType = dto.PortType;
  10919. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10920. var tipsData = new List<int>() { 1, 2, 3 };
  10921. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10922. if (dto.TipsType == 1)
  10923. {
  10924. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10925. }
  10926. else if (dto.TipsType == 2)
  10927. {
  10928. if (portType == 2)
  10929. {
  10930. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10931. }
  10932. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10933. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10934. .Select(x => x.NationalTravelFeeId)
  10935. .Distinct()
  10936. .ToListAsync();
  10937. if (portType == 2)
  10938. {
  10939. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10940. }
  10941. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10942. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10943. .Select(x => x.Country)
  10944. .Distinct()
  10945. .ToArrayAsync();
  10946. if (portType == 2)
  10947. {
  10948. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10949. }
  10950. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10951. return Ok(JsonView(true, "查询成功!", new
  10952. {
  10953. totalAmt = totalAmt,
  10954. remark = remark
  10955. }));
  10956. }
  10957. else if (dto.TipsType == 3)
  10958. {
  10959. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10960. }
  10961. return Ok(JsonView(false));
  10962. }
  10963. /// <summary>
  10964. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10965. /// </summary>
  10966. /// <returns></returns>
  10967. [HttpPost]
  10968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10969. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10970. {
  10971. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10972. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10973. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10974. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10975. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10976. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10977. var info = new Grp_EnterExitCostDraft()
  10978. {
  10979. ProvinceId = dto.ProvinceId,
  10980. DraftName = dto.DraftName,
  10981. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10982. CreateUserId = dto.CurrUserId
  10983. };
  10984. _sqlSugar.BeginTran();
  10985. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10986. if (draftId < 1)
  10987. {
  10988. _sqlSugar.RollbackTran();
  10989. return Ok(JsonView(false, "草稿创建失败!"));
  10990. }
  10991. //添加默认权限
  10992. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10993. _sqlSugar.CommitTran();
  10994. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10995. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10996. mobileInfo.Id = draftId;
  10997. mobileInfo.DraftName = dto.DraftName;
  10998. mobileInfo.Currencys = rateInfos;
  10999. mobileInfo.IsAssignPerm = assignPerm;
  11000. return Ok(JsonView(mobileInfo));
  11001. }
  11002. /// <summary>
  11003. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11004. /// </summary>
  11005. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11006. /// <summary>
  11007. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11008. /// </summary>
  11009. /// <returns></returns>
  11010. [HttpPost]
  11011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11012. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11013. {
  11014. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11015. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11016. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11017. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11018. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11019. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11020. //验证查看编辑权限
  11021. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11022. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11023. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11024. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11025. mobileInfo.IsAssignPerm = assignPerm;
  11026. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11027. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11028. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11029. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11030. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11031. {
  11032. ParentId = dac.ParentId,
  11033. SubId = dac.Id,
  11034. Type = dac.Type,
  11035. Days = dac.Days,
  11036. NationalTravelFeeId = dac.NationalTravelFeeId,
  11037. Arae = $"{ntf.Country}-{ntf.City}",
  11038. Cost = dac.Cost,
  11039. Currency = dac.Currency,
  11040. CurrencyName = sd.Name,
  11041. SubTotal = dac.SubTotal,
  11042. })
  11043. .ToList();
  11044. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11045. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11046. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11047. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11048. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11049. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11050. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11051. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11052. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11053. //其他款项
  11054. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11055. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11056. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11057. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11058. .OrderBy((dop, sd1, sd2) => dop.Index)
  11059. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11060. {
  11061. ParentId = dop.ParentId,
  11062. SubId = dop.Id,
  11063. Index = dop.Index,
  11064. SetDataId = dop.SetDataId,
  11065. SetDataName = sd1.Name,
  11066. Cost = dop.Cost,
  11067. Currency = dop.Currency,
  11068. CurrencyName = sd2.Remark,
  11069. SubTotal = dop.SubTotal,
  11070. Remark = dop.Remark,
  11071. })
  11072. .ToArray();
  11073. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11074. return Ok(mobileInfo);
  11075. }
  11076. /// <summary>
  11077. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11078. /// </summary>
  11079. /// <returns></returns>
  11080. [HttpPost]
  11081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11082. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11083. {
  11084. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11085. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11086. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11087. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11088. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11089. //验证查看编辑权限
  11090. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11091. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11092. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11093. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11094. var subType = dto.SubType;
  11095. if (subType == 1) //1:境内费用
  11096. {
  11097. var oneData = new ChoiceOneMobileSubInfoView()
  11098. {
  11099. Id = eecInfo.Id,
  11100. ChoiceOne = eecInfo.ChoiceOne,
  11101. ChoiceOneTotalCost = eecInfo.InsidePay,
  11102. Visa = eecInfo.Visa,
  11103. VisaRemark = eecInfo.VisaRemark,
  11104. YiMiao = eecInfo.YiMiao,
  11105. HeSuan = eecInfo.HeSuan,
  11106. Service = eecInfo.Service,
  11107. Ticket = eecInfo.Ticket,
  11108. Safe = eecInfo.Safe,
  11109. FirstItemRemark = eecInfo.FirstItemRemark
  11110. };
  11111. return Ok(JsonView(oneData));
  11112. }
  11113. else if (subType == 2) //2:国际旅费
  11114. {
  11115. var twoData = new ChoiceTwoMobileSubInfoView()
  11116. {
  11117. Id = eecInfo.Id,
  11118. ChoiceTwoJJ = eecInfo.SumJJC,
  11119. OutsideJJPay = eecInfo.OutsideJJPay,
  11120. ChoiceTwoGW = eecInfo.SumGWC,
  11121. OutsideGWPay = eecInfo.OutsideGWPay,
  11122. ChoiceTwoTD = eecInfo.SumTDC,
  11123. OutsideTDPay = eecInfo.OutsideTDPay,
  11124. AirJJ = eecInfo.AirJJ,
  11125. AirGW = eecInfo.AirGW,
  11126. AirTD = eecInfo.AirTD,
  11127. CityTranffic = eecInfo.CityTranffic,
  11128. TwoItemRemark = eecInfo.TwoItemRemark
  11129. };
  11130. return Ok(JsonView(twoData));
  11131. }
  11132. else if (subType == 3) //3:住宿费
  11133. {
  11134. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11135. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11136. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11137. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11138. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11139. {
  11140. ParentId = dac.ParentId,
  11141. SubId = dac.Id,
  11142. Type = dac.Type,
  11143. Days = dac.Days,
  11144. NationalTravelFeeId = dac.NationalTravelFeeId,
  11145. Arae = $"{ntf.Country}-{ntf.City}",
  11146. Cost = dac.Cost,
  11147. Currency = dac.Currency,
  11148. CurrencyName = sd.Name,
  11149. SubTotal = dac.SubTotal,
  11150. })
  11151. .ToArray();
  11152. var data = new ChoiceDraftMobileSubInfo3To6View()
  11153. {
  11154. ParentId = eecInfo.Id,
  11155. Choice = eecInfo.ChoiceThree,
  11156. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11157. Details = dayAndCostDatas
  11158. };
  11159. return Ok(JsonView(data));
  11160. }
  11161. else if (subType == 4) //4:伙食费
  11162. {
  11163. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11164. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11165. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11166. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11167. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11168. {
  11169. ParentId = dac.ParentId,
  11170. SubId = dac.Id,
  11171. Type = dac.Type,
  11172. Days = dac.Days,
  11173. NationalTravelFeeId = dac.NationalTravelFeeId,
  11174. Arae = $"{ntf.Country}-{ntf.City}",
  11175. Cost = dac.Cost,
  11176. Currency = dac.Currency,
  11177. CurrencyName = sd.Name,
  11178. SubTotal = dac.SubTotal,
  11179. })
  11180. .ToArray();
  11181. var data = new ChoiceDraftMobileSubInfo3To6View()
  11182. {
  11183. ParentId = eecInfo.Id,
  11184. Choice = eecInfo.ChoiceFour,
  11185. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11186. Details = dayAndCostDatas
  11187. };
  11188. return Ok(JsonView(data));
  11189. }
  11190. else if (subType == 5) //5:公杂费
  11191. {
  11192. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11193. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11194. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11195. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11196. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11197. {
  11198. ParentId = dac.ParentId,
  11199. SubId = dac.Id,
  11200. Type = dac.Type,
  11201. Days = dac.Days,
  11202. NationalTravelFeeId = dac.NationalTravelFeeId,
  11203. Arae = $"{ntf.Country}-{ntf.City}",
  11204. Cost = dac.Cost,
  11205. Currency = dac.Currency,
  11206. CurrencyName = sd.Name,
  11207. SubTotal = dac.SubTotal,
  11208. })
  11209. .ToArray();
  11210. var data = new ChoiceDraftMobileSubInfo3To6View()
  11211. {
  11212. ParentId = eecInfo.Id,
  11213. Choice = eecInfo.ChoiceFive,
  11214. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11215. Details = dayAndCostDatas
  11216. };
  11217. return Ok(JsonView(data));
  11218. }
  11219. else if (subType == 6) //6:培训费
  11220. {
  11221. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11222. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11223. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11224. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11225. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11226. {
  11227. ParentId = dac.ParentId,
  11228. SubId = dac.Id,
  11229. Type = dac.Type,
  11230. Days = dac.Days,
  11231. NationalTravelFeeId = dac.NationalTravelFeeId,
  11232. Arae = $"{ntf.Country}-{ntf.City}",
  11233. Cost = dac.Cost,
  11234. Currency = dac.Currency,
  11235. CurrencyName = sd.Name,
  11236. SubTotal = dac.SubTotal,
  11237. })
  11238. .ToArray();
  11239. var data = new ChoiceDraftMobileSubInfo3To6View()
  11240. {
  11241. ParentId = eecInfo.Id,
  11242. Choice = eecInfo.ChoiceSix,
  11243. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11244. Details = dayAndCostDatas
  11245. };
  11246. return Ok(JsonView(data));
  11247. }
  11248. else if (subType == 7) //7:其他
  11249. {
  11250. //其他款项
  11251. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11252. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11253. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11254. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11255. .OrderBy((dop, sd1, sd2) => dop.Index)
  11256. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11257. {
  11258. ParentId = dop.ParentId,
  11259. SubId = dop.Id,
  11260. Index = dop.Index,
  11261. SetDataId = dop.SetDataId,
  11262. SetDataName = sd1.Name,
  11263. Cost = dop.Cost,
  11264. Currency = dop.Currency,
  11265. CurrencyName = sd2.Name,
  11266. SubTotal = dop.SubTotal,
  11267. Remark = dop.Remark,
  11268. })
  11269. .ToArray();
  11270. var data = new ChoiceSevenDraftMobileSubInfoView()
  11271. {
  11272. ParentId = eecInfo.Id,
  11273. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11274. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11275. Details = otherData
  11276. };
  11277. return Ok(JsonView(data));
  11278. }
  11279. return Ok(JsonView(false));
  11280. }
  11281. #region op
  11282. ///// <summary>
  11283. ///// 移动端更新费用消息通知
  11284. ///// </summary>
  11285. ///// <param name="draftId"></param>
  11286. ///// <param name="id"></param>
  11287. ///// <param name="currUserId"></param>
  11288. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11289. //{
  11290. // try
  11291. // {
  11292. // ////生成默认文件pdf并且通知人员
  11293. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11294. // //{
  11295. // // DiId = draftId,
  11296. // // ExportType = 1,
  11297. // // SubTypeId = 1005
  11298. // //}, "pdf");
  11299. // ////发送通知
  11300. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11301. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11302. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11303. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11304. // ////汇率信息记录
  11305. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11306. // }
  11307. // catch (Exception ex)
  11308. // {
  11309. // //记录日志
  11310. // throw;
  11311. // }
  11312. //}
  11313. /// <summary>
  11314. /// 验证出入境费用数据是否存在
  11315. /// 不存在添加
  11316. /// </summary>
  11317. /// <param name="draftId"></param>
  11318. /// <param name="currUserId"></param>
  11319. /// <returns></returns>
  11320. /// <exception cref="CustomException"></exception>
  11321. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11322. {
  11323. var parentId = 0;
  11324. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11325. if (info != null) parentId = info.Id;
  11326. else
  11327. {
  11328. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11329. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11330. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11331. parentId = addId;
  11332. }
  11333. return parentId;
  11334. }
  11335. /// <summary>
  11336. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11337. /// </summary>
  11338. /// <returns></returns>
  11339. [HttpPost]
  11340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11341. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11342. {
  11343. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11344. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11345. //验证查看权限
  11346. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11347. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11348. var userIds = await _sqlSugar
  11349. .Queryable<Grp_EnterExitCostDraftPermission>()
  11350. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11351. .Select(x => x.UserId)
  11352. .ToArrayAsync();
  11353. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11354. var perUsersView = new List<dynamic>();
  11355. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11356. var viewPermissionData = new List<PermissionViewUserview>();
  11357. if (feeBasePerm.Any())
  11358. {
  11359. foreach (var item in feeBasePerm)
  11360. {
  11361. if (item.Users.Any())
  11362. {
  11363. viewPermissionData.AddRange(item.Users);
  11364. }
  11365. }
  11366. }
  11367. foreach (var item in perUsers)
  11368. {
  11369. bool isView1 = false;
  11370. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11371. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11372. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11373. }
  11374. return Ok(JsonView(perUsersView));
  11375. }
  11376. /// <summary>
  11377. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11378. /// </summary>
  11379. /// <returns></returns>
  11380. [HttpPost]
  11381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11382. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11383. {
  11384. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11385. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11386. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11387. //验证查看编辑权限
  11388. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11389. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11390. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11391. foreach (var userId in dto.UserIds)
  11392. {
  11393. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11394. }
  11395. if (permissions.Any())
  11396. {
  11397. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11398. {
  11399. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11400. }
  11401. _sqlSugar.BeginTran();
  11402. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11403. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11404. if (result < 1)
  11405. {
  11406. _sqlSugar.RollbackTran();
  11407. return Ok(JsonView(false));
  11408. }
  11409. _sqlSugar.CommitTran();
  11410. return Ok(JsonView(true));
  11411. }
  11412. return Ok(JsonView(false));
  11413. }
  11414. /// <summary>
  11415. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11416. /// </summary>
  11417. /// <returns></returns>
  11418. [HttpPost]
  11419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11420. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11421. {
  11422. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11423. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11424. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11425. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11426. int id = dto.DraftId;
  11427. if (id <= 0) //add
  11428. {
  11429. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11430. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11431. if (add < 1) return Ok(JsonView(false));
  11432. id = add;
  11433. }
  11434. else //update
  11435. {
  11436. //验证查看编辑权限
  11437. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11438. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11439. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11440. if (upd < 1) return Ok(JsonView(false));
  11441. }
  11442. return Ok(JsonView(new { parentId = id }));
  11443. }
  11444. /// <summary>
  11445. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11446. /// </summary>
  11447. /// <returns></returns>
  11448. [HttpPost]
  11449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11450. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11451. {
  11452. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11453. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11454. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11455. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11456. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11457. int id = dto.DraftId;
  11458. if (id <= 0) //add
  11459. {
  11460. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11461. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11462. if (add < 1) return Ok(JsonView(false));
  11463. id = add;
  11464. }
  11465. else //update
  11466. {
  11467. //验证查看编辑权限
  11468. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11469. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11470. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11471. if (upd < 1) return Ok(JsonView(false));
  11472. }
  11473. #region 汇率变更时更改币种相关费用
  11474. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11475. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11476. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11477. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11478. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11479. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11480. .Select((dac, sd) => new
  11481. {
  11482. dac.Id,
  11483. dac.ParentId,
  11484. CurrencyCode = sd.Name,
  11485. dac.Cost
  11486. })
  11487. .ToList();
  11488. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11489. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11490. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11491. .Select((dop, sd) => new
  11492. {
  11493. dop.Id,
  11494. dop.ParentId,
  11495. CurrencyCode = sd.Name,
  11496. dop.Cost
  11497. })
  11498. .ToList();
  11499. if (dayCosts.Count > 0)
  11500. {
  11501. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11502. foreach (var dc in new_dayCosts)
  11503. {
  11504. var thisCurrency = dc.Key.ToUpper();
  11505. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11506. if (thisRate == 0.00M) continue;
  11507. foreach (var dcSub in dc)
  11508. {
  11509. opDayCosts.Add(new Grp_DayAndCostDraft()
  11510. {
  11511. Id = dcSub.Id,
  11512. ParentId = dcSub.ParentId,
  11513. Cost = dcSub.Cost,
  11514. SubTotal = dcSub.Cost * thisRate,
  11515. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11516. });
  11517. }
  11518. }
  11519. if (opDayCosts.Count > 0)
  11520. {
  11521. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11522. }
  11523. }
  11524. if (dayOtherCosts.Count > 0)
  11525. {
  11526. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11527. foreach (var dc in new_dayOtherCosts)
  11528. {
  11529. var thisCurrency = dc.Key.ToUpper();
  11530. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11531. if (thisRate == 0.00M) continue;
  11532. foreach (var dcSub in dc)
  11533. {
  11534. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11535. {
  11536. Id = dcSub.Id,
  11537. ParentId = dcSub.ParentId,
  11538. Cost = dcSub.Cost,
  11539. SubTotal = dcSub.Cost * thisRate,
  11540. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11541. });
  11542. }
  11543. }
  11544. if (opDayOtherCosts.Count > 0)
  11545. {
  11546. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11547. }
  11548. }
  11549. #endregion
  11550. ////消息通知
  11551. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11552. ////汇率信息记录
  11553. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11554. return Ok(JsonView(new { parentId = id }));
  11555. }
  11556. /// <summary>
  11557. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11558. /// </summary>
  11559. /// <returns></returns>
  11560. [HttpPost]
  11561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11562. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11563. {
  11564. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11565. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11566. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11567. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11568. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11569. int id = dto.DraftId;
  11570. if (id <= 0) //add
  11571. {
  11572. checkboxInfo.ProvinceId = dto.ProvinceId;
  11573. checkboxInfo.CreateUserId = dto.CurrUserId;
  11574. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11575. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11576. if (add < 1) return Ok(JsonView(false));
  11577. }
  11578. else //update
  11579. {
  11580. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11581. .UpdateColumns(x => new
  11582. {
  11583. x.ChoiceOne,
  11584. x.ChoiceTwo,
  11585. x.SumJJC,
  11586. x.SumGWC,
  11587. x.SumTDC,
  11588. x.ChoiceThree,
  11589. x.ChoiceFour,
  11590. x.ChoiceFive,
  11591. x.ChoiceSix,
  11592. x.OtherExpenses_Checked
  11593. })
  11594. .Where(x => x.Id == id)
  11595. .ExecuteCommandAsync();
  11596. if (upd < 1) return Ok(JsonView(false));
  11597. }
  11598. return Ok(JsonView(new { parentId = id }));
  11599. }
  11600. /// <summary>
  11601. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11602. /// </summary>
  11603. /// <returns></returns>
  11604. [HttpPost]
  11605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11606. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11607. {
  11608. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11609. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11610. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11611. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11612. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11613. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11614. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11615. var checkboxInfo = new Grp_EnterExitCostDraft()
  11616. {
  11617. Id = draftId,
  11618. ProvinceId = dto.ProvinceId,
  11619. CreateUserId = currUserId
  11620. };
  11621. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11622. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11623. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11624. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11625. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11626. if (draftId <= 0) //add
  11627. {
  11628. checkboxInfo.CreateUserId = dto.CurrUserId;
  11629. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11630. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11631. if (add < 1) return Ok(JsonView(false));
  11632. }
  11633. else //update
  11634. {
  11635. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11636. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11637. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11638. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11639. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11640. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11641. .Where(x => x.Id == draftId)
  11642. .ExecuteCommandAsync();
  11643. if (upd < 1) return Ok(JsonView(false));
  11644. }
  11645. return Ok(JsonView(new { parentId = draftId }));
  11646. }
  11647. /// <summary>
  11648. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11649. /// </summary>
  11650. /// <returns></returns>
  11651. [HttpPost]
  11652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11653. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11654. {
  11655. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11656. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11657. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11658. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11659. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11660. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11661. info.ProvinceId = dto.ProvinceId;
  11662. info.FirstItemRemark = dto.FirstItemRemark;
  11663. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11664. if (id <= 0) //add
  11665. {
  11666. info.CreateUserId = dto.CurrUserId;
  11667. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11668. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11669. if (add < 1) return Ok(JsonView(false));
  11670. id = add;
  11671. }
  11672. else //update
  11673. {
  11674. var upd = await _sqlSugar.Updateable(info)
  11675. .UpdateColumns(x => new
  11676. {
  11677. x.ChoiceOne,
  11678. x.InsidePay,
  11679. x.VisaRemark,
  11680. x.Visa,
  11681. x.Service,
  11682. x.Safe,
  11683. x.Ticket,
  11684. x.HeSuan,
  11685. x.YiMiao,
  11686. x.FirstItemRemark
  11687. })
  11688. .Where(x => x.Id == id)
  11689. .ExecuteCommandAsync();
  11690. if (upd < 1) return Ok(JsonView(false));
  11691. }
  11692. ////消息通知
  11693. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11694. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11695. }
  11696. /// <summary>
  11697. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11698. /// </summary>
  11699. /// <returns></returns>
  11700. [HttpPost]
  11701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11702. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11703. {
  11704. int id = dto.DraftId;
  11705. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11706. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11707. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11708. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11709. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11710. info.ProvinceId = dto.ProvinceId;
  11711. info.OutsideJJPay = dto.OutsideJJPay;
  11712. info.OutsideGWPay = dto.OutsideGWPay;
  11713. info.OutsideTDPay = dto.OutsideTDPay;
  11714. info.AirJJ = dto.AirJJ;
  11715. info.AirGW = dto.AirGW;
  11716. info.AirTD = dto.AirTD;
  11717. info.CityTranffic = dto.CityTranffic;
  11718. info.TwoItemRemark = dto.TwoItemRemark;
  11719. info.SumJJC = dto.ChoiceTwoJJ;
  11720. info.SumGWC = dto.ChoiceTwoGW;
  11721. info.SumTDC = dto.ChoiceTwoTD;
  11722. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11723. if (id <= 0) //add
  11724. {
  11725. info.CreateUserId = dto.CurrUserId;
  11726. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11727. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11728. if (addId <= 0) return Ok(JsonView(false));
  11729. id = addId;
  11730. }
  11731. else //update
  11732. {
  11733. var upd = await _sqlSugar.Updateable(info)
  11734. .UpdateColumns(x => new
  11735. {
  11736. x.SumJJC,
  11737. x.OutsideJJPay,
  11738. x.SumGWC,
  11739. x.OutsideGWPay,
  11740. x.SumTDC,
  11741. x.OutsideTDPay,
  11742. x.AirJJ,
  11743. x.AirGW,
  11744. x.AirTD,
  11745. x.CityTranffic,
  11746. x.TwoItemRemark
  11747. })
  11748. .Where(x => x.Id == id)
  11749. .ExecuteCommandAsync();
  11750. if (upd < 1) return Ok(JsonView(false));
  11751. }
  11752. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11753. gwcItemTotal = info.AirGW + info.CityTranffic;
  11754. tdcItemTotal = info.AirTD + info.CityTranffic;
  11755. ////消息通知
  11756. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11757. return Ok(JsonView(new
  11758. {
  11759. parentId = id,
  11760. choiceTwoJJ = dto.ChoiceTwoJJ,
  11761. jjcItemTotal = jjcItemTotal,
  11762. choiceTwoGW = dto.ChoiceTwoGW,
  11763. gwcItemTotal = gwcItemTotal,
  11764. choiceTwoTD = dto.ChoiceTwoTD,
  11765. tdcItemTotal = tdcItemTotal
  11766. }));
  11767. }
  11768. /// <summary>
  11769. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11770. /// </summary>
  11771. /// <returns></returns>
  11772. [HttpPost]
  11773. [ApiExplorerSettings(IgnoreApi = true)]
  11774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11775. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11776. {
  11777. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11778. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11779. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11780. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11781. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11782. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11783. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11784. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11785. {
  11786. Id = x.Id,
  11787. ParentId = dto.DraftId,
  11788. Type = dto.FeeType,
  11789. Days = x.Days,
  11790. NationalTravelFeeId = x.NationalTravelFeeId,
  11791. Cost = x.Cost,
  11792. Currency = x.Currency,
  11793. SubTotal = x.SubTotal,
  11794. CreateUserId = dto.CurrUserId
  11795. })
  11796. .ToList();
  11797. var adds = infos.Where(x => x.Id <= 0).ToList();
  11798. var upds = infos.Where(x => x.Id > 0).ToList();
  11799. if (adds.Count > 0)
  11800. {
  11801. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11802. if (add < 1) return Ok(JsonView(false));
  11803. }
  11804. if (upds.Count > 0)
  11805. {
  11806. var upd = await _sqlSugar.Updateable(adds)
  11807. .UpdateColumns(x => new
  11808. {
  11809. x.Days,
  11810. x.NationalTravelFeeId,
  11811. x.Cost,
  11812. x.Currency,
  11813. x.SubTotal
  11814. })
  11815. .WhereColumns(x => new { x.Id })
  11816. .ExecuteCommandAsync();
  11817. if (upd < 1) return Ok(JsonView(false));
  11818. }
  11819. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11820. ////消息通知
  11821. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11822. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11823. return Ok(JsonView(new { itemTotal = itemTotal }));
  11824. }
  11825. /// <summary>
  11826. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11827. /// </summary>
  11828. /// <returns></returns>
  11829. [HttpPost]
  11830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11831. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11832. {
  11833. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11834. int subId = dto.SubId, feeType = dto.FeeType;
  11835. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11836. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11837. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11838. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11839. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11840. subInfo.Id = subId;
  11841. subInfo.ParentId = dto.DraftId;
  11842. if (feeType == 3) subInfo.Type = 1;
  11843. else if (feeType == 4) subInfo.Type = 2;
  11844. else if (feeType == 5) subInfo.Type = 3;
  11845. else if (feeType == 6) subInfo.Type = 4;
  11846. subInfo.CreateUserId = dto.CurrUserId;
  11847. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11848. if (parentId < 1) return Ok(JsonView(false));
  11849. //子表op
  11850. if (subId < 1)
  11851. {
  11852. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11853. if (subAdd < 1) return Ok(JsonView(false));
  11854. }
  11855. else
  11856. {
  11857. var subUpd = await _sqlSugar.Updateable(subInfo)
  11858. .UpdateColumns(x => new
  11859. {
  11860. x.Days,
  11861. x.NationalTravelFeeId,
  11862. x.Cost,
  11863. x.Currency,
  11864. x.SubTotal
  11865. })
  11866. .WhereColumns(x => new { x.Id })
  11867. .ExecuteCommandAsync();
  11868. if (subUpd < 1) return Ok(JsonView(false));
  11869. }
  11870. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11871. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11872. }
  11873. /// <summary>
  11874. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11875. /// </summary>
  11876. /// <returns></returns>
  11877. [HttpPost]
  11878. [ApiExplorerSettings(IgnoreApi = true)]
  11879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11880. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11881. {
  11882. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11883. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11884. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11885. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11886. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11887. {
  11888. Id = x.Id,
  11889. ParentId = dto.DraftId,
  11890. SetDataId = x.SetDataId,
  11891. Index = x.Index,
  11892. Cost = x.Cost,
  11893. Currency = x.Currency,
  11894. SubTotal = x.SubTotal,
  11895. CreateUserId = dto.CurrUserId,
  11896. Remark = x.Remark
  11897. }).ToList();
  11898. var adds = infos.Where(x => x.Id <= 0).ToList();
  11899. var upds = infos.Where(x => x.Id > 0).ToList();
  11900. if (adds.Count > 0)
  11901. {
  11902. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11903. if (add < 1) return Ok(JsonView(false));
  11904. }
  11905. if (upds.Count > 0)
  11906. {
  11907. var upd = await _sqlSugar.Updateable(adds)
  11908. .UpdateColumns(x => new
  11909. {
  11910. x.Index,
  11911. x.SetDataId,
  11912. x.Cost,
  11913. x.Currency,
  11914. x.SubTotal,
  11915. x.Remark
  11916. })
  11917. .WhereColumns(x => new { x.Id })
  11918. .ExecuteCommandAsync();
  11919. if (upd < 1) return Ok(JsonView(false));
  11920. }
  11921. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11922. //消息通知
  11923. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11924. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11925. return Ok(JsonView(new { itemTotal = itemTotal }));
  11926. }
  11927. /// <summary>
  11928. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11929. /// </summary>
  11930. /// <returns></returns>
  11931. [HttpPost]
  11932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11933. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11934. {
  11935. int subId = dto.SubId, id = dto.DraftId;
  11936. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11937. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11938. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11939. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11940. subInfo.Id = subId;
  11941. subInfo.ParentId = id;
  11942. subInfo.CreateUserId = dto.CurrUserId;
  11943. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11944. if (parentId < 1) return Ok(JsonView(false));
  11945. #region 子表op
  11946. if (subId < 1)//add
  11947. {
  11948. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11949. if (subAdd < 1) return Ok(JsonView(false));
  11950. }
  11951. else //upd
  11952. {
  11953. var subUpd = await _sqlSugar.Updateable(subInfo)
  11954. .UpdateColumns(x => new
  11955. {
  11956. x.Index,
  11957. x.SetDataId,
  11958. x.Cost,
  11959. x.Currency,
  11960. x.SubTotal,
  11961. x.Remark
  11962. })
  11963. .WhereColumns(x => new { x.Id })
  11964. .ExecuteCommandAsync();
  11965. if (subUpd < 1) return Ok(JsonView(false));
  11966. }
  11967. #endregion
  11968. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11969. ////消息通知
  11970. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11971. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11972. }
  11973. /// <summary>
  11974. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11975. /// </summary>
  11976. /// <returns></returns>
  11977. [HttpPost]
  11978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11979. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11980. {
  11981. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11982. if (data.Code != 0)
  11983. {
  11984. return Ok(JsonView(false, data.Msg));
  11985. }
  11986. return Ok(JsonView(true, "操作成功!", data.Data));
  11987. }
  11988. /// <summary>
  11989. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11990. /// </summary>
  11991. /// <param name="dto"></param>
  11992. /// <returns></returns>
  11993. [HttpPost]
  11994. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11995. {
  11996. var data = new Grp_DayOtherPriceDraft()
  11997. {
  11998. Id = dto.Id,
  11999. IsDel = 1,
  12000. DeleteUserId = dto.DeleteUserId,
  12001. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12002. };
  12003. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12004. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12005. return Ok(JsonView(false, "删除失败!"));
  12006. }
  12007. #endregion
  12008. #endregion
  12009. #region 团组经理模块 出入境费用报价表
  12010. /// <summary>
  12011. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12012. /// </summary>
  12013. /// <returns></returns>
  12014. [HttpPost]
  12015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12016. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12017. {
  12018. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12019. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12020. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12021. initRates.Insert(0, cnyInfo);
  12022. liveRates.Insert(0, cnyInfo);
  12023. return Ok(JsonView(true, "查询成功!", new
  12024. {
  12025. InitRates = initRates,
  12026. LiveRates = liveRates
  12027. }));
  12028. }
  12029. /// <summary>
  12030. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12031. /// </summary>
  12032. /// <returns></returns>
  12033. [HttpPost]
  12034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12035. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12036. {
  12037. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12038. }
  12039. /// <summary>
  12040. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12041. /// </summary>
  12042. /// <returns></returns>
  12043. [HttpPost]
  12044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12045. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12046. {
  12047. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12048. }
  12049. /// <summary>
  12050. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12051. /// </summary>
  12052. /// <returns></returns>
  12053. [HttpPost]
  12054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12055. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12056. {
  12057. int groupId = dto.DiId,
  12058. currUserId = dto.CurrUserId;
  12059. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12060. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12061. //验证报价数据是否存在
  12062. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12063. if (isNull != null)
  12064. {
  12065. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12066. if (!info1.Rates.Any())
  12067. {
  12068. var rates = await GeneralMethod.EnterExitCostInitRate();
  12069. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12070. info1.Rates = rates.ToArray();
  12071. }
  12072. return Ok(JsonView(info1));
  12073. }
  12074. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12075. result.GroupId = groupId;
  12076. //处理报价名称
  12077. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12078. if (groupInfo != null)
  12079. {
  12080. var visitCountry = groupInfo.VisitCountry;
  12081. if (!string.IsNullOrEmpty(visitCountry))
  12082. {
  12083. string quoteName = string.Empty;
  12084. if (visitCountry.Contains("|"))
  12085. {
  12086. var countrys = visitCountry.Split("|");
  12087. quoteName = string.Join("、", countrys);
  12088. }
  12089. else quoteName = visitCountry;
  12090. quoteName += $"团组报价表";
  12091. result.Name = quoteName;
  12092. }
  12093. }
  12094. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12095. if (info.Code != StatusCodes.Status200OK)
  12096. {
  12097. if (!result.Rates.Any())
  12098. {
  12099. var rates = await GeneralMethod.EnterExitCostInitRate();
  12100. result.Rates = rates.ToArray();
  12101. }
  12102. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12103. }
  12104. var infoView = info.Data as EnterExitCostInfoView;
  12105. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12106. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12107. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12108. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12109. var eecRates = infoView.Currencys;
  12110. //默认添加人名币
  12111. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12112. {
  12113. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12114. }
  12115. //处理团组人数
  12116. int pplNum = 1;
  12117. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12118. var views = new List<QuoteSubItemInfo>();
  12119. #region 数据填充
  12120. var intTravelCosts = new List<QuoteSubItemInfo>();
  12121. #region 机票费用 1354
  12122. int intTravelIndex = 1;
  12123. if (infoView.SumJJC == 1)
  12124. {
  12125. intTravelCosts.Add(new QuoteSubItemInfo
  12126. {
  12127. ItemId = 1354,
  12128. Index = intTravelIndex,
  12129. FeeName = "经济舱",
  12130. UnitPrice = infoView.AirJJ,
  12131. Currency = "CNY",
  12132. Quantity = 1,
  12133. PplNum = 1,
  12134. TotalAmt = infoView.AirJJ,
  12135. Remark = "",
  12136. });
  12137. intTravelIndex++;
  12138. }
  12139. if (infoView.SumGWC == 1)
  12140. {
  12141. intTravelCosts.Add(new QuoteSubItemInfo
  12142. {
  12143. ItemId = 1354,
  12144. Index = intTravelIndex,
  12145. FeeName = "公务舱",
  12146. UnitPrice = infoView.AirGW,
  12147. Currency = "CNY",
  12148. Quantity = 1,
  12149. PplNum = 1,
  12150. TotalAmt = infoView.AirGW,
  12151. Remark = "",
  12152. });
  12153. intTravelIndex++;
  12154. }
  12155. if (infoView.SumTDC == 1)
  12156. {
  12157. intTravelCosts.Add(new QuoteSubItemInfo
  12158. {
  12159. ItemId = 1354,
  12160. Index = intTravelIndex,
  12161. FeeName = "头等舱",
  12162. UnitPrice = infoView.AirTD,
  12163. Currency = "CNY",
  12164. Quantity = 1,
  12165. PplNum = 1,
  12166. TotalAmt = infoView.AirTD,
  12167. Remark = "",
  12168. });
  12169. intTravelIndex++;
  12170. }
  12171. intTravelCosts.Add(new QuoteSubItemInfo
  12172. {
  12173. ItemId = 1354,
  12174. Index = intTravelIndex,
  12175. FeeName = "城市间交通费用",
  12176. UnitPrice = infoView.CityTranffic,
  12177. Currency = "CNY",
  12178. Quantity = 1,
  12179. PplNum = pplNum,
  12180. TotalAmt = infoView.CityTranffic * pplNum,
  12181. Remark = "",
  12182. });
  12183. views.AddRange(intTravelCosts);
  12184. #endregion
  12185. var accomCosts = new List<QuoteSubItemInfo>();
  12186. #region 住宿费 1355
  12187. if (infoView.QuarterageData.Any())
  12188. {
  12189. int accomIndex = 1;
  12190. int accomItemTypeId = 1355;
  12191. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12192. foreach (var item in groupData)
  12193. {
  12194. string feeName = string.Empty;
  12195. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12196. if (countryInfo != null)
  12197. {
  12198. feeName = countryInfo.Country;
  12199. var city = countryInfo.City;
  12200. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12201. {
  12202. feeName += $"-{city}";
  12203. }
  12204. }
  12205. var hotelInfo = item.FirstOrDefault();
  12206. if (hotelInfo == null) continue;
  12207. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12208. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12209. int quantity = item.ToList().Count;
  12210. accomCosts.Add(new QuoteSubItemInfo
  12211. {
  12212. ItemId = accomItemTypeId,
  12213. Index = accomIndex,
  12214. FeeName = feeName,
  12215. UnitPrice = hotelInfo.Cost,
  12216. Currency = thisCurrency,
  12217. Quantity = quantity,
  12218. PplNum = pplNum,
  12219. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12220. Remark = "",
  12221. });
  12222. accomIndex++;
  12223. }
  12224. views.AddRange(accomCosts);
  12225. }
  12226. #endregion
  12227. var mealCosts = new List<QuoteSubItemInfo>();
  12228. #region 餐饮费 1356
  12229. if (infoView.BoardWagesData.Any())
  12230. {
  12231. var mealIndex = 1;
  12232. int mealItemTypeId = 1356;
  12233. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12234. foreach (var item in groupData)
  12235. {
  12236. string feeName = string.Empty;
  12237. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12238. if (countryInfo != null)
  12239. {
  12240. feeName = countryInfo.Country;
  12241. var city = countryInfo.City;
  12242. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12243. {
  12244. feeName += $"-{city}";
  12245. }
  12246. }
  12247. var mealInfo = item.FirstOrDefault();
  12248. if (mealInfo == null) continue;
  12249. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12250. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12251. int quantity = item.ToList().Count;
  12252. mealCosts.Add(new QuoteSubItemInfo
  12253. {
  12254. ItemId = mealItemTypeId,
  12255. Index = mealIndex,
  12256. FeeName = feeName,
  12257. UnitPrice = mealInfo.Cost,
  12258. Currency = thisCurrency,
  12259. Quantity = quantity,
  12260. PplNum = pplNum,
  12261. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12262. Remark = "",
  12263. });
  12264. mealIndex++;
  12265. }
  12266. views.AddRange(mealCosts);
  12267. }
  12268. #endregion
  12269. var miscCosts = new List<QuoteSubItemInfo>();
  12270. #region 公杂费 1364
  12271. if (infoView.MiscellaneousFeeData.Any())
  12272. {
  12273. var miscIndex = 1;
  12274. int miscItemTypeId = 1364;
  12275. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12276. foreach (var item in groupData)
  12277. {
  12278. string feeName = string.Empty;
  12279. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12280. if (countryInfo != null)
  12281. {
  12282. feeName = countryInfo.Country;
  12283. var city = countryInfo.City;
  12284. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12285. {
  12286. feeName += $"-{city}";
  12287. }
  12288. }
  12289. var miscInfo = item.FirstOrDefault();
  12290. if (miscInfo == null) continue;
  12291. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12292. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12293. int quantity = item.ToList().Count;
  12294. miscCosts.Add(new QuoteSubItemInfo
  12295. {
  12296. ItemId = miscItemTypeId,
  12297. Index = miscIndex,
  12298. FeeName = feeName,
  12299. UnitPrice = miscInfo.Cost,
  12300. Currency = thisCurrency,
  12301. Quantity = quantity,
  12302. PplNum = pplNum,
  12303. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12304. Remark = "",
  12305. });
  12306. miscIndex++;
  12307. }
  12308. views.AddRange(miscCosts);
  12309. }
  12310. #endregion
  12311. #region 签证+保险 1362
  12312. int visaInsIndex = 1;
  12313. int visaInsItemTypeId = 1362;
  12314. if (infoView.Visa > 0)
  12315. {
  12316. views.Add(new QuoteSubItemInfo()
  12317. {
  12318. ItemId = visaInsItemTypeId,
  12319. Index = visaInsIndex,
  12320. FeeName = $"签证",
  12321. UnitPrice = infoView.Visa,
  12322. Currency = $"CNY",
  12323. Quantity = 1,
  12324. PplNum = pplNum,
  12325. TotalAmt = infoView.Visa * pplNum,
  12326. Remark = "",
  12327. });
  12328. visaInsIndex++;
  12329. }
  12330. if (infoView.Safe > 0)
  12331. {
  12332. views.Add(new QuoteSubItemInfo()
  12333. {
  12334. ItemId = visaInsItemTypeId,
  12335. Index = visaInsIndex,
  12336. FeeName = $"保险",
  12337. UnitPrice = infoView.Safe,
  12338. Currency = $"CNY",
  12339. Quantity = 1,
  12340. PplNum = pplNum,
  12341. TotalAmt = infoView.Safe * pplNum,
  12342. Remark = "",
  12343. });
  12344. }
  12345. #endregion
  12346. #region 服务费 1363
  12347. int serviceFeeIndex = 1;
  12348. int serviceFeeItemTypeId = 1363;
  12349. if (infoView.Service > 0)
  12350. {
  12351. views.Add(new QuoteSubItemInfo()
  12352. {
  12353. ItemId = serviceFeeItemTypeId,
  12354. Index = serviceFeeIndex,
  12355. FeeName = $"服务费",
  12356. UnitPrice = infoView.Service,
  12357. Currency = $"CNY",
  12358. Quantity = 1,
  12359. PplNum = pplNum,
  12360. TotalAmt = infoView.Service * pplNum,
  12361. Remark = "",
  12362. });
  12363. }
  12364. #endregion
  12365. #endregion
  12366. if (result.FeeItems.Any())
  12367. {
  12368. result.FeeItems.Select(x =>
  12369. {
  12370. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12371. if (feeInfos.Any()) x.Infos = feeInfos;
  12372. return x;
  12373. }
  12374. ).OrderBy(x => x.Index)
  12375. .ToList();
  12376. if (!result.Rates.Any())
  12377. {
  12378. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12379. else
  12380. {
  12381. var rates = await GeneralMethod.EnterExitCostInitRate();
  12382. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12383. result.Rates = rates.ToArray();
  12384. }
  12385. }
  12386. }
  12387. return Ok(JsonView(result));
  12388. }
  12389. /// <summary>
  12390. /// 团组模块 - 出入境费用报价表 - Info
  12391. /// </summary>
  12392. /// <returns></returns>
  12393. [HttpPost]
  12394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12395. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12396. {
  12397. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12398. if (!info.Rates.Any())
  12399. {
  12400. var rates = await GeneralMethod.EnterExitCostInitRate();
  12401. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12402. info.Rates = rates.ToArray();
  12403. }
  12404. return Ok(JsonView(info));
  12405. }
  12406. /// <summary>
  12407. /// 团组模块 - 出入境费用报价表 - OP
  12408. /// </summary>
  12409. /// <returns></returns>
  12410. [HttpPost]
  12411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12412. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12413. {
  12414. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12415. }
  12416. /// <summary>
  12417. /// 团组模块 - 出入境费用报价表 - 删除 项
  12418. /// </summary>
  12419. /// <returns></returns>
  12420. [HttpPost]
  12421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12422. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12423. {
  12424. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12425. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12426. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12427. }
  12428. /// <summary>
  12429. /// 团组模块 - 出入境费用报价表 - 导出
  12430. /// </summary>
  12431. /// <returns></returns>
  12432. [HttpPost]
  12433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12434. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12435. {
  12436. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12437. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12438. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12439. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12440. var rates = info.Rates;
  12441. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12442. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12443. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12444. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12445. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12446. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12447. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12448. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12449. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12450. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12451. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12452. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12453. //获取模板
  12454. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12455. var designer = new WorkbookDesigner();
  12456. designer.Workbook = new Workbook(tempPath);
  12457. designer.SetDataSource("QuoteName", info.Name);
  12458. designer.SetDataSource("CompanyTitle", "公司名称");
  12459. designer.SetDataSource("CompanyLabel", "");
  12460. #region 国际旅费
  12461. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12462. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12463. {
  12464. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12465. var label = new StringBuilder();
  12466. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12467. if (infos.Any())
  12468. {
  12469. label.Append(infos.Sum(x => x.PplNum));
  12470. label.Append("人全程机票:");
  12471. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12472. label.AppendLine("元");
  12473. }
  12474. foreach (var item in intTravelCosts.Infos)
  12475. {
  12476. label.Append(item.FeeName);
  12477. label.Append(":");
  12478. label.Append(item.UnitPrice.TruncDecimals(2));
  12479. label.Append("元/人*");
  12480. label.Append(item.PplNum);
  12481. label.AppendLine("人");
  12482. }
  12483. if (label.HasValue())
  12484. {
  12485. label.Append("\r\n以上小计:");
  12486. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12487. label.Append("元");
  12488. }
  12489. designer.SetDataSource("IntTravelLabel", label.ToString());
  12490. }
  12491. #endregion
  12492. #region 住宿费
  12493. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12494. if (accomCosts != null && accomCosts.Infos.Any())
  12495. {
  12496. string currencyName = string.Empty,
  12497. countryName = string.Empty;
  12498. decimal rate = 1.0000M;
  12499. var label = new StringBuilder();
  12500. label.AppendLine("全程五星酒店,每人1间房");
  12501. foreach (var item in accomCosts.Infos)
  12502. {
  12503. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12504. string name = string.Empty, thisCountryName = string.Empty;
  12505. if (item.FeeName.Contains('-'))
  12506. {
  12507. var feeName = item.FeeName.Split('-');
  12508. thisCountryName = feeName[0];
  12509. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12510. name = feeName[1];
  12511. }
  12512. else name = item.FeeName;
  12513. string thisFeeName = string.Empty;
  12514. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12515. else thisFeeName = $"\r\n{name}:";
  12516. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12517. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12518. rate = rateInfo?.Rate ?? 1.0000M;
  12519. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12520. label.AppendLine(subLabel);
  12521. }
  12522. if (label.HasValue())
  12523. {
  12524. //以上小计:52440元(美金汇率:7.5 )
  12525. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12526. label.AppendLine(subLabel);
  12527. }
  12528. designer.SetDataSource("AccomLabel", label.ToString());
  12529. }
  12530. #endregion
  12531. #region 餐饮费
  12532. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12533. if (mealCosts != null && mealCosts.Infos.Any())
  12534. {
  12535. string currencyName = string.Empty;
  12536. decimal rate = 1.0000M;
  12537. var label = new StringBuilder();
  12538. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12539. foreach (var item in mealCosts.Infos)
  12540. {
  12541. string name = string.Empty;
  12542. if (item.FeeName.Contains('-'))
  12543. {
  12544. var feeName = item.FeeName.Split('-');
  12545. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12546. }
  12547. else name = $"\r\n{item.FeeName}:";
  12548. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12549. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12550. rate = rateInfo?.Rate ?? 1.0000M;
  12551. label.Append(name);
  12552. label.Append(item.UnitPrice.TruncDecimals(2));
  12553. label.Append(currencyName);
  12554. label.Append("/天*");
  12555. label.Append(item.Quantity.ToString("#0"));
  12556. label.Append('*');
  12557. label.Append(item.PplNum);
  12558. label.Append("人\r\n");
  12559. }
  12560. if (label.HasValue())
  12561. {
  12562. label.Append("\r\n以上小计:");
  12563. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12564. label.Append("元\r\n(");
  12565. label.Append("汇率:");
  12566. label.Append(rate.TruncDecimals(4));
  12567. label.Append(')');
  12568. }
  12569. designer.SetDataSource("MealLabel", label.ToString());
  12570. }
  12571. #endregion
  12572. #region 车辆安排
  12573. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12574. if (vehArranges != null && vehArranges.Infos.Any())
  12575. {
  12576. string currencyName = string.Empty;
  12577. //decimal rate = 1.0000M;
  12578. var label = new StringBuilder();
  12579. foreach (var item in vehArranges.Infos)
  12580. {
  12581. label.AppendLine();
  12582. label.AppendLine();
  12583. label.Append(item.FeeName);
  12584. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12585. }
  12586. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12587. }
  12588. #endregion
  12589. #region 邀请函发放对象
  12590. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12591. designer.SetDataSource("InviteToContent", "");
  12592. #endregion
  12593. #region 邀请函费
  12594. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12595. var is_label = new StringBuilder();
  12596. if (inviteCosts != null && inviteCosts.Infos.Any())
  12597. {
  12598. string currencyName = string.Empty;
  12599. decimal rate = 1.0000M;
  12600. foreach (var item in inviteCosts.Infos)
  12601. {
  12602. //乌兹别克斯坦:2000美金
  12603. currencyName = item.Currency;
  12604. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12605. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12606. is_label.AppendLine(label);
  12607. }
  12608. if (is_label.HasValue())
  12609. {
  12610. //以上小计:28500元(美金汇率:7.5)
  12611. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12612. is_label.AppendLine(label);
  12613. }
  12614. }
  12615. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12616. #endregion
  12617. #region 邀请函发放时间
  12618. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12619. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12620. #endregion
  12621. #region 公务活动(含翻译)
  12622. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12623. var oa_label = new StringBuilder();
  12624. if (officialActs != null && officialActs.Infos.Any())
  12625. {
  12626. string currencyName = string.Empty;
  12627. decimal rate = 1.0000M;
  12628. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12629. foreach (var item in officialActs.Infos)
  12630. {
  12631. //乌兹别克斯坦:1000美金/场
  12632. currencyName = item.Currency;
  12633. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12634. string label_remark = string.Empty;
  12635. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12636. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12637. }
  12638. label_content += "*总费用中未含超出公务活动价格";
  12639. //8场公务活动(以上小计:60000元)
  12640. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12641. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12642. oa_label.AppendLine(label_title);
  12643. oa_label.AppendLine(label_content);
  12644. }
  12645. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12646. #endregion
  12647. #region 签证+保险
  12648. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12649. var vi_label = new StringBuilder();
  12650. if (visaIns != null && visaIns.Infos.Any())
  12651. {
  12652. foreach (var item in visaIns.Infos)
  12653. {
  12654. //签证:500元/人
  12655. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12656. vi_label.AppendLine(label);
  12657. }
  12658. if (vi_label.HasValue())
  12659. {
  12660. //以上小计:6000元
  12661. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12662. vi_label.AppendLine(label);
  12663. }
  12664. }
  12665. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12666. #endregion
  12667. #region 服务费
  12668. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12669. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12670. #endregion
  12671. #region 公杂费
  12672. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12673. var pm_label = new StringBuilder();
  12674. if (pubMiscs != null && pubMiscs.Infos.Any())
  12675. {
  12676. string currencyName = string.Empty,
  12677. countryName = string.Empty;
  12678. decimal rate = 1.0000M;
  12679. foreach (var item in pubMiscs.Infos)
  12680. {
  12681. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12682. string name = string.Empty, thisCountryName = string.Empty;
  12683. if (item.FeeName.Contains('-'))
  12684. {
  12685. var feeName = item.FeeName.Split('-');
  12686. thisCountryName = feeName[0];
  12687. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12688. name = feeName[1];
  12689. }
  12690. else name = item.FeeName;
  12691. string thisFeeName = string.Empty;
  12692. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12693. else thisFeeName = $"\r\n{name}:";
  12694. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12695. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12696. rate = rateInfo?.Rate ?? 1.0000M;
  12697. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12698. pm_label.AppendLine(label);
  12699. }
  12700. if (pm_label.HasValue())
  12701. {
  12702. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12703. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12704. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12705. pm_label.AppendLine(string.Format("部分发放成员"));
  12706. }
  12707. }
  12708. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12709. #endregion
  12710. #region 税费
  12711. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12712. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12713. #endregion
  12714. #region 合计(单位:元)
  12715. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12716. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12717. #endregion
  12718. #region 汇率 Remark
  12719. var rate_label = new StringBuilder();
  12720. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12721. foreach (var item in rateGroups)
  12722. {
  12723. //美元汇率按\r\n1:7.5
  12724. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12725. rate_label.AppendLine(label);
  12726. }
  12727. designer.SetDataSource("RateLabel", rate_label.ToString());
  12728. #endregion
  12729. designer.Process();
  12730. //文件名
  12731. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12732. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12733. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12734. return Ok(JsonView(true, "成功", url));
  12735. }
  12736. #endregion
  12737. #region 签证费用录入
  12738. /// <summary>
  12739. /// 根据diid查询签证费用列表
  12740. /// </summary>
  12741. /// <param name="dto"></param>
  12742. /// <returns></returns>
  12743. [HttpPost]
  12744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12745. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12746. {
  12747. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12748. if (groupData.Code != 0)
  12749. {
  12750. return Ok(JsonView(false, groupData.Msg));
  12751. }
  12752. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12753. }
  12754. /// <summary>
  12755. /// 根据签证费用Id查询单条数据及c表数据
  12756. /// </summary>
  12757. /// <param name="dto"></param>
  12758. /// <returns></returns>
  12759. [HttpPost]
  12760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12761. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12762. {
  12763. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12764. if (groupData.Code != 0)
  12765. {
  12766. return Ok(JsonView(false, groupData.Msg));
  12767. }
  12768. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12769. }
  12770. /// <summary>
  12771. /// 签证费用删除
  12772. /// </summary>
  12773. /// <param name="dto"></param>
  12774. /// <returns></returns>
  12775. [HttpPost]
  12776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12777. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12778. {
  12779. _sqlSugar.BeginTran();
  12780. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12781. if (!res)
  12782. {
  12783. _sqlSugar.RollbackTran();
  12784. return Ok(JsonView(false, "删除失败"));
  12785. }
  12786. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12787. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12788. .SetColumns(a => new Grp_CreditCardPayment()
  12789. {
  12790. IsDel = 1,
  12791. DeleteUserId = dto.DeleteUserId,
  12792. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12793. })
  12794. .ExecuteCommand();
  12795. if (resSub < 1)
  12796. {
  12797. _sqlSugar.RollbackTran();
  12798. return Ok(JsonView(false, "删除失败"));
  12799. }
  12800. _sqlSugar.CommitTran();
  12801. return Ok(JsonView(true, "删除成功!"));
  12802. }
  12803. /// <summary>
  12804. /// 签证费用录入下拉框初始化
  12805. /// </summary>
  12806. /// <returns></returns>
  12807. [HttpPost]
  12808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12809. public async Task<IActionResult> VisaPriceAddSelect()
  12810. {
  12811. //支付方式
  12812. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12813. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12814. //币种
  12815. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12816. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12817. //乘客类型
  12818. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12819. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12820. //卡类型
  12821. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12822. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12823. //代办费类型
  12824. var agencyFeeTypeData = new List<dynamic>() {
  12825. new { id = 0 , Text = "未选择" },
  12826. new { id = 1 , Text = "小公务" },
  12827. new { id = 2 , Text = "大公务" },
  12828. };
  12829. //签证费用标准国家Data
  12830. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12831. var data = new
  12832. {
  12833. Payment = _Payment,
  12834. CurrencyList = _CurrencyList,
  12835. PassengerType = _PassengerType,
  12836. BankCard = _BankCard,
  12837. AgencyFeeType = agencyFeeTypeData,
  12838. CountryFeeData = visaCountryFeeData
  12839. };
  12840. return Ok(JsonView(true, "查询成功!", data));
  12841. }
  12842. /// <summary>
  12843. /// 签证费用录入操作(Status:1.新增,2.修改)
  12844. /// </summary>
  12845. /// <param name="dto"></param>
  12846. /// <returns></returns>
  12847. [HttpPost]
  12848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12849. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12850. {
  12851. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12852. if (groupData.Code != 0)
  12853. {
  12854. return Ok(JsonView(false, groupData.Msg));
  12855. }
  12856. #region 应用推送
  12857. try
  12858. {
  12859. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12860. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12861. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12862. //2024-10-21 新增LZ UID
  12863. var userIds = new List<int>() { 21 };
  12864. string title = $"系统通知";
  12865. string content = "";
  12866. var diId = dto.DiId;
  12867. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12868. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12869. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12870. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12871. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12872. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12873. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12874. }
  12875. catch (Exception ex)
  12876. {
  12877. }
  12878. #endregion
  12879. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12880. }
  12881. #endregion
  12882. #region 签证提成录入
  12883. /// <summary>
  12884. /// 签证提成录入
  12885. /// 基础数据
  12886. /// </summary>
  12887. /// <returns></returns>
  12888. [HttpGet]
  12889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12890. public async Task<IActionResult> VisaCommissionInit()
  12891. {
  12892. return Ok(await _visaCommissionRep.Init());
  12893. }
  12894. /// <summary>
  12895. /// 签证提成录入
  12896. /// Item
  12897. /// </summary>
  12898. /// <param name="_dto"></param>
  12899. /// <returns></returns>
  12900. [HttpPost]
  12901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12902. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12903. {
  12904. var validator = new VisaCommissionItemDtoValidator();
  12905. var validatorRes = await validator.ValidateAsync(_dto);
  12906. if (!validatorRes.IsValid)
  12907. {
  12908. var sb = new StringBuilder();
  12909. foreach (var item in validatorRes.Errors)
  12910. {
  12911. sb.AppendLine(item.ErrorMessage);
  12912. }
  12913. return Ok(JsonView(false, sb.ToString()));
  12914. }
  12915. return Ok(await _visaCommissionRep.Item(_dto));
  12916. }
  12917. /// <summary>
  12918. /// 签证提成录入
  12919. /// Save
  12920. /// </summary>
  12921. /// <param name="_dto"></param>
  12922. /// <returns></returns>
  12923. [HttpPost]
  12924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12925. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12926. {
  12927. //参数验证
  12928. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12929. foreach (var item in _dto.Items)
  12930. {
  12931. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12932. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12933. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12934. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12935. }
  12936. return Ok(await _visaCommissionRep.Save(_dto));
  12937. }
  12938. /// <summary>
  12939. /// 签证提成录入
  12940. /// Create
  12941. /// </summary>
  12942. /// <param name="_dto"></param>
  12943. /// <returns></returns>
  12944. [HttpPost]
  12945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12946. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12947. {
  12948. var validator = new VisaCommissionCreateDtoValidator();
  12949. var validatorRes = await validator.ValidateAsync(_dto);
  12950. if (!validatorRes.IsValid)
  12951. {
  12952. var sb = new StringBuilder();
  12953. foreach (var item in validatorRes.Errors)
  12954. {
  12955. sb.AppendLine(item.ErrorMessage);
  12956. }
  12957. return Ok(JsonView(false, sb.ToString()));
  12958. }
  12959. return Ok(await _visaCommissionRep.Create(_dto));
  12960. }
  12961. /// <summary>
  12962. /// 签证提成录入
  12963. /// Put(编辑)
  12964. /// </summary>
  12965. /// <param name="id"></param>
  12966. /// <param name="_dto"></param>
  12967. /// <returns></returns>
  12968. [HttpPut]
  12969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12970. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12971. {
  12972. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12973. var validator = new VisaCommissionCreateDtoValidator();
  12974. var validatorRes = await validator.ValidateAsync(_dto);
  12975. if (!validatorRes.IsValid)
  12976. {
  12977. var sb = new StringBuilder();
  12978. foreach (var item in validatorRes.Errors)
  12979. {
  12980. sb.AppendLine(item.ErrorMessage);
  12981. }
  12982. return Ok(JsonView(false, sb.ToString()));
  12983. }
  12984. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12985. }
  12986. /// <summary>
  12987. /// 签证提成录入
  12988. /// Del
  12989. /// </summary>
  12990. /// <param name="id"></param>
  12991. /// <param name="currUserId"></param>
  12992. /// <returns></returns>
  12993. [HttpPost]
  12994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12995. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12996. {
  12997. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12998. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12999. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13000. }
  13001. #endregion
  13002. #region op费用录入
  13003. /// <summary>
  13004. /// 根据diid查询op费用列表
  13005. /// </summary>
  13006. /// <param name="dto"></param>
  13007. /// <returns></returns>
  13008. [HttpPost]
  13009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13010. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13011. {
  13012. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13013. if (groupData.Code != 0)
  13014. {
  13015. return Ok(JsonView(false, groupData.Msg));
  13016. }
  13017. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13018. }
  13019. /// <summary>
  13020. /// 根据op费用Id查询单条数据及c表数据
  13021. /// </summary>
  13022. /// <param name="dto"></param>
  13023. /// <returns></returns>
  13024. [HttpPost]
  13025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13026. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13027. {
  13028. try
  13029. {
  13030. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13031. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13032. var data = new
  13033. {
  13034. CarTouristGuideGround = _groupData,
  13035. CreditCardPayment = _creditCardPayment
  13036. };
  13037. return Ok(JsonView(true, "查询成功!", data));
  13038. }
  13039. catch (Exception ex)
  13040. {
  13041. return Ok(JsonView(false, "程序错误!"));
  13042. }
  13043. }
  13044. /// <summary>
  13045. /// op费用删除
  13046. /// </summary>
  13047. /// <param name="dto"></param>
  13048. /// <returns></returns>
  13049. [HttpPost]
  13050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13051. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13052. {
  13053. try
  13054. {
  13055. _sqlSugar.BeginTran();
  13056. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13057. if (!res)
  13058. {
  13059. return Ok(JsonView(false, "删除失败"));
  13060. }
  13061. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13062. {
  13063. IsDel = 1,
  13064. DeleteUserId = dto.DeleteUserId,
  13065. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13066. }).ExecuteCommandAsync();
  13067. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13068. {
  13069. IsDel = 1,
  13070. DeleteUserId = dto.DeleteUserId,
  13071. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13072. }).ExecuteCommandAsync();
  13073. #region 删除超支相关数据
  13074. //删除导入的超支数据
  13075. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13076. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13077. {
  13078. IsDel = 1,
  13079. DeleteUserId = dto.DeleteUserId,
  13080. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13081. }).ExecuteCommand();
  13082. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13083. {
  13084. IsDel = 1,
  13085. DeleteUserId = dto.DeleteUserId,
  13086. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13087. }).ExecuteCommand();
  13088. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13089. {
  13090. IsDel = 1,
  13091. DeleteUserId = dto.DeleteUserId,
  13092. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13093. }).ExecuteCommand();
  13094. #endregion
  13095. _sqlSugar.CommitTran();
  13096. return Ok(JsonView(true, "删除成功!"));
  13097. }
  13098. catch (Exception ex)
  13099. {
  13100. _sqlSugar.RollbackTran();
  13101. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13102. }
  13103. }
  13104. /// <summary>
  13105. /// op费用录入操作(Status:1.新增,2.修改)
  13106. /// </summary>
  13107. /// <param name="dto"></param>
  13108. /// <returns></returns>
  13109. [HttpPost]
  13110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13111. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13112. {
  13113. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13114. if (groupData.Code != 0)
  13115. {
  13116. return Ok(JsonView(false, groupData.Msg));
  13117. }
  13118. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13119. }
  13120. /// <summary>
  13121. /// 填写费用详细页面初始化绑定
  13122. /// </summary>
  13123. /// <param name="dto"></param>
  13124. /// <returns></returns>
  13125. [HttpPost]
  13126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13127. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13128. {
  13129. try
  13130. {
  13131. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13132. if (groupData.Code != 0)
  13133. {
  13134. return Ok(JsonView(false, groupData.Msg));
  13135. }
  13136. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13137. }
  13138. catch (Exception ex)
  13139. {
  13140. return Ok(JsonView(false, ex.Message));
  13141. }
  13142. }
  13143. /// <summary>
  13144. /// 根据op费用Id查询详细数据
  13145. /// </summary>
  13146. /// <param name="dto"></param>
  13147. /// <returns></returns>
  13148. [HttpPost]
  13149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13150. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13151. {
  13152. try
  13153. {
  13154. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13155. if (groupData.Code != 0)
  13156. {
  13157. return Ok(JsonView(false, groupData.Msg));
  13158. }
  13159. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13160. }
  13161. catch (Exception ex)
  13162. {
  13163. return Ok(JsonView(false, ex.Message));
  13164. }
  13165. }
  13166. /// <summary>
  13167. /// OP费用录入填写详情
  13168. /// </summary>
  13169. /// <param name="dto"></param>
  13170. /// <returns></returns>
  13171. [HttpPost]
  13172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13173. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13174. {
  13175. try
  13176. {
  13177. #region 参数校验
  13178. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13179. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13180. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13181. #endregion
  13182. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13183. if (groupData.Code != 0)
  13184. {
  13185. return Ok(JsonView(false, groupData.Msg));
  13186. }
  13187. //自动审核
  13188. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13189. #region 应用推送
  13190. try
  13191. {
  13192. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13193. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13194. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13195. //2024-10-21 新增LZ UID
  13196. var userIds = new List<int>() { 21 };
  13197. string title = $"系统通知";
  13198. var diId = dto.DiId;
  13199. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13200. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13201. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13202. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13203. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13204. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13205. }
  13206. catch (Exception ex)
  13207. {
  13208. }
  13209. #endregion
  13210. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13211. }
  13212. catch (Exception ex)
  13213. {
  13214. return Ok(JsonView(false, ex.Message));
  13215. }
  13216. }
  13217. /// <summary>
  13218. /// 获取三公详细所有城市
  13219. /// </summary>
  13220. /// <returns></returns>
  13221. [HttpGet]
  13222. public IActionResult OpCarCityResult()
  13223. {
  13224. var jw = JsonView(false);
  13225. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13226. {
  13227. x.Id,
  13228. x.Country,
  13229. x.City,
  13230. }).ToList();
  13231. if (data.Count > 0)
  13232. {
  13233. jw = JsonView(true, "获取成功!", data);
  13234. }
  13235. else
  13236. {
  13237. jw.Msg = "城市数据为空!";
  13238. jw.Data = Array.Empty<string>();
  13239. }
  13240. return Ok(jw);
  13241. }
  13242. /// <summary>
  13243. /// 导出地接费用明细
  13244. /// </summary>
  13245. /// <param name="dto"></param>
  13246. /// <returns></returns>
  13247. [HttpPost]
  13248. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13249. {
  13250. var jw = JsonView(false);
  13251. if (dto.Diid < 1)
  13252. {
  13253. jw.Msg = "请输入正确的diid!";
  13254. return Ok(jw);
  13255. }
  13256. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13257. if (group == null)
  13258. {
  13259. jw.Msg = "未找到团组信息!";
  13260. return Ok(jw);
  13261. }
  13262. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13263. if (localGuideArr.Count == 0)
  13264. {
  13265. jw.Msg = "该团组暂无地接信息!";
  13266. return Ok(jw);
  13267. }
  13268. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13269. var overspendSoure = new Dictionary<int, int>
  13270. {
  13271. { 91, 982 }, //车
  13272. { 92 , 1059} ,//导游
  13273. { 994 , 1073}, //翻译
  13274. { 988 , 1074 }, //早餐
  13275. { 93 , 1075 }, //午餐
  13276. { 989 , 1076 }, //晚餐
  13277. };
  13278. var Zips = new Dictionary<string, Stream>();
  13279. foreach (var groupArr in localGroup)
  13280. {
  13281. var keyValue = groupArr.Key;
  13282. if (int.TryParse(keyValue, out int cityid))
  13283. {
  13284. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13285. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13286. }
  13287. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13288. foreach (var item in groupArr)
  13289. {
  13290. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13291. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13292. new Grp_CarTouristGuideGroundReservationsContentExtend
  13293. {
  13294. Count = a.Count,
  13295. CreateTime = a.CreateTime,
  13296. CreateUserId = a.CreateUserId,
  13297. CTGGRId = a.CTGGRId,
  13298. Currency = a.Currency,
  13299. DatePrice = a.DatePrice,
  13300. DeleteTime = a.DeleteTime,
  13301. DeleteUserId = a.DeleteUserId,
  13302. DiId = a.DiId,
  13303. Id = a.Id,
  13304. IsDel = a.IsDel,
  13305. Price = a.Price,
  13306. PriceContent = a.PriceContent,
  13307. Remark = a.Remark,
  13308. SId = a.SId,
  13309. SidName = b.Name,
  13310. Units = a.Units,
  13311. }
  13312. ).ToList();
  13313. if (content.Count > 0)
  13314. {
  13315. contentArr.Add(content);
  13316. }
  13317. }
  13318. //open excel
  13319. //set excel
  13320. //save excel
  13321. try
  13322. {
  13323. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13324. IWorkbook workbook;
  13325. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13326. {
  13327. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13328. }
  13329. else
  13330. {
  13331. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13332. }
  13333. ISheet sheet = workbook.GetSheetAt(0);
  13334. var rowStartIndex = 2;
  13335. var clounmCount = 10;
  13336. var initStyleRow = sheet.GetRow(2);
  13337. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13338. //var overspendArrDetail =
  13339. var existsId = new List<CarCompare>();
  13340. var lastElem = arr.Last();
  13341. var thisSid = -1;
  13342. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13343. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13344. {
  13345. Name = "未知币种!",
  13346. Remark = "未知币种!",
  13347. };
  13348. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13349. Action cloneRowFn = () =>
  13350. {
  13351. rowStartIndex++;
  13352. var cloneRow = sheet.CreateRow(rowStartIndex);
  13353. // 复制样式
  13354. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13355. {
  13356. ICell sourceCell = initStyleRow.GetCell(i);
  13357. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13358. // 确保单元格存在样式
  13359. if (sourceCell.CellStyle != null)
  13360. {
  13361. targetCell.CellStyle = sourceCell.CellStyle;
  13362. }
  13363. }
  13364. };
  13365. var mergeRow = () =>
  13366. {
  13367. for (int i = 2; i < sheet.LastRowNum; i++)
  13368. {
  13369. var row = sheet.GetRow(i);
  13370. var cellFirst = row.GetCell(0);
  13371. var thisIndex = i + 1;
  13372. while (thisIndex < sheet.LastRowNum)
  13373. {
  13374. var nextRow = sheet.GetRow(thisIndex);
  13375. var nextCellFirst = nextRow.GetCell(0);
  13376. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13377. {
  13378. thisIndex++;
  13379. }
  13380. else
  13381. {
  13382. break;
  13383. }
  13384. }
  13385. thisIndex--;
  13386. if (thisIndex != i)
  13387. {
  13388. //合并row
  13389. var cellRangeAddress = new CellRangeAddress(
  13390. i, // 起始行索引(0-based)
  13391. thisIndex, // 结束行索引(0-based)
  13392. 0, // 起始列索引(0-based)
  13393. 0 // 结束列索引(0-based)
  13394. );
  13395. sheet.AddMergedRegion(cellRangeAddress);
  13396. i = thisIndex;
  13397. }
  13398. }
  13399. };
  13400. var chaoshiNumber = 0;
  13401. var totalNumber = 0.00M;
  13402. string lastStr = "";
  13403. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13404. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13405. {
  13406. b.IsAuditGM,
  13407. x.Id,
  13408. x.Area,
  13409. b.PayPercentage,
  13410. b.PayMoney,
  13411. }).ToList();
  13412. string yesPayment = "", noPayment = "";
  13413. foreach (var item in queryCarArrByCityAndDiid)
  13414. {
  13415. if (item.IsAuditGM == 1)
  13416. {
  13417. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13418. }
  13419. else
  13420. {
  13421. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13422. }
  13423. }
  13424. lastStr = yesPayment + noPayment;
  13425. foreach (var item in arr)
  13426. {
  13427. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13428. {
  13429. if (thisSid != item.SId)
  13430. {
  13431. if (thisSid == -1)
  13432. {
  13433. thisSid = item.SId;
  13434. }
  13435. else
  13436. {
  13437. //合并小计行
  13438. //创建合并区域的实例
  13439. var cellRangeAddress = new CellRangeAddress(
  13440. rowStartIndex, // 起始行索引(0-based)
  13441. rowStartIndex, // 结束行索引(0-based)
  13442. 0, // 起始列索引(0-based)
  13443. 3 // 结束列索引(0-based)
  13444. );
  13445. sheet.AddMergedRegion(cellRangeAddress);
  13446. var CellStyle = workbook.CreateCellStyle();
  13447. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13448. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13449. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13450. for (int i = 0; i <= clounmCount; i++)
  13451. {
  13452. if (i > 6)
  13453. {
  13454. var CellStyle1 = workbook.CreateCellStyle();
  13455. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13456. IFont Font = workbook.CreateFont(); // 创建字体
  13457. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13458. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13459. CellStyle1.SetFont(Font);
  13460. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13461. }
  13462. else
  13463. {
  13464. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13465. }
  13466. }
  13467. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13468. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13469. //超时合计
  13470. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13471. //超时数
  13472. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13473. //超时合计费用
  13474. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13475. thisSid = item.SId;
  13476. cloneRowFn();
  13477. chaoshiNumber = 0;
  13478. totalNumber = 0;
  13479. }
  13480. }
  13481. IRow row = sheet.GetRow(rowStartIndex);
  13482. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13483. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13484. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13485. if (isOpenOverspendSoure)
  13486. {
  13487. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13488. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13489. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13490. }
  13491. for (int i = 0; i <= clounmCount; i++)
  13492. {
  13493. var cell = row.GetCell(i);
  13494. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13495. if (cell == null)
  13496. {
  13497. cell = row.CreateCell(i);
  13498. }
  13499. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13500. fontRed.CloneStyleFrom(cell.CellStyle);
  13501. IFont Font = workbook.CreateFont(); // 创建字体
  13502. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13503. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13504. fontRed.SetFont(Font);
  13505. byte[] rgb = new byte[3] { 255, 242, 204 };
  13506. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13507. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13508. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13509. if (workbook is XSSFWorkbook)
  13510. {
  13511. BackgroundColor255_242_204.FillForegroundColor = 0;
  13512. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13513. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13514. }
  13515. else
  13516. {
  13517. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13518. }
  13519. if (i == 1 || i > 6)
  13520. {
  13521. if (i > 6)
  13522. {
  13523. fontRed.FillForegroundColor = 0;
  13524. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13525. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13526. }
  13527. cell.CellStyle = fontRed;
  13528. }
  13529. if (i > 2 && i < 7)
  13530. {
  13531. cell.CellStyle = BackgroundColor255_242_204;
  13532. }
  13533. cell.SetCellValue(setCellValue); //写入单元格
  13534. }
  13535. if (overspendSoure.ContainsKey(thisSid))
  13536. {
  13537. var overspendId = overspendSoure[thisSid];
  13538. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13539. }
  13540. cloneRowFn();
  13541. existsId.Add(new CarCompare
  13542. {
  13543. DataPrice = item.DatePrice.ObjToDate(),
  13544. Sid = item.SId
  13545. });
  13546. }
  13547. if (item.Equals(lastElem))
  13548. {
  13549. //合并小计行
  13550. //创建合并区域的实例
  13551. var cellRangeAddress = new CellRangeAddress(
  13552. rowStartIndex, // 起始行索引(0-based)
  13553. rowStartIndex, // 结束行索引(0-based)
  13554. 0, // 起始列索引(0-based)
  13555. 3 // 结束列索引(0-based)
  13556. );
  13557. sheet.AddMergedRegion(cellRangeAddress);
  13558. var CellStyle = workbook.CreateCellStyle();
  13559. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13560. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13561. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13562. for (int i = 0; i <= clounmCount; i++)
  13563. {
  13564. if (i > 6)
  13565. {
  13566. var CellStyle1 = workbook.CreateCellStyle();
  13567. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13568. IFont Font = workbook.CreateFont(); // 创建字体
  13569. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13570. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13571. CellStyle1.SetFont(Font);
  13572. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13573. }
  13574. else
  13575. {
  13576. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13577. }
  13578. }
  13579. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13580. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13581. //超时合计
  13582. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13583. //超时数
  13584. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13585. //超时合计费用
  13586. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13587. cloneRowFn();
  13588. // 创建合并区域的实例
  13589. cellRangeAddress = new CellRangeAddress(
  13590. rowStartIndex, // 起始行索引(0-based)
  13591. rowStartIndex, // 结束行索引(0-based)
  13592. 0, // 起始列索引(0-based)
  13593. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13594. );
  13595. // 添加合并区域
  13596. sheet.AddMergedRegion(cellRangeAddress);
  13597. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13598. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13599. }
  13600. }
  13601. mergeRow();
  13602. // 保存修改后的Excel文件到新文件
  13603. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13604. // new FileStream(newFilePath, FileMode.CreateNew)
  13605. using (var stream = new MemoryStream())
  13606. {
  13607. workbook.Write(stream, true);
  13608. stream.Flush();
  13609. stream.Seek(0, SeekOrigin.Begin);
  13610. var memoryStream = new MemoryStream();
  13611. stream.CopyTo(memoryStream);
  13612. memoryStream.Seek(0, SeekOrigin.Begin);
  13613. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13614. }
  13615. workbook.Close();
  13616. workbook.Dispose();
  13617. }
  13618. catch (Exception ex)
  13619. {
  13620. jw.Msg = "出现异常!" + ex.Message;
  13621. return Ok(jw);
  13622. }
  13623. }
  13624. if (Zips.Count > 0)
  13625. {
  13626. var io = new IOOperatorHelper();
  13627. var byts = io.ConvertZipStream(Zips);
  13628. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13629. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13630. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13631. }
  13632. else
  13633. {
  13634. jw.Msg = "暂无生成文件!";
  13635. }
  13636. return Ok(jw);
  13637. }
  13638. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13639. {
  13640. string outStr = string.Empty;
  13641. switch (i)
  13642. {
  13643. case 0:
  13644. outStr = arr[0].SidName;
  13645. break;
  13646. case 1:
  13647. outStr = arr[0].DataPriceStr;
  13648. break;
  13649. case 2:
  13650. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13651. break;
  13652. case 4:
  13653. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13654. break;
  13655. case 7:
  13656. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13657. {
  13658. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13659. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13660. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13661. }
  13662. break;
  13663. case 8:
  13664. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13665. {
  13666. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13667. }
  13668. break;
  13669. case 9:
  13670. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13671. {
  13672. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13673. }
  13674. break;
  13675. case 10:
  13676. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13677. {
  13678. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13679. }
  13680. break;
  13681. }
  13682. return outStr;
  13683. }
  13684. #region OP行程单
  13685. /// <summary>
  13686. /// OP行程单初始化
  13687. /// </summary>
  13688. /// <param name="dto"></param>
  13689. /// <returns></returns>
  13690. [HttpPost]
  13691. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13692. {
  13693. var jw = JsonView(false);
  13694. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13695. var group = groupList.First();
  13696. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13697. if (group == null)
  13698. {
  13699. jw.Msg = "暂无团组!";
  13700. return Ok(jw);
  13701. }
  13702. group = groupList.Find(x => x.Id == diid);
  13703. if (group == null)
  13704. {
  13705. jw.Msg = "请输入正确的团组ID!";
  13706. return Ok(jw);
  13707. }
  13708. string city = string.Empty;
  13709. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13710. if (blackCode.Count > 0)
  13711. {
  13712. var black = blackCode.First();
  13713. black.BlackCode = black.BlackCode ?? "";
  13714. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13715. if (blackSp.Length > 0)
  13716. {
  13717. try
  13718. {
  13719. var cityArrCode = new List<string>(20);
  13720. foreach (var item in blackSp)
  13721. {
  13722. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13723. var IndexSelect = itemSp[2];
  13724. var cityArrCodeLength = cityArrCode.Count - 1;
  13725. var startCity = IndexSelect.Substring(0, 3);
  13726. if (cityArrCodeLength > 0)
  13727. {
  13728. var arrEndCity = cityArrCode[cityArrCodeLength];
  13729. if (arrEndCity != startCity)
  13730. {
  13731. cityArrCode.Add(startCity.ToUpper());
  13732. }
  13733. }
  13734. else
  13735. {
  13736. cityArrCode.Add(startCity.ToUpper());
  13737. }
  13738. var endCity = IndexSelect.Substring(3, 3);
  13739. cityArrCode.Add(endCity.ToUpper());
  13740. }
  13741. var cityThree = string.Empty;
  13742. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13743. cityThree = cityThree.TrimEnd(',');
  13744. if (string.IsNullOrWhiteSpace(cityThree))
  13745. {
  13746. throw new
  13747. Exception("error");
  13748. }
  13749. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13750. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13751. foreach (var item in cityArrCode)
  13752. {
  13753. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13754. if (find != null)
  13755. {
  13756. city += find.City + "/";
  13757. }
  13758. else
  13759. {
  13760. city += item + "三字码未收入/";
  13761. }
  13762. }
  13763. city = city.TrimEnd('/');
  13764. }
  13765. catch (Exception e)
  13766. {
  13767. city = "黑屏代码格式不正确!";
  13768. }
  13769. }
  13770. }
  13771. else
  13772. {
  13773. city = "未录入黑屏代码";
  13774. }
  13775. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13776. {
  13777. Date = x.Date,
  13778. Days = x.Days,
  13779. Diffgroup = x.Diffgroup,
  13780. Diid = x.Diid,
  13781. Traffic_First = x.Traffic_First,
  13782. Traffic_Second = x.Traffic_Second,
  13783. Trip = x.Trip,
  13784. WeekDay = x.WeekDay,
  13785. Id = x.Id
  13786. }).ToList();
  13787. jw.Data = new
  13788. {
  13789. groupList = groupList.Select(x => new
  13790. {
  13791. x.Id,
  13792. x.TeamName,
  13793. x.TourCode
  13794. }).ToList(),
  13795. groupInfo = new
  13796. {
  13797. group.VisitDays,
  13798. group.TourCode,
  13799. group.VisitPNumber,
  13800. group.TeamName,
  13801. city
  13802. },
  13803. OpTravelList
  13804. };
  13805. jw.Code = 200;
  13806. jw.Msg = "操作成功!";
  13807. return Ok(jw);
  13808. }
  13809. /// <summary>
  13810. /// 删除团组行程单
  13811. /// </summary>
  13812. /// <returns></returns>
  13813. [HttpPost]
  13814. public IActionResult DelTravel(DelOpTravelDto dto)
  13815. {
  13816. var jw = JsonView(false);
  13817. if (dto.UserId <= 0 || dto.Diid <= 0)
  13818. {
  13819. jw.Msg = "请输入正确的参数!";
  13820. return Ok(jw);
  13821. }
  13822. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13823. .SetColumns(x => new Grp_TravelList
  13824. {
  13825. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13826. DeleteUserId = dto.UserId,
  13827. IsDel = 1,
  13828. }).ExecuteCommand();
  13829. jw = JsonView(true);
  13830. return Ok(jw);
  13831. }
  13832. /// <summary>
  13833. /// 行程单保存
  13834. /// </summary>
  13835. /// <returns></returns>
  13836. [HttpPost]
  13837. public IActionResult TravelSave(TravelSaveDto dto)
  13838. {
  13839. var jw = JsonView(false);
  13840. if (dto.Arr.Count > 0)
  13841. {
  13842. try
  13843. {
  13844. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13845. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13846. .ToList();
  13847. _sqlSugar.BeginTran();
  13848. foreach (var item in dto.Arr)
  13849. {
  13850. if (item.Id == 0)
  13851. {
  13852. throw new Exception("请传入正确的Id");
  13853. }
  13854. //比较上一次的差异
  13855. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13856. if (findTravel != null)
  13857. {
  13858. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13859. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13860. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13861. }
  13862. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13863. .SetColumns(x => new Grp_TravelList
  13864. {
  13865. Trip = item.Trip
  13866. }).ExecuteCommand();
  13867. }
  13868. _sqlSugar.CommitTran();
  13869. jw = JsonView(true);
  13870. }
  13871. catch (Exception ex)
  13872. {
  13873. _sqlSugar.RollbackTran();
  13874. jw.Msg = "程序异常!" + ex.Message;
  13875. }
  13876. }
  13877. else
  13878. {
  13879. jw.Msg = "请传入正确的参数!";
  13880. }
  13881. return Ok(jw);
  13882. }
  13883. private static string CheckStr(string original, string changed)
  13884. {
  13885. // 创建diff_match_patch对象
  13886. var dmp = new diff_match_patch();
  13887. // 计算差异
  13888. List<Diff> diffs = dmp.diff_main(original, changed);
  13889. // 清理和合并差异
  13890. dmp.diff_cleanupSemantic(diffs);
  13891. // 使用StringBuilder构建最终的字符串
  13892. var finalString = new StringBuilder();
  13893. // 输出差异结果,并构建变动后的字符串
  13894. foreach (Diff diff in diffs)
  13895. {
  13896. switch (diff.operation)
  13897. {
  13898. case Operation.EQUAL:
  13899. // 相等的部分,直接添加到最终字符串
  13900. finalString.Append(diff.text);
  13901. break;
  13902. case Operation.INSERT:
  13903. // 插入的部分,添加标记并添加到最终字符串
  13904. finalString.Append("[++]" + diff.text + "[++]");
  13905. break;
  13906. case Operation.DELETE:
  13907. // 删除的部分,不添加到最终字符串
  13908. //finalString.Append("[++]" + diff.text + "[++]");
  13909. break;
  13910. }
  13911. }
  13912. // 输出变动后的字符串
  13913. return finalString.ToString();
  13914. }
  13915. private class tagContent
  13916. {
  13917. public DateTime Date { get; set; }
  13918. public string StartTag { get; set; }
  13919. public string EndTag { get; set; }
  13920. public string Content { get; set; }
  13921. public static int tagLength { get { return 3; } }
  13922. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13923. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13924. public bool IsFinally { get; set; }
  13925. }
  13926. private static List<string> ExtractContentBetweenTags(string input, string tag)
  13927. {
  13928. var results = new List<string>();
  13929. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13930. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13931. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13932. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13933. string[] strValueArr = new string[1];
  13934. foreach (System.Text.RegularExpressions.Match match in matches)
  13935. {
  13936. var strValue = match.Groups[1].Value;
  13937. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13938. }
  13939. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13940. return results;
  13941. }
  13942. /// <summary>
  13943. /// 导出行程单
  13944. /// </summary>
  13945. /// <param name="dto"></param>
  13946. /// <returns></returns>
  13947. [HttpPost]
  13948. public IActionResult ExportTravel(ExportTravelDto dto)
  13949. {
  13950. var jw = JsonView(false);
  13951. jw.Data = "";
  13952. int diid = 0;
  13953. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13954. if (Find == null)
  13955. {
  13956. jw.Msg = "请选择正确的团组!";
  13957. return Ok(jw);
  13958. }
  13959. else
  13960. {
  13961. diid = Find.Id;
  13962. }
  13963. //数据源
  13964. var _travelList = new List<Grp_TravelList>();
  13965. DataTable dtBlack = null;
  13966. try
  13967. {
  13968. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13969. }
  13970. catch (Exception)
  13971. {
  13972. jw.Msg = "机票黑屏代码有误!";
  13973. return Ok(jw);
  13974. }
  13975. string CityStr = string.Empty;
  13976. if (dtBlack.Rows.Count == 0)
  13977. {
  13978. jw.Msg = "机票黑屏代码有误!";
  13979. return Ok(jw);
  13980. }
  13981. else
  13982. {
  13983. foreach (DataRow row in dtBlack.Rows)
  13984. {
  13985. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13986. {
  13987. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13988. return Ok(jw);
  13989. }
  13990. }
  13991. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13992. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13993. }
  13994. // 指定的文字
  13995. var targetTextDic = new Dictionary<string, List<string>>();
  13996. //创建数据源Table
  13997. var dtSource = new DataTable();
  13998. dtSource.Columns.Add("Days", typeof(string));
  13999. dtSource.Columns.Add("Date", typeof(string));
  14000. dtSource.Columns.Add("Week", typeof(string));
  14001. dtSource.Columns.Add("Traffic", typeof(string));
  14002. dtSource.Columns.Add("Trip", typeof(string));
  14003. //获取数据,放到datatable
  14004. foreach (var item in _travelList)
  14005. {
  14006. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14007. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14008. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14009. .Replace("[++]", string.Empty);
  14010. DataRow dr = dtSource.NewRow();
  14011. dr["Days"] = item.Days;
  14012. dr["Date"] = item.Date;
  14013. dr["Week"] = item.WeekDay;
  14014. dr["Traffic"] = item.Traffic_First
  14015. + "\r\n"
  14016. + item.Traffic_Second;
  14017. dr["Trip"] = item.Trip;
  14018. dtSource.Rows.Add(dr);
  14019. }
  14020. var dic = new Dictionary<string, string>
  14021. {
  14022. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14023. { "City", CityStr },
  14024. { "Days", Find.VisitDays.ToString() },
  14025. { "DeleCode", Find.TourCode },
  14026. { "Pnum", Find.VisitPNumber.ToString() }
  14027. };
  14028. //模板路径
  14029. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14030. //载入模板
  14031. Document doc = null;
  14032. DocumentBuilder builder = null;
  14033. try
  14034. {
  14035. //载入模板
  14036. doc = new Document(tempPath);
  14037. builder = new DocumentBuilder(doc);
  14038. }
  14039. catch (Exception)
  14040. {
  14041. jw.Msg = "模板位置不存在!";
  14042. return Ok(jw);
  14043. }
  14044. foreach (var key in dic.Keys)
  14045. {
  14046. Bookmark bookmark = doc.Range.Bookmarks[key];
  14047. if (bookmark != null)
  14048. {
  14049. builder.MoveToBookmark(key);
  14050. builder.Write(dic[key]);
  14051. }
  14052. }
  14053. //获取word里所有表格
  14054. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14055. //获取所填表格的序数
  14056. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14057. try
  14058. {
  14059. //循环赋值
  14060. for (int i = 0; i < dtSource.Rows.Count; i++)
  14061. {
  14062. builder.MoveToCell(0, i + 1, 0, 0);
  14063. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14064. builder.MoveToCell(0, i + 1, 1, 0);
  14065. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14066. builder.MoveToCell(0, i + 1, 2, 0);
  14067. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14068. var trip = dtSource.Rows[i]["Trip"].ToString();
  14069. builder.MoveToCell(0, i + 1, 3, 0);
  14070. builder.Write(trip);
  14071. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14072. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14073. // 获取特定索引的段落
  14074. Paragraph paragraph = (Paragraph)paragraphs[0];
  14075. Run run = paragraph.Runs[0];
  14076. Aspose.Words.Font font = run.Font;
  14077. font.Name = "黑体";
  14078. //设置双休红色
  14079. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14080. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14081. paragraph = (Paragraph)paragraphs[1];
  14082. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14083. {
  14084. run = paragraph.Runs[0];
  14085. font = run.Font;
  14086. font.Color = Color.Red;
  14087. }
  14088. }
  14089. }
  14090. catch (Exception ex)
  14091. {
  14092. }
  14093. //删除多余行
  14094. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14095. {
  14096. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14097. }
  14098. var targetTextList = new List<string>();
  14099. // 遍历文档中的表格
  14100. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14101. {
  14102. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14103. {
  14104. var cellIndex = 0;
  14105. foreach (Cell cell in row.Cells)
  14106. {
  14107. if (cellIndex == 1 && row.Cells.Count == 4)
  14108. {
  14109. foreach (var target in targetTextDic.Keys)
  14110. {
  14111. if (cell.GetText().Contains(target))
  14112. {
  14113. targetTextList = targetTextDic[target];
  14114. break;
  14115. }
  14116. }
  14117. }
  14118. // 遍历单元格中的所有段落
  14119. foreach (Paragraph paragraph in cell.Paragraphs)
  14120. {
  14121. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14122. var runs = new List<Run>();
  14123. foreach (Run run in paragraph.Runs)
  14124. {
  14125. runs.Add(run);
  14126. }
  14127. foreach (Run run in runs)
  14128. {
  14129. foreach (var targetText in targetTextList)
  14130. {
  14131. // 检查文字是否包含指定文字
  14132. if (run.Text.Contains(targetText))
  14133. {
  14134. // 将包含的部分设置为红色
  14135. HighlightText(run, targetText, Color.Red);
  14136. }
  14137. }
  14138. }
  14139. }
  14140. cellIndex++;
  14141. }
  14142. }
  14143. }
  14144. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14145. if (!Directory.Exists(savePath))
  14146. {
  14147. try
  14148. {
  14149. Directory.CreateDirectory(savePath);
  14150. }
  14151. catch
  14152. {
  14153. }
  14154. }
  14155. string path = savePath + Find.TeamName + "出访日程";
  14156. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14157. try
  14158. {
  14159. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14160. string postfix = ".docx";
  14161. if (dto.IsPDF == 1)
  14162. {
  14163. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14164. postfix = ".pdf";
  14165. }
  14166. doc.Save(path + postfix, saveFormat);
  14167. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14168. }
  14169. catch (Exception)
  14170. {
  14171. jw = JsonView(false);
  14172. }
  14173. return Ok(jw);
  14174. }
  14175. /// <summary>
  14176. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14177. /// </summary>
  14178. /// <param name="num"></param>
  14179. /// <returns></returns>
  14180. static string GetNum(string num)
  14181. {
  14182. string str = "";
  14183. switch (num)
  14184. {
  14185. case "1":
  14186. str = "一";
  14187. break;
  14188. case "2":
  14189. str = "二";
  14190. break;
  14191. case "3":
  14192. str = "三";
  14193. break;
  14194. case "4":
  14195. str = "四";
  14196. break;
  14197. case "5":
  14198. str = "五";
  14199. break;
  14200. case "6":
  14201. str = "六";
  14202. break;
  14203. case "7":
  14204. str = "七";
  14205. break;
  14206. case "8":
  14207. str = "八";
  14208. break;
  14209. case "9":
  14210. str = "九";
  14211. break;
  14212. case "10":
  14213. str = "十";
  14214. break;
  14215. case "11":
  14216. str = "十一";
  14217. break;
  14218. case "12":
  14219. str = "十二";
  14220. break;
  14221. case "一":
  14222. str = "1";
  14223. break;
  14224. case "二":
  14225. str = "2";
  14226. break;
  14227. case "三":
  14228. str = "3";
  14229. break;
  14230. case "四":
  14231. str = "4";
  14232. break;
  14233. case "五":
  14234. str = "5";
  14235. break;
  14236. case "六":
  14237. str = "6";
  14238. break;
  14239. case "七":
  14240. str = "7";
  14241. break;
  14242. case "八":
  14243. str = "8";
  14244. break;
  14245. case "九":
  14246. str = "9";
  14247. break;
  14248. case "十":
  14249. str = "10";
  14250. break;
  14251. case "十一":
  14252. str = "11";
  14253. break;
  14254. case "十二":
  14255. str = "12";
  14256. break;
  14257. }
  14258. return str;
  14259. }
  14260. /// <summary>
  14261. /// 高亮包含指定文字的部分
  14262. /// </summary>
  14263. /// <param name="run"></param>
  14264. /// <param name="targetText"></param>
  14265. /// <param name="color"></param>
  14266. static void HighlightText(Run run, string targetText, Color color)
  14267. {
  14268. string text = run.Text;
  14269. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14270. if (startIndex >= 0)
  14271. {
  14272. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14273. // 前部分
  14274. if (startIndex > 0)
  14275. {
  14276. Run beforeRun = (Run)run.Clone(true);
  14277. beforeRun.Text = text.Substring(0, startIndex);
  14278. parentParagraph.InsertBefore(beforeRun, run);
  14279. }
  14280. // 匹配部分
  14281. Run matchRun = (Run)run.Clone(true);
  14282. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14283. matchRun.Font.Color = color;
  14284. parentParagraph.InsertBefore(matchRun, run);
  14285. // 后部分
  14286. if (startIndex + targetText.Length < text.Length)
  14287. {
  14288. Run afterRun = (Run)run.Clone(true);
  14289. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14290. parentParagraph.InsertBefore(afterRun, run);
  14291. }
  14292. // 删除原始Run
  14293. run.Remove();
  14294. }
  14295. }
  14296. #endregion
  14297. #endregion
  14298. #region 团组成本
  14299. /// <summary>
  14300. /// 团组成本数据初始化
  14301. /// </summary>
  14302. /// <param name="dto"></param>
  14303. /// <returns></returns>
  14304. [HttpPost]
  14305. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14306. {
  14307. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14308. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14309. WHEN COUNT(*) >= 0 THEN 'True'
  14310. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14311. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14312. ").ToList(); //团组列表
  14313. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14314. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14315. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14316. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14317. if (groupinfoValue != null)
  14318. {
  14319. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14320. var spArr = new string[1] { countryArr };
  14321. if (countryArr.Contains("|"))
  14322. {
  14323. spArr = countryArr.Split("|");
  14324. }
  14325. else if (countryArr.Contains("、"))
  14326. {
  14327. spArr = countryArr.Split("、");
  14328. }
  14329. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14330. {
  14331. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14332. if (dbQueryCountry != null)
  14333. {
  14334. visaCountryInfoArr.Add(dbQueryCountry);
  14335. }
  14336. }
  14337. }
  14338. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14339. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14340. #region 屏蔽黑屏代码生成
  14341. //var create = _GroupCostRepository.
  14342. // CreateGroupCostByBlackCode(dto.Diid);
  14343. //if (groupCost.Count == 0 && create.Code == 0)
  14344. //{
  14345. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14346. //}
  14347. #endregion
  14348. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14349. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14350. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14351. groupCostMap = groupCostMap.Select(x =>
  14352. {
  14353. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14354. {
  14355. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14356. }
  14357. return x;
  14358. }).ToList();
  14359. //GroupCostParameter.Add(new
  14360. // Grp_GroupCostParameter());
  14361. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14362. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14363. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14364. return Ok(JsonView(new
  14365. {
  14366. groupList,
  14367. groupInfo,
  14368. groupChecks,
  14369. groupCost = groupCostMap,
  14370. hotelNumber,
  14371. GroupCostParameter = GroupCostParameterMap,
  14372. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14373. {
  14374. x.VisaCountry,
  14375. x.VisaPrice,
  14376. x.Id,
  14377. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14378. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14379. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14380. x.VisaTime, // 一般签证时间
  14381. x.PettyBusinessAgencyFee, //小公务代办费
  14382. x.GrandBusinessAgencyFee //大公务代办费
  14383. }).ToList(),
  14384. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14385. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14386. hotelIsTrue,
  14387. groupModuleOperators
  14388. }));
  14389. }
  14390. /// <summary>
  14391. /// 团组成本信息保存
  14392. /// </summary>
  14393. /// <param name="dto"></param>
  14394. /// <returns></returns>
  14395. [HttpPost]
  14396. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14397. {
  14398. if (dto.Diid <= 0 || dto.Userid <= 0)
  14399. {
  14400. return Ok(JsonView(false));
  14401. }
  14402. JsonView jw = null;
  14403. bool isTrue = false;
  14404. #region 复制团组成本
  14405. //if (dto.Diid == 2581)
  14406. //{
  14407. // dto.Diid = 2599;
  14408. // dto.CheckBoxs.ForEach(x =>
  14409. // {
  14410. // x.Diid = 2599;
  14411. // });
  14412. // dto.GroupCosts.ForEach(x =>
  14413. // {
  14414. // x.Diid = 2599;
  14415. // });
  14416. // dto.CostTypeHotelNumbers.ForEach(x =>
  14417. // {
  14418. // x.Diid = 2599;
  14419. // });
  14420. // dto.GroupCostParameters.ForEach(x =>
  14421. // {
  14422. // x.DiId = 2599;
  14423. // });
  14424. //}
  14425. #endregion
  14426. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14427. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14428. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14429. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14430. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14431. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14432. try
  14433. {
  14434. _sqlSugar.BeginTran();
  14435. isTrue = await _GroupCostRepository.
  14436. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14437. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14438. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14439. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14440. _sqlSugar.CommitTran();
  14441. jw = JsonView(true, "保存成功!", isTrue);
  14442. }
  14443. catch (Exception)
  14444. {
  14445. _sqlSugar.RollbackTran();
  14446. jw = JsonView(false);
  14447. }
  14448. return Ok(jw);
  14449. }
  14450. /// <summary>
  14451. /// 复制团组成本信息
  14452. /// </summary>
  14453. /// <param name="dto"></param>
  14454. /// <returns></returns>
  14455. [HttpPost]
  14456. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14457. {
  14458. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14459. {
  14460. return Ok(JsonView(false, "参数有误!"));
  14461. }
  14462. #region 复制团组成本
  14463. dto.Diid = dto.ToGroupId;
  14464. dto.CheckBoxs.ForEach(x =>
  14465. {
  14466. x.Diid = dto.ToGroupId;
  14467. });
  14468. dto.GroupCosts.ForEach(x =>
  14469. {
  14470. x.Diid = dto.ToGroupId;
  14471. });
  14472. dto.CostTypeHotelNumbers.ForEach(x =>
  14473. {
  14474. x.Diid = dto.ToGroupId;
  14475. });
  14476. dto.GroupCostParameters.ForEach(x =>
  14477. {
  14478. x.DiId = dto.ToGroupId;
  14479. });
  14480. #endregion
  14481. JsonView jw = null;
  14482. bool isTrue = false;
  14483. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14484. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14485. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14486. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14487. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14488. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14489. try
  14490. {
  14491. _sqlSugar.BeginTran();
  14492. isTrue = await _GroupCostRepository.
  14493. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14494. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14495. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14496. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14497. _sqlSugar.CommitTran();
  14498. jw = JsonView(true, "保存成功!", isTrue);
  14499. }
  14500. catch (Exception)
  14501. {
  14502. _sqlSugar.RollbackTran();
  14503. jw = JsonView(false);
  14504. }
  14505. return Ok(jw);
  14506. }
  14507. /// <summary>
  14508. /// 司兼导数据
  14509. /// </summary>
  14510. /// <param name="dto"></param>
  14511. /// <returns></returns>
  14512. [HttpPost]
  14513. public IActionResult GetCarGuides(CarGuidesDto dto)
  14514. {
  14515. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14516. return Ok(JsonView(true, "获取成功!", Data));
  14517. }
  14518. /// <summary>
  14519. /// 导游数据
  14520. /// </summary>
  14521. /// <param name="dto"></param>
  14522. /// <returns></returns>
  14523. [HttpPost]
  14524. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14525. {
  14526. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14527. // 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
  14528. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14529. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14530. return Ok(JsonView(true, "获取成功!", Data));
  14531. }
  14532. /// <summary>
  14533. /// 成本车数据
  14534. /// </summary>
  14535. /// <param name="dto"></param>
  14536. /// <returns></returns>
  14537. [HttpPost]
  14538. public IActionResult GetCarInfo(CarGuidesDto dto)
  14539. {
  14540. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14541. return Ok(JsonView(true, "获取成功!", Data));
  14542. }
  14543. /// <summary>
  14544. /// 景点数据
  14545. /// </summary>
  14546. /// <param name="dto"></param>
  14547. /// <returns></returns>
  14548. [HttpPost]
  14549. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14550. {
  14551. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14552. return Ok(JsonView(true, "获取成功!", Data));
  14553. }
  14554. /// <summary>
  14555. /// 成本通知
  14556. /// </summary>
  14557. /// <param name="dto"></param>
  14558. /// <returns></returns>
  14559. [HttpPost]
  14560. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14561. {
  14562. if (dto.Diid < 0)
  14563. {
  14564. return Ok(JsonView(false));
  14565. }
  14566. JsonView jw;
  14567. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14568. if (GroupCostParameter != null)
  14569. {
  14570. int IsShare = 0;
  14571. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14572. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14573. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14574. string msg = string.Empty;
  14575. if (isTrue)
  14576. {
  14577. if (IsShare == 0)
  14578. {
  14579. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14580. }
  14581. else
  14582. {
  14583. #region 企微通知对应岗位用户
  14584. try
  14585. {
  14586. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14587. }
  14588. catch (Exception)
  14589. {
  14590. }
  14591. #endregion
  14592. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14593. }
  14594. jw = JsonView(isTrue, msg, new { IsShare });
  14595. }
  14596. else
  14597. {
  14598. msg = "修改失败!";
  14599. jw = JsonView(isTrue, msg);
  14600. }
  14601. }
  14602. else
  14603. {
  14604. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14605. }
  14606. return Ok(jw);
  14607. }
  14608. /// <summary>
  14609. /// 导出报价单
  14610. /// </summary>
  14611. /// <param name="dto"></param>
  14612. /// <returns></returns>
  14613. [HttpPost]
  14614. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14615. {
  14616. if (dto.Diid == 0)
  14617. {
  14618. return Ok(JsonView(false, "请传递团组id"));
  14619. }
  14620. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14621. if (deleInfo.Code != 0)
  14622. {
  14623. return Ok(JsonView(false, "团组信息查询失败!"));
  14624. }
  14625. var di = deleInfo.Data as DelegationInfoWebView;
  14626. if (di != null)
  14627. {
  14628. di.TeamName = di.TeamName.Replace("|", "、");
  14629. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14630. //文件名
  14631. string strFileName = di.TeamName + "-收款账单.doc";
  14632. //获取模板
  14633. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14634. //载入模板
  14635. Document doc = new Document(tmppath);
  14636. decimal TotalPrice = 0.00M;
  14637. string itemStr = string.Empty;
  14638. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14639. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14640. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14641. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14642. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14643. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14644. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14645. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14646. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14647. foreach (var cost in groupCostType)
  14648. {
  14649. var List = cost.ToList();
  14650. if (cost.Key == "A")
  14651. {
  14652. foreach (var ListItem in List)
  14653. {
  14654. if (ListItem.number > 0)
  14655. {
  14656. if (ListItem.code.Contains("TBR"))
  14657. {
  14658. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14659. }
  14660. else
  14661. {
  14662. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14663. }
  14664. TotalPrice += (ListItem.number * ListItem.price);
  14665. }
  14666. }
  14667. }
  14668. else
  14669. {
  14670. itemStr = itemStr.Insert(0, "A段\r\n");
  14671. itemStr += "B段\r\n";
  14672. foreach (var ListItem in List)
  14673. {
  14674. if (ListItem.number > 0)
  14675. {
  14676. if (ListItem.code.Contains("TBR"))
  14677. {
  14678. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14679. }
  14680. else
  14681. {
  14682. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14683. }
  14684. TotalPrice += (ListItem.number * ListItem.price);
  14685. }
  14686. }
  14687. }
  14688. }
  14689. #region 替换Word模板书签内容
  14690. Dictionary<string, string> marks = new Dictionary<string, string>();
  14691. marks.Add("To", di.ClientUnit);//付款方
  14692. marks.Add("ToTel", di.TellPhone);//付款方电话
  14693. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14694. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14695. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14696. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14697. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14698. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14699. marks.Add("PayItemContent", itemStr);//详细信息
  14700. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14701. #endregion
  14702. ////注
  14703. //if (doc.Range.Bookmarks["Attention"] != null)
  14704. //{
  14705. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14706. // mark.Text = frList[0].Attention;
  14707. //}
  14708. foreach (var item in marks.Keys)
  14709. {
  14710. if (doc.Range.Bookmarks[item] != null)
  14711. {
  14712. Bookmark mark = doc.Range.Bookmarks[item];
  14713. mark.Text = marks[item];
  14714. }
  14715. }
  14716. byte[] bytes = null;
  14717. using (MemoryStream stream = new MemoryStream())
  14718. {
  14719. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14720. bytes = stream.ToArray();
  14721. }
  14722. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14723. return Ok(JsonView(true, "", new
  14724. {
  14725. Data = bytes,
  14726. strFileName,
  14727. }));
  14728. }
  14729. else
  14730. {
  14731. return Ok(JsonView(false, "团组信息不存在!"));
  14732. }
  14733. }
  14734. /// <summary>
  14735. /// 导出团组成本
  14736. /// </summary>
  14737. /// <param name="dto"></param>
  14738. /// <returns></returns>
  14739. [HttpPost]
  14740. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14741. {
  14742. var jw = JsonView(false);
  14743. if (dto.Diid == 0)
  14744. {
  14745. return Ok(JsonView(false, "请传递团组id"));
  14746. }
  14747. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14748. if (deleInfo.Code != 0)
  14749. {
  14750. return Ok(JsonView(false, "团组信息查询失败!"));
  14751. }
  14752. var di = deleInfo.Data as DelegationInfoWebView;
  14753. if (di == null)
  14754. {
  14755. return Ok(JsonView(false, "团组信息查询失败!"));
  14756. }
  14757. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14758. WorkbookDesigner designer = new WorkbookDesigner();
  14759. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14760. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14761. List<int> hideColumnList = new List<int>();
  14762. var ColumnSetting = new[]
  14763. {
  14764. new { tag = "VF", Index = 4, P = "CarCost" },
  14765. new { tag = "VN", Index = 5, P = "CarNumber" },
  14766. new { tag = "VRD", Index = 6, P = "CarTiming" },
  14767. new { tag = "T/G S", Index = 7, P = "TGS" },
  14768. new { tag = "TGWH", Index = 8, P = "TGWH" },
  14769. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  14770. new { tag = "T/G M", Index = 10, P = "TGM" },
  14771. new { tag = "T/G A", Index = 11, P = "TGA" },
  14772. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  14773. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  14774. new { tag = "C/F S", Index = 14, P = "CFS" },
  14775. new { tag = "C/F M", Index = 15, P = "CFM" },
  14776. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  14777. new { tag = "B", Index = 17, P = "B" },
  14778. new { tag = "L", Index = 18, P = "L" },
  14779. new { tag = "D", Index = 19, P = "D" },
  14780. new { tag = "TBR", Index = 20, P = "TBR" },
  14781. new { tag = "SGR", Index = 21, P = "SGR" },
  14782. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  14783. new { tag = "Suite", Index = 23, P = "Suite" },
  14784. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  14785. new { tag = "T/V", Index = 25, P = "TV" },
  14786. new { tag = "1/L", Index = 26, P = "iL" },
  14787. new { tag = "I/F", Index = 27, P = "IF" },
  14788. new { tag = "EF", Index = 28, P = "EF" },
  14789. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  14790. new { tag = "TE", Index = 30, P = "TE" },
  14791. new { tag = "T/G T", Index = 31, P = "TGTips" },
  14792. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  14793. new { tag = "P/C", Index = 33, P = "PC" },
  14794. new { tag = "T/L F", Index = 34, P = "TLF" },
  14795. new { tag = "E/C T", Index = 35, P = "ECT" }
  14796. };
  14797. Func<string, bool> isEmpty = (str) =>
  14798. {
  14799. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  14800. {
  14801. return true;
  14802. }
  14803. if (string.IsNullOrWhiteSpace(str))
  14804. {
  14805. return true;
  14806. }
  14807. return false;
  14808. };
  14809. for (int i = 0; i < List_GC.Count; i++)
  14810. {
  14811. GroupCost_Excel gc = new GroupCost_Excel();
  14812. gc.Id = List_GC[i].Id;
  14813. gc.Diid = List_GC[i].Diid.ToString();
  14814. gc.DAY = List_GC[i].DAY;
  14815. string week = "";
  14816. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14817. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14818. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14819. gc.ITIN = List_GC[i].ITIN;
  14820. gc.CarType = List_GC[i].CarType;
  14821. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  14822. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  14823. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  14824. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  14825. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  14826. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  14827. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  14828. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  14829. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  14830. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  14831. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  14832. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  14833. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  14834. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  14835. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  14836. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  14837. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  14838. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  14839. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  14840. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  14841. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  14842. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  14843. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  14844. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  14845. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  14846. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  14847. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  14848. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  14849. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  14850. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  14851. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  14852. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  14853. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  14854. gc.EFR = List_GC[i].EFR;
  14855. List_GC1.Add(gc);
  14856. }
  14857. if (List_GC1.Count > 0)
  14858. {
  14859. var p = List_GC1[0];
  14860. var prs = p.GetType().GetProperties();
  14861. foreach (var item in prs)
  14862. {
  14863. var tp = item.PropertyType;
  14864. if (tp == typeof(int))
  14865. {
  14866. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  14867. if (val == 0)
  14868. {
  14869. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14870. if (columnSetting != null)
  14871. {
  14872. hideColumnList.Add(columnSetting.Index);
  14873. }
  14874. }
  14875. }
  14876. if (tp == typeof(decimal))
  14877. {
  14878. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  14879. if (val == 0)
  14880. {
  14881. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14882. if (columnSetting != null)
  14883. {
  14884. hideColumnList.Add(columnSetting.Index);
  14885. }
  14886. }
  14887. }
  14888. if (tp == typeof(string))
  14889. {
  14890. var val = List_GC1.Sum(x =>
  14891. {
  14892. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  14893. if (decimal.TryParse(str, out decimal str_De))
  14894. {
  14895. return str_De;
  14896. }
  14897. else
  14898. {
  14899. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  14900. }
  14901. });
  14902. if (val == 0)
  14903. {
  14904. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14905. if (columnSetting != null)
  14906. {
  14907. hideColumnList.Add(columnSetting.Index);
  14908. }
  14909. }
  14910. }
  14911. }
  14912. }
  14913. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14914. dt.TableName = "TB";
  14915. //报表标题等不用dt的值
  14916. designer.SetDataSource("TeamName", dto.title.TeamName);
  14917. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14918. designer.SetDataSource("Tax", dto.title.Tax);
  14919. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14920. designer.SetDataSource("Currency", dto.title.Currency);
  14921. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14922. designer.SetDataSource("Rate", dto.title.Rate);
  14923. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14924. var Aparams = hotels.Find(x => x.Type == "Default");
  14925. if (Aparams == null)
  14926. {
  14927. return Ok(jw);
  14928. }
  14929. //酒店数量
  14930. var txtSGRNumber = Aparams.SGR.ToString();
  14931. var txtTBRNumber = Aparams.TBR.ToString();
  14932. var txtJSESNumber = Aparams.JSES.ToString();
  14933. var txtSUITENumbe = Aparams.SUITE.ToString();
  14934. if (dto.costType == "B")
  14935. {
  14936. Aparams = hotels.Find(x => x.Type == "A");
  14937. var Bparams = hotels.Find(x => x.Type == "B");
  14938. if (Aparams == null || Bparams == null)
  14939. {
  14940. return Ok(jw);
  14941. }
  14942. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14943. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14944. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14945. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14946. }
  14947. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14948. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14949. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14950. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14951. var ws = designer.Workbook.Worksheets[1];
  14952. int Row = List_GC.Count;
  14953. int startIndex = 0;
  14954. int HideRows = 0;
  14955. Row = 0;
  14956. List<int> hideRowsList = new List<int>();
  14957. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14958. #region A段left数据
  14959. var left = dto.leftInfo.Find(x => x.Type == "A");
  14960. if (left == null)
  14961. {
  14962. return Ok(jw);
  14963. }
  14964. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14965. if (leftBindData != null)
  14966. {
  14967. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14968. designer.SetDataSource("VisaRS", leftBindData.rs);
  14969. designer.SetDataSource("VisaXS", leftBindData.xs);
  14970. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14971. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14972. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14973. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14974. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14975. }
  14976. else
  14977. {
  14978. hideRowsList.Add(Row + startIndex + HideRows);
  14979. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14980. }
  14981. HideRows += 2;
  14982. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14983. if (leftBindData != null)
  14984. {
  14985. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14986. designer.SetDataSource("BXRS", leftBindData.rs);
  14987. designer.SetDataSource("BXXS", leftBindData.xs);
  14988. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14989. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14990. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14991. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14992. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14993. }
  14994. else
  14995. {
  14996. hideRowsList.Add(Row + startIndex + HideRows);
  14997. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14998. }
  14999. HideRows += 2;
  15000. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15001. if (leftBindData != null)
  15002. {
  15003. designer.SetDataSource("HSDRCB", leftBindData.cb);
  15004. designer.SetDataSource("HSRS", leftBindData.rs);
  15005. designer.SetDataSource("HSXS", leftBindData.xs);
  15006. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15007. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15008. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15009. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15010. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15011. }
  15012. else
  15013. {
  15014. hideRowsList.Add(Row + startIndex + HideRows);
  15015. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15016. }
  15017. HideRows += 2;
  15018. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15019. if (leftBindData != null)
  15020. {
  15021. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  15022. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15023. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15024. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15025. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15026. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15027. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15028. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15029. }
  15030. else
  15031. {
  15032. hideRowsList.Add(Row + startIndex + HideRows);
  15033. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15034. }
  15035. HideRows += 2;
  15036. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15037. if (leftBindData != null)
  15038. {
  15039. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  15040. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15041. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15042. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15043. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15044. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15045. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15046. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15047. }
  15048. else
  15049. {
  15050. hideRowsList.Add(Row + startIndex + HideRows);
  15051. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15052. }
  15053. HideRows += 2;
  15054. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15055. if (leftBindData != null)
  15056. {
  15057. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15058. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15059. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15060. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15061. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15062. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15063. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15064. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15065. }
  15066. else
  15067. {
  15068. hideRowsList.Add(Row + startIndex + HideRows);
  15069. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15070. }
  15071. HideRows += 2;
  15072. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15073. if (leftBindData != null)
  15074. {
  15075. ////TBR
  15076. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15077. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15078. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15079. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15080. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15081. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15082. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15083. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15084. }
  15085. else
  15086. {
  15087. hideRowsList.Add(Row + startIndex + HideRows);
  15088. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15089. }
  15090. HideRows += 2;
  15091. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15092. if (leftBindData != null)
  15093. {
  15094. ////SGR
  15095. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  15096. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  15097. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  15098. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15099. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15100. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15101. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15102. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15103. }
  15104. else
  15105. {
  15106. hideRowsList.Add(Row + startIndex + HideRows);
  15107. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15108. }
  15109. HideRows += 2;
  15110. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15111. if (leftBindData != null)
  15112. {
  15113. ////JS/ES
  15114. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15115. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15116. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15117. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15118. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15119. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15120. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15121. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15122. }
  15123. else
  15124. {
  15125. hideRowsList.Add(Row + startIndex + HideRows);
  15126. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15127. }
  15128. HideRows += 2;
  15129. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15130. if (leftBindData != null)
  15131. {
  15132. ////SUITE
  15133. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15134. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15135. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15136. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15137. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15138. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15139. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15140. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15141. }
  15142. else
  15143. {
  15144. hideRowsList.Add(Row + startIndex + HideRows);
  15145. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15146. }
  15147. HideRows += 2;
  15148. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15149. if (leftBindData != null)
  15150. {
  15151. designer.SetDataSource("DJDRCB", leftBindData.cb);
  15152. designer.SetDataSource("DJRS", leftBindData.rs);
  15153. designer.SetDataSource("DJXS", leftBindData.xs);
  15154. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15155. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15156. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15157. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15158. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15159. }
  15160. else
  15161. {
  15162. hideRowsList.Add(Row + startIndex + HideRows);
  15163. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15164. }
  15165. HideRows += 2;
  15166. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15167. if (leftBindData != null)
  15168. {
  15169. designer.SetDataSource("HCPCB", leftBindData.cb);
  15170. designer.SetDataSource("HCPRS", leftBindData.rs);
  15171. designer.SetDataSource("HCPXS", leftBindData.xs);
  15172. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15173. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15174. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15175. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15176. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15177. }
  15178. else
  15179. {
  15180. hideRowsList.Add(Row + startIndex + HideRows);
  15181. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15182. }
  15183. HideRows += 2;
  15184. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15185. if (leftBindData != null)
  15186. {
  15187. designer.SetDataSource("CPCB", leftBindData.cb);
  15188. designer.SetDataSource("CPRS", leftBindData.rs);
  15189. designer.SetDataSource("CPXS", leftBindData.xs);
  15190. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15191. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15192. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15193. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15194. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15195. }
  15196. else
  15197. {
  15198. hideRowsList.Add(Row + startIndex + HideRows);
  15199. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15200. }
  15201. HideRows += 2;
  15202. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15203. if (leftBindData != null)
  15204. {
  15205. designer.SetDataSource("GWDRCD", leftBindData.cb);
  15206. designer.SetDataSource("GWRS", leftBindData.rs);
  15207. designer.SetDataSource("GWXS", leftBindData.xs);
  15208. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15209. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15210. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15211. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15212. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15213. }
  15214. else
  15215. {
  15216. hideRowsList.Add(Row + startIndex + HideRows);
  15217. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15218. }
  15219. HideRows += 2;
  15220. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15221. if (leftBindData != null)
  15222. {
  15223. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15224. designer.SetDataSource("LYJRS", leftBindData.rs);
  15225. designer.SetDataSource("LYJXS", leftBindData.xs);
  15226. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15227. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15228. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15229. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15230. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15231. }
  15232. else
  15233. {
  15234. hideRowsList.Add(Row + startIndex + HideRows);
  15235. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15236. }
  15237. #endregion
  15238. #region A段Right信息
  15239. var right = dto.rightInfo.Find(x => x.Type == "A");
  15240. if (right == null)
  15241. {
  15242. return Ok(jw);
  15243. }
  15244. HideRows += 4;
  15245. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15246. if (rightBindData != null)
  15247. {
  15248. //经济舱 + 双人间 TBR
  15249. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15250. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15251. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15252. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15253. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15254. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15255. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15256. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15257. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15258. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15259. }
  15260. else
  15261. {
  15262. hideRowsList.Add(Row + startIndex + HideRows);
  15263. }
  15264. HideRows += 2;
  15265. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15266. if (rightBindData != null)
  15267. {
  15268. //经济舱 + 单人间 SGR
  15269. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15270. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15271. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15272. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15273. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15274. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15275. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15276. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15277. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15278. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15279. }
  15280. else
  15281. {
  15282. hideRowsList.Add(Row + startIndex + HideRows);
  15283. }
  15284. HideRows += 2;
  15285. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15286. if (rightBindData != null)
  15287. {
  15288. //公务舱 + 单人间 SGR
  15289. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15290. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15291. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15292. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15293. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15294. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15295. designer.SetDataSource("lblGWCSGRZLR", (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("公务舱 JS/ES"));
  15306. if (rightBindData != null)
  15307. {
  15308. //公务舱 + 小套房 JSES
  15309. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15310. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15311. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15312. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15313. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15314. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15315. designer.SetDataSource("lblGWCJSESZLR", (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("公务舱 SUITE"));
  15326. if (rightBindData != null)
  15327. {
  15328. //公务舱 + 小套房 JSES
  15329. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15330. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15331. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15332. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15333. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15334. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15335. designer.SetDataSource("lblGWCSUITEZLR", (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("经济舱 SUITE"));
  15346. if (rightBindData != null)
  15347. {
  15348. //经济舱 + 大套房
  15349. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15350. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15351. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15352. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15353. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15354. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15355. designer.SetDataSource("lblJJCSUITEZLR", (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("头等舱 JS/ES"));
  15366. if (rightBindData != null)
  15367. {
  15368. //头等舱 + 小套房 JSES
  15369. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15370. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15371. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15372. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15373. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15374. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15375. designer.SetDataSource("lblTDCJSESZLR", (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("lblTDCSUITEDRCB", rightBindData.cb);
  15390. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15391. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15392. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15393. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15394. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15395. designer.SetDataSource("lblTDCSUITEZLR", (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. #endregion
  15405. #region B段标题清空
  15406. designer.SetDataSource("CostBDRCB", "");
  15407. designer.SetDataSource("CostBRS", "");
  15408. designer.SetDataSource("CostBXS", "");
  15409. designer.SetDataSource("CostBZCB", "");
  15410. designer.SetDataSource("CostBDRBJ", "");
  15411. designer.SetDataSource("CostBZBJ", "");
  15412. designer.SetDataSource("CostBDRLR", "");
  15413. designer.SetDataSource("CostBZLR", "");
  15414. designer.SetDataSource("CostBDRCBOM", "");
  15415. designer.SetDataSource("CostBRSOM", "");
  15416. designer.SetDataSource("CostBZCBOM", "");
  15417. designer.SetDataSource("CostBDRBJOM", "");
  15418. designer.SetDataSource("CostBZBJOM", "");
  15419. designer.SetDataSource("CostBDRLROM", "");
  15420. designer.SetDataSource("CostBZLROM", "");
  15421. #endregion
  15422. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15423. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15424. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15425. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15426. designer.SetDataSource("DJName", "地接(CNY)");
  15427. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15428. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15429. designer.SetDataSource("GWName", "公务(CNY)");
  15430. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15431. designer.SetDataSource("LYJName", "零用金(CNY)");
  15432. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15433. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15434. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15435. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15436. designer.SetDataSource("BXName", "保险(CNY)");
  15437. designer.SetDataSource("VisaName", "签证(CNY)");
  15438. #region B段基本数据
  15439. if (dto.costType == "B")
  15440. {
  15441. left = dto.leftInfo.Find(x => x.Type == "B");
  15442. if (left == null)
  15443. {
  15444. return Ok(jw);
  15445. }
  15446. #region B段left数据
  15447. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15448. if (leftBindData != null)
  15449. {
  15450. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15451. designer.SetDataSource("BHSRS", leftBindData.rs);
  15452. designer.SetDataSource("BHSXS", leftBindData.xs);
  15453. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15454. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15455. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15456. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15457. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15458. }
  15459. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15460. if (leftBindData != null)
  15461. {
  15462. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15463. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15464. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15465. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15466. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15467. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15468. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15469. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15470. }
  15471. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15472. if (leftBindData != null)
  15473. {
  15474. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15475. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15476. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15477. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15478. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15479. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15480. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15481. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15482. }
  15483. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15484. if (leftBindData != null)
  15485. {
  15486. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15487. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15488. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15489. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15490. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15491. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15492. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15493. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15494. }
  15495. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15496. if (leftBindData != null)
  15497. {
  15498. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15499. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15500. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15501. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15502. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15503. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15504. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15505. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15506. }
  15507. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15508. if (leftBindData != null)
  15509. {
  15510. designer.SetDataSource("BCPCB", leftBindData.cb);
  15511. designer.SetDataSource("BCPRS", leftBindData.rs);
  15512. designer.SetDataSource("BCPXS", leftBindData.xs);
  15513. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15514. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15515. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15516. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15517. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15518. }
  15519. //TBR
  15520. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15521. if (leftBindData != null)
  15522. {
  15523. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15524. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15525. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15526. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15527. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15528. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15529. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15530. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15531. }
  15532. //SGR
  15533. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15534. if (leftBindData != null)
  15535. {
  15536. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15537. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15538. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15539. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15540. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15541. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15542. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15543. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15544. }
  15545. //JS/ES
  15546. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15547. if (leftBindData != null)
  15548. {
  15549. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15550. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15551. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15552. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15553. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15554. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15555. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15556. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15557. }
  15558. //SUITE
  15559. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15560. if (leftBindData != null)
  15561. {
  15562. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15563. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15564. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15565. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15566. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15567. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15568. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15569. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15570. }
  15571. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15572. if (leftBindData != null)
  15573. {
  15574. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15575. designer.SetDataSource("BDJRS", leftBindData.rs);
  15576. designer.SetDataSource("BDJXS", leftBindData.xs);
  15577. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15578. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15579. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15580. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15581. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15582. }
  15583. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15584. if (leftBindData != null)
  15585. {
  15586. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15587. designer.SetDataSource("BGWRS", leftBindData.rs);
  15588. designer.SetDataSource("BGWXS", leftBindData.xs);
  15589. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15590. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15591. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15592. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15593. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15594. }
  15595. #region 优化方案
  15596. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15597. //excelBind.Add("零用金", new {
  15598. //cb="",
  15599. //rs="",
  15600. //xs ="",
  15601. //zcb = "",
  15602. //});
  15603. #endregion
  15604. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15605. if (leftBindData != null)
  15606. {
  15607. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15608. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15609. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15610. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15611. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15612. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15613. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15614. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15615. }
  15616. #endregion
  15617. #region B段Right信息
  15618. right = dto.rightInfo.Find(x => x.Type == "B");
  15619. if (right == null)
  15620. {
  15621. return Ok(jw);
  15622. }
  15623. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15624. if (rightBindData != null)
  15625. {
  15626. //经济舱 + 双人间 TBR
  15627. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15628. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15629. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15630. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15631. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15632. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15633. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15634. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15635. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15636. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15637. }
  15638. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15639. if (rightBindData != null)
  15640. {
  15641. //经济舱 + 单人间 SGR
  15642. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15643. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15644. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15645. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15646. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15647. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15648. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15649. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15650. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15651. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15652. }
  15653. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15654. if (rightBindData != null)
  15655. {
  15656. //公务舱 + 单人间 SGR
  15657. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15658. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15659. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15660. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15661. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15662. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15663. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15664. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15665. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15666. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15667. }
  15668. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15669. if (rightBindData != null)
  15670. {
  15671. //公务舱 + 小套房 JSES
  15672. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15673. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15674. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15675. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15676. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15677. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15678. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15679. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15680. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15681. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15682. }
  15683. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15684. if (rightBindData != null)
  15685. {
  15686. //公务舱 + 小套房 JSES
  15687. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15688. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15689. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15690. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15691. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15692. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15693. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15694. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15695. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15696. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15697. }
  15698. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15699. if (rightBindData != null)
  15700. {
  15701. //经济舱 + 大套房
  15702. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15703. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15704. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15705. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15706. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15707. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15708. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15709. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15710. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15711. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15712. }
  15713. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15714. if (rightBindData != null)
  15715. {
  15716. //头等舱 + 小套房 JSES
  15717. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15718. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15719. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15720. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15721. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15722. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15723. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15724. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15725. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15726. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15727. }
  15728. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15729. if (rightBindData != null)
  15730. {
  15731. //头等舱 + 大套房
  15732. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15733. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15734. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15735. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15736. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15737. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15738. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15739. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15740. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15741. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15742. }
  15743. #endregion
  15744. #region 标题
  15745. designer.SetDataSource("CostBDRCB", "单人成本");
  15746. designer.SetDataSource("CostBRS", "人数");
  15747. designer.SetDataSource("CostBXS", "系数");
  15748. designer.SetDataSource("CostBZCB", "总成本");
  15749. designer.SetDataSource("CostBDRBJ", "单人报价");
  15750. designer.SetDataSource("CostBZBJ", "总报价");
  15751. designer.SetDataSource("CostBDRLR", "单人利润");
  15752. designer.SetDataSource("CostBZLR", "总利润");
  15753. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15754. designer.SetDataSource("CostBRSOM", "人数");
  15755. designer.SetDataSource("CostBZCBOM", "总成本");
  15756. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15757. designer.SetDataSource("CostBZBJOM", "总报价");
  15758. designer.SetDataSource("CostBDRLROM", "单人利润");
  15759. designer.SetDataSource("CostBZLROM", "总利润");
  15760. #endregion
  15761. }
  15762. #endregion
  15763. designer.SetDataSource("TzZCB2", TzZCB2);
  15764. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15765. designer.SetDataSource("TzZLR2", TzZLR2);
  15766. string[] dataSourceKeys = new string[]
  15767. {
  15768. "VF",
  15769. "TGS",
  15770. "TGOF",
  15771. "TGM",
  15772. "TGA",
  15773. "TGTF",
  15774. "TGEF",
  15775. "CFM",
  15776. "CFOF",
  15777. "B",
  15778. "L",
  15779. "D",
  15780. "TBR",
  15781. "SGR",
  15782. "JSES",
  15783. "Suite",
  15784. "TV",
  15785. "1L",
  15786. "IF",
  15787. "EF",
  15788. "BRF",
  15789. "TE",
  15790. "TGT",
  15791. "DRVT",
  15792. "PC",
  15793. "TLF",
  15794. "ECT"
  15795. };
  15796. foreach (var item in dataSourceKeys)
  15797. {
  15798. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  15799. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  15800. var find = dto.titleModel.FirstOrDefault(expr);
  15801. if (find != null)
  15802. {
  15803. designer.SetDataSource(item, find.text);
  15804. }
  15805. else
  15806. {
  15807. designer.SetDataSource(item, 0);
  15808. }
  15809. }
  15810. designer.SetDataSource(dt);
  15811. //根据数据源处理生成报表内容
  15812. designer.Process();
  15813. designer.Workbook.Worksheets[0].Name = "费用明细";
  15814. designer.Workbook.Worksheets[1].Name = "费用总核算";
  15815. Worksheet sheet = designer.Workbook.Worksheets[0];
  15816. #region 隐藏舱位
  15817. var settingAir = new[]
  15818. {
  15819. new { key = "经济舱", index = 7 },
  15820. new { key = "公务舱", index = 19 },
  15821. new { key = "头等舱", index = 11 }
  15822. };
  15823. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  15824. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  15825. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  15826. .Select((c, s) => s.Name)
  15827. .ToList()
  15828. .GroupBy(x => x)
  15829. .Select(x => x.Key);
  15830. foreach (var item in settingAir)
  15831. {
  15832. if (!airType.Contains(item.key))
  15833. {
  15834. hideRowsList.Add(item.index);
  15835. }
  15836. }
  15837. #endregion
  15838. foreach (var Rowindex in hideRowsList)
  15839. {
  15840. ws.Cells.HideRows(Rowindex, 2);
  15841. }
  15842. ws = designer.Workbook.Worksheets[0];
  15843. foreach (var Column in hideColumnList)
  15844. {
  15845. ws.Cells.HideColumns(Column, 1);
  15846. }
  15847. byte[] bytes = null;
  15848. string strFileName = di.TeamName + "-团组-成本.xls";
  15849. using (MemoryStream stream = new MemoryStream())
  15850. {
  15851. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15852. bytes = stream.ToArray();
  15853. }
  15854. return Ok(JsonView(true, "", new
  15855. {
  15856. Data = bytes,
  15857. strFileName,
  15858. }));
  15859. }
  15860. /// <summary>
  15861. /// 导出客户报表
  15862. /// </summary>
  15863. /// <returns></returns>
  15864. [HttpPost]
  15865. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15866. {
  15867. var jw = JsonView(false);
  15868. if (dto.Diid == 0)
  15869. {
  15870. return Ok(JsonView(false, "请传递团组id"));
  15871. }
  15872. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15873. if (deleInfo.Code != 0)
  15874. {
  15875. return Ok(JsonView(false, "团组信息查询失败!"));
  15876. }
  15877. var di = deleInfo.Data as DelegationInfoWebView;
  15878. if (di == null)
  15879. {
  15880. return Ok(JsonView(false, "团组信息查询失败!"));
  15881. }
  15882. //文件名
  15883. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15884. //获取模板
  15885. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15886. //载入模板
  15887. Document doc = new Document(tmppath);
  15888. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15889. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15890. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15891. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15892. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15893. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15894. if (AParameter == null)
  15895. {
  15896. return Ok(JsonView(false, "系数不存在!"));
  15897. }
  15898. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15899. , TzAirDesc, TzZCost;
  15900. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15901. = TzAirDesc = TzZCost = string.Empty;
  15902. TzNumber = AParameter.CostTypenumber.ToString();
  15903. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15904. CarGuides1 = dto.CarGuides1;
  15905. Meal = dto.Meal;
  15906. SubsidizedMeals = dto.SubsidizedMeals;
  15907. NightRepair = dto.NightRepair;
  15908. AttractionsTickets = dto.AttractionsTickets;
  15909. MiscellaneousFees = dto.MiscellaneousFees;
  15910. ATip = dto.ATip;
  15911. TzHotelDesc = "";
  15912. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15913. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15914. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15915. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15916. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15917. TzAirDesc = "";
  15918. TzZCost = dto.TzZCost;
  15919. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15920. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15921. var index = 1;
  15922. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15923. foreach (var item in TzHotelDescArr)
  15924. {
  15925. if (AinfoArr != null)
  15926. {
  15927. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15928. if (Ainfo != null)
  15929. {
  15930. if (int.Parse(Ainfo.rs) <= 0)
  15931. {
  15932. continue;
  15933. }
  15934. var hotelText = string.Empty;
  15935. switch (item)
  15936. {
  15937. case "SGR":
  15938. hotelText = "单人间";
  15939. break;
  15940. case "JSES":
  15941. hotelText = "小套房";
  15942. break;
  15943. case "SUITE":
  15944. hotelText = "套房";
  15945. break;
  15946. case "TBR":
  15947. hotelText = "双人间";
  15948. break;
  15949. }
  15950. if (item != "TBR")
  15951. {
  15952. 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";
  15953. }
  15954. else
  15955. {
  15956. 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";
  15957. }
  15958. index++;
  15959. }
  15960. }
  15961. }
  15962. index = 1;
  15963. foreach (var item in TzAirDescArr)
  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. 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";
  15975. index++;
  15976. }
  15977. }
  15978. }
  15979. if (dto.costType == "B")
  15980. {
  15981. if (BParameter == null)
  15982. {
  15983. return Ok(JsonView(false, "B段系数不存在!"));
  15984. }
  15985. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15986. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15987. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15988. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15989. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15990. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15991. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15992. foreach (var item in TzHotelDescArr)
  15993. {
  15994. if (AinfoArr != null)
  15995. {
  15996. TzHotelDesc += "B段信息 \r\n";
  15997. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15998. if (Ainfo != null)
  15999. {
  16000. if (int.Parse(Ainfo.rs) <= 0)
  16001. {
  16002. continue;
  16003. }
  16004. var hotelText = string.Empty;
  16005. switch (item)
  16006. {
  16007. case "SGR":
  16008. hotelText = "单人间";
  16009. break;
  16010. case "JSES":
  16011. hotelText = "小套房";
  16012. break;
  16013. case "SUITE":
  16014. hotelText = "套房";
  16015. break;
  16016. case "TBR":
  16017. hotelText = "双人间";
  16018. break;
  16019. }
  16020. if (item != "TBR")
  16021. {
  16022. 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";
  16023. }
  16024. else
  16025. {
  16026. 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";
  16027. }
  16028. index++;
  16029. }
  16030. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16031. }
  16032. }
  16033. index = 1;
  16034. foreach (var item in TzAirDescArr)
  16035. {
  16036. if (AinfoArr != null)
  16037. {
  16038. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16039. if (Ainfo != null)
  16040. {
  16041. if (int.Parse(Ainfo.rs) <= 0)
  16042. {
  16043. continue;
  16044. }
  16045. 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";
  16046. index++;
  16047. }
  16048. }
  16049. }
  16050. }
  16051. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16052. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16053. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16054. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16055. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16056. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16057. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16058. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16059. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16060. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16061. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16062. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16063. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16064. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16065. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16066. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16067. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16068. DickeyValue.Add("TzZCost", TzZCost);
  16069. foreach (var key in DickeyValue.Keys)
  16070. {
  16071. if (doc.Range.Bookmarks[key] != null)
  16072. {
  16073. Bookmark mark = doc.Range.Bookmarks[key];
  16074. mark.Text = DickeyValue[key];
  16075. }
  16076. }
  16077. byte[] bytes = null;
  16078. string strFileName = di.TeamName + "-客户报价.doc";
  16079. using (MemoryStream stream = new MemoryStream())
  16080. {
  16081. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  16082. bytes = stream.ToArray();
  16083. }
  16084. return Ok(JsonView(true, "", new
  16085. {
  16086. Data = bytes,
  16087. strFileName,
  16088. }));
  16089. }
  16090. /// <summary>
  16091. /// 团组成本 各模块(酒店,地接,机票)成本提示
  16092. /// </summary>
  16093. /// <param name="dto"></param>
  16094. /// <returns></returns>
  16095. [HttpPost]
  16096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16097. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  16098. {
  16099. try
  16100. {
  16101. #region 参数验证
  16102. if (dto.DiId < 0)
  16103. {
  16104. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  16105. }
  16106. List<int> cTableIds = new List<int>() {
  16107. 76 ,//酒店预订
  16108. 77 ,//行程
  16109. 79 ,//车/导游地接
  16110. 80 ,//签证
  16111. 81 ,//邀请/公务活
  16112. 82 ,//团组客户保险
  16113. 85 ,//机票预订
  16114. 98 ,//其他款项
  16115. 285 ,//收款退还
  16116. 751 ,//酒店早餐
  16117. 1015 // 超支费用
  16118. };
  16119. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  16120. {
  16121. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  16122. }
  16123. #endregion
  16124. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  16125. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  16126. if (_GroupCostParameters.Count <= 0)
  16127. {
  16128. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  16129. }
  16130. if (_GroupCostParameters[0].IsShare == 0)
  16131. {
  16132. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  16133. }
  16134. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16135. //处理date为空问题
  16136. if (_GroupCosts.Count > 0)
  16137. {
  16138. for (int i = 0; i < _GroupCosts.Count; i++)
  16139. {
  16140. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  16141. {
  16142. if (i > 0)
  16143. {
  16144. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  16145. }
  16146. }
  16147. }
  16148. }
  16149. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  16150. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  16151. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  16152. string currCode = "";
  16153. #region currCode 验证
  16154. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16155. if (isInt)
  16156. {
  16157. var currData = currDatas.Find(it => it.Id == intCurrency);
  16158. if (currData != null)
  16159. {
  16160. currCode = currData.Name;
  16161. }
  16162. }
  16163. else
  16164. {
  16165. currCode = _GroupCostParameters[0].Currency.Trim();
  16166. }
  16167. #endregion
  16168. //op,酒店单段模式存储
  16169. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16170. {
  16171. CurrencyCode = currCode,
  16172. Rate = _GroupCostParameters[0].Rate,
  16173. CostType = _GroupCostParameters[0].CostType,
  16174. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16175. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16176. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16177. };
  16178. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16179. if (_GroupCostParameters.Count == 2)
  16180. {
  16181. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16182. }
  16183. foreach (var item in _GroupCostParameters)
  16184. {
  16185. decimal _rate = 1;
  16186. decimal _rate1 = item.Rate;
  16187. decimal _scale = 1;
  16188. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16189. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16190. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16191. //if (userInfo != null)
  16192. //{
  16193. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16194. // {
  16195. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16196. // {
  16197. // _scale = 1.00M;
  16198. // }
  16199. // }
  16200. //}
  16201. #endregion
  16202. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16203. {
  16204. CurrencyCode = currCode,
  16205. Rate = _rate1,
  16206. CostType = item.CostType,
  16207. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16208. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16209. CostTypeNumber = item.CostTypenumber
  16210. };
  16211. if (_GroupCostParameters.Count > 1)
  16212. {
  16213. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16214. }
  16215. else
  16216. {
  16217. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16218. }
  16219. if (dto.CTable == 79)//
  16220. {
  16221. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16222. modulePromptInfo.TotalCost = item.DJCB;
  16223. }
  16224. List<string> costTypes = new List<string>() { "A", "B" };
  16225. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16226. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16227. if (_GroupCostsDuplicates.Count() == 1)
  16228. {
  16229. _GroupCostsTypeData = _GroupCosts;
  16230. }
  16231. else
  16232. {
  16233. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16234. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16235. }
  16236. /*
  16237. * 76 酒店预订
  16238. * 77 行程
  16239. * 79 车/导游地接
  16240. * 80 签证
  16241. * 81 邀请/公务活动
  16242. * 82 团组客户保险
  16243. * 85 机票预订
  16244. * 98 其他款项
  16245. * 285 收款退还
  16246. * 751 酒店早餐
  16247. * 1015 超支费用
  16248. */
  16249. switch (dto.CTable)
  16250. {
  16251. case 76: // 酒店预订
  16252. _ModuleSubPromptInfo.AddRange(
  16253. _GroupCostsTypeData.Select(it => new
  16254. {
  16255. it.DAY,
  16256. it.Date,
  16257. it.ACCON,
  16258. it.ITIN,
  16259. it.SGR,
  16260. it.TBR,
  16261. it.JS_ES,
  16262. it.Suite
  16263. })
  16264. );
  16265. break;
  16266. case 79: // 车/导游地接
  16267. _ModuleSubPromptInfo.AddRange(
  16268. _GroupCostsTypeData.Select(it => new
  16269. {
  16270. Date = it.Date, //日期
  16271. CarFee = it.CarCost * _rate * _scale, //车费用
  16272. CarType = it.CarType, //车型
  16273. DriverFee = it.CFS * _rate * _scale, //司机工资
  16274. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16275. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16276. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16277. GuideFee = it.TGS * _rate * _scale, //导游费用
  16278. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16279. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16280. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16281. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16282. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16283. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16284. Breakfast = it.B * _rate * _scale, //早餐费
  16285. Lunch = it.L * _rate * _scale, //午餐费
  16286. Dinner = it.D * _rate * _scale, //晚餐费
  16287. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16288. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16289. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16290. TicketFee = it.EF * _rate * _scale, //门票费
  16291. TicketRemark = it.EFR, //门票费描述
  16292. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16293. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16294. SpentCash = it.PC * _rate * _scale, //零用金
  16295. LeadersFee = it.TLF * _rate * _scale, //领队费
  16296. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16297. })
  16298. );
  16299. break;
  16300. case 85: // 机票
  16301. List<dynamic> datas = new List<dynamic>();
  16302. datas.Add(
  16303. new
  16304. {
  16305. AirType = "经济舱",
  16306. AirNum = item.JJCRS,
  16307. AirDRCB = item.JJCCB,
  16308. AirZCB = (item.JJCRS * item.JJCCB)
  16309. }
  16310. );
  16311. datas.Add(
  16312. new
  16313. {
  16314. AirType = "公务舱",
  16315. AirNum = item.GWCRS,
  16316. AirDRCB = item.GWCCB,
  16317. AirZCB = (item.GWCRS * item.GWCCB)
  16318. }
  16319. );
  16320. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16321. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16322. modulePromptInfo.Data = new
  16323. {
  16324. airFeeData = datas,
  16325. airInitData = initDatas
  16326. };
  16327. _ModulePromptInfos.Add(modulePromptInfo);
  16328. break;
  16329. default:
  16330. break;
  16331. }
  16332. }
  16333. if (dto.CTable != 85)
  16334. {
  16335. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16336. _ModulePromptInfos.Add(_ModulePromptInfo);
  16337. }
  16338. _view.ModulePromptInfos = _ModulePromptInfos;
  16339. return Ok(JsonView(true, "操作成功!", _view));
  16340. }
  16341. catch (Exception ex)
  16342. {
  16343. return Ok(JsonView(false, ex.Message));
  16344. }
  16345. }
  16346. /// <summary>
  16347. /// 根据黑屏代码重新生成行程
  16348. /// </summary>
  16349. /// <param name="dto"></param>
  16350. /// <returns></returns>
  16351. [HttpPost]
  16352. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16353. {
  16354. var jw = JsonView(false, "Error");
  16355. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16356. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16357. .Select(x => new
  16358. {
  16359. x.Id,
  16360. x.Title
  16361. })
  16362. .ToList();
  16363. if (Create.Any())
  16364. {
  16365. jw.Msg = "获取成功!";
  16366. jw.Code = 200;
  16367. jw.Data = new
  16368. {
  16369. BlackCodeListSelect = Create,
  16370. blackCodeIsTrue = true
  16371. };
  16372. }
  16373. else
  16374. {
  16375. jw.Code = 400;
  16376. jw.Data = new
  16377. {
  16378. BlackCodeListSelect = Create,
  16379. blackCodeIsTrue = false,
  16380. };
  16381. }
  16382. return Ok(jw);
  16383. }
  16384. /// <summary>
  16385. /// 根据黑屏代码Id重新生成行程
  16386. /// </summary>
  16387. /// <param name="dto"></param>
  16388. /// <returns></returns>
  16389. [HttpPost]
  16390. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16391. {
  16392. var jw = JsonView(false, "Error");
  16393. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16394. if (result.Code == 0)
  16395. {
  16396. jw.Msg = "获取成功!";
  16397. jw.Code = 200;
  16398. jw.Data = new
  16399. {
  16400. groupCost = result.Data,
  16401. blackCodeIsTrue = true
  16402. };
  16403. }
  16404. else
  16405. {
  16406. jw.Code = 400;
  16407. jw.Data = new
  16408. {
  16409. groupCost = result.Data,
  16410. blackCodeIsTrue = false,
  16411. };
  16412. }
  16413. return Ok(jw);
  16414. }
  16415. /// <summary>
  16416. /// 成本获取OP历史车费用
  16417. /// </summary>
  16418. /// <param name="dto"></param>
  16419. /// <returns></returns>
  16420. [HttpPost]
  16421. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16422. {
  16423. var jw = JsonView(false);
  16424. try
  16425. {
  16426. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16427. //获取现有所有车的数据
  16428. if (!dto.Param.IsNullOrWhiteSpace())
  16429. {
  16430. string sql = $@"
  16431. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16432. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16433. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16434. 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
  16435. AND gctggr.ServiceEndTime is not NULL
  16436. ORDER by gctggrc.id DESC
  16437. ";
  16438. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16439. var numeberResult = await Task.Run(() =>
  16440. {
  16441. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16442. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16443. return numberArr;
  16444. });
  16445. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16446. foreach (var item in numeberResult)
  16447. {
  16448. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16449. {
  16450. Country = "数据异常!",
  16451. City = string.Empty,
  16452. };
  16453. item.Area = find.Country + " " + find.City;
  16454. }
  16455. dbResult.AddRange(numeberResult);
  16456. if (dto.Param.Contains("、"))
  16457. {
  16458. var sp = dto.Param.Split("、");
  16459. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16460. .Where(x =>
  16461. {
  16462. return System.Array.Exists(sp, e =>
  16463. {
  16464. bool where = false;
  16465. if (x.Area != null)
  16466. {
  16467. where = x.Area.Contains(e);
  16468. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16469. {
  16470. return false;
  16471. }
  16472. }
  16473. if (x.PriceName != null && !where)
  16474. {
  16475. where = x.PriceName.Contains(e);
  16476. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16477. {
  16478. return false;
  16479. }
  16480. }
  16481. return where;
  16482. });
  16483. }).ToList();
  16484. }
  16485. else
  16486. {
  16487. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16488. .Where(x =>
  16489. {
  16490. bool where = false;
  16491. if (x.Area != null)
  16492. {
  16493. where = x.Area.Contains(dto.Param);
  16494. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16495. {
  16496. return false;
  16497. }
  16498. }
  16499. if (x.PriceName != null && !where)
  16500. {
  16501. where = x.PriceName.Contains(dto.Param);
  16502. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16503. {
  16504. return false;
  16505. }
  16506. }
  16507. return where;
  16508. }
  16509. )
  16510. .ToList();
  16511. }
  16512. }
  16513. var view = dbResult.Select(x =>
  16514. {
  16515. decimal dp = 0.00M;
  16516. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16517. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16518. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16519. {
  16520. if (startB && endB)
  16521. {
  16522. var timesp = endD.Subtract(startD);
  16523. if ((timesp.Days + 1) != 0)
  16524. {
  16525. dp = x.Price / (timesp.Days + 1);
  16526. }
  16527. }
  16528. }
  16529. else
  16530. {
  16531. dp = x.Price;
  16532. }
  16533. return new
  16534. {
  16535. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16536. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16537. x.Area,
  16538. x.id,
  16539. price = x.Price.ToString("F2"),
  16540. x.PriceName,
  16541. x.PriceContent,
  16542. x.TeamName,
  16543. x.DatePrice,
  16544. dayPrice = dp.ToString("F2"),
  16545. };
  16546. }).OrderByDescending(x => x.id).ToList();
  16547. jw = JsonView(true, "获取成功!", view);
  16548. }
  16549. catch (Exception e)
  16550. {
  16551. jw = JsonView(false, e.Message);
  16552. }
  16553. return Ok(jw);
  16554. }
  16555. [HttpPost]
  16556. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16557. {
  16558. var jw = JsonView(true);
  16559. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16560. #region SQL语句
  16561. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16562. //{
  16563. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16564. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16565. // WHEN COUNT(*) >= 0 THEN 'True'
  16566. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16567. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16568. // ")
  16569. // .ToList();
  16570. //}
  16571. //else
  16572. //{
  16573. // string likeKey = string.Empty;
  16574. // foreach (var item in dto.Keyword)
  16575. // {
  16576. // likeKey += "%" + item;
  16577. // }
  16578. // likeKey += "%";
  16579. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16580. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16581. // WHEN COUNT(*) >= 0 THEN 'True'
  16582. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16583. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16584. // ")
  16585. // .ToList();
  16586. //}
  16587. #endregion
  16588. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16589. {
  16590. @KeyWord = dto.Keyword
  16591. });
  16592. if (table != null && table.Rows.Count > 0)
  16593. {
  16594. foreach (DataRow row in table.Rows)
  16595. {
  16596. matches.Add(new DelegationInfoAndIsTrueView
  16597. {
  16598. Id = row.Field<int>("Id"),
  16599. GroupName = row.Field<string>("GroupName"),
  16600. isTrue = row.Field<string>("isTrue")
  16601. });
  16602. }
  16603. }
  16604. if (matches.Any())
  16605. {
  16606. jw.Data = matches;
  16607. }
  16608. else
  16609. {
  16610. jw.Code = 201;
  16611. jw.Msg = "empty list";
  16612. jw.Data = new List<string>(1);
  16613. }
  16614. return Ok(jw);
  16615. }
  16616. /// <summary>
  16617. /// 报价Word下载
  16618. /// </summary>
  16619. /// <param name="dto"></param>
  16620. /// <returns></returns>
  16621. [HttpPost]
  16622. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16623. {
  16624. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16625. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16626. if (di == null)
  16627. {
  16628. return Ok(JsonView(false, "团组不存在!"));
  16629. }
  16630. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16631. if (mainPrice == null || mainPrice.IsShare == 0)
  16632. {
  16633. return Ok(JsonView(false, "团组成本不存在!"));
  16634. }
  16635. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16636. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16637. if (costTypeHotelNumbers == null)
  16638. {
  16639. return Ok(JsonView(false, "团组成本不存在!"));
  16640. }
  16641. //文件名
  16642. string strFileName = di.TeamName + "-收款账单.doc";
  16643. //获取模板
  16644. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16645. //载入模板
  16646. Document doc = new Document(tmppath);
  16647. decimal allPrice = 0.00M;
  16648. string itemStr = string.Empty;
  16649. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16650. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16651. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16652. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16653. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16654. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16655. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16656. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16657. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16658. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16659. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16660. {
  16661. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16662. ("BXRS", "BXCB", "BXXS", "bx"),
  16663. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16664. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16665. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16666. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16667. ("CPRS", "CPCB", "CPXS", "cp"),
  16668. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16669. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16670. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16671. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16672. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16673. ("DJRS", "DJCB", "DJXS", "dj"),
  16674. ("GWRS", "GWCB", "GWXS", "gw"),
  16675. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16676. };
  16677. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16678. var rightSum = 0.00M;
  16679. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16680. {
  16681. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16682. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16683. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16684. if (prefix == "tbr")
  16685. {
  16686. rsValue *= 2;
  16687. cbValue /= 2;
  16688. }
  16689. if (OtherCostPropertyBJ.Contains(prefix))
  16690. {
  16691. rightSum += cbValue * xsValue;
  16692. }
  16693. }
  16694. var hotelRooms = new Dictionary<string, int>
  16695. {
  16696. { "SGR", costTypeHotelNumbers.SGR },
  16697. { "TBR", costTypeHotelNumbers.TBR },
  16698. { "JSES", costTypeHotelNumbers.JSES },
  16699. { "SUITE", costTypeHotelNumbers.SUITE }
  16700. };
  16701. var flights = new Dictionary<string, int>
  16702. {
  16703. { "经济舱", mainPrice.JJCRS },
  16704. { "公务舱", mainPrice.GWCRS },
  16705. { "头等舱", mainPrice.TDCRS }
  16706. };
  16707. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16708. {
  16709. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16710. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16711. { "头等舱", new[] { "SUITE", "JSES" } }
  16712. };
  16713. var result = new Dictionary<string, int>();
  16714. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16715. foreach (var flight in flights.Keys)
  16716. {
  16717. // 获取当前舱位的匹配规则
  16718. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16719. {
  16720. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16721. }
  16722. }
  16723. #region right计算
  16724. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16725. {
  16726. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16727. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16728. airHotelPriceList.Add(new
  16729. AirHotelPrice
  16730. {
  16731. Name = "经济舱TBR",
  16732. Price = rightSum + air + hotel,
  16733. Count = result["经济舱TBR"] * 2
  16734. });
  16735. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16736. }
  16737. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16738. {
  16739. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16740. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16741. airHotelPriceList.Add(new
  16742. AirHotelPrice
  16743. {
  16744. Name = "经济舱SGR",
  16745. Price = rightSum + air + hotel,
  16746. Count = result["经济舱SGR"]
  16747. });
  16748. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16749. }
  16750. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16751. {
  16752. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16753. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16754. airHotelPriceList.Add(new
  16755. AirHotelPrice
  16756. {
  16757. Name = "公务舱SGR",
  16758. Price = rightSum + air + hotel,
  16759. Count = result["公务舱SGR"]
  16760. });
  16761. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16762. }
  16763. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16764. {
  16765. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16766. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16767. airHotelPriceList.Add(new
  16768. AirHotelPrice
  16769. {
  16770. Name = "公务舱JSES",
  16771. Price = rightSum + air + hotel,
  16772. Count = result["公务舱JSES"]
  16773. });
  16774. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16775. }
  16776. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16777. {
  16778. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16779. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16780. airHotelPriceList.Add(new
  16781. AirHotelPrice
  16782. {
  16783. Name = "公务舱SUITE",
  16784. Price = rightSum + air + hotel,
  16785. Count = result["公务舱SUITE"]
  16786. });
  16787. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16788. }
  16789. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16790. {
  16791. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16792. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16793. airHotelPriceList.Add(new
  16794. AirHotelPrice
  16795. {
  16796. Name = "经济舱SUITE",
  16797. Price = rightSum + air + hotel,
  16798. Count = result["经济舱SUITE"]
  16799. });
  16800. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16801. }
  16802. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16803. {
  16804. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16805. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16806. airHotelPriceList.Add(new
  16807. AirHotelPrice
  16808. {
  16809. Name = "头等舱JSES",
  16810. Price = rightSum + air + hotel,
  16811. Count = result["头等舱JSES"]
  16812. });
  16813. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16814. }
  16815. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16816. {
  16817. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16818. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16819. airHotelPriceList.Add(new
  16820. AirHotelPrice
  16821. {
  16822. Name = "头等舱SUITE",
  16823. Price = rightSum + air + hotel,
  16824. Count = result["头等舱SUITE"]
  16825. });
  16826. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16827. }
  16828. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16829. {
  16830. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16831. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16832. airHotelPriceList.Add(new
  16833. AirHotelPrice
  16834. {
  16835. Name = "经济舱JSES",
  16836. Price = rightSum + air + hotel,
  16837. Count = result["经济舱JSES"]
  16838. });
  16839. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16840. }
  16841. #endregion
  16842. foreach (var item in airSouer.Keys)
  16843. {
  16844. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16845. if (find != null && find.Count > 0)
  16846. {
  16847. if (item.Contains("TBR"))
  16848. {
  16849. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16850. }
  16851. else
  16852. {
  16853. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16854. }
  16855. }
  16856. }
  16857. #region 替换Word模板书签内容
  16858. Dictionary<string, string> marks = new Dictionary<string, string>();
  16859. marks.Add("To", di.ClientUnit);//付款方
  16860. marks.Add("ToTel", di.TellPhone);//付款方电话
  16861. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16862. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16863. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16864. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16865. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16866. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16867. marks.Add("PayItemContent", itemStr);//详细信息
  16868. marks.Add("Total", allPrice.ToString("F2"));//合计
  16869. #endregion
  16870. foreach (var item in marks.Keys)
  16871. {
  16872. if (doc.Range.Bookmarks[item] != null)
  16873. {
  16874. Bookmark mark = doc.Range.Bookmarks[item];
  16875. mark.Text = marks[item];
  16876. }
  16877. }
  16878. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16879. doc.Save(savePaht);
  16880. var jw = new JsonView();
  16881. jw.Msg = "生成成功!";
  16882. jw.Code = 200;
  16883. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16884. return Ok(jw);
  16885. }
  16886. /// <summary>
  16887. /// 详细报价费用Excel下载
  16888. /// </summary>
  16889. /// <param name="dto"></param>
  16890. /// <returns></returns>
  16891. [HttpPost]
  16892. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16893. {
  16894. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16895. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16896. if (di == null)
  16897. {
  16898. return Ok(JsonView(false, "团组不存在!"));
  16899. }
  16900. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16901. if (mainPrice == null || mainPrice.IsShare == 0)
  16902. {
  16903. return Ok(JsonView(false, "团组成本不存在!"));
  16904. }
  16905. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16906. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16907. if (costTypeHotelNumbers == null)
  16908. {
  16909. return Ok(JsonView(false, "团组成本不存在!"));
  16910. }
  16911. WorkbookDesigner designer = new WorkbookDesigner();
  16912. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16913. List<int> hideRowsList = new List<int>();
  16914. int conterStartIndex = 3;
  16915. int rowIndex = conterStartIndex;
  16916. designer.SetDataSource("GroupName", di.TeamName);
  16917. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16918. {
  16919. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16920. ("BXRS", "BXCB", "BXXS", "bx"),
  16921. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16922. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16923. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16924. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16925. ("CPRS", "CPCB", "CPXS", "cp") ,
  16926. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16927. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16928. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16929. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16930. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16931. ("DJRS", "DJCB", "DJXS", "dj") ,
  16932. ("GWRS", "GWCB", "GWXS", "gw") ,
  16933. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16934. };
  16935. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16936. var rightSum = 0.00M;
  16937. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16938. {
  16939. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16940. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16941. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16942. if (prefix == "tbr")
  16943. {
  16944. rsValue *= 2;
  16945. cbValue /= 2;
  16946. }
  16947. if (OtherCostPropertyBJ.Contains(prefix))
  16948. {
  16949. rightSum += cbValue * xsValue;
  16950. }
  16951. if (rsValue == 0)
  16952. {
  16953. hideRowsList.Add(rowIndex);
  16954. }
  16955. else
  16956. {
  16957. designer.SetDataSource($"{prefix}rs", rsValue);
  16958. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16959. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16960. }
  16961. rowIndex += 2;
  16962. }
  16963. var hotelRooms = new Dictionary<string, int>
  16964. {
  16965. { "SGR", costTypeHotelNumbers.SGR },
  16966. { "TBR", costTypeHotelNumbers.TBR },
  16967. { "JSES", costTypeHotelNumbers.JSES },
  16968. { "SUITE", costTypeHotelNumbers.SUITE }
  16969. };
  16970. var flights = new Dictionary<string, int>
  16971. {
  16972. { "经济舱", mainPrice.JJCRS },
  16973. { "公务舱", mainPrice.GWCRS },
  16974. { "头等舱", mainPrice.TDCRS }
  16975. };
  16976. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16977. {
  16978. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16979. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16980. { "头等舱", new[] { "SUITE", "JSES" } }
  16981. };
  16982. var result = new Dictionary<string, int>();
  16983. foreach (var flight in flights.Keys)
  16984. {
  16985. // 获取当前舱位的匹配规则
  16986. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16987. {
  16988. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16989. }
  16990. }
  16991. var allPrice = 0.00M;
  16992. #region right计算
  16993. int airRowIndex = 35;
  16994. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16995. {
  16996. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16997. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16998. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16999. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17000. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17001. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17002. }
  17003. else
  17004. {
  17005. hideRowsList.Add(airRowIndex);
  17006. }
  17007. airRowIndex += 2;
  17008. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17009. {
  17010. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17011. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17012. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17013. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17014. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17015. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17016. }
  17017. else
  17018. {
  17019. hideRowsList.Add(airRowIndex);
  17020. }
  17021. airRowIndex += 2;
  17022. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17023. {
  17024. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17025. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17026. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17027. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17028. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17029. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17030. }
  17031. else
  17032. {
  17033. hideRowsList.Add(airRowIndex);
  17034. }
  17035. airRowIndex += 2;
  17036. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17037. {
  17038. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17039. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17040. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17041. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17042. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17043. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17044. }
  17045. else
  17046. {
  17047. hideRowsList.Add(airRowIndex);
  17048. }
  17049. airRowIndex += 2;
  17050. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17051. {
  17052. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17053. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17054. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17055. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17056. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17057. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17058. }
  17059. else
  17060. {
  17061. hideRowsList.Add(airRowIndex);
  17062. }
  17063. airRowIndex += 2;
  17064. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17065. {
  17066. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17067. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17068. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17069. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17070. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17071. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17072. }
  17073. else
  17074. {
  17075. hideRowsList.Add(airRowIndex);
  17076. }
  17077. airRowIndex += 2;
  17078. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17079. {
  17080. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17081. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17082. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  17083. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  17084. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  17085. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17086. }
  17087. else
  17088. {
  17089. hideRowsList.Add(airRowIndex);
  17090. }
  17091. airRowIndex += 2;
  17092. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17093. {
  17094. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17095. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17096. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  17097. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  17098. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  17099. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17100. }
  17101. else
  17102. {
  17103. hideRowsList.Add(airRowIndex);
  17104. }
  17105. airRowIndex += 2;
  17106. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17107. {
  17108. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17109. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17110. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  17111. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  17112. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  17113. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17114. }
  17115. else
  17116. {
  17117. hideRowsList.Add(airRowIndex);
  17118. }
  17119. #endregion
  17120. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  17121. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  17122. var ws = designer.Workbook.Worksheets[0];
  17123. foreach (var Rowindex in hideRowsList)
  17124. {
  17125. ws.Cells.HideRows(Rowindex, 2);
  17126. }
  17127. designer.Process();
  17128. designer.Workbook.Save(savePaht);
  17129. return Ok(JsonView(true, "生成成功!", new
  17130. {
  17131. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  17132. }));
  17133. }
  17134. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  17135. {
  17136. foreach (var roomType in roomTypes)
  17137. {
  17138. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  17139. {
  17140. hotelRooms[roomType]--;
  17141. flights[flightType]--;
  17142. if (roomType == "TBR")
  17143. {
  17144. flights[flightType]--; // 双人间在减少1
  17145. }
  17146. string key = flightType + roomType;
  17147. if (result.Keys.Contains(key))
  17148. {
  17149. result[key]++;
  17150. }
  17151. else
  17152. {
  17153. result.Add(key, 1);
  17154. }
  17155. }
  17156. }
  17157. }
  17158. private class AirHotelPrice
  17159. {
  17160. public string Name { get; set; }
  17161. public decimal Price { get; set; }
  17162. public int Count { get; set; }
  17163. }
  17164. /// <summary>
  17165. /// 团组系数设置
  17166. /// </summary>
  17167. /// <param name="dto"></param>
  17168. /// <returns></returns>
  17169. [HttpPost]
  17170. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17171. {
  17172. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17173. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17174. if (di == null)
  17175. {
  17176. return Ok(JsonView(false, "团组不存在!"));
  17177. }
  17178. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  17179. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  17180. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  17181. // FirstAsync(firstExpression.ToExpression());
  17182. #region JSON
  17183. string hcpJson = @"
  17184. [
  17185. {
  17186. ""min"": 1,
  17187. ""max"": 500,
  17188. ""value"": 1.50
  17189. },
  17190. {
  17191. ""min"": 501,
  17192. ""max"": 1000,
  17193. ""value"": 1.40
  17194. },
  17195. {
  17196. ""min"": 1001,
  17197. ""max"": 2000,
  17198. ""value"": 1.35
  17199. }
  17200. ]";
  17201. #endregion
  17202. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  17203. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  17204. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  17205. .ToList();
  17206. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  17207. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  17208. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  17209. // new List<(Predicate<decimal>, decimal)>()
  17210. // {
  17211. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  17212. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  17213. // }
  17214. // ));
  17215. #region 签证系数
  17216. var visaXS = 0.00M;
  17217. switch (dto.VisaCB)
  17218. {
  17219. case decimal n when (n > 1 && n < 500):
  17220. switch (dto.VisaRS)
  17221. {
  17222. case 2 or 3:
  17223. visaXS = 1.35M;
  17224. break;
  17225. case 4 or 5:
  17226. visaXS = 1.30M;
  17227. break;
  17228. case 6 or 7:
  17229. visaXS = 1.25M;
  17230. break;
  17231. case 8 or 9 or 10:
  17232. visaXS = 1.20M;
  17233. break;
  17234. case > 10:
  17235. visaXS = 1.15M;
  17236. break;
  17237. default:
  17238. visaXS = 0.00M;
  17239. break;
  17240. }
  17241. break;
  17242. case decimal n when (n >= 500 && n < 1000):
  17243. switch (dto.VisaRS)
  17244. {
  17245. case 2 or 3 or 4:
  17246. visaXS = 1.30M;
  17247. break;
  17248. case 5 or 6 or 7 or 8:
  17249. visaXS = 1.25M;
  17250. break;
  17251. case 9 or 10:
  17252. visaXS = 1.20M;
  17253. break;
  17254. case > 10:
  17255. visaXS = 1.15M;
  17256. break;
  17257. default:
  17258. visaXS = 0.00M;
  17259. break;
  17260. }
  17261. break;
  17262. default:
  17263. switch (dto.VisaRS)
  17264. {
  17265. case 2 or 3 or 4:
  17266. visaXS = 1.30M;
  17267. break;
  17268. case 5 or 6 or 7 or 8:
  17269. visaXS = 1.25M;
  17270. break;
  17271. case 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. }
  17283. #endregion
  17284. #region 火车系数
  17285. var hcpXS = 0.00M;
  17286. foreach (var (condition, result) in hcpSwitchDictionary)
  17287. {
  17288. if (condition(dto.HCPCB))
  17289. {
  17290. hcpXS = result;
  17291. break;
  17292. }
  17293. }
  17294. #endregion
  17295. #region 机票系数
  17296. #region 经济舱系数
  17297. var jjcXS = 0.00M;
  17298. switch (dto.JJCCB)
  17299. {
  17300. case decimal x when (x >= 1000 && x <= 3000):
  17301. jjcXS = 2.6M;
  17302. break;
  17303. case decimal x when (x >= 3001 && x <= 8000):
  17304. jjcXS = 2.3M;
  17305. break;
  17306. case decimal x when (x >= 8001 && x <= 15000):
  17307. jjcXS = 2.1M;
  17308. break;
  17309. case decimal x when (x >= 15001 && x <= 30000):
  17310. jjcXS = 1.95M;
  17311. break;
  17312. case > 30000:
  17313. jjcXS = 1.8M;
  17314. break;
  17315. default:
  17316. break;
  17317. }
  17318. #endregion
  17319. #region 公务舱系数
  17320. var gwcXS = 0.00M;
  17321. switch (dto.GWCCB)
  17322. {
  17323. case decimal x when (x >= 1000 && x <= 3000):
  17324. gwcXS = 2.5M;
  17325. break;
  17326. case decimal x when (x >= 3001 && x <= 8000):
  17327. gwcXS = 2.2M;
  17328. break;
  17329. case decimal x when (x >= 8001 && x <= 15000):
  17330. gwcXS = 2.0M;
  17331. break;
  17332. case decimal x when (x >= 15001 && x <= 30000):
  17333. gwcXS = 1.85M;
  17334. break;
  17335. case > 30000:
  17336. gwcXS = 1.7M;
  17337. break;
  17338. default:
  17339. break;
  17340. }
  17341. #endregion
  17342. #region 头等舱系数
  17343. var tdcXS = 0.00M;
  17344. switch (dto.TDCCB)
  17345. {
  17346. case > 70000:
  17347. tdcXS = 1.5M;
  17348. break;
  17349. default:
  17350. tdcXS = 1.9M;
  17351. break;
  17352. }
  17353. #endregion
  17354. #endregion
  17355. #region 酒店系数
  17356. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  17357. {
  17358. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  17359. {1.5M, new List<string>(){"越南社会主义共和国",
  17360. "老挝",
  17361. "柬埔寨",
  17362. "泰国",
  17363. "缅甸",
  17364. "马来西亚",
  17365. //"新加坡",
  17366. "文莱达鲁萨兰",
  17367. "印度尼西亚",
  17368. "东帝汶"}},
  17369. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  17370. };
  17371. #region SGR
  17372. var sgrXS = 1.25M;
  17373. #endregion
  17374. #region TBR
  17375. var tbrXS = 1.25M;
  17376. #endregion
  17377. #region JSES
  17378. var jsesXS = 1.25M;
  17379. #endregion
  17380. #region SUITE
  17381. var suiteXS = 1.25M;
  17382. #endregion
  17383. var countryArr = di.VisitCountry.Split("|");
  17384. foreach (var item in dic)
  17385. {
  17386. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  17387. .Count();
  17388. if (extsisCount > 0)
  17389. {
  17390. jsesXS = item.Key;
  17391. sgrXS = item.Key;
  17392. tbrXS = item.Key;
  17393. suiteXS = item.Key;
  17394. }
  17395. }
  17396. #endregion
  17397. #region 地接系数
  17398. var djXS = 0.00M;
  17399. switch (dto.DJRS)
  17400. {
  17401. case 2 or 3 :
  17402. djXS = 2.65M;
  17403. break;
  17404. case 4:
  17405. djXS = 2.6M;
  17406. break;
  17407. case 5 or 6:
  17408. djXS = 2.5M;
  17409. break;
  17410. case 7 or 8:
  17411. djXS = 2.4M;
  17412. break;
  17413. case 9 or 10:
  17414. djXS = 2.3M;
  17415. break;
  17416. case 11:
  17417. djXS = 2.2M;
  17418. break;
  17419. case 12:
  17420. djXS = 2.1M;
  17421. break;
  17422. case 13 or 14:
  17423. djXS = 2M;
  17424. break;
  17425. case 15:
  17426. djXS = 1.9M;
  17427. break;
  17428. case 16 or 17 or 18:
  17429. djXS = 1.8M;
  17430. break;
  17431. case 19 or 20:
  17432. djXS = 1.7M;
  17433. break;
  17434. }
  17435. #endregion
  17436. #region 零用金系数
  17437. var lyjXS = 0.00M;
  17438. switch (dto.LYJRS)
  17439. {
  17440. case 2:
  17441. lyjXS = 1.25M;
  17442. break;
  17443. case 3 or 4 or 5:
  17444. lyjXS = 1.2M;
  17445. break;
  17446. case int number when (number > 5 && number < 10):
  17447. lyjXS = 1.15M;
  17448. break;
  17449. case > 10:
  17450. lyjXS = 1.1M;
  17451. break;
  17452. default:
  17453. break;
  17454. }
  17455. #endregion
  17456. return Ok(JsonView(true, "查询成功", new ArrayList()
  17457. {
  17458. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  17459. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  17460. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  17461. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  17462. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  17463. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  17464. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  17465. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  17466. new { label = "地接系数", value = djXS, key = "djXS" },
  17467. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  17468. new { label = "公务系数", value = 2M, key = "gwXS" }
  17469. }));
  17470. }
  17471. #endregion
  17472. #region 酒店预订 New 2023-12-28 17:45
  17473. /// <summary>
  17474. /// 酒店预订
  17475. /// 酒店费用列表 根据团组Id查询
  17476. /// </summary>
  17477. /// <param name="_dto"></param>
  17478. /// <returns></returns>
  17479. [HttpPost]
  17480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17481. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17482. {
  17483. #region 参数验证
  17484. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17485. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17486. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17487. #region 团组操作权限验证 76 酒店预定模块
  17488. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17489. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17490. #endregion
  17491. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17492. #region 页面操作权限验证
  17493. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17494. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17495. #endregion
  17496. #endregion
  17497. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17498. }
  17499. /// <summary>
  17500. /// 酒店预订
  17501. /// 基础数据
  17502. /// </summary>
  17503. /// <param name="_dto"></param>
  17504. /// <returns></returns>
  17505. [HttpPost]
  17506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17507. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17508. {
  17509. #region 参数验证
  17510. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17511. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17512. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17513. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17514. #region 页面操作权限验证
  17515. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17516. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17517. #endregion
  17518. #region 团组操作权限验证 76 酒店预定模块
  17519. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17520. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17521. #endregion
  17522. #endregion
  17523. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17524. }
  17525. /// <summary>
  17526. /// 酒店预订
  17527. /// 创建 入住卷号码
  17528. /// </summary>
  17529. /// <param name="_dto"></param>
  17530. /// <returns></returns>
  17531. [HttpPost]
  17532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17533. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17534. {
  17535. #region 参数验证
  17536. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17537. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17538. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17539. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17540. #region 页面操作权限验证
  17541. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17542. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17543. #endregion
  17544. #region 团组操作权限验证 76 酒店预定模块
  17545. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17546. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17547. #endregion
  17548. #endregion
  17549. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17550. if (data.Code != 0)
  17551. {
  17552. return Ok(JsonView(false, data.Msg));
  17553. }
  17554. return Ok(JsonView(true, data.Msg, data.Data));
  17555. }
  17556. /// <summary>
  17557. /// 酒店预订
  17558. /// 详情
  17559. /// </summary>
  17560. /// <param name="_dto"></param>
  17561. /// <returns></returns>
  17562. [HttpPost]
  17563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17564. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17565. {
  17566. #region 参数验证
  17567. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17568. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17569. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17570. #region 团组操作权限验证 76 酒店预定模块
  17571. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17572. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17573. #endregion
  17574. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17575. #region 页面操作权限验证
  17576. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17577. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17578. #endregion
  17579. #endregion
  17580. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17581. }
  17582. /// <summary>
  17583. /// 酒店预订
  17584. /// Add Or Edit
  17585. /// </summary>
  17586. /// <param name="_dto"></param>
  17587. /// <returns></returns>
  17588. [HttpPost]
  17589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17590. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17591. {
  17592. #region 参数验证
  17593. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17594. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17595. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17596. #region 团组操作权限验证 76 酒店预定模块
  17597. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17598. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17599. #endregion
  17600. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17601. #region 页面操作权限验证
  17602. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17603. if (_dto.Id == 0) // Add
  17604. {
  17605. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17606. }
  17607. else if (_dto.Id > 1) // Edit
  17608. {
  17609. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17610. }
  17611. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17612. #endregion
  17613. #endregion
  17614. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17615. if (_view.Code != 200)
  17616. {
  17617. return Ok(_view);
  17618. }
  17619. #region 成本无酒店价格数据进入超支
  17620. _sqlSugar.BeginTran();
  17621. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17622. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17623. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17624. for (int i = 0; i < groupCost.Count; i++)
  17625. {
  17626. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17627. {
  17628. groupCost[i].Date = groupCost[i - 1].Date;
  17629. }
  17630. }
  17631. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17632. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17633. List<Fin_GroupExtraCostDto_OP>();
  17634. if (start_Bool && end_Bool)
  17635. {
  17636. while (start_Time < end_Time)
  17637. {
  17638. foreach (var item in groupCost_Grp)
  17639. {
  17640. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17641. {
  17642. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17643. {
  17644. extraCostList.Add(new
  17645. Fin_GroupExtraCostDto_OP
  17646. {
  17647. Area = _dto.AreaId,
  17648. coefficient = 1.5M,
  17649. createUser = _dto.UserId,
  17650. currency = _dto.CardPriceCurrency,
  17651. diId = _dto.DiId,
  17652. ManagerConfirm = 0,
  17653. SupervisorConfirm = 0,
  17654. SYsupervisorConfirm = 0,
  17655. editType = 1,
  17656. PortType = 1,
  17657. price = _dto.CardPrice,
  17658. PriceCount = 1,
  17659. priceType = 1027,
  17660. priceDetailType = 1044,
  17661. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17662. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17663. });
  17664. }
  17665. }
  17666. }
  17667. start_Time = start_Time.AddDays(1);
  17668. }
  17669. }
  17670. if (extraCostList.Any())
  17671. {
  17672. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17673. }
  17674. _sqlSugar.CommitTran();
  17675. #endregion
  17676. #region 应用推送
  17677. try
  17678. {
  17679. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17680. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17681. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17682. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17683. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17684. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17685. var diId = _dto.DiId;
  17686. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17687. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17688. #region 操作记录
  17689. var opInfo = new Crm_TableOperationRecord()
  17690. {
  17691. TableName = "Grp_HotelReservations",
  17692. PortType = _dto.PortType,
  17693. DataId = hotelId,
  17694. CreateUserId = _dto.UserId
  17695. };
  17696. //var opStatus = OperationEnum.NoOperation;
  17697. if (_dto.Id < 1) //添加操作
  17698. {
  17699. opInfo.OperationItem = OperationEnum.Add;
  17700. }
  17701. else if (_dto.Id > 0)
  17702. {
  17703. opInfo.OperationItem = OperationEnum.Edit;
  17704. }
  17705. string opRemark = string.Empty;
  17706. if (ccpInfo != null)
  17707. {
  17708. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17709. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17710. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17711. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17712. }
  17713. opInfo.Remark = opRemark;
  17714. await _tableorRep.AddAsync(opInfo);
  17715. #endregion
  17716. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17717. //2024-10-21 新增LZ UID
  17718. var userIds = new List<int>() { 21 };
  17719. string title = $"费用审核";
  17720. string content = "";
  17721. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17722. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17723. try
  17724. {
  17725. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17726. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17727. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17728. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17729. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17730. }
  17731. catch (Exception ex)
  17732. {
  17733. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17734. }
  17735. }
  17736. catch (Exception ex)
  17737. {
  17738. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17739. }
  17740. try
  17741. {
  17742. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17743. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17744. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17745. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17746. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17747. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17748. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17749. //自动审核
  17750. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17751. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17752. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17753. //2024-10-21 新增LZ UID
  17754. var userIds = new List<int>() { 21 };
  17755. string title = $"系统通知";
  17756. var diId = _dto.DiId;
  17757. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17758. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17759. string content = "";
  17760. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17761. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17762. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17763. }
  17764. catch (Exception ex)
  17765. {
  17766. }
  17767. #endregion
  17768. return Ok(_view);
  17769. }
  17770. /// <summary>
  17771. /// 酒店自动审核测试
  17772. /// Add Or Edit
  17773. /// </summary>
  17774. /// <param name="diid"></param>
  17775. /// <param name="dataId"></param>
  17776. /// <returns></returns>
  17777. [HttpPost]
  17778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17779. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17780. {
  17781. #region 应用推送
  17782. try
  17783. {
  17784. //自动审核
  17785. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17786. }
  17787. catch (Exception ex)
  17788. {
  17789. return Ok(JsonView(false, ex.Message));
  17790. }
  17791. #endregion
  17792. return Ok(JsonView(false, "操作成功"));
  17793. }
  17794. /// <summary>
  17795. /// 酒店预订
  17796. /// Del
  17797. /// </summary>
  17798. /// <param name="_dto"></param>
  17799. /// <returns></returns>
  17800. [HttpPost]
  17801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17802. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17803. {
  17804. #region 参数验证
  17805. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17806. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17807. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17808. #region 团组操作权限验证 76 酒店预定模块
  17809. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17810. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17811. #endregion
  17812. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17813. #region 页面操作权限验证
  17814. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17815. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17816. #endregion
  17817. #endregion
  17818. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  17819. #region 操作记录
  17820. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17821. {
  17822. TableName = "Grp_HotelReservations",
  17823. PortType = _dto.PortType,
  17824. OperationItem = OperationEnum.Del,
  17825. DataId = _dto.Id,
  17826. CreateUserId = _dto.UserId
  17827. });
  17828. #endregion
  17829. return Ok(data);
  17830. }
  17831. /// <summary>
  17832. /// 酒店预订
  17833. /// 生成VOUCHER
  17834. /// 2024.05.06 之前版本
  17835. /// </summary>
  17836. /// <param name="_dto"></param>
  17837. /// <returns></returns>
  17838. [HttpPost]
  17839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17840. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17841. {
  17842. try
  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. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17849. #region 团组操作权限验证 76 酒店预定模块
  17850. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17851. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17852. #endregion
  17853. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17854. #region 页面操作权限验证
  17855. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17856. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17857. #endregion
  17858. #endregion
  17859. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17860. //判断数据是否完整
  17861. if (hr != null)
  17862. {
  17863. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17864. {
  17865. string strFileName = "HotelStatement/";
  17866. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17867. if (dele != null)
  17868. strFileName += dele.TourCode;
  17869. //载入模板
  17870. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17871. Document doc = new Document(sss);
  17872. DocumentBuilder builder = new DocumentBuilder(doc);
  17873. #region 替换Word模板书签内容
  17874. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17875. //入住卷预定号码
  17876. if (doc.Range.Bookmarks["VNO"] != null)
  17877. {
  17878. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17879. mark.Text = hr.CheckNumber;
  17880. }
  17881. //酒店时间
  17882. if (doc.Range.Bookmarks["Date"] != null)
  17883. {
  17884. Bookmark mark = doc.Range.Bookmarks["Date"];
  17885. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17886. }
  17887. //团号
  17888. if (doc.Range.Bookmarks["TNo"] != null)
  17889. {
  17890. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17891. mark.Text = dele.TourCode;
  17892. }
  17893. //预定号码
  17894. if (doc.Range.Bookmarks["BookingId"] != null)
  17895. {
  17896. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17897. mark.Text = hr.ReservationsNo;
  17898. }
  17899. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17900. {
  17901. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17902. mark.Text = hr.DetermineNo;
  17903. }
  17904. //酒店城市
  17905. if (doc.Range.Bookmarks["City"] != null)
  17906. {
  17907. Bookmark mark = doc.Range.Bookmarks["City"];
  17908. mark.Text = hr.City;
  17909. }
  17910. //酒店名称
  17911. if (doc.Range.Bookmarks["HName"] != null)
  17912. {
  17913. Bookmark mark = doc.Range.Bookmarks["HName"];
  17914. mark.Text = hr.HotelName;
  17915. }
  17916. //酒店地址
  17917. if (doc.Range.Bookmarks["Address"] != null)
  17918. {
  17919. Bookmark mark = doc.Range.Bookmarks["Address"];
  17920. mark.Text = hr.HotelAddress;
  17921. }
  17922. //酒店电话
  17923. if (doc.Range.Bookmarks["Tel"] != null)
  17924. {
  17925. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17926. mark.Text = hr.HotelTel;
  17927. }
  17928. //酒店传真
  17929. if (doc.Range.Bookmarks["Fax"] != null)
  17930. {
  17931. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17932. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17933. {
  17934. mark.Text = hr.HotelFax;
  17935. }
  17936. }
  17937. //入住时间
  17938. if (doc.Range.Bookmarks["CIn"] != null)
  17939. {
  17940. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17941. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17942. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17943. }
  17944. //退房时间
  17945. if (doc.Range.Bookmarks["COut"] != null)
  17946. {
  17947. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17948. Bookmark mark = doc.Range.Bookmarks["COut"];
  17949. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17950. }
  17951. //客户名称
  17952. if (doc.Range.Bookmarks["GName"] != null)
  17953. {
  17954. string guestName = "";
  17955. string[] clients = Array.Empty<string>();
  17956. if (hr.GuestName.Contains(","))
  17957. {
  17958. clients = hr.GuestName.Split(",");
  17959. }
  17960. else
  17961. {
  17962. clients = new string[] { hr.GuestName };
  17963. }
  17964. List<int> clientIds_int = new List<int>();
  17965. if (clients.Length > 0)
  17966. {
  17967. foreach (var item in clients)
  17968. {
  17969. if (item.IsNumeric())
  17970. {
  17971. clientIds_int.Add(int.Parse(item));
  17972. }
  17973. }
  17974. }
  17975. if (clientIds_int.Count > 0)
  17976. {
  17977. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17978. foreach (var client in _clientDatas)
  17979. {
  17980. //男
  17981. if (client.Sex == 0) guestName += $"Mr.";
  17982. //女
  17983. else if (client.Sex == 1) guestName += $"Ms.";
  17984. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17985. {
  17986. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17987. }
  17988. //guestName += $"{client.Pinyin},";
  17989. }
  17990. if (guestName.Length > 0)
  17991. {
  17992. guestName = guestName.Substring(0, guestName.Length - 1);
  17993. }
  17994. }
  17995. else
  17996. {
  17997. guestName = hr.GuestName;
  17998. }
  17999. Bookmark mark = doc.Range.Bookmarks["GName"];
  18000. mark.Text = guestName;
  18001. }
  18002. //房间介绍
  18003. if (doc.Range.Bookmarks["ROOM"] != null)
  18004. {
  18005. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18006. mark.Text = hr.RoomExplanation;
  18007. }
  18008. //报价描述
  18009. if (doc.Range.Bookmarks["NOTE"] != null)
  18010. {
  18011. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18012. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18013. if (ss != null)
  18014. mark.Text = ss.Name;
  18015. }
  18016. //入住时间
  18017. if (doc.Range.Bookmarks["CheckIn"] != null)
  18018. {
  18019. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18020. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18021. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18022. }
  18023. //退房时间
  18024. if (doc.Range.Bookmarks["CheckOut"] != null)
  18025. {
  18026. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18027. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18028. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18029. }
  18030. //日期
  18031. if (doc.Range.Bookmarks["DT"] != null)
  18032. {
  18033. Bookmark mark = doc.Range.Bookmarks["DT"];
  18034. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18035. }
  18036. //名称
  18037. if (doc.Range.Bookmarks["VName"] != null)
  18038. {
  18039. Bookmark mark = doc.Range.Bookmarks["VName"];
  18040. mark.Text = hr.HotelName;
  18041. }
  18042. //号码
  18043. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18044. {
  18045. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18046. mark.Text = hr.CheckNumber;
  18047. }
  18048. #endregion
  18049. strFileName += "VOUCHER.doc";
  18050. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18051. doc.Save(fileDir);
  18052. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18053. return Ok(JsonView(true, "操作成功!", Url));
  18054. }
  18055. else
  18056. {
  18057. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18058. }
  18059. }
  18060. else
  18061. {
  18062. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18063. }
  18064. }
  18065. catch (Exception ex)
  18066. {
  18067. return Ok(JsonView(false, ex.Message));
  18068. }
  18069. }
  18070. /// <summary>
  18071. /// 酒店预订
  18072. /// 生成VOUCHER
  18073. /// 2024.05.06 之后版本
  18074. /// </summary>
  18075. /// <param name="_dto"></param>
  18076. /// <returns></returns>
  18077. [HttpPost]
  18078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18079. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  18080. {
  18081. #region 参数验证
  18082. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18083. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18084. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18085. #region 团组操作权限验证 76 酒店预定模块
  18086. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18087. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18088. #endregion
  18089. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18090. #region 页面操作权限验证
  18091. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18092. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18093. #endregion
  18094. #endregion
  18095. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  18096. //判断数据是否完整
  18097. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18098. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18099. string strFileName = "HotelStatement/";
  18100. string guestNames = ""; //格式Mr.xxx Ms.xxx
  18101. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  18102. #region 数据处理
  18103. List<int> guestIds = new List<int>();
  18104. //int index = 0;
  18105. foreach (var item in hrDtas)
  18106. {
  18107. if (item.GuestName.Contains(","))
  18108. {
  18109. string[] guestIdArr = item.GuestName.Split(',');
  18110. foreach (var guestIdStr in guestIdArr)
  18111. {
  18112. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  18113. if (guestBool)
  18114. {
  18115. guestIds.Add(guestId);
  18116. }
  18117. }
  18118. }
  18119. else guestNames += item.GuestName;
  18120. var voucherInfo = new HotelVoucherInfoView()
  18121. {
  18122. HotelName = item.HotelName,
  18123. CheckInDate = item.CheckInDate,
  18124. CheckOutDate = item.CheckOutDate,
  18125. ConfirmationNumber = item.DetermineNo.Trim(),
  18126. RoomType = item.RoomExplanation
  18127. };
  18128. vouchers.Add(voucherInfo);
  18129. }
  18130. if (guestIds.Count > 0)
  18131. {
  18132. guestIds = guestIds.Distinct().ToList();
  18133. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  18134. if (guestDatas.Count > 0)
  18135. {
  18136. guestNames = "";
  18137. foreach (var guest in guestDatas)
  18138. {
  18139. string guestName = "";
  18140. if (guest.Sex == 0) guestName += @"MR.";
  18141. else if (guest.Sex == 1) guestName += @"MS.";
  18142. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18143. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18144. guestNames += @$"{guestName.Trim()}、";
  18145. }
  18146. if (guestNames.Length > 0)
  18147. {
  18148. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18149. }
  18150. }
  18151. }
  18152. #endregion
  18153. //载入模板
  18154. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  18155. Document doc = new Document(sss);
  18156. DocumentBuilder builder = new DocumentBuilder(doc);
  18157. if (doc.Range.Bookmarks["GuestName"] != null)
  18158. {
  18159. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  18160. mark.Text = guestNames;
  18161. }
  18162. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18163. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  18164. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  18165. for (int i = 1; i <= vouchers.Count; i++)
  18166. {
  18167. HotelVoucherInfoView hviv = vouchers[i - 1];
  18168. builder.MoveToCell(0, i, 0, 0);
  18169. builder.Write(hviv.HotelName);
  18170. builder.MoveToCell(0, i, 1, 0);
  18171. builder.Write(hviv.CheckInDate);
  18172. builder.MoveToCell(0, i, 2, 0);
  18173. builder.Write(hviv.CheckOutDate);
  18174. builder.MoveToCell(0, i, 3, 0);
  18175. builder.Write(hviv.RoomType);
  18176. builder.MoveToCell(0, i, 4, 0);
  18177. builder.Write(hviv.ConfirmationNumber);
  18178. }
  18179. //删除多余行
  18180. int currRowIndex = vouchers.Count + 1;
  18181. int delRows = 21 - currRowIndex;
  18182. if (delRows > 0)
  18183. {
  18184. for (int i = 0; i < delRows; i++)
  18185. {
  18186. table.Rows.RemoveAt(currRowIndex);
  18187. //cultivateRowIndex++;
  18188. }
  18189. }
  18190. strFileName += "VOUCHER.docx";
  18191. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18192. doc.Save(fileDir);
  18193. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18194. return Ok(JsonView(true, "操作成功!", Url));
  18195. }
  18196. /// <summary>
  18197. /// 酒店预订
  18198. /// 生成VOUCHER 批量生成
  18199. /// New
  18200. /// </summary>
  18201. /// <param name="_dto"></param>
  18202. /// <returns></returns>
  18203. [HttpPost]
  18204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18205. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  18206. {
  18207. #region 参数验证
  18208. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18209. if (_dto.PageId < 1) _dto.PageId = 28;
  18210. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18211. #region 团组操作权限验证 76 酒店预定模块
  18212. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18213. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18214. #endregion
  18215. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18216. #region 页面操作权限验证
  18217. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18218. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18219. #endregion
  18220. #endregion
  18221. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  18222. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  18223. .OrderBy(x => x.CheckInDate)
  18224. .ToListAsync();
  18225. //判断数据是否完整
  18226. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18227. string strFileName = "HotelStatement/";
  18228. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18229. if (dele != null)
  18230. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  18231. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  18232. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  18233. .Where(it => it.IsDel == 0)
  18234. .ToListAsync();
  18235. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  18236. for (int i = 0; i < hrDtas.Count; i++)
  18237. {
  18238. string guestNames = string.Empty;
  18239. List<int> guestIds = new List<int>();
  18240. var item = hrDtas[i];
  18241. //处理客户姓名
  18242. if (item.GuestName.Contains(","))
  18243. {
  18244. string[] guestIdArr = item.GuestName.Split(',');
  18245. foreach (var guestIdStr in guestIdArr)
  18246. if (int.TryParse(guestIdStr, out int guestId))
  18247. guestIds.Add(guestId);
  18248. }
  18249. else
  18250. {
  18251. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  18252. if (guestIdBool)
  18253. {
  18254. guestIds.Add(guestId);
  18255. }
  18256. //NaN
  18257. if (item.GuestName.Contains("NaN"))
  18258. {
  18259. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  18260. }
  18261. }
  18262. if (guestIds.Count > 0)
  18263. {
  18264. guestIds = guestIds.Distinct().ToList();
  18265. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  18266. if (guestDatas1.Count > 0)
  18267. {
  18268. guestNames = "";
  18269. foreach (var guest in guestDatas1)
  18270. {
  18271. string guestName = "";
  18272. if (guest.Sex == 0) guestName += @"MR.";
  18273. else if (guest.Sex == 1) guestName += @"MS.";
  18274. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18275. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18276. guestNames += @$"{guestName.Trim()}、";
  18277. }
  18278. if (guestNames.Length > 0)
  18279. {
  18280. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18281. }
  18282. }
  18283. }
  18284. //if (!string.IsNullOrEmpty(guestNames))
  18285. //{
  18286. hrDtas[i].GuestName = guestNames;
  18287. //}
  18288. }
  18289. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  18290. Document doc = new Document();
  18291. DocumentBuilder builder = new DocumentBuilder(doc);
  18292. try
  18293. {
  18294. builder.MoveToDocumentStart();
  18295. foreach (var item in hrDtas)
  18296. {
  18297. //标题
  18298. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18299. builder.ParagraphFormat.LineSpacing = 1;
  18300. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18301. builder.ParagraphFormat.Style.Font.Size = 9;
  18302. builder.ParagraphFormat.Style.Font.Bold = true;
  18303. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18304. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  18305. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18306. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18307. builder.ParagraphFormat.LineSpacing = 1;
  18308. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18309. builder.ParagraphFormat.Style.Font.Size = 9;
  18310. builder.ParagraphFormat.Style.Font.Bold = true;
  18311. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  18312. builder.StartTable();
  18313. // 设置边框颜色
  18314. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  18315. //设置边框样式
  18316. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  18317. //表格
  18318. #region 第一行
  18319. builder.InsertCell();
  18320. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18321. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18322. //builder.CellFormat.AllowAutoFit = false;
  18323. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18324. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18325. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18326. builder.CellFormat.WrapText = true; //自动换行
  18327. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18328. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  18329. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18330. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18331. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18332. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18333. builder.Write("TOUR NO:");
  18334. builder.InsertCell();
  18335. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18336. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18337. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18338. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18339. builder.ParagraphFormat.Style.Font.Bold = false;
  18340. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18341. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18342. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18343. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18344. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18345. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18346. builder.Write($"{dele?.TourCode ?? "-"}");
  18347. builder.InsertCell();
  18348. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18349. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18350. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18351. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18352. builder.ParagraphFormat.Style.Font.Bold = false;
  18353. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18354. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18355. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18356. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18357. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18358. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18359. builder.Write($"CITY:");
  18360. builder.InsertCell();
  18361. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18362. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18363. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18364. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18365. builder.ParagraphFormat.Style.Font.Bold = false;
  18366. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18367. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18368. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18369. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18370. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18371. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18372. builder.Write($"{item.City}");
  18373. builder.EndRow();
  18374. #endregion
  18375. #region 第二行
  18376. builder.InsertCell();
  18377. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18378. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18379. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18380. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18381. builder.ParagraphFormat.Style.Font.Bold = false;
  18382. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18383. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18384. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18385. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18386. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18387. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18388. builder.Write("CONFIRMATION NO:");
  18389. builder.InsertCell();
  18390. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18391. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18392. builder.ParagraphFormat.Style.Font.Size = 8;
  18393. builder.ParagraphFormat.Style.Font.Bold = false;
  18394. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18395. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18396. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18397. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18398. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18399. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18400. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18401. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18402. builder.Write($"{item.DetermineNo}");
  18403. builder.InsertCell();
  18404. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18405. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18406. builder.InsertCell();
  18407. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18408. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18409. builder.EndRow();
  18410. #endregion
  18411. #region 第三行
  18412. builder.InsertCell();
  18413. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18414. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18415. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18416. builder.ParagraphFormat.Style.Font.Bold = false;
  18417. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18418. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18419. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18420. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18421. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18422. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18423. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18424. builder.Write($"HOTEL NAME:");
  18425. builder.InsertCell();
  18426. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18427. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18428. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18429. builder.ParagraphFormat.Style.Font.Bold = false;
  18430. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18431. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18432. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18433. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18434. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18435. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18436. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18437. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18438. builder.Write($"{item.HotelName}");
  18439. builder.InsertCell();
  18440. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18441. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18442. builder.InsertCell();
  18443. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18444. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18445. builder.EndRow();
  18446. #endregion
  18447. #region 第四行
  18448. builder.InsertCell();
  18449. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18450. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18451. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18452. builder.ParagraphFormat.Style.Font.Bold = false;
  18453. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18454. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18455. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18456. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18457. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18458. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18459. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18460. builder.Write($"HOTEL ADDRESS:");
  18461. builder.InsertCell();
  18462. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18463. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18464. builder.ParagraphFormat.Style.Font.Size = 8;
  18465. builder.ParagraphFormat.Style.Font.Bold = false;
  18466. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18467. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18468. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18469. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18470. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18471. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18472. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18473. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18474. builder.Write($"{item.HotelAddress}");
  18475. builder.InsertCell();
  18476. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18477. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18478. builder.InsertCell();
  18479. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18480. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18481. builder.EndRow();
  18482. #endregion
  18483. #region 第五行
  18484. builder.InsertCell();
  18485. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18486. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18487. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18488. builder.ParagraphFormat.Style.Font.Bold = false;
  18489. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18490. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18491. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18492. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18493. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18494. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18495. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18496. builder.Write("TEL:");
  18497. builder.InsertCell();
  18498. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18499. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18500. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18501. builder.ParagraphFormat.Style.Font.Bold = false;
  18502. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18503. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18504. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18505. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18506. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18507. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18508. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18509. builder.Write($"{item.HotelTel}");
  18510. builder.InsertCell();
  18511. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18512. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18513. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18514. builder.ParagraphFormat.Style.Font.Bold = false;
  18515. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18516. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18517. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18518. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18519. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18520. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18521. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18522. builder.Write($"FAX:");
  18523. builder.InsertCell();
  18524. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18525. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18526. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18527. builder.ParagraphFormat.Style.Font.Bold = false;
  18528. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18529. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18530. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18531. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18532. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18533. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18534. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18535. builder.Write($"{item.HotelFax}");
  18536. builder.EndRow();
  18537. #endregion
  18538. #region 第六行
  18539. builder.InsertCell();
  18540. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18541. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18542. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18543. builder.ParagraphFormat.Style.Font.Bold = false;
  18544. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18545. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18546. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18547. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18548. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18549. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18550. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18551. builder.Write("CHECK IN:");
  18552. builder.InsertCell();
  18553. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18554. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18555. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18556. builder.ParagraphFormat.Style.Font.Bold = false;
  18557. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18558. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18559. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18560. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18561. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18562. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18563. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18564. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18565. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18566. builder.Write($"{checkInStr}");
  18567. builder.InsertCell();
  18568. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18569. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18570. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18571. builder.ParagraphFormat.Style.Font.Bold = false;
  18572. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18573. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18574. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18575. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18576. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18577. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18578. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18579. builder.Write($"CHECK OUT:");
  18580. builder.InsertCell();
  18581. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18582. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18583. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18584. builder.ParagraphFormat.Style.Font.Bold = false;
  18585. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18586. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18587. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18588. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18589. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18590. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18591. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18592. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18593. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18594. builder.Write($"{checkOutStr}");
  18595. builder.EndRow();
  18596. #endregion
  18597. #region 第七行
  18598. builder.InsertCell();
  18599. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18600. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18601. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18602. builder.ParagraphFormat.Style.Font.Bold = false;
  18603. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18604. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18605. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18606. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18607. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18608. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18609. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18610. builder.Write($"GUEST NAME:");
  18611. builder.InsertCell();
  18612. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18613. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18614. builder.ParagraphFormat.Style.Font.Size = 8;
  18615. builder.ParagraphFormat.Style.Font.Bold = false;
  18616. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18617. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18618. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18619. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18620. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18621. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18622. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18623. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18624. builder.Write($"{item.GuestName.Trim()}");
  18625. builder.InsertCell();
  18626. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18627. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18628. builder.InsertCell();
  18629. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18630. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18631. builder.EndRow();
  18632. #endregion
  18633. #region 第八行
  18634. builder.InsertCell();
  18635. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18636. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18637. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18638. builder.ParagraphFormat.Style.Font.Bold = false;
  18639. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18640. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18641. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18642. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18643. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18644. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18645. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18646. builder.Write($"ROOM TYPE:");
  18647. builder.InsertCell();
  18648. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18649. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18650. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18651. builder.ParagraphFormat.Style.Font.Bold = false;
  18652. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18653. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18654. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18655. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18656. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18657. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18658. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18659. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18660. builder.Write($"{item.RoomExplanation}");
  18661. builder.InsertCell();
  18662. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18663. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18664. builder.InsertCell();
  18665. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18666. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18667. builder.EndRow();
  18668. #endregion
  18669. #region 第九行
  18670. builder.InsertCell();
  18671. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18672. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18673. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18674. builder.ParagraphFormat.Style.Font.Bold = false;
  18675. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18676. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18677. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18678. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18679. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18680. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18681. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18682. builder.Write($"NOTE:");
  18683. builder.InsertCell();
  18684. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18685. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18686. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18687. builder.ParagraphFormat.Style.Font.Bold = false;
  18688. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18689. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18690. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18691. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18692. 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.");
  18693. builder.InsertCell();
  18694. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18695. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18696. builder.InsertCell();
  18697. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18698. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18699. builder.EndRow();
  18700. #endregion
  18701. builder.EndTable();
  18702. //换行
  18703. builder.Writeln("");
  18704. builder.Writeln("");
  18705. }
  18706. #region 获取文档中的所有表格 设置文字自适应
  18707. // 获取文档中的所有表格。
  18708. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18709. {
  18710. // 遍历表格中的所有行。
  18711. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18712. {
  18713. foreach (Cell cell in row.Cells)
  18714. {
  18715. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18716. cellFormat.Width = 0;
  18717. }
  18718. }
  18719. }
  18720. #endregion
  18721. #region 设置页眉
  18722. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18723. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18724. if (System.IO.File.Exists(voucherHeaderPath))
  18725. {
  18726. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18727. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18728. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18729. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18730. // 调整图片位置
  18731. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18732. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18733. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18734. shape.Left = 0; // 将图片距离页面左边缘的距离
  18735. shape.Width = 81; // 设置图片宽度
  18736. shape.Height = 36; // 设置图片高度
  18737. }
  18738. //靠右
  18739. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18740. //// 设置页脚上下边距
  18741. //builder.PageSetup.HeaderDistance = 42;
  18742. // 添加页眉线
  18743. Aspose.Words.Border borderHeader = null;
  18744. try
  18745. {
  18746. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18747. }
  18748. catch (Exception e)
  18749. {
  18750. // TODO Auto-generated catch block
  18751. //e.printStackTrace();
  18752. }
  18753. borderHeader.Shadow = true;
  18754. borderHeader.DistanceFromText = 2;
  18755. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18756. #endregion
  18757. }
  18758. catch (Exception ex)
  18759. {
  18760. }
  18761. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18762. doc.Save(fileDir);
  18763. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18764. return Ok(JsonView(true, "操作成功!", Url));
  18765. }
  18766. /// <summary>
  18767. /// 酒店预订
  18768. /// 生成 预定成本 Excel
  18769. /// </summary>
  18770. /// <param name="_dto"></param>
  18771. /// <returns></returns>
  18772. [HttpPost]
  18773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18774. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18775. {
  18776. #region 参数验证
  18777. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18778. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18779. if (!vadalitorRes.IsValid)
  18780. {
  18781. var errors = new StringBuilder();
  18782. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18783. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18784. }
  18785. #region 团组操作权限验证 76 酒店预定模块
  18786. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18787. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18788. #endregion
  18789. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18790. #region 页面操作权限验证
  18791. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18792. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18793. #endregion
  18794. #endregion
  18795. decimal _rate = 1.00M;
  18796. string _currency = string.Empty;
  18797. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18798. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18799. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18800. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18801. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18802. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18803. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18804. if (_GroupCostParameter == null)
  18805. {
  18806. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18807. bool isIntType = int.TryParse(_currency, out int currId);
  18808. if (isIntType)
  18809. {
  18810. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18811. }
  18812. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18813. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18814. if (currInfo == null)
  18815. {
  18816. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18817. }
  18818. else _rate = currInfo.Rate;
  18819. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18820. {
  18821. _rate = _GroupCostParameter.Rate;
  18822. }
  18823. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18824. //string strFileName = "HotelStatement/";
  18825. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18826. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18827. var rateDatas = new List<dynamic>();
  18828. #region 数据处理
  18829. foreach (var item in hrDtas)
  18830. {
  18831. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18832. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18833. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18834. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18835. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18836. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18837. {
  18838. continue;
  18839. }
  18840. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18841. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18842. string singleRoomFeeStr = string.Empty,
  18843. doubleRoomFeeStr = string.Empty,
  18844. suiteRoomFeeStr = string.Empty,
  18845. otherRoomFeeStr = string.Empty,
  18846. payMoneyStr = string.Empty,
  18847. cardPriceStr = string.Empty;
  18848. if (roomCurr.Equals("CNY"))
  18849. {
  18850. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18851. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18852. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18853. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18854. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18855. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18856. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18857. }
  18858. else
  18859. {
  18860. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18861. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18862. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18863. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18864. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18865. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18866. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18867. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18868. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18869. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18870. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18871. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18872. if (ccpPaymentCurrency.Equals("CNY"))
  18873. {
  18874. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18875. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18876. }
  18877. else
  18878. {
  18879. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18880. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18881. }
  18882. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18883. if (hotelcardPriceCurrency.Equals("CNY"))
  18884. {
  18885. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18886. }
  18887. else
  18888. {
  18889. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18890. }
  18891. }
  18892. string breakfastPriceStr = string.Empty,
  18893. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18894. governmentRentStr = string.Empty,
  18895. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18896. cityTaxStr = string.Empty,
  18897. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18898. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18899. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18900. {
  18901. if (breakfastCurrency1.Equals("CNY"))
  18902. {
  18903. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18904. }
  18905. else
  18906. {
  18907. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18908. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18909. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18910. }
  18911. }
  18912. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18913. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18914. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18915. {
  18916. if (governmentRentCurrency.Equals("CNY"))
  18917. {
  18918. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18919. }
  18920. else
  18921. {
  18922. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18923. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18924. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18925. }
  18926. }
  18927. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18928. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18929. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18930. {
  18931. if (cityTaxStrCurrency1.Equals("CNY"))
  18932. {
  18933. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18934. }
  18935. else
  18936. {
  18937. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18938. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18939. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18940. }
  18941. }
  18942. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18943. int payDId = roomInfo?.PayDId ?? 0;
  18944. pcfds.Add(new HotelReservations_PCFD_View()
  18945. {
  18946. City = item.City,
  18947. HotelName = item.HotelName,
  18948. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18949. // SingleRoomCount = item.SingleRoomCount,
  18950. SingleRoomPrice = singleRoomFeeStr,
  18951. // DoubleRoomCount = item.DoubleRoomCount,
  18952. DoubleRoomPrice = doubleRoomFeeStr,
  18953. //SuiteRoomCount = item.SuiteRoomCount,
  18954. SuiteRoomPrice = suiteRoomFeeStr,
  18955. OtherRoomPrice = otherRoomFeeStr,
  18956. //OtherRoomCount = item.OtherRoomCount,
  18957. BreakfastPrice = breakfastPriceStr,
  18958. GovernmentRent = governmentRentStr,
  18959. CityTax = cityTaxStr,
  18960. RoomExplanation = item.RoomExplanation,
  18961. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18962. PayTime = roomInfo?.ConsumptionDate,
  18963. BankNo = roomInfo?.BankNo,
  18964. PayMoney = payMoneyStr,
  18965. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18966. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18967. CardPrice = cardPriceStr,
  18968. Remark = ccpInfo.Remark
  18969. });
  18970. }
  18971. #endregion
  18972. //载入模板
  18973. WorkbookDesigner designer = new WorkbookDesigner();
  18974. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18975. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18976. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18977. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18978. var rateDatas1 = rateDatas.Distinct();
  18979. var rateStr = string.Empty;
  18980. foreach (var item in rateDatas1)
  18981. {
  18982. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18983. }
  18984. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18985. designer.SetDataSource("Opertor", userInfo.CnName);
  18986. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18987. dt.TableName = "ViewMyHotelReservations";
  18988. designer.SetDataSource(dt);
  18989. designer.Process();
  18990. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18991. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18992. designer.Workbook.Save(serverPath);
  18993. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18994. #region 删除指定行
  18995. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18996. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18997. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18998. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18999. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19000. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19001. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19002. cssIndex = dt.Columns["CityTax"].Ordinal,
  19003. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19004. remarkIndex = dt.Columns["Remark"].Ordinal;
  19005. //删除指定列
  19006. foreach (DataRow item in dt.Rows)
  19007. {
  19008. string singleStr = item["SingleRoomPrice"].ToString();
  19009. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19010. if (containsDigitButNotZero1) singleDel = false;
  19011. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19012. string doubleStr = item["DoubleRoomPrice"].ToString();
  19013. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19014. if (containsDigitButNotZero2) doubleDel = false;
  19015. string suiteStr = item["SuiteRoomPrice"].ToString();
  19016. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19017. if (containsDigitButNotZero3) suiteDel = false;
  19018. string otherStr = item["OtherRoomPrice"].ToString();
  19019. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19020. if (containsDigitButNotZero4) otherDel = false;
  19021. string zcStr = item["BreakfastPrice"].ToString();
  19022. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19023. if (containsDigitButNotZero5) zcDel = false;
  19024. string dsStr = item["GovernmentRent"].ToString();
  19025. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19026. if (containsDigitButNotZero6) dsDel = false;
  19027. string cssStr = item["CityTax"].ToString();
  19028. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19029. if (containsDigitButNotZero7) cssDel = false;
  19030. string cpStr = item["ConsumptionPatterns"].ToString();
  19031. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19032. string remarkStr = item["Remark"].ToString();
  19033. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19034. }
  19035. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19036. DeleteColumn(serverPath, cpIndex, cpDel);
  19037. DeleteColumn(serverPath, dsIndex, dsDel);
  19038. DeleteColumn(serverPath, cssIndex, cssDel);
  19039. DeleteColumn(serverPath, zcIndex, zcDel);
  19040. DeleteColumn(serverPath, otherIndex, otherDel);
  19041. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19042. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19043. DeleteColumn(serverPath, singleIndex, singleDel);
  19044. #endregion
  19045. //只保留第一个表格
  19046. DeleteSheet(serverPath);
  19047. return Ok(JsonView(true, "操作成功", url = rst));
  19048. }
  19049. else
  19050. {
  19051. _currency = _GroupCostParameter.Currency;
  19052. bool isIntType = int.TryParse(_currency, out int currId);
  19053. if (isIntType)
  19054. {
  19055. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19056. }
  19057. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19058. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19059. if (currInfo == null)
  19060. {
  19061. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19062. }
  19063. if (!_currency.ToUpper().Equals("CNY"))
  19064. {
  19065. _rate = _GroupCostParameter.Rate;
  19066. }
  19067. _rate = currInfo.Rate;
  19068. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19069. //string strFileName = "HotelStatement/";
  19070. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19071. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19072. #region 数据处理
  19073. foreach (var item in hrDtas)
  19074. {
  19075. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19076. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19077. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19078. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19079. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19080. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19081. string singleRoomFeeStr = string.Empty,
  19082. doubleRoomFeeStr = string.Empty,
  19083. suiteRoomFeeStr = string.Empty,
  19084. otherRoomFeeStr = string.Empty,
  19085. payMoneyStr = string.Empty,
  19086. cardPriceStr = string.Empty;
  19087. if (roomCurr.Equals(_currency))
  19088. {
  19089. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  19090. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  19091. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  19092. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  19093. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  19094. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  19095. }
  19096. else
  19097. {
  19098. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19099. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19100. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19101. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19102. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19103. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19104. }
  19105. string breakfastPriceStr = string.Empty,
  19106. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19107. governmentRentStr = string.Empty,
  19108. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19109. cityTaxStrStr = string.Empty,
  19110. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19111. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  19112. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  19113. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  19114. int payDId = roomInfo?.PayDId ?? 0;
  19115. pcfds.Add(new HotelReservations_PCFD_View()
  19116. {
  19117. City = item.City,
  19118. HotelName = item.HotelName,
  19119. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19120. // SingleRoomCount = item.SingleRoomCount,
  19121. SingleRoomPrice = singleRoomFeeStr,
  19122. // DoubleRoomCount = item.DoubleRoomCount,
  19123. DoubleRoomPrice = doubleRoomFeeStr,
  19124. //SuiteRoomCount = item.SuiteRoomCount,
  19125. SuiteRoomPrice = suiteRoomFeeStr,
  19126. OtherRoomPrice = otherRoomFeeStr,
  19127. //OtherRoomCount = item.OtherRoomCount,
  19128. BreakfastPrice = breakfastPriceStr,
  19129. GovernmentRent = governmentRentStr,
  19130. CityTax = cityTaxStrStr,
  19131. RoomExplanation = item.RoomExplanation,
  19132. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19133. PayTime = roomInfo?.ConsumptionDate,
  19134. BankNo = roomInfo?.BankNo,
  19135. PayMoney = payMoneyStr,
  19136. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19137. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19138. CardPrice = cardPriceStr,
  19139. Remark = ccpInfo.Remark
  19140. });
  19141. }
  19142. #endregion
  19143. //载入模板
  19144. WorkbookDesigner designer = new WorkbookDesigner();
  19145. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19146. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19147. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19148. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19149. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  19150. designer.SetDataSource("Opertor", userInfo.CnName);
  19151. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19152. dt.TableName = "ViewMyHotelReservations";
  19153. designer.SetDataSource(dt);
  19154. designer.Process();
  19155. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19156. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19157. designer.Workbook.Save(serverPath);
  19158. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19159. #region 删除指定行
  19160. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19161. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19162. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19163. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19164. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19165. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19166. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19167. cssIndex = dt.Columns["CityTax"].Ordinal,
  19168. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19169. remarkIndex = dt.Columns["Remark"].Ordinal;
  19170. //删除指定列
  19171. foreach (DataRow item in dt.Rows)
  19172. {
  19173. string singleStr = item["SingleRoomPrice"].ToString();
  19174. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19175. if (containsDigitButNotZero1) singleDel = false;
  19176. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19177. string doubleStr = item["DoubleRoomPrice"].ToString();
  19178. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19179. if (containsDigitButNotZero2) doubleDel = false;
  19180. string suiteStr = item["SuiteRoomPrice"].ToString();
  19181. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19182. if (containsDigitButNotZero3) suiteDel = false;
  19183. string otherStr = item["OtherRoomPrice"].ToString();
  19184. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19185. if (containsDigitButNotZero4) otherDel = false;
  19186. string zcStr = item["BreakfastPrice"].ToString();
  19187. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19188. if (containsDigitButNotZero5) zcDel = false;
  19189. string dsStr = item["GovernmentRent"].ToString();
  19190. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19191. if (containsDigitButNotZero6) dsDel = false;
  19192. string cssStr = item["CityTax"].ToString();
  19193. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19194. if (containsDigitButNotZero7) cssDel = false;
  19195. string cpStr = item["ConsumptionPatterns"].ToString();
  19196. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19197. string remarkStr = item["Remark"].ToString();
  19198. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19199. }
  19200. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19201. DeleteColumn(serverPath, cpIndex, cpDel);
  19202. DeleteColumn(serverPath, dsIndex, dsDel);
  19203. DeleteColumn(serverPath, cssIndex, cssDel);
  19204. DeleteColumn(serverPath, zcIndex, zcDel);
  19205. DeleteColumn(serverPath, otherIndex, otherDel);
  19206. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19207. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19208. DeleteColumn(serverPath, singleIndex, singleDel);
  19209. #endregion
  19210. //只保留第一个表格
  19211. DeleteSheet(serverPath);
  19212. return Ok(JsonView(true, "操作成功", url = rst));
  19213. }
  19214. //return Ok(JsonView(false));
  19215. }
  19216. /// <summary>
  19217. /// 删除指定列
  19218. /// </summary>
  19219. /// <param name="file"></param>
  19220. /// <param name="columnIndex"></param>
  19221. /// <param name="isDel"></param>
  19222. private void DeleteColumn(string file, int columnIndex, bool isDel)
  19223. {
  19224. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19225. //wb.Save(file);
  19226. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  19227. if (sheet1 != null)
  19228. {
  19229. if (isDel)
  19230. {
  19231. Cells cells = sheet1.Cells;
  19232. cells.DeleteColumn(columnIndex);
  19233. }
  19234. }
  19235. wb.Save(file);
  19236. }
  19237. /// <summary>
  19238. /// 删除sheet
  19239. /// </summary>
  19240. /// <param name="file"></param>
  19241. private void DeleteSheet(string file)
  19242. {
  19243. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19244. //wb.Save(file);
  19245. List<string> sheets = new List<string>();
  19246. foreach (var item in wb.Worksheets)
  19247. {
  19248. sheets.Add(item.Name);
  19249. }
  19250. if (sheets.Count > 0)
  19251. {
  19252. sheets.RemoveAt(0);//不删除第一个sheet
  19253. foreach (var item in sheets)
  19254. {
  19255. wb.Worksheets.RemoveAt(item);
  19256. }
  19257. }
  19258. wb.Save(file);
  19259. }
  19260. /// <summary>
  19261. /// 酒店预订
  19262. /// 确认单
  19263. /// </summary>
  19264. /// <param name="_dto"></param>
  19265. /// <returns></returns>
  19266. [HttpPost]
  19267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19268. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  19269. {
  19270. try
  19271. {
  19272. #region 参数验证
  19273. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19274. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19275. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19276. #region 团组操作权限验证 76 酒店预定模块
  19277. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19278. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19279. #endregion
  19280. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19281. #region 页面操作权限验证
  19282. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19283. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19284. #endregion
  19285. #endregion
  19286. //团组信息
  19287. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  19288. //酒店数据
  19289. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  19290. if (listhoteldata.Count < 0)
  19291. {
  19292. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  19293. }
  19294. //利datatable存储
  19295. DataTable dt = new DataTable();
  19296. dt.Columns.Add("CheckInDate", typeof(string));
  19297. dt.Columns.Add("City", typeof(string));
  19298. dt.Columns.Add("Hotel", typeof(string));
  19299. dt.Columns.Add("Room", typeof(string));
  19300. for (int i = 0; i < listhoteldata.Count; i++)
  19301. {
  19302. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  19303. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  19304. while (dayStart < dayEnd)
  19305. {
  19306. string temp = "";
  19307. DataRow row = dt.NewRow();
  19308. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  19309. row["City"] = listhoteldata[i].City;
  19310. row["Hotel"] = listhoteldata[i].HotelName;
  19311. if (listhoteldata[i].SingleRoomCount > 0)
  19312. {
  19313. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  19314. }
  19315. if (listhoteldata[i].DoubleRoomCount > 0)
  19316. {
  19317. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  19318. }
  19319. if (listhoteldata[i].SuiteRoomCount > 0)
  19320. {
  19321. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  19322. }
  19323. if (listhoteldata[i].OtherRoomCount > 0)
  19324. {
  19325. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  19326. }
  19327. row["Room"] = temp;
  19328. dt.Rows.Add(row);
  19329. dayStart = dayStart.AddDays(1);
  19330. }
  19331. }
  19332. Dictionary<string, string> dic = new Dictionary<string, string>();
  19333. dic.Add("Dele", di.TeamName);
  19334. dic.Add("City", di.VisitCountry);
  19335. //模板路径
  19336. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  19337. //载入模板
  19338. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  19339. DocumentBuilder builder = new DocumentBuilder(doc);
  19340. foreach (var key in dic.Keys)
  19341. {
  19342. builder.MoveToBookmark(key);
  19343. builder.Write(dic[key]);
  19344. }
  19345. //获取word里所有表格
  19346. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19347. //获取所填表格的序数
  19348. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19349. var rowStart = tableOne.Rows[0]; //获取第1行
  19350. //循环赋值
  19351. for (int i = 0; i < dt.Rows.Count; i++)
  19352. {
  19353. builder.MoveToCell(0, i + 1, 0, 0);
  19354. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  19355. builder.MoveToCell(0, i + 1, 1, 0);
  19356. builder.Write(dt.Rows[i]["City"].ToString());
  19357. builder.MoveToCell(0, i + 1, 2, 0);
  19358. builder.Write(dt.Rows[i]["Hotel"].ToString());
  19359. builder.MoveToCell(0, i + 1, 3, 0);
  19360. builder.Write(dt.Rows[i]["Room"].ToString());
  19361. }
  19362. //删除多余行
  19363. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  19364. {
  19365. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  19366. }
  19367. string strFileName = di.TeamName + "酒店确认单.doc";
  19368. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  19369. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  19370. return Ok(JsonView(true, "成功", url));
  19371. }
  19372. catch (Exception ex)
  19373. {
  19374. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  19375. }
  19376. }
  19377. #endregion
  19378. #region 团组状态
  19379. /// <summary>
  19380. /// 团组状态列表 Page
  19381. /// </summary>
  19382. /// <param name="dto">团组列表请求dto</param>
  19383. /// <returns></returns>
  19384. [HttpPost]
  19385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19386. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  19387. {
  19388. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19389. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  19390. {
  19391. string sqlWhere = string.Empty;
  19392. if (dto.IsSure == 0) //未完成
  19393. {
  19394. sqlWhere += string.Format(@" And IsSure = 0");
  19395. }
  19396. else if (dto.IsSure == 1) //已完成
  19397. {
  19398. sqlWhere += string.Format(@" And IsSure = 1");
  19399. }
  19400. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  19401. {
  19402. string tj = dto.SearchCriteria;
  19403. 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}%')",
  19404. tj, tj, tj, tj, tj);
  19405. }
  19406. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19407. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19408. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19409. From (
  19410. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19411. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19412. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19413. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19414. From Grp_DelegationInfo gdi
  19415. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19416. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19417. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19418. Where gdi.IsDel = 0 {0}
  19419. ) temp ", sqlWhere);
  19420. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19421. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19422. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19423. }
  19424. else
  19425. {
  19426. return Ok(JsonView(false, "查询失败"));
  19427. }
  19428. }
  19429. /// <summary>
  19430. /// 团组状态
  19431. /// 设置操作完成
  19432. /// </summary>
  19433. /// <param name="dto">团组列表请求dto</param>
  19434. /// <returns></returns>
  19435. [HttpPost]
  19436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19437. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19438. {
  19439. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19440. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19441. {
  19442. Id = dto.Id,
  19443. IsSure = 1
  19444. };
  19445. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19446. .UpdateColumns(it => new { it.IsSure })
  19447. .WhereColumns(it => new { it.Id })
  19448. .ExecuteCommandAsync();
  19449. if (result > 0)
  19450. {
  19451. return Ok(JsonView(true, "操作完成!"));
  19452. }
  19453. return Ok(JsonView(false, "操作失败!"));
  19454. }
  19455. #endregion
  19456. #region 保险费用录入
  19457. /// <summary>
  19458. /// 根据团组Id查询保险费用列表
  19459. /// </summary>
  19460. /// <param name="dto"></param>
  19461. /// <returns></returns>
  19462. [HttpPost]
  19463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19464. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19465. {
  19466. Result groupData = await _customersRep.CustomersByDiId(dto);
  19467. if (groupData.Code != 0)
  19468. {
  19469. return Ok(JsonView(false, groupData.Msg));
  19470. }
  19471. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19472. }
  19473. /// <summary>
  19474. /// 根据保险费用Id查询保险费用详细
  19475. /// </summary>
  19476. /// <param name="dto"></param>
  19477. /// <returns></returns>
  19478. [HttpPost]
  19479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19480. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19481. {
  19482. try
  19483. {
  19484. Result groupData = await _customersRep.CustomersById(dto);
  19485. if (groupData.Code != 0)
  19486. {
  19487. return Ok(JsonView(false, groupData.Msg));
  19488. }
  19489. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19490. }
  19491. catch (Exception ex)
  19492. {
  19493. return Ok(JsonView(false, ex.Message));
  19494. }
  19495. }
  19496. /// <summary>
  19497. /// 保险费用录入页面初始化绑定
  19498. /// </summary>
  19499. /// <param name="dto"></param>
  19500. /// <returns></returns>
  19501. [HttpPost]
  19502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19503. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19504. {
  19505. try
  19506. {
  19507. Result groupData = await _customersRep.CustomersInitialize(dto);
  19508. if (groupData.Code != 0)
  19509. {
  19510. return Ok(JsonView(false, groupData.Msg));
  19511. }
  19512. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19513. }
  19514. catch (Exception ex)
  19515. {
  19516. return Ok(JsonView(false, ex.Message));
  19517. }
  19518. }
  19519. /// <summary>
  19520. /// 保险费用操作(Status:1.新增,2.修改)
  19521. /// </summary>
  19522. /// <param name="dto"></param>
  19523. /// <returns></returns>
  19524. [HttpPost]
  19525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19526. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19527. {
  19528. Result groupData = await _customersRep.OpCustomers(dto);
  19529. if (groupData.Code != 0)
  19530. {
  19531. return Ok(JsonView(false, groupData.Msg));
  19532. }
  19533. #region 应用推送
  19534. try
  19535. {
  19536. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19537. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19538. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19539. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19540. //自动审核
  19541. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19542. //2024-10-21 新增LZ UID
  19543. var userIds = new List<int>() { 21 };
  19544. string title = $"系统通知";
  19545. var diId = dto.DiId;
  19546. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19547. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19548. string content = "";
  19549. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19550. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19551. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19552. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19553. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19554. }
  19555. catch (Exception ex)
  19556. {
  19557. }
  19558. #endregion
  19559. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19560. }
  19561. /// <summary>
  19562. /// 保险文件上传
  19563. /// </summary>
  19564. /// <param name="file"></param>
  19565. /// <returns></returns>
  19566. [HttpPost]
  19567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19568. public async Task<IActionResult> UploadCus(IFormFile file)
  19569. {
  19570. try
  19571. {
  19572. if (file != null)
  19573. {
  19574. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19575. //文件名称
  19576. string projectFileName = file.FileName;
  19577. //上传的文件的路径
  19578. string filePath = "";
  19579. if (!Directory.Exists(fileDir))
  19580. {
  19581. Directory.CreateDirectory(fileDir);
  19582. }
  19583. //上传的文件的路径
  19584. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19585. using (FileStream fs = System.IO.File.Create(filePath))
  19586. {
  19587. file.CopyTo(fs);
  19588. fs.Flush();
  19589. }
  19590. return Ok(JsonView(true, "上传成功!", projectFileName));
  19591. }
  19592. else
  19593. {
  19594. return Ok(JsonView(false, "上传失败!"));
  19595. }
  19596. }
  19597. catch (Exception ex)
  19598. {
  19599. return Ok(JsonView(false, ex.Message));
  19600. }
  19601. }
  19602. /// <summary>
  19603. /// 保险删除指定文件
  19604. /// </summary>
  19605. /// <param name="dto"></param>
  19606. /// <returns></returns>
  19607. [HttpPost]
  19608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19609. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19610. {
  19611. try
  19612. {
  19613. string filePath = "";
  19614. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19615. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19616. //int id = 0;
  19617. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19618. // 删除该文件
  19619. try
  19620. {
  19621. System.IO.File.Delete(filePath);
  19622. 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()
  19623. {
  19624. Attachment = "",
  19625. }).ExecuteCommandAsync();
  19626. if (result != 0)
  19627. {
  19628. return Ok(JsonView(true, "成功!"));
  19629. }
  19630. else
  19631. {
  19632. return Ok(JsonView(false, "失败!"));
  19633. }
  19634. }
  19635. catch (Exception)
  19636. {
  19637. 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()
  19638. {
  19639. Attachment = "",
  19640. }).ExecuteCommandAsync();
  19641. if (result != 0)
  19642. {
  19643. return Ok(JsonView(true, "成功!"));
  19644. }
  19645. else
  19646. {
  19647. return Ok(JsonView(false, "失败!"));
  19648. }
  19649. }
  19650. }
  19651. catch (Exception ex)
  19652. {
  19653. return Ok(JsonView(false, "程序错误!"));
  19654. throw;
  19655. }
  19656. }
  19657. /// <summary>
  19658. /// 保险费用操作(删除)
  19659. /// </summary>
  19660. /// <param name="dto"></param>
  19661. /// <returns></returns>
  19662. [HttpPost]
  19663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19664. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19665. {
  19666. try
  19667. {
  19668. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19669. if (!res)
  19670. {
  19671. return Ok(JsonView(false, "删除失败"));
  19672. }
  19673. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19674. {
  19675. IsDel = 1,
  19676. DeleteUserId = dto.DeleteUserId,
  19677. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19678. }).ExecuteCommandAsync();
  19679. return Ok(JsonView(true, "删除成功!"));
  19680. }
  19681. catch (Exception ex)
  19682. {
  19683. return Ok(JsonView(false, "程序错误!"));
  19684. throw;
  19685. }
  19686. }
  19687. #endregion
  19688. #region 接团客户名单 PageId 104
  19689. /// <summary>
  19690. /// 接团客户名单
  19691. /// 迁移数据(慎用!)
  19692. /// </summary>
  19693. /// <returns></returns>
  19694. [HttpPost]
  19695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19696. public async Task<IActionResult> PostTourClientListChange()
  19697. {
  19698. try
  19699. {
  19700. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19701. //var groupClinetData1
  19702. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19703. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19704. int updateCount = 0;
  19705. if (oldOAClientList.Count > 0)
  19706. {
  19707. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19708. _sqlSugar.BeginTran();
  19709. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19710. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19711. foreach (var item in oldOAClientList)
  19712. {
  19713. int comId = 0;
  19714. string format = "yyyy-MM-dd HH:mm:ss";
  19715. string data11 = "1990-01-01 00:00";
  19716. var data1 = IsValidDate(item.OPdate, format);
  19717. if (data1) data11 = item.OPdate;
  19718. //客户公司验证
  19719. if (!string.IsNullOrEmpty(item.Company))
  19720. {
  19721. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19722. if (clientComInfo == null) // add
  19723. {
  19724. var addInfo = new Crm_CustomerCompany()
  19725. {
  19726. CompanyAbbreviation = "",
  19727. CompanyFullName = item.Company,
  19728. Address = "",
  19729. PostCodes = "",
  19730. LastedOpUserId = item.OPer,
  19731. LastedOpDt = Convert.ToDateTime(data11),
  19732. CreateUserId = item.OPer,
  19733. CreateTime = Convert.ToDateTime(data11),
  19734. IsDel = 0
  19735. };
  19736. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19737. if (comId1 > 0) comId = comId1;
  19738. }
  19739. else comId = clientComInfo.Id;
  19740. }
  19741. //客户人员验证
  19742. int clientId = 0;
  19743. string name = item.LastName + item.Name;
  19744. if (!string.IsNullOrEmpty(name))
  19745. {
  19746. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19747. if (clientInfo == null)
  19748. {
  19749. DateTime? dateTime = null;
  19750. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19751. if (isDt) dateTime = birthDayDt;
  19752. var addInfo1 = new Crm_DeleClient()
  19753. {
  19754. CrmCompanyId = comId,
  19755. DiId = -1,
  19756. LastName = item.LastName,
  19757. FirstName = item.Name,
  19758. OldName = "",
  19759. Pinyin = item.Pinyin,
  19760. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19761. Marriage = 0,
  19762. Phone = item.Phone,
  19763. Job = item.Job,
  19764. BirthDay = dateTime
  19765. };
  19766. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19767. if (clientId1 > 0) clientId = clientId1;
  19768. }
  19769. else clientId = clientInfo.Id;
  19770. }
  19771. if (clientId < 1)
  19772. {
  19773. continue;
  19774. }
  19775. int airType = 0;
  19776. if (item.AirType == "超经舱") airType = 459;
  19777. else if (item.AirType == "公务舱") airType = 458;
  19778. else if (item.AirType == "经济舱") airType = 460;
  19779. else if (item.AirType == "其他") airType = 565;
  19780. else if (item.AirType == "头等舱") airType = 457;
  19781. var _TourClientListEntity = new Grp_TourClientList()
  19782. {
  19783. DiId = item.Diid,
  19784. ClientId = clientId,
  19785. CreateUserId = item.OPer,
  19786. CreateTime = Convert.ToDateTime(data11),
  19787. Remark = item.Remark,
  19788. IsDel = item.Isdel,
  19789. ShippingSpaceTypeId = airType,
  19790. ShippingSpaceSpecialNeeds = item.AirRemark,
  19791. HotelSpecialNeeds = item.RoomType
  19792. };
  19793. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19794. if (_TourClientList > 0)
  19795. {
  19796. updateCount++;
  19797. }
  19798. }
  19799. _sqlSugar.CommitTran();
  19800. }
  19801. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19802. }
  19803. catch (Exception ex)
  19804. {
  19805. _sqlSugar.RollbackTran();
  19806. return Ok(JsonView(false, ex.Message));
  19807. }
  19808. //return Ok(JsonView(true));
  19809. }
  19810. private bool IsValidDate(string dateString, string format)
  19811. {
  19812. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  19813. }
  19814. /// <summary>
  19815. /// 接团客户名单
  19816. /// 根据团组Id查询List
  19817. /// </summary>
  19818. /// <param name="_dto"></param>
  19819. /// <returns></returns>
  19820. [HttpPost]
  19821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19822. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19823. {
  19824. #region 参数验证
  19825. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19826. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19827. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19828. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19829. #region 页面操作权限验证
  19830. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19831. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19832. #endregion
  19833. #endregion
  19834. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19835. if (viewData.Code != 0)
  19836. {
  19837. return Ok(JsonView(false, viewData.Msg));
  19838. }
  19839. return Ok(JsonView(viewData.Data));
  19840. }
  19841. /// <summary>
  19842. /// 接团客户名单
  19843. /// 基础数据 Init
  19844. /// </summary>
  19845. /// <param name="_dto"></param>
  19846. /// <returns></returns>
  19847. [HttpPost]
  19848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19849. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19850. {
  19851. #region 参数验证
  19852. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19853. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19854. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19855. #region 页面操作权限验证
  19856. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19857. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19858. #endregion
  19859. #endregion
  19860. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19861. }
  19862. /// <summary>
  19863. /// 接团客户名单
  19864. /// 根据 Id查询 Details
  19865. /// </summary>
  19866. /// <param name="_dto"></param>
  19867. /// <returns></returns>
  19868. [HttpPost]
  19869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19870. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19871. {
  19872. #region 参数验证
  19873. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19874. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19875. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19876. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19877. #region 页面操作权限验证
  19878. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19879. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19880. #endregion
  19881. #endregion
  19882. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19883. if (viewData.Code != 0)
  19884. {
  19885. return Ok(JsonView(false, viewData.Msg));
  19886. }
  19887. return Ok(JsonView(viewData.Data));
  19888. }
  19889. /// <summary>
  19890. /// 接团客户名单
  19891. /// Add Or Edit
  19892. /// </summary>
  19893. /// <param name="_dto"></param>
  19894. /// <returns></returns>
  19895. [HttpPost]
  19896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19897. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19898. {
  19899. #region 参数验证
  19900. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19901. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19902. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19903. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19904. #region 页面操作权限验证
  19905. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19906. if (_dto.Id == 0) //添加
  19907. {
  19908. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19909. }
  19910. else if (_dto.Id >= 0) //修改
  19911. {
  19912. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19913. }
  19914. #endregion
  19915. #endregion
  19916. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19917. if (viewData.Code != 0)
  19918. {
  19919. return Ok(JsonView(false, viewData.Msg));
  19920. }
  19921. return Ok(JsonView(true));
  19922. }
  19923. /// <summary>
  19924. /// 接团客户名单
  19925. /// json字符串 AddMultiple(添加多个)
  19926. /// </summary>
  19927. /// <param name="_dto"></param>
  19928. /// <returns></returns>
  19929. [HttpPost]
  19930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19931. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19932. {
  19933. #region 参数验证
  19934. string jsonLabel = _dto.JsonLabel;
  19935. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19936. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19937. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19938. #region 页面操作权限验证
  19939. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19940. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19941. #endregion
  19942. #endregion
  19943. var request = new TourClientListAddMultipleDto();
  19944. request.DiId = _dto.DiId;
  19945. request.UserId = _dto.UserId;
  19946. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19947. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19948. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19949. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19950. var infos = new List<TourClientListInfo>();
  19951. foreach (var data in datas)
  19952. {
  19953. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19954. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19955. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19956. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19957. {
  19958. continue;
  19959. }
  19960. infos.Add(new TourClientListInfo()
  19961. {
  19962. IsAccompany = 1,
  19963. LastName = lastName,
  19964. FirstName = firstName,
  19965. Pinyin = lastNameEn + @"/" + firstNameEn,
  19966. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19967. CompanyFullName = data.CompanyFullName,
  19968. Job = data.Job
  19969. });
  19970. }
  19971. if (infos.Any())
  19972. {
  19973. var viewData = await _tourClientListRep._AddMultiple(request);
  19974. if (viewData.Code != 0)
  19975. {
  19976. return Ok(JsonView(false, viewData.Msg));
  19977. }
  19978. return Ok(JsonView(true));
  19979. }
  19980. return Ok(JsonView(false));
  19981. }
  19982. /// <summary>
  19983. /// 接团客户名单
  19984. /// AddMultiple(添加多个)
  19985. /// </summary>
  19986. /// <param name="_dto"></param>
  19987. /// <returns></returns>
  19988. [HttpPost]
  19989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19990. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19991. {
  19992. #region 参数验证
  19993. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19994. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19995. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19996. #region 页面操作权限验证
  19997. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19998. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19999. #endregion
  20000. #endregion
  20001. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20002. if (viewData.Code != 0)
  20003. {
  20004. return Ok(JsonView(false, viewData.Msg));
  20005. }
  20006. return Ok(JsonView(true));
  20007. }
  20008. /// <summary>
  20009. /// 接团客户名单
  20010. /// Del
  20011. /// </summary>
  20012. /// <param name="_dto"></param>
  20013. /// <returns></returns>
  20014. [HttpPost]
  20015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20016. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20017. {
  20018. #region 参数验证
  20019. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20020. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20021. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20022. #region 页面操作权限验证
  20023. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20024. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20025. #endregion
  20026. #endregion
  20027. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20028. if (viewData.Code != 0)
  20029. {
  20030. return Ok(JsonView(false, viewData.Msg));
  20031. }
  20032. return Ok(JsonView(true));
  20033. }
  20034. /// <summary>
  20035. /// 接团客户名单
  20036. /// 文件下载 客户名单
  20037. /// </summary>
  20038. /// <param name="_dto"></param>
  20039. /// <returns></returns>
  20040. [HttpPost]
  20041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20042. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20043. {
  20044. #region 参数验证
  20045. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20046. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20047. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20048. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20049. #region 页面操作权限验证
  20050. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20051. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20052. #endregion
  20053. #endregion
  20054. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20055. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20056. From Grp_TourClientList tcl
  20057. Left Join
  20058. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20059. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20060. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20061. From Crm_DeleClient dc
  20062. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20063. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20064. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20065. Where dc.IsDel = 0) temp
  20066. On temp.DcId =tcl.ClientId
  20067. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20068. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20069. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20070. //载入模板
  20071. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20072. if (_dto.Language == 1)
  20073. {
  20074. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20075. }
  20076. //载入模板
  20077. var doc = new Document(tempPath);
  20078. DocumentBuilder builder = new DocumentBuilder(doc);
  20079. //获取word里所有表格
  20080. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20081. //获取所填表格的序数
  20082. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20083. var rowStart = tableOne.Rows[0]; //获取第1行
  20084. if (_dto.Language == 0)
  20085. {
  20086. //循环赋值
  20087. for (int i = 0; i < DcList.Count; i++)
  20088. {
  20089. EncryptionProcessor.DecryptProperties(DcList[i]);
  20090. builder.MoveToCell(0, i + 1, 0, 0);
  20091. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  20092. builder.MoveToCell(0, i + 1, 1, 0);
  20093. int sex = DcList[i].Sex;
  20094. string sexStr = string.Empty;
  20095. if (sex == 0) sexStr = "男";
  20096. else if (sex == 1) sexStr = "女";
  20097. else sexStr = "未设置";
  20098. builder.Write(sexStr);
  20099. builder.MoveToCell(0, i + 1, 2, 0);
  20100. string birthDay = DcList[i].BirthDay;
  20101. string birthDayStr = string.Empty;
  20102. if (!string.IsNullOrEmpty(birthDay))
  20103. {
  20104. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  20105. }
  20106. builder.Write(birthDayStr);
  20107. builder.MoveToCell(0, i + 1, 3, 0);
  20108. string company = "";
  20109. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20110. {
  20111. company = DcList[i].CompanyFullName.ToString();
  20112. }
  20113. builder.Write(company);
  20114. builder.MoveToCell(0, i + 1, 4, 0);
  20115. builder.Write(DcList[i].Job);
  20116. }
  20117. }
  20118. else if (_dto.Language == 1)
  20119. {
  20120. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  20121. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  20122. List<string> transArrayStr = new List<string>();
  20123. string transStrRes1 = "";
  20124. for (int i = 0; i < DcList.Count; i++)
  20125. {
  20126. var dc = DcList[i];
  20127. EncryptionProcessor.DecryptProperties(dc);
  20128. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  20129. if (dc.Job.Equals("暂无")) dc.Job = "-";
  20130. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  20131. if (DcList.Count - 1 == i) transStrRes1 += str1;
  20132. else transStrRes1 += $"{str1}|";
  20133. }
  20134. #region AI转英文
  20135. string jsonValue = JsonConvert.SerializeObject(DcList);
  20136. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  20137. List<SeedMessages> messages = new List<SeedMessages>()
  20138. {
  20139. new SeedMessages
  20140. {
  20141. Role = KimiRole.user,
  20142. Content = jsonValue + text
  20143. }
  20144. };
  20145. KiMiApiClient client = new KiMiApiClient();
  20146. var kimiApiResult = await client.SeedMessage(messages);
  20147. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20148. string clients = kimiApiResult_JObject["content"].ToString();
  20149. string startStr = "```json", endStr = "```";
  20150. // 判断并清除开头部分
  20151. if (clients.StartsWith(startStr))
  20152. {
  20153. clients = clients.Remove(0, startStr.Length);
  20154. }
  20155. // 判断并清除结尾部分
  20156. if (clients.EndsWith(endStr))
  20157. {
  20158. clients = clients.Remove(clients.Length - endStr.Length);
  20159. }
  20160. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  20161. //循环赋值
  20162. for (int i = 0; i < en_Json.Count; i++)
  20163. {
  20164. var dc = en_Json[i];
  20165. var dc1 = DcList.Find(x => x.Id == dc.Id);
  20166. string PYName = dc.FirstName + " " + dc.LastName;
  20167. builder.MoveToCell(0, i + 1, 0, 0);
  20168. builder.Write(PYName);
  20169. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  20170. builder.MoveToCell(0, i + 1, 1, 0);
  20171. builder.Write(sex);
  20172. DateTime birthDt;
  20173. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  20174. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20175. builder.MoveToCell(0, i + 1, 2, 0);
  20176. builder.Write(birthday);
  20177. string company = string.Empty, job = string.Empty;
  20178. company = dc.CompanyFullName;
  20179. job = dc.Job;
  20180. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  20181. {
  20182. //查询对照表
  20183. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  20184. if (tempCec != null)
  20185. {
  20186. company = tempCec.enName;
  20187. }
  20188. }
  20189. builder.MoveToCell(0, i + 1, 3, 0);
  20190. builder.Write(company);
  20191. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  20192. {
  20193. //查询对照表
  20194. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  20195. if (tempPec != null)
  20196. {
  20197. job = tempPec.enName;
  20198. }
  20199. }
  20200. builder.MoveToCell(0, i + 1, 4, 0);
  20201. builder.Write(job);
  20202. }
  20203. #endregion
  20204. #region 旧翻译英文处理
  20205. ////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";
  20206. //string transStrRes = "";
  20207. //if (transStrRes1.Length > 0)
  20208. //{
  20209. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  20210. //}
  20211. ////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
  20212. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  20213. ////List<string> transArray = new List<string> { };
  20214. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  20215. //if (transStrRes.Contains("|"))
  20216. //{
  20217. // string[] transArray1 = transStrRes.Split('|');
  20218. // if (transArray1.Length > 0)
  20219. // {
  20220. // foreach (var item in transArray1)
  20221. // {
  20222. // if (item.Contains("&"))
  20223. // {
  20224. // string[] transArray2 = item.Split('&');
  20225. // int index = 0;
  20226. // string companyName = "", job = "";
  20227. // if (transArray2.Length > 0)
  20228. // {
  20229. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  20230. // if (1 < transArray2.Length) companyName = transArray2[1];
  20231. // if (2 < transArray2.Length) job = transArray2[2];
  20232. // }
  20233. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  20234. // }
  20235. // }
  20236. // }
  20237. //}
  20238. ////循环赋值
  20239. //for (int i = 0; i < DcList.Count; i++)
  20240. //{
  20241. // string PYName = "";
  20242. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  20243. // {
  20244. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  20245. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  20246. // PYName = PY_First + " " + PY_Last;
  20247. // }
  20248. // else
  20249. // {
  20250. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  20251. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  20252. // PYName = PY_First + " " + PY_Last;
  20253. // }
  20254. // builder.MoveToCell(0, i + 1, 0, 0);
  20255. // builder.Write(PYName);
  20256. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  20257. // builder.MoveToCell(0, i + 1, 1, 0);
  20258. // builder.Write(sex);
  20259. // DateTime birthDt;
  20260. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  20261. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20262. // builder.MoveToCell(0, i + 1, 2, 0);
  20263. // builder.Write(birthday);
  20264. // string company = string.Empty, job = string.Empty;
  20265. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  20266. // if (dcTransInfo != null)
  20267. // {
  20268. // company = dcTransInfo.CompanyName;
  20269. // job = dcTransInfo.Job;
  20270. // }
  20271. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20272. // {
  20273. // //查询对照表
  20274. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  20275. // if (tempCec != null)
  20276. // {
  20277. // company = tempCec.enName;
  20278. // }
  20279. // //翻译
  20280. // else
  20281. // {
  20282. // }
  20283. // }
  20284. // builder.MoveToCell(0, i + 1, 3, 0);
  20285. // builder.Write(company);
  20286. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  20287. // {
  20288. // //查询对照表
  20289. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  20290. // if (tempPec != null)
  20291. // {
  20292. // job = tempPec.enName;
  20293. // }
  20294. // //翻译
  20295. // else
  20296. // {
  20297. // }
  20298. // }
  20299. // builder.MoveToCell(0, i + 1, 4, 0);
  20300. // builder.Write(job);
  20301. //}
  20302. #endregion
  20303. }
  20304. //删除多余行
  20305. while (tableOne.Rows.Count > DcList.Count + 1)
  20306. {
  20307. tableOne.Rows.RemoveAt(DcList.Count + 1);
  20308. }
  20309. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  20310. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  20311. doc.Save(fileDir);
  20312. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  20313. return Ok(JsonView(true, "操作成功!", Url));
  20314. }
  20315. private class TranslateInfo
  20316. {
  20317. public int Index { get; set; }
  20318. public string CompanyName { get; set; }
  20319. public string Job { get; set; }
  20320. }
  20321. [HttpPost]
  20322. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  20323. {
  20324. if (files.Count == 0)
  20325. {
  20326. return Ok(JsonView(false, "文件为空"));
  20327. }
  20328. KiMiApiClient KiMiApi = new KiMiApiClient();
  20329. var seedConter = await KiMiApi.UploadFilesAsync(files);
  20330. if (seedConter.Count == 0)
  20331. {
  20332. return Ok(JsonView(false, "上传结果为空!"));
  20333. }
  20334. var messages = new List<SeedMessages>
  20335. {
  20336. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  20337. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  20338. };
  20339. messages.InsertRange(1, seedConter);
  20340. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  20341. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20342. string clients = kimiApiResult_JObject["content"].ToString();
  20343. string startStr = "```json", endStr = "```";
  20344. // 判断并清除开头部分
  20345. if (clients.StartsWith(startStr))
  20346. {
  20347. clients = clients.Remove(0, startStr.Length);
  20348. }
  20349. // 判断并清除结尾部分
  20350. if (clients.EndsWith(endStr))
  20351. {
  20352. clients = clients.Remove(clients.Length - endStr.Length);
  20353. }
  20354. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  20355. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  20356. {
  20357. {"姓", "LastName" },
  20358. {"名", "FirstName" },
  20359. {"姓名拼音", "Pinyin" },
  20360. {"性别", "Sex" },
  20361. {"单位", "CompanyFullName" },
  20362. {"职务", "Job" },
  20363. {"出生日期", "Birthday" },
  20364. };
  20365. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  20366. foreach (var item in clients_JObject)
  20367. {
  20368. BaiduClientOCRView cdc = new BaiduClientOCRView();
  20369. foreach (var field in clientFieldMap.Keys)
  20370. {
  20371. if (item.TryGetValue(field, out JToken value))
  20372. {
  20373. var getValue = value.ToString();
  20374. System.Type type = cdc.GetType();
  20375. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  20376. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  20377. propertyInfo.SetValue(cdc, propertyValue);
  20378. }
  20379. }
  20380. crmClients.Add(cdc);
  20381. }
  20382. return Ok(JsonView(new
  20383. {
  20384. fileCount = files.Count,
  20385. UploadCount = seedConter.Count,
  20386. ApiResult = clients,
  20387. CrmClients = crmClients
  20388. }));
  20389. }
  20390. #endregion
  20391. #region 团组倒推表
  20392. /// <summary>
  20393. /// 倒推表基础数据
  20394. /// Init
  20395. /// </summary>
  20396. /// <returns></returns>
  20397. [HttpPost]
  20398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20399. public async Task<IActionResult> PostInvertedListInit()
  20400. {
  20401. var viewData = await _invertedListRep._Init();
  20402. if (viewData.Code != 0)
  20403. {
  20404. return Ok(JsonView(false, viewData.Msg));
  20405. }
  20406. return Ok(JsonView(viewData.Data));
  20407. }
  20408. /// <summary>
  20409. /// 倒推表
  20410. /// Info
  20411. /// </summary>
  20412. /// <param name="dto"></param>
  20413. /// <returns></returns>
  20414. [HttpPost]
  20415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20416. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20417. {
  20418. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20419. if (viewData.Code != 0)
  20420. {
  20421. return Ok(JsonView(false, viewData.Msg));
  20422. }
  20423. return Ok(JsonView(viewData.Data));
  20424. }
  20425. /// <summary>
  20426. /// 倒推表
  20427. /// Create
  20428. /// </summary>
  20429. /// <param name="dto"></param>
  20430. /// <returns></returns>
  20431. [HttpPost]
  20432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20433. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20434. {
  20435. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20436. if (viewData.Code != 0)
  20437. {
  20438. return Ok(JsonView(false, viewData.Msg));
  20439. }
  20440. return Ok(JsonView(viewData.Data));
  20441. }
  20442. /// <summary>
  20443. /// 倒推表
  20444. /// Update
  20445. /// </summary>
  20446. /// <param name="dto"></param>
  20447. /// <returns></returns>
  20448. [HttpPost]
  20449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20450. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20451. {
  20452. var viewData = await _invertedListRep._Update(dto);
  20453. if (viewData.Code != 0)
  20454. {
  20455. return Ok(JsonView(false, viewData.Msg));
  20456. }
  20457. return Ok(JsonView(viewData.Data));
  20458. }
  20459. /// <summary>
  20460. /// 倒推表
  20461. /// File Download
  20462. /// </summary>
  20463. /// <param name="dto"></param>
  20464. /// <returns></returns>
  20465. [HttpPost]
  20466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20467. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20468. {
  20469. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20470. if (info2.Code != 0)
  20471. {
  20472. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20473. }
  20474. var info1 = info2.Data as InvertedListInfoView;
  20475. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20476. string teamName = "";
  20477. if (info != null) teamName = info.TeamName;
  20478. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20479. var doc = new Document();
  20480. var builder = new DocumentBuilder(doc);
  20481. #region old insert
  20482. ////载入模板
  20483. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20484. //Document doc = new Document(tempPath);
  20485. //DocumentBuilder builder = new DocumentBuilder(doc);
  20486. //利用键值对存放数据
  20487. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20488. //dic.Add("TeamName", teamName);
  20489. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20490. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20491. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20492. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20493. //dic.Add("SQRemark", info1.ApprovalRemark);
  20494. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20495. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20496. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20497. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20498. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20499. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20500. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20501. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20502. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20503. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20504. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20505. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20506. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20507. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20508. //#region 填充word模板书签内容
  20509. //foreach (var key in dic.Keys)
  20510. //{
  20511. // builder.MoveToBookmark(key);
  20512. // builder.Write(dic[key]);
  20513. //}
  20514. //#endregion
  20515. #endregion
  20516. #region New Insert
  20517. string titleFont = $"仿宋",
  20518. contentFont = $"仿宋";
  20519. var fontColor = Color.FromArgb(64, 64, 64);
  20520. //设置标题 团组名称
  20521. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20522. builder.Font.Name = titleFont;
  20523. builder.Font.Color = fontColor;
  20524. builder.Font.Size = 12;
  20525. builder.Font.Bold = true;
  20526. builder.Writeln(teamName);
  20527. //设置副标题 团组出访时间
  20528. builder.Font.Size = 12;
  20529. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20530. builder.Writeln();
  20531. var backgroundColor = Color.FromArgb(199, 199, 199);
  20532. var table = builder.StartTable();
  20533. builder.InsertCell();
  20534. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20535. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20536. builder.CellFormat.Borders.LineWidth = 1;
  20537. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20538. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20539. builder.RowFormat.Height = 40;
  20540. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20541. builder.Font.Name = contentFont;
  20542. builder.Font.Size = 12;
  20543. builder.Font.Bold = true;
  20544. builder.Font.Color = fontColor;
  20545. builder.Write("时间");
  20546. builder.InsertCell();
  20547. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20548. builder.Write("流程");
  20549. builder.InsertCell();
  20550. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20551. builder.Write("说明");
  20552. builder.EndRow();
  20553. //报批资料准备
  20554. if (info1.IsSelectedAirportd)
  20555. {
  20556. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20557. }
  20558. //报批/提供送签资料
  20559. if (info1.IsSelectedApprovalData)
  20560. {
  20561. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20562. }
  20563. //出批件护照办理
  20564. if (info1.IsSelectedIssueApproval)
  20565. {
  20566. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20567. }
  20568. //签证资料准备
  20569. if (info1.IsSelectedVisaInfo)
  20570. {
  20571. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20572. }
  20573. //送签
  20574. if (info1.IsSelectedSendVisa)
  20575. {
  20576. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20577. }
  20578. //出签
  20579. if (info1.IsSelectedIssueVisa)
  20580. {
  20581. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20582. }
  20583. //机票
  20584. if (info1.IsSelectedAirTicket)
  20585. {
  20586. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20587. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20588. }
  20589. //酒店
  20590. if (info1.IsSelectedHotel)
  20591. {
  20592. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20593. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20594. }
  20595. //开行前会
  20596. if (info1.IsSelectedPreTripMeeting)
  20597. {
  20598. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20599. }
  20600. //送机
  20601. if (info1.IsSelectedAirportdDropOff)
  20602. {
  20603. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20604. }
  20605. builder.EndTable();
  20606. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20607. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20608. for (int i = 0; i < table.Rows.Count; i++)
  20609. {
  20610. var row = table.Rows[i];
  20611. //设置宽度
  20612. row.Cells[0].CellFormat.Width = 20.00;
  20613. row.Cells[1].CellFormat.Width = 30.00;
  20614. row.Cells[2].CellFormat.Width = 50.00;
  20615. if (i != 0)
  20616. {
  20617. //边框设置
  20618. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20619. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20620. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20621. }
  20622. }
  20623. #region 页脚插入图片
  20624. // 创建页脚
  20625. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20626. doc.FirstSection.HeadersFooters.Add(footer);
  20627. Paragraph para = new Paragraph(doc);
  20628. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20629. footer.AppendChild(para);
  20630. builder.MoveTo(para);
  20631. string imagePath = "./Images/FMGJ_Log.png";
  20632. builder.InsertImage(imagePath);
  20633. #endregion
  20634. #endregion
  20635. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20636. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20637. string filePath = fileDir + $@"InvertedList/{fileName}";
  20638. doc.Save(filePath);
  20639. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20640. return Ok(JsonView(true, "操作成功!", Url));
  20641. }
  20642. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20643. {
  20644. var fontColor = Color.FromArgb(64, 64, 64);
  20645. builder.InsertCell();
  20646. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20647. builder.RowFormat.Height = 40;
  20648. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20649. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20650. builder.Font.Name = fontName;
  20651. builder.Font.Size = 8;
  20652. builder.Font.Bold = true;
  20653. builder.Font.Color = fontColor;
  20654. builder.Write(dateTime);
  20655. builder.InsertCell();
  20656. builder.Font.Size = 9;
  20657. builder.Font.Bold = true;
  20658. builder.Font.Color = fontColor;
  20659. builder.Write(content);
  20660. builder.InsertCell();
  20661. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20662. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20663. builder.Font.Size = 9;
  20664. builder.Font.Bold = false;
  20665. builder.Font.Color = fontColor;
  20666. builder.Write(reamrk);
  20667. builder.EndRow();
  20668. }
  20669. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20670. {
  20671. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20672. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20673. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20674. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20675. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20676. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20677. }
  20678. #endregion
  20679. #region 会务倒推表
  20680. /// <summary>
  20681. /// 会务倒推表
  20682. /// Init
  20683. /// </summary>
  20684. /// <returns></returns>
  20685. [HttpPost]
  20686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20687. public async Task<IActionResult> InforRetrogressTableInit()
  20688. {
  20689. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20690. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20691. return Ok(JsonView(false, groupData.Msg));
  20692. }
  20693. /// <summary>
  20694. /// 会务倒推表
  20695. /// ExcelDownload
  20696. /// </summary>
  20697. /// <param name="dto"></param>
  20698. /// <returns></returns>
  20699. [HttpPost]
  20700. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20702. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20703. {
  20704. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20705. var validatorRes = await validator.ValidateAsync(dto);
  20706. if (!validatorRes.IsValid)
  20707. {
  20708. StringBuilder sb = new StringBuilder();
  20709. foreach (var item in validatorRes.Errors)
  20710. {
  20711. sb.AppendLine(item.ErrorMessage);
  20712. }
  20713. return Ok(JsonView(false, sb.ToString()));
  20714. }
  20715. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20716. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20717. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20718. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20719. #region Excel
  20720. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20721. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20722. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20723. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20724. var fileNamePrefix = string.Empty;
  20725. if (days >= 30)
  20726. {
  20727. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20728. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20729. }
  20730. else if (days < 30 && days > 7)
  20731. {
  20732. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20733. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20734. }
  20735. else if (days <= 7)
  20736. {
  20737. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20738. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20739. }
  20740. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20741. fileName = CommonFun.ValidFileName(fileName);
  20742. //载入模板
  20743. WorkbookDesigner designer = new WorkbookDesigner();
  20744. designer.Workbook = new Workbook(tempPath);
  20745. designer.Process();
  20746. if (!Directory.Exists(savePath))
  20747. {
  20748. Directory.CreateDirectory(savePath);
  20749. }
  20750. string serverPath = $"{savePath}{fileName}";
  20751. designer.Workbook.Save(serverPath);
  20752. string rst = $"{servicePath}{ftpPath}{fileName}";
  20753. #endregion
  20754. return Ok(JsonView(new { url = rst }));
  20755. }
  20756. #endregion
  20757. #region 三公签证费用(签证费、代办费)
  20758. /// <summary>
  20759. /// 三公签证费用(签证费、代办费)
  20760. /// List
  20761. /// </summary>
  20762. /// <returns></returns>
  20763. [HttpPost]
  20764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20765. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20766. {
  20767. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  20768. }
  20769. /// <summary>
  20770. /// 三公签证费用(签证费、代办费)
  20771. /// Add Or Update
  20772. /// </summary>
  20773. /// <returns></returns>
  20774. [HttpPost]
  20775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20776. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20777. {
  20778. var _view = await _visaFeeInfoRep.Update(_dto);
  20779. if (_view.Code != 0)
  20780. {
  20781. return Ok(JsonView(false, _view.Msg));
  20782. }
  20783. return Ok(JsonView(true, _view.Msg));
  20784. }
  20785. #endregion
  20786. #region 酒店询价
  20787. /// <summary>
  20788. /// 酒店询价
  20789. /// Init
  20790. /// </summary>
  20791. /// <returns></returns>
  20792. [HttpPost]
  20793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20794. public async Task<IActionResult> PostHotelInquiryInit()
  20795. {
  20796. var res = await _hotelInquiryRep._Init();
  20797. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20798. return Ok(JsonView(true, res.Msg, res.Data));
  20799. }
  20800. /// <summary>
  20801. /// 酒店询价
  20802. /// page Item
  20803. /// </summary>
  20804. /// <param name="_dto"></param>
  20805. /// <returns></returns>
  20806. [HttpPost]
  20807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20808. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20809. {
  20810. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20811. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20812. var view = res.Data as PageDataViewBase;
  20813. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20814. }
  20815. /// <summary>
  20816. /// 酒店询价
  20817. /// info
  20818. /// </summary>
  20819. /// <param name="_dto"></param>
  20820. /// <returns></returns>
  20821. [HttpPost]
  20822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20823. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20824. {
  20825. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20826. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20827. return Ok(JsonView(true, res.Msg, res.Data));
  20828. }
  20829. /// <summary>
  20830. /// 酒店询价
  20831. /// Add Or Edit
  20832. /// </summary>
  20833. /// <param name="_dto"></param>
  20834. /// <returns></returns>
  20835. [HttpPost]
  20836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20837. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20838. {
  20839. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20840. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20841. return Ok(JsonView(true, res.Msg, res.Data));
  20842. }
  20843. /// <summary>
  20844. /// 酒店询价
  20845. /// Del
  20846. /// </summary>
  20847. /// <param name="_dto"></param>
  20848. /// <returns></returns>
  20849. [HttpPost]
  20850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20851. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20852. {
  20853. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20854. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20855. return Ok(JsonView(true, res.Msg, res.Data));
  20856. }
  20857. #endregion
  20858. #region 下载匹配op行程单
  20859. /// <summary>
  20860. /// 匹配op行程单
  20861. /// Init
  20862. /// </summary>
  20863. /// <param name="dto">团组列表请求dto</param>
  20864. /// <returns></returns>
  20865. [HttpPost]
  20866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20867. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20868. {
  20869. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20870. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20871. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20872. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20873. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20874. .Where(it => it.IsDel == 0)
  20875. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20876. .OrderByDescending(it => it.VisitStartDate)
  20877. .ToList();
  20878. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20879. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20880. var diids = groupInfos.Select(it => it.Id).ToList();
  20881. List<string> countrys = new List<string>();
  20882. foreach (var item in country)
  20883. {
  20884. var data = _groupRepository.FormartTeamName(item);
  20885. var dataArray = _groupRepository.GroupSplitCountry(data);
  20886. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20887. }
  20888. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20889. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20890. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20891. foreach (var item in areaItem)
  20892. {
  20893. string areaStr = item.Value;
  20894. if (!string.IsNullOrEmpty(areaStr))
  20895. {
  20896. string[] str1 = areaStr.Split("-");
  20897. if (str1.Length > 0)
  20898. {
  20899. areaArray.AddRange(str1);
  20900. }
  20901. }
  20902. }
  20903. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20904. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20905. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20906. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20907. .ToList();
  20908. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20909. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20910. .Where(it => countriesIds.Contains(it.Id))
  20911. .Select(it => new { it.Id, Name = it.Name_CN })
  20912. .ToList();
  20913. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20914. .Select(it => it.TeamName).ToList();
  20915. stopwatch.Stop();
  20916. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20917. }
  20918. ///// <summary>
  20919. ///// 匹配op行程单
  20920. ///// Init 查询区域数据
  20921. ///// </summary>
  20922. ///// <param name="dto">团组列表请求dto</param>
  20923. ///// <returns></returns>
  20924. //[HttpPost]
  20925. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20926. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20927. //{
  20928. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20929. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20930. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20931. // if (string.IsNullOrEmpty(countriesDataStr))
  20932. // {
  20933. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20934. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20935. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20936. // }
  20937. // else
  20938. // {
  20939. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20940. // }
  20941. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20942. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20943. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20944. // List<dynamic> childList = new List<dynamic>();
  20945. // int parentId = dto.CountriesId;
  20946. // if (provinceData.Count > 1)
  20947. // {
  20948. // foreach (var item1 in provinceData)
  20949. // {
  20950. // List<dynamic> childList1 = new List<dynamic>();
  20951. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20952. // foreach (var item2 in citiesData1)
  20953. // {
  20954. // List<dynamic> childList2 = new List<dynamic>();
  20955. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20956. // foreach (var item3 in countiesData1)
  20957. // {
  20958. // childList2.Add(new
  20959. // {
  20960. // id = item3.Id,
  20961. // parentId = item2.Id,
  20962. // level = "district",
  20963. // name = item3.Name_CN,
  20964. // });
  20965. // }
  20966. // childList1.Add(new
  20967. // {
  20968. // id = item2.Id,
  20969. // parentId = item1.Id,
  20970. // level = "city",
  20971. // name = item2.Name_CN,
  20972. // childList = childList2
  20973. // });
  20974. // }
  20975. // childList.Add(new
  20976. // {
  20977. // id = item1.Id,
  20978. // parentId = parentId,
  20979. // level = "province",
  20980. // name = item1.Name_CN,
  20981. // childList = childList1
  20982. // });
  20983. // }
  20984. // //城市
  20985. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20986. // foreach (var item2 in citiesData2)
  20987. // {
  20988. // List<dynamic> childList22 = new List<dynamic>();
  20989. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20990. // foreach (var item3 in countiesData1)
  20991. // {
  20992. // childList22.Add(new
  20993. // {
  20994. // id = item3.Id,
  20995. // parentId = item2.Id,
  20996. // level = "district",
  20997. // name = item3.Name_CN,
  20998. // });
  20999. // }
  21000. // childList.Add(new
  21001. // {
  21002. // id = item2.Id,
  21003. // parentId = parentId,
  21004. // level = "city",
  21005. // name = item2.Name_CN,
  21006. // childList = childList22
  21007. // });
  21008. // }
  21009. // }
  21010. // else
  21011. // {
  21012. // foreach (var item2 in citiesData)
  21013. // {
  21014. // string cname = item2.Name_CN;
  21015. // List<dynamic> childList1 = new List<dynamic>();
  21016. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21017. // foreach (var item3 in countiesData1)
  21018. // {
  21019. // childList1.Add(new
  21020. // {
  21021. // Id = item3.Id,
  21022. // parentId = item2.Id,
  21023. // level = "district",
  21024. // name = item3.Name_CN
  21025. // });
  21026. // }
  21027. // childList.Add(new
  21028. // {
  21029. // id = item2.Id,
  21030. // parentId = parentId,
  21031. // level = "city",
  21032. // name = item2.Name_CN,
  21033. // childList = childList1
  21034. // });
  21035. // }
  21036. // }
  21037. // stopwatch.Stop();
  21038. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21039. //}
  21040. /// <summary>
  21041. /// 匹配op行程单
  21042. /// 接团信息列表 Page
  21043. /// </summary>
  21044. /// <param name="dto">团组列表请求dto</param>
  21045. /// <returns></returns>
  21046. [HttpPost]
  21047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21048. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21049. {
  21050. var swatch = new Stopwatch();
  21051. swatch.Start();
  21052. #region 参数验证
  21053. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21054. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21055. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21056. #region 页面操作权限验证
  21057. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21058. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21059. #endregion
  21060. #endregion
  21061. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21062. {
  21063. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21064. //string sqlWhere = "";
  21065. if (!string.IsNullOrEmpty(dto.Country))
  21066. {
  21067. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  21068. }
  21069. if (!string.IsNullOrEmpty(dto.Area))
  21070. {
  21071. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  21072. }
  21073. if (!string.IsNullOrEmpty(dto.TeamName))
  21074. {
  21075. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  21076. }
  21077. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  21078. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  21079. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  21080. swatch.Stop();
  21081. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  21082. }
  21083. else
  21084. {
  21085. return Ok(JsonView(false, "查询失败"));
  21086. }
  21087. }
  21088. /// <summary>
  21089. /// 匹配op行程单
  21090. /// 行程单下载
  21091. /// </summary>
  21092. /// <param name="dto">团组列表请求dto</param>
  21093. /// <returns></returns>
  21094. [HttpPost]
  21095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21096. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  21097. {
  21098. #region 参数验证
  21099. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21100. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21101. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21102. #region 页面操作权限验证
  21103. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21104. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  21105. #endregion
  21106. #endregion
  21107. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21108. {
  21109. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  21110. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  21111. }
  21112. else
  21113. {
  21114. return Ok(JsonView(false, "下载失败!"));
  21115. }
  21116. }
  21117. #endregion
  21118. #region 国家信息 数据 注释
  21119. //[HttpPost]
  21120. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  21121. //{
  21122. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  21123. // foreach (var item in dto)
  21124. // {
  21125. // infos.Add(new Grp_GroupsTaskAssignment()
  21126. // {
  21127. // DIId = item,
  21128. // CTId = 82,
  21129. // UId = 248,
  21130. // IsEnable = 1,
  21131. // CreateUserId = 233,
  21132. // CreateTime = DateTime.Now,
  21133. // IsDel = 0
  21134. // });
  21135. // infos.Add(new Grp_GroupsTaskAssignment()
  21136. // {
  21137. // DIId = item,
  21138. // CTId = 82,
  21139. // UId = 286,
  21140. // IsEnable = 1,
  21141. // CreateUserId = 233,
  21142. // CreateTime = DateTime.Now,
  21143. // IsDel = 0
  21144. // });
  21145. // }
  21146. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  21147. // return Ok("操作成功");
  21148. //}
  21149. //public class paramJsonDto
  21150. //{
  21151. // public List<CountriesInfo> str { get; set; }
  21152. //}
  21153. //[HttpPost]
  21154. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  21155. //{
  21156. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  21157. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  21158. // List<Sys_Cities> cities = new List<Sys_Cities>();
  21159. // List<Sys_Cities> districts = new List<Sys_Cities>();
  21160. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21161. // _sqlSugar.BeginTran();
  21162. // int countitiesIndex = 0;
  21163. // foreach (var item in dto.str)
  21164. // {
  21165. // dynamic data = item.c;
  21166. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  21167. // if (data != null)
  21168. // {
  21169. // countitiesIndex++;
  21170. // foreach (var item1 in data)
  21171. // {
  21172. // string cnname = item1.cn;
  21173. // string enname = item1.en;
  21174. // Sys_Cities provinceInfo = new Sys_Cities()
  21175. // {
  21176. // CountriesId = countriesId,
  21177. // Name_CN = cnname,
  21178. // Name_EN = enname,
  21179. // ParentId = 0,
  21180. // IsCapital = 1,
  21181. // CreateUserId = 208,
  21182. // CreateTime = DateTime.Now,
  21183. // IsDel = 0
  21184. // };
  21185. // if (item1.lv == "province") //省份
  21186. // {
  21187. // provinceInfo.Level = 1;
  21188. // int provinceId = 0;
  21189. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  21190. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  21191. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21192. // var data1 = item1.c;
  21193. // foreach (var item2 in data1)
  21194. // {
  21195. // if (item2.lv == "city")
  21196. // {
  21197. // string citycnname = item2.cn;
  21198. // string cityenname = item2.en;
  21199. // Sys_Cities cityInfo = new Sys_Cities()
  21200. // {
  21201. // CountriesId = countriesId,
  21202. // ParentId = provinceId,
  21203. // Level = 2,
  21204. // Name_CN = citycnname,
  21205. // Name_EN = cityenname,
  21206. // IsCapital = 1,
  21207. // CreateUserId = 208,
  21208. // CreateTime = DateTime.Now,
  21209. // IsDel = 0
  21210. // };
  21211. // if (item2.c != null)
  21212. // {
  21213. // int cityId = 0;
  21214. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  21215. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21216. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  21217. // foreach (var item3 in item2.c)
  21218. // {
  21219. // if (item3.lv == "district")
  21220. // {
  21221. // var districtInfo = new Sys_Cities()
  21222. // {
  21223. // CountriesId = countriesId,
  21224. // Name_CN = item3.cn,
  21225. // Name_EN = item3.en,
  21226. // Level = 3,
  21227. // ParentId = cityId,
  21228. // IsCapital = 1,
  21229. // CreateUserId = 208,
  21230. // CreateTime = DateTime.Now,
  21231. // IsDel = 0
  21232. // };
  21233. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21234. // //{
  21235. // districts.Add(districtInfo);
  21236. // //}
  21237. // }
  21238. // }
  21239. // }
  21240. // else
  21241. // {
  21242. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  21243. // //{
  21244. // cities.Add(cityInfo);
  21245. // //}
  21246. // }
  21247. // }
  21248. // }
  21249. // }
  21250. // else if (item1.lv == "city")//城市
  21251. // {
  21252. // provinceInfo.Level = 2;
  21253. // if (item1.c != null)
  21254. // {
  21255. // int cityId = 0;
  21256. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  21257. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21258. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21259. // foreach (var item3 in item1.c)
  21260. // {
  21261. // if (item3.lv == "district")
  21262. // {
  21263. // var districtInfo = new Sys_Cities()
  21264. // {
  21265. // CountriesId = countriesId,
  21266. // Name_CN = item3.cn,
  21267. // Name_EN = item3.en,
  21268. // Level = 3,
  21269. // ParentId = cityId,
  21270. // IsCapital = 1,
  21271. // CreateUserId = 208,
  21272. // CreateTime = DateTime.Now,
  21273. // IsDel = 0
  21274. // };
  21275. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21276. // //{
  21277. // districts.Add(districtInfo);
  21278. // //}
  21279. // }
  21280. // }
  21281. // }
  21282. // else
  21283. // {
  21284. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  21285. // //{
  21286. // cities.Add(provinceInfo);
  21287. // //}
  21288. // }
  21289. // }
  21290. // }
  21291. // }
  21292. // }
  21293. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  21294. // cities = cities.Distinct().ToList();
  21295. // districts = districts.Distinct().ToList();
  21296. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  21297. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  21298. // cities.AddRange(districts);
  21299. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  21300. // //_sqlSugar.RollbackTran();
  21301. // _sqlSugar.CommitTran();
  21302. // return Ok(JsonView(false, "操作成功!"));
  21303. //}
  21304. //[HttpPost]
  21305. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  21306. //{
  21307. // List<CountitiesInfo> infos = dto.MyProperty;
  21308. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  21309. // _sqlSugar.BeginTran();
  21310. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21311. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  21312. // foreach (var item in infos)
  21313. // {
  21314. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  21315. // if (countryInfo != null)
  21316. // {
  21317. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  21318. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  21319. // if (cityInfo1 != null)
  21320. // {
  21321. // cityInfo1.IsCapital = 0;
  21322. // cityInfos.Add(cityInfo1);
  21323. // }
  21324. // }
  21325. // }
  21326. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  21327. // .UpdateColumns(it => it.IsCapital)
  21328. // .WhereColumns(it => it.Id)
  21329. // .ExecuteCommand();
  21330. // //_sqlSugar.RollbackTran();
  21331. // _sqlSugar.CommitTran();
  21332. // return Ok(JsonView(false, "操作成功!"));
  21333. //}
  21334. //public class CounrtiesDto
  21335. //{
  21336. // public List<CountitiesInfo> MyProperty { get; set; }
  21337. //}
  21338. //public class CountitiesInfo
  21339. //{
  21340. // /// <summary>
  21341. // /// 圣约翰
  21342. // /// </summary>
  21343. // public string capital_name_chinese { get; set; }
  21344. // /// <summary>
  21345. // ///
  21346. // /// </summary>
  21347. // public string capital_name { get; set; }
  21348. // /// <summary>
  21349. // ///
  21350. // /// </summary>
  21351. // public string country_type { get; set; }
  21352. // /// <summary>
  21353. // /// 安提瓜和巴布达
  21354. // /// </summary>
  21355. // public string country_name_chinese { get; set; }
  21356. // /// <summary>
  21357. // /// 安提瓜和巴布达
  21358. // /// </summary>
  21359. // public string country_name_chinese_short { get; set; }
  21360. // /// <summary>
  21361. // /// 安提瓜和巴布达
  21362. // /// </summary>
  21363. // public string country_name_chinese_UN { get; set; }
  21364. // /// <summary>
  21365. // ///
  21366. // /// </summary>
  21367. // public string country_name_english_abbreviation { get; set; }
  21368. // /// <summary>
  21369. // ///
  21370. // /// </summary>
  21371. // public string country_name_english_formal { get; set; }
  21372. // /// <summary>
  21373. // ///
  21374. // /// </summary>
  21375. // public string country_name_english_UN { get; set; }
  21376. // /// <summary>
  21377. // ///
  21378. // /// </summary>
  21379. // public string continent_name { get; set; }
  21380. // /// <summary>
  21381. // ///
  21382. // /// </summary>
  21383. // public string subregion_name { get; set; }
  21384. // /// <summary>
  21385. // ///
  21386. // /// </summary>
  21387. // public string country_code2 { get; set; }
  21388. // /// <summary>
  21389. // ///
  21390. // /// </summary>
  21391. // public string country_code3 { get; set; }
  21392. // /// <summary>
  21393. // ///
  21394. // /// </summary>
  21395. // public string phone_code { get; set; }
  21396. //}
  21397. //public class CountriesInfo : BasicInfo
  21398. //{
  21399. // public List<CitiesInfo> c { get; set; }
  21400. //}
  21401. //public class CitiesInfo : BasicInfo
  21402. //{
  21403. // public List<AreaInfo> c { get; set; }
  21404. //}
  21405. //public class AreaInfo : BasicInfo
  21406. //{
  21407. // public List<AreaInfo> c { get; set; }
  21408. //}
  21409. //public class BasicInfo
  21410. //{
  21411. // public string code { get; set; }
  21412. // public string cn { get; set; }
  21413. // public string lv { get; set; }
  21414. // public string en { get; set; }
  21415. //}
  21416. #endregion
  21417. #region 查看邀请方
  21418. /// <summary>
  21419. /// 查看邀请方
  21420. /// 邀请方信息 Init
  21421. /// </summary>
  21422. /// <param name="dto"></param>
  21423. /// <returns></returns>
  21424. [HttpPost]
  21425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21426. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21427. {
  21428. string sqlWhere = string.Empty;
  21429. if (!string.IsNullOrEmpty(dto.Search))
  21430. {
  21431. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21432. }
  21433. string sql = string.Format($@"Select
  21434. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21435. Id,
  21436. UnitName
  21437. From Res_InvitationOfficialActivityData
  21438. Where IsDel = 0
  21439. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21440. RefAsync<int> total = 0;
  21441. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21442. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21443. }
  21444. /// <summary>
  21445. /// 查看邀请方
  21446. /// 国家信息 Init
  21447. /// </summary>
  21448. /// <param name="dto"></param>
  21449. /// <returns></returns>
  21450. [HttpPost]
  21451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21452. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21453. {
  21454. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21455. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21456. var diids = groupInfos.Select(it => it.Id).ToList();
  21457. List<string> countrys = new List<string>();
  21458. foreach (var item in country)
  21459. {
  21460. var data = _groupRepository.FormartTeamName(item);
  21461. var dataArray = _groupRepository.GroupSplitCountry(data);
  21462. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21463. }
  21464. countrys = countrys.Distinct().ToList();
  21465. for (int i = 0; i < countrys.Count; i++)
  21466. {
  21467. string item = countrys[i];
  21468. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21469. {
  21470. countrys.Remove(item);
  21471. i--;
  21472. }
  21473. }
  21474. RefAsync<int> total = 0;
  21475. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21476. .Where(it => countrys.Contains(it.Name_CN))
  21477. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21478. .Select(it => new { id = it.Id, name = it.Name_CN })
  21479. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21480. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21481. }
  21482. /// <summary>
  21483. /// 查看邀请方
  21484. /// 城市信息 Init
  21485. /// </summary>
  21486. /// <param name="dto"></param>
  21487. /// <returns></returns>
  21488. [HttpPost]
  21489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21490. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21491. {
  21492. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21493. RefAsync<int> total = 0;
  21494. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21495. .Where(it => it.CountriesId == dto.CountiesId)
  21496. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21497. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21498. .Select(it => new { id = it.Id, name = it.Name_CN })
  21499. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21500. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21501. }
  21502. /// <summary>
  21503. /// 查看邀请方
  21504. /// 团组名称 Init
  21505. /// </summary>
  21506. /// <param name="dto"></param>
  21507. /// <returns></returns>
  21508. [HttpPost]
  21509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21510. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21511. {
  21512. var watch = new Stopwatch();
  21513. watch.Start();
  21514. RefAsync<int> total = 0;
  21515. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21516. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21517. .Where((oa, di) => oa.IsDel == 0)
  21518. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21519. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21520. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21521. .Distinct()
  21522. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21523. watch.Stop();
  21524. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21525. }
  21526. /// <summary>
  21527. /// 查看邀请方
  21528. /// 团组 & 邀请方信息
  21529. /// </summary>
  21530. /// <param name="dto"></param>
  21531. /// <returns></returns>
  21532. [HttpPost]
  21533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21534. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21535. {
  21536. var watch = new Stopwatch();
  21537. watch.Start();
  21538. RefAsync<int> total = 0;
  21539. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21540. .AS("Grp_DelegationInfo")
  21541. .Includes(x => x.InvitingInfos)
  21542. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21543. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21544. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21545. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21546. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21547. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21548. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21549. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21550. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21551. infos.ForEach(x =>
  21552. {
  21553. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21554. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21555. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21556. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21557. });
  21558. watch.Stop();
  21559. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21560. }
  21561. #endregion
  21562. #region 报批行程
  21563. /// <summary>
  21564. /// 报批行程初始化
  21565. /// </summary>
  21566. /// <param name="dto"></param>
  21567. /// <returns></returns>
  21568. [HttpPost]
  21569. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21570. {
  21571. const int chiNumber = 5;
  21572. var jw = JsonView(false);
  21573. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21574. var group = groupList.First();
  21575. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21576. group = groupList.First(x => x.Id == diid);
  21577. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21578. .Where(x => x.DiId == diid && x.IsDel == 0)
  21579. .ToArray();
  21580. var count = 1;
  21581. foreach (var item in blackCodeList)
  21582. {
  21583. if (string.IsNullOrWhiteSpace(item.Title))
  21584. {
  21585. item.Title = "未设置名称数据" + count;
  21586. }
  21587. count++;
  21588. }
  21589. ;
  21590. if (group == null)
  21591. {
  21592. jw.Msg = "暂无团组!";
  21593. return Ok(jw);
  21594. }
  21595. var data = new
  21596. {
  21597. groupList = groupList.Select(x => new
  21598. {
  21599. x.TeamName,
  21600. x.Id
  21601. }),
  21602. content = new ArrayList(),
  21603. groupInfo = new
  21604. {
  21605. group.VisitDays,
  21606. group.TourCode,
  21607. group.VisitPNumber,
  21608. group.TeamName,
  21609. group.Id,
  21610. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21611. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21612. group.ClientUnit
  21613. },
  21614. blackCodeList = blackCodeList.Select(x => new
  21615. {
  21616. x.Title,
  21617. x.Id
  21618. }),
  21619. FileTempList = new ArrayList()
  21620. {
  21621. new { Index = 1,FileName = "旧模板" },
  21622. new { Index = 2,FileName = "省外办" },
  21623. new { Index = 3,FileName = "市外办" },
  21624. }
  21625. };
  21626. var resultArr = new ArrayList();
  21627. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21628. #region 默认不生成行程
  21629. //if (content.Count == 0)
  21630. //{
  21631. // var stay = "-";
  21632. // var cityPath = "-";
  21633. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21634. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21635. // .ToList();
  21636. // //添加城市路径以及住宿地
  21637. // //黑屏代码数据
  21638. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21639. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21640. // {
  21641. // jw = JsonView(true, "黑屏代码有误!", data);
  21642. // return Ok(jw);
  21643. // }
  21644. // data = data with
  21645. // {
  21646. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21647. // {
  21648. // x.Title,
  21649. // x.Id,
  21650. // }).ToArray())
  21651. // };
  21652. // foreach (DataRow row in dtBlack.Rows)
  21653. // {
  21654. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21655. // {
  21656. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21657. // return Ok(jw);
  21658. // }
  21659. // }
  21660. // //黑屏代码获取时间区间
  21661. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21662. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21663. // _sqlSugar.BeginTran();
  21664. // for (int i = 0; i < timeArr.Count; i++)
  21665. // {
  21666. // stay = "-";
  21667. // cityPath = "-";
  21668. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21669. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21670. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21671. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21672. // if (tbSelect.Length > 0)
  21673. // {
  21674. // List<string> threeCodeStr = new List<string>();
  21675. // foreach (var item in tbSelect)
  21676. // {
  21677. // var threeCode = item["Three"].ToString() ?? "";
  21678. // if (threeCode.Length == 6)
  21679. // {
  21680. // var start = threeCode.Substring(0, 3);
  21681. // var end = threeCode.Substring(3, 3);
  21682. // if (threeCodeStr.Count == 0)
  21683. // {
  21684. // threeCodeStr.Add(start);
  21685. // threeCodeStr.Add(end);
  21686. // }
  21687. // else
  21688. // {
  21689. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21690. // {
  21691. // threeCodeStr.Add(end);
  21692. // }
  21693. // else
  21694. // {
  21695. // threeCodeStr.Add(start);
  21696. // threeCodeStr.Add(end);
  21697. // }
  21698. // }
  21699. // }
  21700. // }
  21701. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21702. // var last = threeCodeStr.Last();
  21703. // foreach (var item in threeCodeStr)
  21704. // {
  21705. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21706. // if (item.Equals(last))
  21707. // {
  21708. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21709. // }
  21710. // }
  21711. // cityPath = cityPath.Trim('-');
  21712. // }
  21713. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21714. // appro.Diid = diid ?? -1;
  21715. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21716. // appro.Id = thisId;
  21717. // appro.CreateUserId = dto.UserId;
  21718. // appro.CreateTime = DateTime.Now;
  21719. // content.Add(appro);
  21720. // }
  21721. // _sqlSugar.CommitTran();
  21722. //}
  21723. #endregion
  21724. foreach (var x in content)
  21725. {
  21726. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21727. if (chiList.Count < chiNumber)
  21728. {
  21729. for (int i = chiList.Count; i < chiNumber; i++)
  21730. {
  21731. chiList.Add(new Grp_ApprovalTravelDetails());
  21732. }
  21733. }
  21734. resultArr.Add(new
  21735. {
  21736. x.Id,
  21737. x.Date,
  21738. x.Diid,
  21739. chiList = chiList.Select(x1 => new
  21740. {
  21741. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21742. x1.Details,
  21743. x1.ParentId,
  21744. x1.Id
  21745. })
  21746. });
  21747. }
  21748. data = data with
  21749. {
  21750. content = resultArr,
  21751. };
  21752. jw = JsonView(true, "获取成功!", data);
  21753. return Ok(jw);
  21754. }
  21755. /// <summary>
  21756. /// 报批行程删除
  21757. /// </summary>
  21758. /// <param name="dto"></param>
  21759. /// <returns></returns>
  21760. [HttpPost]
  21761. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21762. {
  21763. var jw = JsonView(false);
  21764. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21765. if (group == null)
  21766. {
  21767. jw.Msg = "团组参数有误!";
  21768. return Ok(jw);
  21769. }
  21770. try
  21771. {
  21772. _sqlSugar.BeginTran();
  21773. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21774. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21775. {
  21776. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21777. DeleteUserId = dto.uesrId,
  21778. IsDel = 1
  21779. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21780. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21781. {
  21782. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21783. DeleteUserId = dto.uesrId,
  21784. IsDel = 1
  21785. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21786. _sqlSugar.CommitTran();
  21787. jw = JsonView(true, "删除成功");
  21788. }
  21789. catch (Exception ex)
  21790. {
  21791. jw = JsonView(false, ex.Message);
  21792. }
  21793. return Ok(jw);
  21794. }
  21795. /// <summary>
  21796. /// 报批行程保存
  21797. /// </summary>
  21798. /// <param name="dto"></param>
  21799. /// <returns></returns>
  21800. [HttpPost]
  21801. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21802. {
  21803. var jw = JsonView(false);
  21804. var Find = dto.Arr.Find(x => x.id == 0);
  21805. if (Find != null)
  21806. {
  21807. jw.Msg = "生成的ID为0!";
  21808. return Ok(jw);
  21809. }
  21810. foreach (var item in dto.Arr)
  21811. {
  21812. foreach (var chi in item.chiList)
  21813. {
  21814. if (chi.parentId == 0)
  21815. {
  21816. chi.parentId = item.id;
  21817. }
  21818. }
  21819. }
  21820. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21821. _sqlSugar.BeginTran();
  21822. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21823. {
  21824. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21825. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21826. {
  21827. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21828. DeleteUserId = dto.UserId,
  21829. IsDel = 1
  21830. }).ExecuteCommand();
  21831. }
  21832. try
  21833. {
  21834. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21835. {
  21836. CreateTime = DateTime.Now,
  21837. CreateUserId = dto.UserId,
  21838. Details = x.details,
  21839. ParentId = x.parentId,
  21840. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21841. Remark = "",
  21842. IsDel = 0
  21843. }).ToList()).ExecuteCommand();
  21844. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21845. {
  21846. Id = x.id,
  21847. Details = x.details,
  21848. ParentId = x.parentId,
  21849. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21850. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21851. {
  21852. Details = x.Details,
  21853. ParentId = x.ParentId,
  21854. Time = x.Time
  21855. }).ExecuteCommand();
  21856. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21857. {
  21858. Id = x.id,
  21859. Date = x.date,
  21860. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21861. {
  21862. Date = x.Date
  21863. }).ExecuteCommand();
  21864. _sqlSugar.CommitTran();
  21865. jw = JsonView(true, "保存成功!");
  21866. }
  21867. catch (Exception ex)
  21868. {
  21869. _sqlSugar.RollbackTran();
  21870. jw = JsonView(false, "保存失败!" + ex.Message);
  21871. }
  21872. return Ok(jw);
  21873. }
  21874. /// <summary>
  21875. /// 报批行程生成
  21876. /// </summary>
  21877. /// <param name="dto"></param>
  21878. /// <returns></returns>
  21879. [HttpPost]
  21880. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21881. {
  21882. var jw = JsonView(false);
  21883. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21884. if (group == null)
  21885. {
  21886. jw.Msg = "暂无该团组!";
  21887. return Ok(jw);
  21888. }
  21889. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21890. //黑屏代码数据
  21891. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21892. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21893. {
  21894. jw.Msg = "黑屏代码有误!";
  21895. return Ok(jw);
  21896. }
  21897. foreach (DataRow row in dtBlack.Rows)
  21898. {
  21899. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21900. {
  21901. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21902. return Ok(jw);
  21903. }
  21904. }
  21905. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21906. var resultArr = new ArrayList();
  21907. //if (officialActivitiesArr.Count == 0)
  21908. //{
  21909. // jw.Msg = "暂无公务出访信息!";
  21910. // return Ok(jw);
  21911. //}
  21912. try
  21913. {
  21914. _sqlSugar.BeginTran();
  21915. DeleteApprovalJourney(new
  21916. Domain.Dtos.Groups.DeleteApprovalJourney
  21917. {
  21918. Diid = dto.Diid,
  21919. uesrId = dto.Userid
  21920. });
  21921. var stay = "-";
  21922. var cityPath = "-";
  21923. var arriveCountry = string.Empty;
  21924. //添加城市路径以及住宿地
  21925. //黑屏代码获取时间区间
  21926. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21927. var empty = "【未收入该三字码!请机票同事录入】";
  21928. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21929. #region 配置公务活动时间
  21930. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21931. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21932. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21933. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21934. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21935. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21936. {
  21937. 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" }),
  21938. 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"}),
  21939. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21940. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21941. };
  21942. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21943. {
  21944. 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" }),
  21945. 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"}),
  21946. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21947. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21948. };
  21949. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21950. {
  21951. 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" }),
  21952. 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"}),
  21953. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21954. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21955. };
  21956. #endregion
  21957. var nextDayNum = 0;
  21958. for (int i = 0; i < timeArr.Count; i++)
  21959. {
  21960. stay = "-";
  21961. cityPath = "-";
  21962. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21963. DateTime NewData = DateTime.Parse(timeArr[i]);
  21964. //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();
  21965. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21966. if (nextDayNum > 0)
  21967. {
  21968. nextDayNum--;
  21969. }
  21970. if (tbSelect.Length > 0)
  21971. {
  21972. List<string> threeCodeStr = new List<string>();
  21973. bool isTrade = false;
  21974. string trip = string.Empty;
  21975. foreach (var item in tbSelect)
  21976. {
  21977. if (nextDayNum == 0)
  21978. {
  21979. nextDayNum = Convert.ToInt32(item["Sign"]);
  21980. }
  21981. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21982. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21983. var takeOffTime = DateTime.Parse(timeArr[i]);
  21984. var fallToTime = DateTime.Parse(timeArr[i]);
  21985. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21986. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21987. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21988. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21989. if (nextDayNum > 0)
  21990. {
  21991. fallToTime = fallToTime.AddDays(nextDayNum);
  21992. }
  21993. trip = string.Empty;
  21994. var start = string.Empty;
  21995. var end = string.Empty;
  21996. var threeCode = item["Three"].ToString() ?? "";
  21997. if (threeCode.Length == 6)
  21998. {
  21999. start = threeCode.Substring(0, 3);
  22000. end = threeCode.Substring(3, 3);
  22001. if (threeCodeStr.Count == 0)
  22002. {
  22003. threeCodeStr.Add(start);
  22004. threeCodeStr.Add(end);
  22005. }
  22006. else
  22007. {
  22008. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22009. {
  22010. threeCodeStr.Add(end);
  22011. }
  22012. else
  22013. {
  22014. threeCodeStr.Add(start);
  22015. threeCodeStr.Add(end);
  22016. }
  22017. }
  22018. }
  22019. //处理机票信息
  22020. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22021. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22022. if (start_Object == null)
  22023. {
  22024. start_Object = new Res_ThreeCode()
  22025. {
  22026. AirPort = empty,
  22027. AirPort_En = empty,
  22028. City = empty,
  22029. Country = empty,
  22030. Four = empty,
  22031. Three = empty,
  22032. };
  22033. }
  22034. if (end_Object == null)
  22035. {
  22036. end_Object = new Res_ThreeCode()
  22037. {
  22038. AirPort = empty,
  22039. AirPort_En = empty,
  22040. City = empty,
  22041. Country = empty,
  22042. Four = empty,
  22043. Three = empty,
  22044. };
  22045. }
  22046. //机型判断
  22047. string airModel = item["AirModel"].ToString();
  22048. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22049. string flightTime = item["FlightTime"].ToString();
  22050. flightTime = ParseBlackTime(flightTime);
  22051. //航班号
  22052. string flightcode = item["Fliagtcode"].ToString();
  22053. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22054. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22055. if (aircompany == null)
  22056. {
  22057. aircompany = new Res_AirCompany
  22058. {
  22059. CnName = hsEmpty,
  22060. EnName = hsEmpty,
  22061. ShortCode = hsEmpty,
  22062. };
  22063. }
  22064. //航班前公务安排
  22065. if (tbSelect.First().Equals(item) && i != 0)
  22066. {
  22067. foreach (var takeoff in takeoffTimes)
  22068. {
  22069. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  22070. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  22071. {
  22072. foreach (var addTime in takeoff.Item2)
  22073. {
  22074. chiarr.Add(new Grp_ApprovalTravelDetails
  22075. {
  22076. Time = addTime,
  22077. CreateTime = DateTime.Now,
  22078. CreateUserId = dto.Userid,
  22079. ParentId = 0,
  22080. Details = "公务活动"
  22081. });
  22082. }
  22083. break;
  22084. }
  22085. }
  22086. }
  22087. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  22088. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  22089. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  22090. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  22091. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  22092. if (isTrade)
  22093. {
  22094. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  22095. trip += "(转机不出机场)。";
  22096. }
  22097. //else
  22098. //{
  22099. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  22100. //}
  22101. chiarr.Add(new Grp_ApprovalTravelDetails
  22102. {
  22103. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  22104. CreateTime = DateTime.Now,
  22105. CreateUserId = dto.Userid,
  22106. ParentId = 0,
  22107. Details = trip
  22108. });
  22109. //最后一条到达的时间安排公务
  22110. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  22111. {
  22112. bool isCheckCountry = false;
  22113. if (end_Object.Country != arriveCountry)
  22114. {
  22115. arriveCountry = end_Object.Country;
  22116. isCheckCountry = true;
  22117. }
  22118. if (nextDayNum == 0)
  22119. {
  22120. //需要入境的情况
  22121. if (isCheckCountry)
  22122. {
  22123. foreach (var fallTime in fallTimesCheckCountry)
  22124. {
  22125. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22126. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22127. {
  22128. foreach (var addTime in fallTime.Item2)
  22129. {
  22130. chiarr.Add(new Grp_ApprovalTravelDetails
  22131. {
  22132. Time = addTime,
  22133. CreateTime = DateTime.Now,
  22134. CreateUserId = dto.Userid,
  22135. ParentId = 0,
  22136. Details = "公务活动"
  22137. });
  22138. }
  22139. break;
  22140. }
  22141. }
  22142. }
  22143. else
  22144. {
  22145. foreach (var fallTime in fallTimesNotCheckCountry)
  22146. {
  22147. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22148. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22149. {
  22150. foreach (var addTime in fallTime.Item2)
  22151. {
  22152. chiarr.Add(new Grp_ApprovalTravelDetails
  22153. {
  22154. Time = addTime,
  22155. CreateTime = DateTime.Now,
  22156. CreateUserId = dto.Userid,
  22157. ParentId = 0,
  22158. Details = "公务活动"
  22159. });
  22160. }
  22161. break;
  22162. }
  22163. }
  22164. }
  22165. }
  22166. }
  22167. }
  22168. //添加乘车语句
  22169. //chiarr.Add(new Grp_ApprovalTravelDetails
  22170. //{
  22171. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  22172. // CreateTime = DateTime.Now,
  22173. // CreateUserId = dto.Userid,
  22174. // ParentId = 0,
  22175. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  22176. //});
  22177. //if (i != timeArr.Count - 1)
  22178. //{
  22179. // fallToTime = fallToTime.AddHours(2.5);
  22180. // foreach (var item in Times)
  22181. // {
  22182. // //排列公务时间
  22183. // if (fallToTime.Hour < item.Item1)
  22184. // {
  22185. // chiarr.Add(new Grp_ApprovalTravelDetails
  22186. // {
  22187. // Time = $"{item.Item2} - {item.Item3}",
  22188. // CreateTime = DateTime.Now,
  22189. // CreateUserId = dto.Userid,
  22190. // ParentId = 0,
  22191. // Details = "公务活动"
  22192. // });
  22193. // }
  22194. // }
  22195. //}
  22196. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22197. var last = threeCodeStr.Last();
  22198. foreach (var item in threeCodeStr)
  22199. {
  22200. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22201. if (item.Equals(last))
  22202. {
  22203. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22204. }
  22205. }
  22206. cityPath = cityPath.Trim('-');
  22207. }
  22208. else
  22209. {
  22210. foreach (var item in Times)
  22211. {
  22212. chiarr.Add(new Grp_ApprovalTravelDetails
  22213. {
  22214. Time = $"{item.Item2} - {item.Item3}",
  22215. CreateTime = DateTime.Now,
  22216. CreateUserId = dto.Userid,
  22217. ParentId = 0,
  22218. Details = "公务活动"
  22219. });
  22220. }
  22221. }
  22222. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22223. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22224. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  22225. appro.Diid = dto.Diid;
  22226. appro.CreateUserId = dto.Userid;
  22227. appro.CreateTime = DateTime.Now;
  22228. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22229. appro.Id = thisId;
  22230. //foreach (var item in gwinfo)
  22231. //{
  22232. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  22233. // chi.Details = "拜访" + item.Client;
  22234. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  22235. // {
  22236. // chi.Details += "," + item.ReqSample;
  22237. // }
  22238. // chi.ParentId = thisId;
  22239. // chi.Time = item.Time;
  22240. // chiarr.Add(chi);
  22241. //}
  22242. if (chiarr.Count < 6)
  22243. {
  22244. for (int j = chiarr.Count; j < 6; j++)
  22245. {
  22246. chiarr.Add(new
  22247. Grp_ApprovalTravelDetails());
  22248. }
  22249. }
  22250. resultArr.Add(new
  22251. {
  22252. appro.Id,
  22253. appro.Date,
  22254. appro.Diid,
  22255. chiList = chiarr.Select(x1 => new
  22256. {
  22257. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22258. x1.Details,
  22259. x1.ParentId,
  22260. x1.Id
  22261. })
  22262. });
  22263. }
  22264. _sqlSugar.CommitTran();
  22265. jw = JsonView(true, "生成成功!", resultArr);
  22266. }
  22267. catch (Exception ex)
  22268. {
  22269. jw.Code = 400;
  22270. jw.Msg = "生成失败!" + ex.Message;
  22271. }
  22272. return Ok(jw);
  22273. }
  22274. /// <summary>
  22275. /// 报批行程word导出
  22276. /// </summary>
  22277. /// <param name="dto"></param>
  22278. /// <returns></returns>
  22279. [HttpPost]
  22280. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  22281. {
  22282. var jw = JsonView(false);
  22283. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22284. if (group == null)
  22285. {
  22286. jw.Msg = "暂无该团组!";
  22287. return Ok(jw);
  22288. }
  22289. //模板路径
  22290. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  22291. var fileName = string.Empty;
  22292. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  22293. bool bold = false;
  22294. if (dto.FileIndex == 1)
  22295. {
  22296. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  22297. }
  22298. else if (dto.FileIndex == 2)
  22299. {
  22300. fileName = "省外办-报批.docx";
  22301. bold = false;
  22302. titleFont = "方正黑体简体";
  22303. timeFont = "Times New Roman";
  22304. contentFont = "方正仿宋_GBK";
  22305. }
  22306. else if (dto.FileIndex == 3)
  22307. {
  22308. fileName = "市外办-报批.docx";
  22309. titleFont = "方正黑体简体";
  22310. timeFont = "Times New Roman";
  22311. contentFont = "方正仿宋简体";
  22312. }
  22313. tempPath = tempPath + fileName;
  22314. //载入模板
  22315. Document doc = new Document(tempPath);
  22316. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22317. //获取所填表格的序数
  22318. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22319. Aspose.Words.Tables.Row titleRowClone = null;
  22320. Aspose.Words.Tables.Row CenterRowClone = null;
  22321. int index = 0;
  22322. int indexChi = 0;
  22323. int SetIndex = 0;
  22324. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  22325. //获取数据,放到datatable
  22326. foreach (var item in ApprovalTravelArr)
  22327. {
  22328. if (index > 0)
  22329. {
  22330. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  22331. tableOne.AppendChild(titleRowClone);
  22332. }
  22333. var textTime = item.Date;
  22334. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  22335. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  22336. SetIndex++;
  22337. if (ChiRep.Count > 0)
  22338. {
  22339. foreach (var itemChi in ChiRep)
  22340. {
  22341. var txtTime = itemChi.Time;
  22342. var txtDetail = itemChi.Details;
  22343. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  22344. {
  22345. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  22346. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22347. //indexChi++;
  22348. //SetIndex++;
  22349. break;
  22350. }
  22351. if (indexChi > 0)
  22352. {
  22353. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22354. tableOne.AppendChild(CenterRowClone);
  22355. }
  22356. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  22357. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  22358. indexChi++;
  22359. SetIndex++;
  22360. }
  22361. }
  22362. //else
  22363. //{
  22364. // if (indexChi > 0)
  22365. // {
  22366. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22367. // tableOne.AppendChild(CenterRowClone);
  22368. // }
  22369. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  22370. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22371. // indexChi++;
  22372. // SetIndex++;
  22373. //}
  22374. index++;
  22375. }
  22376. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  22377. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22378. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22379. jw.Code = 200;
  22380. jw.Msg = "";
  22381. return Ok(jw);
  22382. }
  22383. private string ParseBlackTime(string time)
  22384. {
  22385. // 匹配可能只有分钟的情况
  22386. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  22387. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  22388. if (match.Success)
  22389. {
  22390. string hours = match.Groups[1].Value;
  22391. string minutes = match.Groups[2].Value;
  22392. // 如果小时部分为空,则只显示分钟
  22393. if (string.IsNullOrEmpty(hours))
  22394. {
  22395. return $"{minutes}分钟";
  22396. }
  22397. // 如果分钟部分为空,则只显示小时
  22398. else if (string.IsNullOrEmpty(minutes))
  22399. {
  22400. return $"{hours}小时";
  22401. }
  22402. // 否则显示完整格式
  22403. else
  22404. {
  22405. return $"{hours}小时{minutes}分钟";
  22406. }
  22407. }
  22408. else
  22409. {
  22410. return "未知时长";
  22411. }
  22412. }
  22413. private string intToString(int numberVal)
  22414. {
  22415. string numberval = numberVal.ToString();
  22416. Dictionary<char, string> Number = new Dictionary<char, string>();
  22417. Number.Add('1', "一");
  22418. Number.Add('2', "二");
  22419. Number.Add('3', "三");
  22420. Number.Add('4', "四");
  22421. Number.Add('5', "五");
  22422. Number.Add('6', "六");
  22423. Number.Add('7', "七");
  22424. Number.Add('8', "八");
  22425. Number.Add('9', "九");
  22426. string stringNumberVal = string.Empty;
  22427. for (int i = 0; i < numberval.Length; i++)
  22428. {
  22429. if (i == 0)
  22430. {
  22431. stringNumberVal += Number[numberval[i]];
  22432. }
  22433. else if (i >= 1)
  22434. {
  22435. if (numberval[i] == '0')
  22436. {
  22437. stringNumberVal = "十";
  22438. }
  22439. else
  22440. {
  22441. stringNumberVal += "十" + Number[numberval[i]];
  22442. }
  22443. }
  22444. }
  22445. return stringNumberVal;
  22446. }
  22447. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22448. {
  22449. //获取table中的某个单元格,从0开始
  22450. Cell lshCell = table.Rows[rows].Cells[cells];
  22451. //将单元格中段落移除
  22452. foreach (Paragraph item in lshCell.Paragraphs)
  22453. {
  22454. lshCell.Paragraphs.Remove(item);
  22455. }
  22456. if (val.Contains("\r\n"))
  22457. {
  22458. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22459. foreach (var item in spArr)
  22460. {
  22461. //新建一个段落
  22462. Paragraph p = new Paragraph(doc);
  22463. var r = new Run(doc, item);
  22464. //设置字体
  22465. if (!string.IsNullOrEmpty(font))
  22466. {
  22467. r.Font.Name = font;
  22468. }
  22469. r.Font.Bold = bold;
  22470. //把设置的值赋给之前新建的段落
  22471. p.AppendChild(r);
  22472. //将此段落加到单元格内
  22473. lshCell.AppendChild(p);
  22474. }
  22475. }
  22476. else
  22477. {
  22478. //新建一个段落
  22479. Paragraph p = new Paragraph(doc);
  22480. var r = new Run(doc, val);
  22481. //设置字体
  22482. if (!string.IsNullOrEmpty(font))
  22483. {
  22484. r.Font.Name = font;
  22485. }
  22486. r.Font.Bold = bold;
  22487. //把设置的值赋给之前新建的段落
  22488. p.AppendChild(r);
  22489. //将此段落加到单元格内
  22490. lshCell.AppendChild(p);
  22491. }
  22492. }
  22493. /// <summary>
  22494. /// 报批行程AI续写
  22495. /// </summary>
  22496. /// <returns></returns>
  22497. [HttpPost]
  22498. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22499. {
  22500. var jw = JsonView(false);
  22501. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22502. {
  22503. jw.Msg = "参数有误!";
  22504. return Ok(jw);
  22505. }
  22506. KiMiApiClient kiMi = new KiMiApiClient();
  22507. List<SeedMessages> messages = new List<SeedMessages>() {
  22508. new SeedMessages
  22509. {
  22510. Role = KimiRole.system,
  22511. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22512. },
  22513. new SeedMessages
  22514. {
  22515. Role = KimiRole.user,
  22516. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22517. }
  22518. };
  22519. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22520. string data = kimi_result.Choices[0]?.Message.Content;
  22521. if (string.IsNullOrWhiteSpace(data))
  22522. {
  22523. jw.Data = "Ai续写失败!";
  22524. }
  22525. else
  22526. {
  22527. jw = JsonView(true, "success!", data);
  22528. }
  22529. return Ok(jw);
  22530. }
  22531. #endregion
  22532. #region 团组接待意见调查
  22533. /// <summary>
  22534. /// 团组接待意见调查 - 信息管理
  22535. /// 基础数据(团组)
  22536. /// </summary>
  22537. /// <returns></returns>
  22538. [HttpGet]
  22539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22540. public async Task<IActionResult> OpinionaireInit()
  22541. {
  22542. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22543. .Select(x => new
  22544. {
  22545. x.Id,
  22546. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22547. })
  22548. .OrderByDescending(x => x.Id)
  22549. .ToListAsync();
  22550. return Ok(JsonView(groupData, groupData.Count));
  22551. }
  22552. /// <summary>
  22553. /// 团组接待意见调查 - 信息管理
  22554. /// 列表
  22555. /// </summary>
  22556. /// <param name="groupId"></param>
  22557. /// <returns></returns>
  22558. [HttpGet("{groupId}")]
  22559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22560. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22561. {
  22562. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22563. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22564. .Select(x => new
  22565. {
  22566. x.Id,
  22567. x.TourGuideName,
  22568. x.CityName,
  22569. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22570. x.CreateTime
  22571. })
  22572. .OrderBy(x => x.Id)
  22573. .ToListAsync();
  22574. return Ok(JsonView(data));
  22575. }
  22576. /// <summary>
  22577. /// 团组接待意见调查 - 信息管理
  22578. /// 保存
  22579. /// </summary>
  22580. /// <param name="dto"></param>
  22581. /// <returns></returns>
  22582. [HttpPost]
  22583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22584. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22585. {
  22586. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22587. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22588. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22589. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22590. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22591. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22592. _opinionaireRep.BeginTran();
  22593. if (addData != null && addData.Count > 0)
  22594. {
  22595. foreach (var item in addData)
  22596. {
  22597. item.CreateUserId = currUserInfo.UserId;
  22598. item.DiId = dto.DiId;
  22599. }
  22600. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22601. }
  22602. if (updData != null && updData.Count > 0)
  22603. {
  22604. var upd = await _opinionaireRep._sqlSugar
  22605. .Updateable(updData)
  22606. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22607. .WhereColumns(x => new { x.Id })
  22608. .ExecuteCommandAsync();
  22609. }
  22610. _opinionaireRep.CommitTran();
  22611. return Ok(JsonView("操作成功!"));
  22612. }
  22613. /// <summary>
  22614. /// 团组接待意见调查 - 信息管理
  22615. /// 删除
  22616. /// </summary>
  22617. /// <param name="id"></param>
  22618. /// <returns></returns>
  22619. [HttpDelete("{id}")]
  22620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22621. public async Task<IActionResult> OpinionaireManageDel(int id)
  22622. {
  22623. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22624. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22625. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22626. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22627. if (!del) return Ok(JsonView("操作失败!"));
  22628. return Ok(JsonView("操作成功!"));
  22629. }
  22630. /// <summary>
  22631. /// 团组接待意见调查 - 用户
  22632. /// 列表
  22633. /// </summary>
  22634. /// <param name="diId"></param>
  22635. /// <returns></returns>
  22636. [HttpGet("{diId}")]
  22637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22638. public async Task<IActionResult> OpinionaireUserList(int diId)
  22639. {
  22640. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22641. var sql = string.Format(@"
  22642. SELECT
  22643. o.Id,
  22644. o.DiId,
  22645. di.TeamName AS 'GroupName',
  22646. di.VisitPNumber AS 'PeopleNumber',
  22647. di.ClientName AS 'LeadGroup',
  22648. di.VisitCountry AS 'Travel',
  22649. di.VisitDays AS 'Days',
  22650. o.CityName,
  22651. o.TourGuideName,
  22652. o.Catering,
  22653. o.CateringReason,
  22654. o.Stay,
  22655. o.StayReason,
  22656. o.[Route],
  22657. o.RouteReason,
  22658. o.OfficialActivity,
  22659. o.OfficialActivityReason,
  22660. o.TourGuide,
  22661. o.TourGuideReason,
  22662. o.[Translate],
  22663. o.TranslateReason,
  22664. o.Trip,
  22665. o.TripReason,
  22666. o.ESFileName,
  22667. o.SignatureDate,
  22668. o.Remark
  22669. FROM
  22670. Grp_Opinionaire o
  22671. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22672. WHERE
  22673. o.IsDel = 0
  22674. AND o.DiId = {0}
  22675. ORDER BY
  22676. o.Id ASC", diId);
  22677. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22678. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22679. return Ok(JsonView(data));
  22680. }
  22681. /// <summary>
  22682. /// 团组接待意见调查 - 用户
  22683. /// 保存
  22684. /// </summary>
  22685. /// <param name="dto"></param>
  22686. /// <returns></returns>
  22687. [HttpPost]
  22688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22689. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22690. {
  22691. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22692. foreach (var item in dto)
  22693. {
  22694. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22695. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22696. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22697. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22698. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22699. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22700. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22701. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22702. }
  22703. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22704. if (!Directory.Exists(filePathBase))
  22705. {
  22706. Directory.CreateDirectory(filePathBase);
  22707. }
  22708. #region 上传文件
  22709. var filePaths = new List<string>();
  22710. foreach (var item in dto)
  22711. {
  22712. var file = item.File;
  22713. // 将文件保存到指定位置
  22714. var filePath = Path.Combine(filePathBase, file.FileName);
  22715. using (var stream = new FileStream(filePath, FileMode.Create))
  22716. {
  22717. await file.CopyToAsync(stream);
  22718. }
  22719. //验证文件是否上传成功
  22720. if (!System.IO.File.Exists(filePath))
  22721. {
  22722. foreach (var filePathStr in filePaths)
  22723. {
  22724. System.IO.File.Delete(filePathStr);
  22725. }
  22726. return Ok(JsonView(false, "文件上传失败!"));
  22727. }
  22728. item.ESFileName = file.FileName;
  22729. }
  22730. #endregion
  22731. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22732. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22733. .UpdateColumns(x => new
  22734. {
  22735. x.Catering,
  22736. x.CateringReason,
  22737. x.Stay,
  22738. x.StayReason,
  22739. x.Route,
  22740. x.RouteReason,
  22741. x.OfficialActivity,
  22742. x.OfficialActivityReason,
  22743. x.TourGuide,
  22744. x.TourGuideReason,
  22745. x.Translate,
  22746. x.TranslateReason,
  22747. x.Trip,
  22748. x.TripReason,
  22749. x.ESFileName,
  22750. x.SignatureDate,
  22751. x.Remark
  22752. })
  22753. .WhereColumns(x => new { x.Id })
  22754. .ExecuteCommandAsync();
  22755. if (upd < 1)
  22756. {
  22757. foreach (var filePathStr in filePaths)
  22758. {
  22759. System.IO.File.Delete(filePathStr);
  22760. }
  22761. return Ok(JsonView(false));
  22762. }
  22763. return Ok(JsonView(true));
  22764. }
  22765. #endregion
  22766. #region 团组餐厅相关信息
  22767. /// <summary>
  22768. /// 团组相关餐厅信息
  22769. /// 基础数据(团组)
  22770. /// </summary>
  22771. /// <returns></returns>
  22772. [HttpGet]
  22773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22774. public async Task<IActionResult> RestaurantInit()
  22775. {
  22776. return Ok(await _restaurantRep.InitAsync());
  22777. }
  22778. /// <summary>
  22779. /// 团组相关餐厅信息
  22780. /// Item
  22781. /// </summary>
  22782. /// <param name="dto"></param>
  22783. /// <returns></returns>
  22784. [HttpPost]
  22785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22786. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22787. {
  22788. int portType = dto.PortType,
  22789. groupId = dto.GroupId;
  22790. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22791. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22792. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22793. }
  22794. /// <summary>
  22795. /// 团组相关餐厅信息
  22796. /// List
  22797. /// </summary>
  22798. /// <param name="dto"></param>
  22799. /// <returns></returns>
  22800. [HttpPost]
  22801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22802. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22803. {
  22804. int portType = dto.PortType,
  22805. groupId = dto.GroupId;
  22806. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22807. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22808. var sql = string.Format(@" SELECT
  22809. ri.Id,
  22810. ri.GroupId,
  22811. ri.Date,
  22812. ri.StartTime,
  22813. ri.EndTime,
  22814. CASE WHEN ri.Type = 1 THEN '早餐'
  22815. WHEN ri.Type = 2 THEN '午餐'
  22816. WHEN ri.Type = 3 THEN '晚餐'
  22817. ELSE '其他'
  22818. END AS 'Type',
  22819. ri.Name,
  22820. ri.Address,
  22821. ri.Tel,
  22822. ri.Remark,
  22823. ri.CreateTime,
  22824. u.CnName AS CreateUserName
  22825. FROM
  22826. Grp_RestaurantInfo ri
  22827. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22828. WHERE
  22829. ri.IsDel = 0
  22830. AND ri.GroupId = {0}
  22831. ORDER BY
  22832. ri.Date ASC
  22833. ", groupId);
  22834. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22835. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22836. return Ok(JsonView(infos));
  22837. }
  22838. /// <summary>
  22839. /// 团组相关餐厅信息
  22840. /// Info
  22841. /// </summary>
  22842. /// <param name="dto"></param>
  22843. /// <returns></returns>
  22844. [HttpPost]
  22845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22846. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22847. {
  22848. int portType = dto.PortType,
  22849. id = dto.Id;
  22850. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22851. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22852. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22853. }
  22854. /// <summary>
  22855. /// 团组相关餐厅信息
  22856. /// Op
  22857. /// </summary>
  22858. /// <param name="dto"></param>
  22859. /// <returns></returns>
  22860. [HttpPost]
  22861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22862. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22863. {
  22864. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22865. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22866. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22867. return Ok(await _restaurantRep.OpAsync(dto));
  22868. }
  22869. /// <summary>
  22870. /// 团组相关餐厅信息
  22871. /// Del
  22872. /// </summary>
  22873. /// <param name="dto"></param>
  22874. /// <returns></returns>
  22875. [HttpPost]
  22876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22877. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22878. {
  22879. int userId = dto.DeleteUserId;
  22880. var id = dto.Id;
  22881. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22882. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22883. return Ok(await _restaurantRep.DelAsync(dto));
  22884. }
  22885. #endregion
  22886. #region 团组会务成本
  22887. /// <summary>
  22888. /// 团组会务成本数据初始化
  22889. /// </summary>
  22890. /// <returns></returns>
  22891. [HttpPost]
  22892. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  22893. {
  22894. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  22895. .OrderByDescending(x => x.CreateTime)
  22896. .Where(x => x.IsDel == 0)
  22897. .Select<DelegationEasyView>();
  22898. DelegationEasyView di = Dto.GroupId == 0 ?
  22899. expr.First() :
  22900. expr.First(x => x.Id == Dto.GroupId);
  22901. if (di == null)
  22902. {
  22903. return Ok(JsonView(false, "团组信息不存在!"));
  22904. }
  22905. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  22906. .Where(x => x.IsDel == 0 && x.STid == 21)
  22907. .Select(x => new { x.Id, Text = x.Name })
  22908. .ToListAsync();
  22909. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  22910. .Where(x => x.IsDel == 0)
  22911. .OrderByDescending(x => x.VisitDate)
  22912. .Select(x => new { x.Id, x.TeamName })
  22913. .ToListAsync();
  22914. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  22915. var userList = await _sqlSugar.Queryable<Sys_Users>()
  22916. .Where(x => x.IsDel == 0)
  22917. .Select(x => new { x.Id, x.CnName })
  22918. .ToListAsync();
  22919. var units = await _sqlSugar.Queryable<Sys_SetData>()
  22920. .Where(x => x.IsDel == 0 && x.STid == 119)
  22921. .Select(x => new { x.Id, Text = x.Name })
  22922. .ToListAsync();
  22923. var FileType = new[]
  22924. {
  22925. new { Id = 0 , Name = "成本下载" },
  22926. new { Id = 1 , Name = "报价下载" },
  22927. new { Id = 2 , Name = "总表下载" },
  22928. };
  22929. var GM = new List<int>();
  22930. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  22931. try
  22932. {
  22933. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  22934. }
  22935. catch (Exception ex)
  22936. {
  22937. GM = new List<int>() { 21 };
  22938. }
  22939. var isReview = Dto.UserId == 21;
  22940. var isGM = GM.Contains(Dto.UserId);
  22941. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  22942. .Where(x => x.IsDel == 0)
  22943. .Select<ConferenceAffairsCostView>()
  22944. .First(x=> x.Diid == di.Id);
  22945. if (ConferenceAffairsCost == null)
  22946. {
  22947. ConferenceAffairsCost = new ConferenceAffairsCostView();
  22948. ConferenceAffairsCost.Diid = di.Id;
  22949. }
  22950. #region 权限校验
  22951. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  22952. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  22953. .Select(x=> x.UserId)
  22954. .Distinct()
  22955. .ToList();
  22956. if (!ids.Contains(Dto.UserId) && !isGM )
  22957. {
  22958. return Ok(JsonView(201, "暂无权限!", new
  22959. {
  22960. typeData,
  22961. groupList,
  22962. currenyList,
  22963. isGM,
  22964. userList,
  22965. units,
  22966. isReview,
  22967. operatorUser = ids,
  22968. di,
  22969. FileType
  22970. }));
  22971. }
  22972. #endregion
  22973. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  22974. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  22975. .Select<ConferenceAffairsCostChildView>()
  22976. .OrderBy(x=>x.Index)
  22977. .ToList();
  22978. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  22979. {
  22980. ConferenceAffairsCostChi[i - 1].Index = i;
  22981. }
  22982. var backData = new
  22983. {
  22984. ConferenceAffairsCost,
  22985. ConferenceAffairsCostChi,
  22986. typeData,
  22987. groupList,
  22988. currenyList,
  22989. isGM,
  22990. userList,
  22991. units,
  22992. isReview,
  22993. operatorUser = ids,
  22994. di,
  22995. FileType
  22996. };
  22997. return Ok(JsonView(true, "SUCCESS", backData));
  22998. }
  22999. /// <summary>
  23000. /// 会务成本保存
  23001. /// </summary>
  23002. /// <returns></returns>
  23003. [HttpPost]
  23004. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23005. {
  23006. _sqlSugar.BeginTran();
  23007. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23008. try
  23009. {
  23010. if (data.Id == 0)
  23011. {
  23012. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23013. .Where(x => x.Diid == Dto.GroupId)
  23014. .SetColumns(x => new Grp_ConferenceAffairsCost
  23015. {
  23016. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23017. DeleteUserId = Dto.UserId
  23018. })
  23019. .ExecuteCommand();
  23020. data.Diid = Dto.GroupId;
  23021. data.CreateTime = DateTime.Now;
  23022. data.CreateUserId = Dto.UserId;
  23023. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23024. .ExecuteReturnIdentity();
  23025. }
  23026. else
  23027. {
  23028. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23029. .ExecuteCommand();
  23030. data.Id = data.Id;
  23031. }
  23032. if (Dto.ConferenceAffairsCostChild.Any())
  23033. {
  23034. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23035. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23036. var updateArr = datas.Where(x => x.Id != 0).ToList();
  23037. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23038. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23039. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23040. .IgnoreColumns(x=> new { x.ConferenceAffairsCostId })
  23041. .ExecuteCommand() : 0;
  23042. }
  23043. _sqlSugar.CommitTran();
  23044. }
  23045. catch (Exception ex)
  23046. {
  23047. _sqlSugar.RollbackTran();
  23048. return Ok(JsonView(false, "失败!" + ex.Message));
  23049. }
  23050. return Ok(JsonView(true,"操作成功!"));
  23051. }
  23052. [HttpPost]
  23053. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  23054. {
  23055. var count = 0;
  23056. if (Dto.ConferenceAffairsCostChildids.Any())
  23057. {
  23058. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  23059. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  23060. SetColumns(x => new Grp_ConferenceAffairsCostChild
  23061. {
  23062. ReviewStatus = Dto.ReviewStatus
  23063. }).
  23064. ExecuteCommand();
  23065. }
  23066. return Ok(JsonView(true, "操作成功!",count));
  23067. }
  23068. /// <summary>
  23069. /// 会务成本所有数据清除
  23070. /// </summary>
  23071. /// <param name="Dto"></param>
  23072. /// <returns></returns>
  23073. [HttpPost]
  23074. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  23075. {
  23076. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23077. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  23078. _sqlSugar.BeginTran();
  23079. try
  23080. {
  23081. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23082. .Where(x => x.Diid == Dto.GroupId)
  23083. .SetColumns(x => new Grp_ConferenceAffairsCost
  23084. {
  23085. IsDel = 1,
  23086. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23087. DeleteUserId = Dto.UserId
  23088. })
  23089. .ExecuteCommand();
  23090. if (delCount > 0)
  23091. {
  23092. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23093. .Where(x => x.Diid == Dto.GroupId)
  23094. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23095. {
  23096. IsDel = 1,
  23097. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23098. DeleteUserId = Dto.UserId
  23099. })
  23100. .ExecuteCommand();
  23101. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23102. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23103. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23104. {
  23105. IsDel = 1,
  23106. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23107. DeleteUserId = Dto.UserId
  23108. })
  23109. .ExecuteCommand();
  23110. }
  23111. _sqlSugar.CommitTran();
  23112. }
  23113. catch (Exception ex)
  23114. {
  23115. _sqlSugar.RollbackTran();
  23116. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23117. }
  23118. return Ok(JsonView(true, "操作成功!"));
  23119. }
  23120. /// <summary>
  23121. /// 子项数据删除
  23122. /// </summary>
  23123. /// <param name="Dto"></param>
  23124. /// <returns></returns>
  23125. [HttpPost]
  23126. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  23127. {
  23128. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  23129. .Any(x => x.ReviewStatus == 1);
  23130. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  23131. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23132. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  23133. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23134. {
  23135. IsDel = 1,
  23136. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23137. DeleteUserId = Dto.UserId
  23138. })
  23139. .ExecuteCommand();
  23140. return Ok(JsonView(true, "SUCCESS!", count));
  23141. }
  23142. /// <summary>
  23143. /// 会务成本权限分配
  23144. /// </summary>
  23145. /// <param name="Dto"></param>
  23146. /// <returns></returns>
  23147. [HttpPost]
  23148. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  23149. {
  23150. _sqlSugar.BeginTran();
  23151. var count = 0;
  23152. try
  23153. {
  23154. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23155. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23156. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23157. {
  23158. IsDel = 1,
  23159. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23160. DeleteUserId = Dto.CreateUserId
  23161. })
  23162. .ExecuteCommand();
  23163. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  23164. {
  23165. CreateTime = DateTime.Now,
  23166. CreateUserId = Dto.CreateUserId,
  23167. UserId = x,
  23168. Diid = Dto.GroupId,
  23169. }).ToList()).ExecuteCommand();
  23170. _sqlSugar.CommitTran();
  23171. }
  23172. catch (Exception ex)
  23173. {
  23174. _sqlSugar.RollbackTran();
  23175. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23176. }
  23177. return Ok(JsonView(true, "操作成功!", count));
  23178. }
  23179. /// <summary>
  23180. /// 团组会务成本文件下载
  23181. /// </summary>
  23182. /// <returns></returns>
  23183. [HttpPost]
  23184. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  23185. {
  23186. var FileType = new[]
  23187. {
  23188. new { Id = 0 , Name = "成本下载" },
  23189. new { Id = 1 , Name = "报价下载" },
  23190. new { Id = 2 , Name = "总表下载" },
  23191. };
  23192. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23193. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  23194. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23195. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  23196. .Select<DelegationEasyView>()
  23197. .First();
  23198. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23199. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  23200. if (main == null)
  23201. {
  23202. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  23203. }
  23204. JsonView jw = JsonView(false);
  23205. //总表下载
  23206. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  23207. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  23208. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  23209. var field = string.Empty;
  23210. var fileTypeName = string.Empty;
  23211. field = @$"
  23212. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  23213. b.Name as PriceTypeStr ,
  23214. c.Name as CurrencyStr ,
  23215. d.Name as UnitStr ,
  23216. case a.ReviewStatus
  23217. WHEN 1 THEN '已通过'
  23218. WHEN 0 THEN '未审核'
  23219. WHEN -1 THEN '未通过'
  23220. ELSE '未审核'
  23221. END AS ReviewStatusStr
  23222. ";
  23223. if (Dto.FileTypeId == 0)
  23224. {
  23225. fileTypeName = "会务成本成本表";
  23226. loadPath += $"{fileTypeName}.xlsx";
  23227. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23228. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23229. }
  23230. else if (Dto.FileTypeId == 1)
  23231. {
  23232. fileTypeName = "会务成本报价表";
  23233. loadPath += $"{fileTypeName}.xlsx";
  23234. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23235. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23236. }
  23237. else if (Dto.FileTypeId == 2)
  23238. {
  23239. fileTypeName = "会务成本总表";
  23240. loadPath += $"{fileTypeName}.xlsx";
  23241. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23242. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23243. }
  23244. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  23245. SELECT
  23246. {field}
  23247. FROM Grp_ConferenceAffairsCostChild a
  23248. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  23249. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  23250. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  23251. WHERE a.isdel = 0
  23252. AND a.Diid = {main.Diid}
  23253. AND a.ConferenceAffairsCostId = {main.Id}
  23254. ").ToList();
  23255. var currLists = chiExcelContent.Select(x => new CurrList
  23256. {
  23257. CurrName = x.CurrencyStr,
  23258. CurrRate = x.Rate
  23259. })
  23260. .Distinct()
  23261. .ToList();
  23262. var designer = new WorkbookDesigner
  23263. {
  23264. Workbook = new Workbook(loadPath)
  23265. };
  23266. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x=>x.IsDel == 0 && x.Id == main.MostCurr);
  23267. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  23268. designer.SetDataSource("TeamName", di.TeamName);
  23269. designer.SetDataSource("City", main.City);
  23270. designer.SetDataSource("AllCost", main.CostAll);
  23271. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  23272. designer.SetDataSource("Curr", MostCurr.Name);
  23273. designer.SetDataSource("Curr1", MostCurr.Name);
  23274. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  23275. dt.TableName = "TB";
  23276. designer.SetDataSource(dt);
  23277. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  23278. dt1.TableName = "currTb";
  23279. designer.SetDataSource(dt1);
  23280. designer.Process();
  23281. designer.Workbook.Save(outputPath);
  23282. jw = JsonView(true, "操作成功!", new
  23283. {
  23284. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  23285. FilePath = networkPath
  23286. });
  23287. return Ok(jw);
  23288. }
  23289. #endregion
  23290. #region 团组签证流程
  23291. #endregion
  23292. /// <summary>
  23293. /// 123132123
  23294. /// </summary>
  23295. /// <param name="_dto"></param>
  23296. /// <returns></returns>
  23297. [HttpPost]
  23298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23299. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  23300. {
  23301. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  23302. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  23303. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  23304. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  23305. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  23306. dicDetail.Add(789, 1034);
  23307. dicDetail.Add(790, 1035);
  23308. dicDetail.Add(791, 1036);
  23309. dicDetail.Add(792, 1037);
  23310. dicDetail.Add(793, 1038);
  23311. dicDetail.Add(794, 1039);
  23312. dicDetail.Add(795, 1040);
  23313. dicDetail.Add(796, 1041);
  23314. dicDetail.Add(797, 1042);
  23315. dicDetail.Add(798, 1043);
  23316. dicDetail.Add(801, 1044);
  23317. dicDetail.Add(802, 1045);
  23318. dicDetail.Add(803, 1046);
  23319. Dictionary<int, int> dic = new Dictionary<int, int>();
  23320. dic.Add(806, 1027);
  23321. dic.Add(807, 1028);
  23322. dic.Add(808, 1029);
  23323. dic.Add(809, 1030);
  23324. dic.Add(810, 1031);
  23325. dic.Add(811, 1032);
  23326. dic.Add(812, 1033);
  23327. foreach (var item in list_visa)
  23328. {
  23329. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  23330. temp.Coefficient = item.coefficient;
  23331. DateTime dtCrt;
  23332. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  23333. if (b1)
  23334. {
  23335. temp.CreateTime = dtCrt;
  23336. }
  23337. else
  23338. {
  23339. temp.CreateTime = DateTime.Now;
  23340. }
  23341. temp.CreateUserId = item.Operators;
  23342. temp.DeleteTime = "";
  23343. temp.DeleteUserId = 0;
  23344. temp.DiId = int.Parse(item.DIID);
  23345. temp.FilePath = item.FilePath;
  23346. temp.IsDel = item.IsDel;
  23347. temp.Price = item.Price;
  23348. temp.PriceCount = 1;
  23349. temp.PriceCurrency = item.Currency;
  23350. int detailId = 0;
  23351. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  23352. {
  23353. detailId = dicDetail[item.PriceTypeDetail];
  23354. }
  23355. temp.PriceDetailType = detailId;
  23356. temp.PriceDt = DateTime.Now;
  23357. temp.PriceName = item.PriceName;
  23358. temp.PriceSum = item.Price;
  23359. int tid = 0;
  23360. if (dic.ContainsKey(item.PriceType))
  23361. {
  23362. tid = dic[item.PriceType];
  23363. }
  23364. temp.PriceType = tid;
  23365. temp.Remark = item.Remark;
  23366. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  23367. }
  23368. return Ok(JsonView(true, "操作成功!"));
  23369. }
  23370. [HttpPost]
  23371. public IActionResult TimeTest()
  23372. {
  23373. var jw = JsonView(false, "error");
  23374. _sqlSugar.BeginTran();
  23375. try
  23376. {
  23377. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  23378. .Select(x => new Crm_NewClientData
  23379. {
  23380. Id = x.Id,
  23381. Client = x.Client,
  23382. Contact = x.Contact,
  23383. Location = x.Location,
  23384. })
  23385. .ToList();
  23386. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  23387. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  23388. Stopwatch stopwatch = new Stopwatch();
  23389. // 开始计时
  23390. stopwatch.Start();
  23391. foreach (var item in clientList)
  23392. {
  23393. EncryptionProcessor.DecryptProperties(item);
  23394. }
  23395. stopwatch.Stop();
  23396. jw.Code = 200;
  23397. jw.Data = stopwatch.ElapsedMilliseconds;
  23398. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  23399. }
  23400. catch (Exception ex)
  23401. {
  23402. jw.Code = 400;
  23403. jw.Msg = ex.Message;
  23404. }
  23405. return Ok(jw);
  23406. }
  23407. }
  23408. }