GroupsController.cs 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Dm.util;
  7. using Humanizer;
  8. using Microsoft.AspNetCore.SignalR;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.UserModel;
  11. using NPOI.SS.Util;
  12. using NPOI.Util;
  13. using NPOI.XSSF.UserModel;
  14. using OASystem.API.Middlewares;
  15. using OASystem.API.OAMethodLib;
  16. using OASystem.API.OAMethodLib.APNs;
  17. using OASystem.API.OAMethodLib.DeepSeekAPI;
  18. using OASystem.API.OAMethodLib.File;
  19. using OASystem.API.OAMethodLib.Hub.HubClients;
  20. using OASystem.API.OAMethodLib.Hub.Hubs;
  21. using OASystem.API.OAMethodLib.JuHeAPI;
  22. using OASystem.API.OAMethodLib.KiMiApi;
  23. using OASystem.API.OAMethodLib.Logging;
  24. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  25. using OASystem.Domain.AesEncryption;
  26. using OASystem.Domain.Attributes;
  27. using OASystem.Domain.Dtos.CRM;
  28. using OASystem.Domain.Dtos.FileDto;
  29. using OASystem.Domain.Dtos.Financial;
  30. using OASystem.Domain.Dtos.Groups;
  31. using OASystem.Domain.Entities.Customer;
  32. using OASystem.Domain.Entities.Financial;
  33. using OASystem.Domain.Entities.Groups;
  34. using OASystem.Domain.ViewModels.CRM;
  35. using OASystem.Domain.ViewModels.Financial;
  36. using OASystem.Domain.ViewModels.Groups;
  37. using OASystem.Domain.ViewModels.OCR;
  38. using OASystem.Domain.ViewModels.SmallFun;
  39. using OASystem.Infrastructure.Repositories.CRM;
  40. using OASystem.Infrastructure.Repositories.Financial;
  41. using OASystem.Infrastructure.Repositories.Groups;
  42. using Quartz.Logging;
  43. using Quartz.Util;
  44. using SQLitePCL;
  45. using SqlSugar.Extensions;
  46. using System.Collections;
  47. using System.ComponentModel.DataAnnotations;
  48. using System.Data;
  49. using System.Diagnostics;
  50. using System.Globalization;
  51. using System.IO;
  52. using System.IO.Compression;
  53. using System.Linq.Expressions;
  54. using System.Text.Json;
  55. using System.Text.RegularExpressions;
  56. using System.Threading.Tasks;
  57. using System.Web;
  58. using static OASystem.API.OAMethodLib.JWTHelper;
  59. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  60. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  61. using Bookmark = Aspose.Words.Bookmark;
  62. using Cell = Aspose.Words.Tables.Cell;
  63. using Table = Aspose.Words.Tables.Table;
  64. namespace OASystem.API.Controllers
  65. {
  66. /// <summary>
  67. /// 团组相关
  68. /// </summary>
  69. //[Authorize]
  70. [Route("api/[controller]/[action]")]
  71. public class GroupsController : ControllerBase
  72. {
  73. private readonly ILogger<GroupsController> _logger;
  74. private readonly ITextFileLogger _eec_textLogger;
  75. private readonly IGroupTextFileLogger _groupTextLogger;
  76. private readonly GrpScheduleRepository _grpScheduleRep;
  77. private readonly IMapper _mapper;
  78. private readonly DelegationInfoRepository _groupRepository;
  79. private readonly TaskAssignmentRepository _taskAssignmentRep;
  80. private readonly AirTicketResRepository _airTicketResRep;
  81. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  82. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  83. private readonly DelegationEnDataRepository _delegationEnDataRep;
  84. private readonly DelegationVisaRepository _delegationVisaRep;
  85. private readonly VisaPriceRepository _visaPriceRep;
  86. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  87. private readonly HotelPriceRepository _hotelPriceRep;
  88. private readonly CustomersRepository _customersRep;
  89. private readonly MessageRepository _message;
  90. private readonly SqlSugarClient _sqlSugar;
  91. private readonly TourClientListRepository _tourClientListRep;
  92. private readonly TeamRateRepository _teamRateRep;
  93. #region 成本相关
  94. private readonly CheckBoxsRepository _checkBoxs;
  95. private readonly GroupCostRepository _GroupCostRepository;
  96. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  97. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  98. #endregion
  99. private readonly SetDataRepository _setDataRep;
  100. private string url;
  101. private string path;
  102. private readonly EnterExitCostRepository _enterExitCostRep;
  103. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  104. private readonly UsersRepository _usersRep;
  105. private readonly IJuHeApiService _juHeApi;
  106. private readonly InvertedListRepository _invertedListRep;
  107. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  108. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  109. private readonly ThreeCodeRepository _threeCodeRepository;
  110. private readonly HotelInquiryRepository _hotelInquiryRep;
  111. private readonly FeeAuditRepository _feeAuditRep;
  112. private readonly VisaCommissionRepository _visaCommissionRep;
  113. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  114. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  115. private readonly List<CurrencyInfo> _currencyInit;
  116. private readonly List<int> _portTypeData;
  117. private readonly TableOperationRecordRepository _tableorRep;
  118. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  119. private readonly RestaurantRepository _restaurantRep;
  120. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  121. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  122. private readonly VisaProcessRepository _visaProcessRep;
  123. private readonly ProcessOverviewRepository _processOverviewRep;
  124. private readonly IDeepSeekService _deepSeekService;
  125. /// <summary>
  126. /// 构造函数
  127. /// </summary>
  128. /// <param name="logger"></param>
  129. /// <param name="eec_textLogger"></param>
  130. /// <param name="groupTextLogger"></param>
  131. /// <param name="mapper"></param>
  132. /// <param name="hubContext"></param>
  133. /// <param name="sqlSugar"></param>
  134. /// <param name="grpScheduleRep"></param>
  135. /// <param name="groupRepository"></param>
  136. /// <param name="taskAssignmentRep"></param>
  137. /// <param name="airTicketResRep"></param>
  138. /// <param name="decreasePaymentsRep"></param>
  139. /// <param name="InvitationOfficialActivitiesRep"></param>
  140. /// <param name="delegationEnDataRep"></param>
  141. /// <param name="enterExitCostRep"></param>
  142. /// <param name="delegationVisaRep"></param>
  143. /// <param name="message"></param>
  144. /// <param name="visaPriceRep"></param>
  145. /// <param name="carTouristGuideGroundRep"></param>
  146. /// <param name="checkBoxs"></param>
  147. /// <param name="GroupCostRepository"></param>
  148. /// <param name="CostTypeHotelNumberRepository"></param>
  149. /// <param name="GroupCostParameterRepository"></param>
  150. /// <param name="hotelPriceRep"></param>
  151. /// <param name="customersRep"></param>
  152. /// <param name="setDataRep"></param>
  153. /// <param name="tourClientListRep"></param>
  154. /// <param name="teamRateRep"></param>
  155. /// <param name="usersRep"></param>
  156. /// <param name="juHeApi"></param>
  157. /// <param name="invertedListRep"></param>
  158. /// <param name="visaFeeInfoRep"></param>
  159. /// <param name="ticketBlackCodeRep"></param>
  160. /// <param name="hotelInquiryRep"></param>
  161. /// <param name="threeCodeRepository"></param>
  162. /// <param name="feeAuditRep"></param>
  163. /// <param name="visaCommissionRep"></param>
  164. /// <param name="ffrRep"></param>
  165. /// <param name="opinionaireRep"></param>
  166. /// <param name="tableorRep"></param>
  167. /// <param name="enterExitCostDraftRep"></param>
  168. /// <param name="restaurantRep"></param>
  169. /// <param name="enterExitCostQuoteRep"></param>
  170. /// <param name="grpOrderPreInfoRep"></param>
  171. /// <param name="visaProcessRep"></param>
  172. /// <param name="processOverviewRep"></param>
  173. public GroupsController(
  174. ILogger<GroupsController> logger,
  175. ITextFileLogger eec_textLogger,
  176. IGroupTextFileLogger groupTextLogger,
  177. IMapper mapper,
  178. IHubContext<ChatHub, IChatClient> hubContext,
  179. SqlSugarClient sqlSugar,
  180. GrpScheduleRepository grpScheduleRep,
  181. DelegationInfoRepository groupRepository,
  182. TaskAssignmentRepository taskAssignmentRep,
  183. AirTicketResRepository airTicketResRep,
  184. DecreasePaymentsRepository decreasePaymentsRep,
  185. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  186. DelegationEnDataRepository delegationEnDataRep,
  187. EnterExitCostRepository enterExitCostRep,
  188. DelegationVisaRepository delegationVisaRep,
  189. MessageRepository message,
  190. VisaPriceRepository visaPriceRep,
  191. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  192. CheckBoxsRepository checkBoxs,
  193. GroupCostRepository GroupCostRepository,
  194. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  195. GroupCostParameterRepository GroupCostParameterRepository,
  196. HotelPriceRepository hotelPriceRep,
  197. CustomersRepository customersRep,
  198. SetDataRepository setDataRep,
  199. TourClientListRepository tourClientListRep,
  200. TeamRateRepository teamRateRep,
  201. UsersRepository usersRep,
  202. IJuHeApiService juHeApi,
  203. InvertedListRepository invertedListRep,
  204. VisaFeeInfoRepository visaFeeInfoRep,
  205. TicketBlackCodeRepository ticketBlackCodeRep,
  206. HotelInquiryRepository hotelInquiryRep,
  207. ThreeCodeRepository threeCodeRepository,
  208. FeeAuditRepository feeAuditRep,
  209. VisaCommissionRepository visaCommissionRep,
  210. ForeignReceivablesRepository ffrRep,
  211. OpinionaireRepository opinionaireRep,
  212. TableOperationRecordRepository tableorRep,
  213. EnterExitCostDraftRepository enterExitCostDraftRep,
  214. RestaurantRepository restaurantRep,
  215. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  216. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  217. VisaProcessRepository visaProcessRep,
  218. ProcessOverviewRepository processOverviewRep
  219. )
  220. {
  221. _logger = logger;
  222. _eec_textLogger = eec_textLogger;
  223. _groupTextLogger = groupTextLogger;
  224. _mapper = mapper;
  225. _grpScheduleRep = grpScheduleRep;
  226. _groupRepository = groupRepository;
  227. _taskAssignmentRep = taskAssignmentRep;
  228. _airTicketResRep = airTicketResRep;
  229. _sqlSugar = sqlSugar;
  230. url = AppSettingsHelper.Get("ExcelBaseUrl");
  231. path = AppSettingsHelper.Get("ExcelBasePath");
  232. if (!System.IO.Directory.Exists(path))
  233. {
  234. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  235. }
  236. _decreasePaymentsRep = decreasePaymentsRep;
  237. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  238. _delegationEnDataRep = delegationEnDataRep;
  239. _enterExitCostRep = enterExitCostRep;
  240. _delegationVisaRep = delegationVisaRep;
  241. _message = message;
  242. _visaPriceRep = visaPriceRep;
  243. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  244. _checkBoxs = checkBoxs;
  245. _GroupCostRepository = GroupCostRepository;
  246. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  247. _GroupCostParameterRepository = GroupCostParameterRepository;
  248. _hotelPriceRep = hotelPriceRep;
  249. _customersRep = customersRep;
  250. _setDataRep = setDataRep;
  251. _tourClientListRep = tourClientListRep;
  252. _teamRateRep = teamRateRep;
  253. _hubContext = hubContext;
  254. _usersRep = usersRep;
  255. _juHeApi = juHeApi;
  256. _invertedListRep = invertedListRep;
  257. _visaFeeInfoRep = visaFeeInfoRep;
  258. _ticketBlackCodeRep = ticketBlackCodeRep;
  259. _hotelInquiryRep = hotelInquiryRep;
  260. _threeCodeRepository = threeCodeRepository;
  261. _feeAuditRep = feeAuditRep;
  262. _visaCommissionRep = visaCommissionRep;
  263. _ffrRep = ffrRep;
  264. _opinionaireRep = opinionaireRep;
  265. _currencyInit = new List<CurrencyInfo>()
  266. {
  267. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  268. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  269. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  270. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  271. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  272. };
  273. _portTypeData = new List<int>() { 2, 3 };
  274. _tableorRep = tableorRep;
  275. _enterExitCostDraftRep = enterExitCostDraftRep;
  276. _restaurantRep = restaurantRep;
  277. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  278. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  279. _visaProcessRep = visaProcessRep;
  280. _processOverviewRep = processOverviewRep;
  281. }
  282. #region 页面加载弹窗信息
  283. /// <summary>
  284. /// 提示用户录入团组费用信息
  285. /// 根据用户ID获取分配权限内团组名称
  286. /// </summary>
  287. /// <param name="currUSerId">用户Id</param>
  288. /// <param name="daysAgo">往前推的天数</param>
  289. /// <returns></returns>
  290. [HttpGet]
  291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  292. public async Task<IActionResult> GetGroupNamesByUserId(int currUSerId, int daysAgo = 5)
  293. {
  294. var stopwatch = Stopwatch.StartNew();
  295. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  296. .Where(x => x.Id == currUSerId && x.IsDel == 0)
  297. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  298. .FirstAsync();
  299. if (userInfo == null)
  300. {
  301. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  302. }
  303. var jobId = userInfo.JobPostId;
  304. //初始化岗位对应负责的数据类型
  305. /*
  306. * 岗位ID
  307. * 24 机票
  308. * 25 酒店
  309. * 26 签证
  310. * 27 商邀
  311. * 28 OP
  312. *
  313. * 费用类型ID
  314. * 76 酒店预订
  315. * 79 车/导游地接
  316. * 80 签证
  317. * 81 邀请/公务活动
  318. * 82 团组客户保险
  319. * 85 机票预订
  320. * 98 其他款项
  321. */
  322. Dictionary<int, List<int>> dataInit = new() {
  323. { 24, new List<int> { 85 } }, // 机票 -> 机票预订
  324. { 25, new List<int> { 76 } }, // 酒店 -> 酒店预订
  325. { 26, new List<int> { 80, 82 } }, // 签证 -> 签证, 团组客户保险
  326. { 27, new List<int> { 81 } }, // 地接专员 -> 邀请/公务活动
  327. { 28, new List<int> { 79 } } // 商邀 -> 车/导游地接
  328. };
  329. var feeTypeIds = new List<int>() { };
  330. if (dataInit.TryGetValue(jobId, out var values))
  331. {
  332. feeTypeIds = values;
  333. }
  334. /*
  335. * 获取今天时间往前推5天查询团组c表里有没有费用
  336. */
  337. var today_startDate = DateTime.Now.Date.AddDays(-daysAgo);
  338. var today_endDate = DateTime.Now.Date.AddDays(-daysAgo).AddDays(1).AddSeconds(-1);
  339. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  340. .Where(di => di.IsDel == 0)
  341. .Where(di => di.VisitDate >= today_startDate && di.VisitDate <= today_endDate)
  342. .Where(di => SqlFunc.Subqueryable<Grp_GroupsTaskAssignment>()
  343. .Where(gta => gta.DIId == di.Id && gta.IsDel == 0 && feeTypeIds.Contains(gta.CTId))
  344. .Any())
  345. .Where(di => !SqlFunc.Subqueryable<Grp_CreditCardPayment>()
  346. .Where(ccp => ccp.DIId == di.Id && ccp.IsDel == 0 && feeTypeIds.Contains(ccp.CTable))
  347. .Any())
  348. .Select(di => new
  349. {
  350. di.Id,
  351. di.TeamName,
  352. di.VisitDate
  353. })
  354. .OrderBy(di => di.VisitDate)
  355. .ToListAsync();
  356. stopwatch.Stop();
  357. return Ok(JsonView(true, $"操作成功!【耗时:{stopwatch.ElapsedMilliseconds}ms】", new
  358. {
  359. isTips = groupNames.Any(),
  360. groupNames = groupNames.Select(x => new { x.Id, GroupName = x.TeamName })
  361. }));
  362. }
  363. #endregion
  364. #region 流程管控
  365. /// <summary>
  366. /// 获取团组流程管控信息
  367. /// </summary>
  368. /// <param name="_jsonDto">查询参数</param>
  369. /// <returns></returns>
  370. [HttpPost]
  371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  372. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  373. {
  374. if (string.IsNullOrEmpty(_jsonDto.Paras))
  375. {
  376. return Ok(JsonView(false, "参数为空"));
  377. }
  378. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  379. if (_ScheduleDto != null)
  380. {
  381. if (_ScheduleDto.SearchType == 2)//获取列表
  382. {
  383. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  384. return Ok(JsonView(_grpScheduleViewList));
  385. }
  386. else//获取对象
  387. {
  388. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  389. if (_grpScheduleView != null)
  390. {
  391. return Ok(JsonView(_grpScheduleView));
  392. }
  393. }
  394. }
  395. else
  396. {
  397. return Ok(JsonView(false, "参数反序列化失败"));
  398. }
  399. return Ok(JsonView(false, "暂无数据!"));
  400. }
  401. /// <summary>
  402. /// 修改团组流程管控详细表数据
  403. /// </summary>
  404. /// <param name="dto"></param>
  405. /// <returns></returns>
  406. [HttpPost]
  407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  408. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  409. {
  410. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  411. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  412. .SetColumns(it => it.Duty == _detail.Duty)
  413. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  414. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  415. .SetColumns(it => it.JobContent == _detail.JobContent)
  416. .SetColumns(it => it.Remark == _detail.Remark)
  417. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  418. .Where(s => s.Id == dto.Id)
  419. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  420. .ExecuteCommandAsync();
  421. if (result > 0)
  422. {
  423. return Ok(JsonView(true, "保存成功!"));
  424. }
  425. return Ok(JsonView(false, "保存失败!"));
  426. }
  427. /// <summary>
  428. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  429. /// </summary>
  430. /// <param name="dto"></param>
  431. /// <returns></returns>
  432. [HttpPost]
  433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  434. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  435. {
  436. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  437. _detail.IsDel = 1;
  438. _detail.DeleteUserId = dto.Duty;
  439. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  440. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  441. .SetColumns(it => it.IsDel == _detail.IsDel)
  442. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  443. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  444. .Where(it => it.Id == dto.Id)
  445. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  446. //.WhereColumns(s => s.Id == dto.Id)
  447. .ExecuteCommandAsync();
  448. if (result > 0)
  449. {
  450. return Ok(JsonView(true, "删除成功!"));
  451. }
  452. return Ok(JsonView(false, "删除失败!"));
  453. }
  454. /// <summary>
  455. /// 增加团组流程管控详细表数据
  456. /// </summary>
  457. /// <param name="dto"></param>
  458. /// <returns></returns>
  459. [HttpPost]
  460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  461. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  462. {
  463. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  464. if (DateTime.Now < _detail.ExpectBeginDt)
  465. {
  466. _detail.StepStatus = 0;
  467. }
  468. else
  469. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  470. _detail.StepStatus = 1;
  471. }
  472. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  473. if (result > 0)
  474. {
  475. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  476. return Ok(JsonView(true, "添加成功!", _result));
  477. }
  478. return Ok(JsonView(false, "添加失败!"));
  479. }
  480. #endregion
  481. #region 团组前期信息
  482. /// <summary>
  483. /// 团组前期信息H5-URL(员工对应地址)
  484. /// </summary>
  485. /// <param name="name">用户名称</param>
  486. /// <returns></returns>
  487. [HttpGet]
  488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  489. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  490. {
  491. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  492. .Where(x => x.IsDel == 0)
  493. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  494. .OrderBy(x => x.Id)
  495. .Select(x => new
  496. {
  497. name = x.CnName,
  498. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  499. })
  500. .ToListAsync();
  501. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  502. }
  503. /// <summary>
  504. /// 团组前期信息 List
  505. /// </summary>
  506. /// <returns></returns>
  507. [HttpPost]
  508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  509. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  510. {
  511. var search = dto.Search;
  512. int[] nameTempIds = new int[] { 1, 12, 28 },
  513. countryTempIds = new int[] { 2, 13, 29 },
  514. daysTempIds = new int[] { 4, 15, 31 },
  515. ppNumTempIds = new int[] { 6 };
  516. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  517. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  518. .Where((opi, u) => opi.IsDel == 0)
  519. .OrderByDescending((opi, u) => opi.CreateTime)
  520. .Select((opi, u) => new GroupOrderPreInfoListView()
  521. {
  522. Id = opi.Id,
  523. Name = opi.Name,
  524. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  525. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  526. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  527. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  528. Operator = u.CnName,
  529. OperationTime = opi.CreateTime
  530. })
  531. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  532. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  533. .ToListAsync();
  534. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  535. int total = list.Count;
  536. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  537. var listPageData1 = listPageData
  538. .Skip((dto.PageIndex - 1) * dto.PageSize)
  539. .Take(dto.PageSize)
  540. .ToList();
  541. var infoIds = listPageData1.Select(x => x.Id).ToList();
  542. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  543. .Where(x => x.IsDel == 0 && x.STid == 109)
  544. .ToArrayAsync();
  545. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  546. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  547. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  548. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  549. .ToListAsync();
  550. foreach (var item in listPageData1)
  551. {
  552. var typeDatas1 = typeDatas.Select(x => new
  553. {
  554. x.Id,
  555. x.Name,
  556. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  557. }).ToArray();
  558. item.VersionDetails = typeDatas1;
  559. }
  560. return Ok(JsonView(listPageData1, listPageData1.Count));
  561. }
  562. /// <summary>
  563. /// 团组前期信息 Init
  564. /// </summary>
  565. /// <returns></returns>
  566. [HttpGet("{userId}")]
  567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  568. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  569. {
  570. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  571. }
  572. /// <summary>
  573. /// 国家数据源
  574. /// </summary>
  575. /// <param name="pageIndex">当前页码</param>
  576. /// <param name="pageSize">每页条数</param>
  577. /// <param name="search">查询条件</param>
  578. /// <returns></returns>
  579. [HttpGet]
  580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  581. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  582. {
  583. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  584. if (pageIndex == 0 && pageSize == 0)
  585. {
  586. //所有数据
  587. return Ok(JsonView(countrys, countrys.Count));
  588. }
  589. //分页
  590. int skip = (pageIndex - 1) * pageSize;
  591. int take = pageSize;
  592. if (!string.IsNullOrEmpty(search))
  593. {
  594. IEnumerable<char> charSequence = search.Select(c => c);
  595. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  596. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  597. return Ok(JsonView(pageData, pageResult1.Count));
  598. }
  599. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  600. return Ok(JsonView(pageResult2, countrys.Count));
  601. }
  602. /// <summary>
  603. /// 城市数据源
  604. /// </summary>
  605. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  606. /// <param name="pageIndex">当前页码</param>
  607. /// <param name="pageSize">每页条数</param>
  608. /// <param name="search">查询条件</param>
  609. /// <returns></returns>
  610. [HttpGet("{countryLabel}")]
  611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  612. public async Task<IActionResult> CityByCountry(
  613. string countryLabel,
  614. [FromQuery] int pageIndex,
  615. [FromQuery] int pageSize,
  616. [FromQuery] string search)
  617. {
  618. countryLabel = HttpUtility.UrlDecode(countryLabel);
  619. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  620. var citys = Array.Empty<string?>();
  621. if (countryList.Any())
  622. {
  623. var cityDatas = await _sqlSugar
  624. .Queryable<Grp_NationalTravelFee>()
  625. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  626. .ToArrayAsync();
  627. foreach (var item in cityDatas)
  628. {
  629. if (item.City.Contains("城市"))
  630. {
  631. item.City = item.Country + "-所有城市";
  632. }
  633. }
  634. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  635. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  636. }
  637. if (pageIndex == 0 && pageSize == 0)
  638. {
  639. //所有数据
  640. return Ok(JsonView(citys, citys?.Length ?? 0));
  641. }
  642. //分页
  643. int skip = (pageIndex - 1) * pageSize;
  644. int take = pageSize;
  645. if (!string.IsNullOrEmpty(search))
  646. {
  647. IEnumerable<char> charSequence = search.Select(c => c);
  648. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  649. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  650. return Ok(JsonView(pageData, pageResult1.Count));
  651. }
  652. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  653. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  654. }
  655. /// <summary>
  656. /// 团组前期信息 Info
  657. /// </summary>
  658. /// <param name="dto">Id</param>
  659. /// <returns></returns>
  660. [HttpGet("{Id}/{TempId}")]
  661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  662. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  663. {
  664. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  665. }
  666. /// <summary>
  667. /// 团组前期信息 移动端 Info
  668. /// </summary>
  669. /// <param name="dto">Id</param>
  670. /// <returns></returns>
  671. [HttpGet("{Id}/{TempId}")]
  672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  673. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  674. {
  675. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  676. }
  677. /// <summary>
  678. /// 团组前期信息 Save
  679. /// </summary>
  680. /// <param name="dto">Id</param>
  681. /// <returns></returns>
  682. [HttpPost]
  683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  684. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  685. {
  686. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  687. }
  688. /// <summary>
  689. /// 团组前期信息 Del
  690. /// </summary>
  691. /// <param name="dto">Id</param>
  692. /// <returns></returns>
  693. [HttpPost]
  694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  695. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  696. {
  697. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  698. }
  699. /// <summary>
  700. /// 团组前期信息 文件下载
  701. /// </summary>
  702. /// <param name="dto">Id</param>
  703. /// <returns></returns>
  704. [HttpGet("{Id}/{TempId}")]
  705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  706. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  707. {
  708. int id = dto.Id, tempId = dto.TempId;
  709. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  710. var data = view.Data as GrpOrderPreInfoView;
  711. #region Excel
  712. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  713. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  714. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  715. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  716. var fileNamePrefix = string.Empty;
  717. if (tempId == 1405)
  718. {
  719. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  720. fileNamePrefix = $"{data.Name}_无商邀版";
  721. }
  722. else if (tempId == 1406)
  723. {
  724. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  725. fileNamePrefix = $"{data.Name}_有商邀版";
  726. }
  727. else
  728. {
  729. //tempId == 1404 默认下载
  730. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  731. fileNamePrefix = $"{data.Name}_单接送机";
  732. }
  733. foreach (var item in data.Items)
  734. {
  735. var obj = item.NewValue;
  736. if (obj == null) item.OriginVal = "";
  737. else if (obj.Equals("有") || obj.Equals("无"))
  738. {
  739. item.OriginVal = obj.ToString();
  740. }
  741. else if (obj is object[] objArray)
  742. {
  743. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  744. item.OriginVal = string.Join("、", stringArray);
  745. }
  746. else if (obj is string[] stringArray)
  747. {
  748. item.OriginVal = string.Join("、", stringArray);
  749. }
  750. else if (obj.Equals("-"))
  751. {
  752. item.OriginVal = "";
  753. }
  754. }
  755. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  756. fileName = CommonFun.ValidFileName(fileName);
  757. //载入模板
  758. var designer = new WorkbookDesigner
  759. {
  760. Workbook = new Workbook(tempPath)
  761. };
  762. if (tempId == 1406)
  763. {
  764. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  765. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  766. for (int i = 1; i <= view2.Length; i++)
  767. {
  768. view2[i - 1].Index = i;
  769. }
  770. designer.SetDataSource("View1", view1);
  771. designer.SetDataSource("View2", view2);
  772. }
  773. else
  774. {
  775. designer.SetDataSource("View", data.Items);
  776. }
  777. designer.Process();
  778. if (!Directory.Exists(savePath))
  779. {
  780. Directory.CreateDirectory(savePath);
  781. }
  782. string serverPath = $"{savePath}{fileName}";
  783. designer.Workbook.Save(serverPath);
  784. string rst = $"{servicePath}{ftpPath}{fileName}";
  785. #endregion
  786. return Ok(JsonView(new { url = rst }));
  787. }
  788. #endregion
  789. #region 团组基本信息
  790. /// <summary>
  791. /// 接团信息列表
  792. /// </summary>
  793. /// <param name="dto">团组列表请求dto</param>
  794. /// <returns></returns>
  795. [HttpPost]
  796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  797. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  798. {
  799. var groupData = await _groupRepository.GetGroupList(dto);
  800. if (groupData.Code != 0)
  801. {
  802. return Ok(JsonView(false, groupData.Msg));
  803. }
  804. return Ok(JsonView(groupData.Data));
  805. }
  806. /// <summary>
  807. /// 分页查询团组列表
  808. /// </summary>
  809. /// <param name="dto"></param>
  810. /// <returns></returns>
  811. [HttpPost]
  812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  813. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  814. {
  815. var watch = new Stopwatch();
  816. watch.Start();
  817. RefAsync<int> total = 0;
  818. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  819. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  820. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  821. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  822. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  823. .Distinct()
  824. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  825. watch.Stop();
  826. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  827. }
  828. /// <summary>
  829. /// 接团信息列表 Page Init
  830. /// </summary>
  831. /// <returns></returns>
  832. [HttpPost]
  833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  834. public async Task<IActionResult> PostGroupPageListInit()
  835. {
  836. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  837. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  838. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  839. var _view = new
  840. {
  841. depData = depDatas,
  842. rankData = rankDatas
  843. };
  844. return Ok(JsonView(true, "查询成功!", _view));
  845. }
  846. /// <summary>
  847. /// 接团信息列表 Page
  848. /// </summary>
  849. /// <param name="dto">团组列表请求dto</param>
  850. /// <returns></returns>
  851. [HttpPost]
  852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  853. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  854. {
  855. #region 参数验证
  856. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  857. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  858. #region 页面操作权限验证
  859. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  860. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  861. #endregion
  862. #endregion
  863. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  864. {
  865. string sqlWhere = string.Empty;
  866. if (dto.IsSure == 0) //未完成
  867. {
  868. sqlWhere += string.Format(@" And IsSure = 0");
  869. }
  870. else if (dto.IsSure == 1) //已完成
  871. {
  872. sqlWhere += string.Format(@" And IsSure = 1");
  873. }
  874. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  875. {
  876. string tj = dto.SearchCriteria;
  877. 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}%')",
  878. tj, tj, tj, tj, tj);
  879. }
  880. if (int.TryParse(dto.Rank, out int rankId))
  881. {
  882. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  883. }
  884. string sqlWhere1 = string.Empty;
  885. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  886. {
  887. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  888. }
  889. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  890. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  891. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  892. JietuanOperator,IsSure,CreateTime,IsBid,Step
  893. From (
  894. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  895. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  896. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  897. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,gdi.Step,
  898. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  899. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  900. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  901. From Grp_DelegationInfo gdi
  902. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  903. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  904. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  905. Where gdi.IsDel = 0 {0}
  906. ) temp {1}", sqlWhere, sqlWhere1);
  907. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  908. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  909. //处理 团组模块实际操作人
  910. _DelegationList.ForEach(async x =>
  911. {
  912. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  913. var operatorNames = new StringBuilder();
  914. //operatorNames.AppendLine("各模块实际操作人:");
  915. if (operators.Any())
  916. {
  917. operators.ForEach(y =>
  918. {
  919. string label = string.Empty;
  920. if (y.OperationUsers.Any())
  921. {
  922. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  923. label = string.Join('、', users);
  924. }
  925. else label = "暂未指定";
  926. operatorNames.AppendLine($"{y.CTableName}:{label}");
  927. operatorNames.AppendLine();
  928. });
  929. }
  930. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  931. });
  932. var _view = new
  933. {
  934. PageFuncAuth = pageFunAuthView,
  935. Data = _DelegationList
  936. };
  937. return Ok(JsonView(true, "查询成功!", _view, total));
  938. }
  939. else
  940. {
  941. return Ok(JsonView(false, "查询失败"));
  942. }
  943. }
  944. /// <summary>
  945. /// 团组列表
  946. /// </summary>
  947. /// <returns></returns>
  948. [HttpPost]
  949. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  950. {
  951. #region 参数验证
  952. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  953. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  954. #region 页面操作权限验证
  955. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  956. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  957. #endregion
  958. #endregion
  959. if (dto.PortType != 1 && dto.PortType != 2)
  960. {
  961. return Ok(JsonView(false, "查询失败!"));
  962. }
  963. string orderbyStr = "order by gdi.CreateTime Desc";
  964. string sqlWhere = string.Empty;
  965. if (dto.IsSure == 0) //未完成
  966. {
  967. sqlWhere += string.Format(@" And IsSure = 0");
  968. }
  969. else if (dto.IsSure == 1) //已完成
  970. {
  971. sqlWhere += string.Format(@" And IsSure = 1");
  972. }
  973. //团组类型
  974. if (dto.TeamDid > 0)
  975. {
  976. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  977. }
  978. //团组名称
  979. if (!string.IsNullOrEmpty(dto.TeamName))
  980. {
  981. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  982. }
  983. //客户名称
  984. if (!string.IsNullOrEmpty(dto.ClientName))
  985. {
  986. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  987. }
  988. //客户单位
  989. if (!string.IsNullOrEmpty(dto.ClientUnit))
  990. {
  991. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  992. }
  993. //出访时间
  994. if (!string.IsNullOrEmpty(dto.visitDataTime))
  995. {
  996. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  997. orderbyStr = "order by gdi.VisitDate";
  998. }
  999. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1000. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  1001. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  1002. JietuanOperator,IsSure,CreateTime
  1003. From (
  1004. Select row_number() over({0}) as Row_Number,
  1005. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  1006. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  1007. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  1008. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1009. From Grp_DelegationInfo gdi
  1010. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1011. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1012. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1013. Where gdi.IsDel = 0 {1}
  1014. ) temp ", orderbyStr, sqlWhere);
  1015. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1016. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  1017. #region 处理所属部门
  1018. /*
  1019. * 1.sq 和 gyy 等显示 市场部
  1020. * 2.王鸽和主管及张总还有管理员号统一国交部
  1021. * 2-1. 4 管理员 ,21 张海麟
  1022. */
  1023. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  1024. var userIds1 = new List<int>() { 4, 21 };
  1025. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  1026. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1027. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1028. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1029. .ToList();
  1030. foreach (var item in _DelegationList)
  1031. {
  1032. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1033. }
  1034. #endregion
  1035. var _view = new
  1036. {
  1037. PageFuncAuth = pageFunAuthView,
  1038. Data = _DelegationList
  1039. };
  1040. return Ok(JsonView(true, "查询成功!", _view, total));
  1041. }
  1042. /// <summary>
  1043. /// 接团信息详情
  1044. /// </summary>
  1045. /// <param name="dto">团组info请求dto</param>
  1046. /// <returns></returns>
  1047. [HttpPost]
  1048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1049. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  1050. {
  1051. var groupData = await _groupRepository.GetGroupInfo(dto);
  1052. if (groupData.Code != 0)
  1053. {
  1054. return Ok(JsonView(false, groupData.Msg));
  1055. }
  1056. return Ok(JsonView(groupData.Data));
  1057. }
  1058. /// <summary>
  1059. /// 接团信息 编辑添加
  1060. /// 基础信息数据源
  1061. /// </summary>
  1062. /// <param name="dto"></param>
  1063. /// <returns></returns>
  1064. [HttpPost]
  1065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1066. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  1067. {
  1068. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  1069. if (groupData.Code != 0)
  1070. {
  1071. return Ok(JsonView(false, groupData.Msg));
  1072. }
  1073. return Ok(JsonView(groupData.Data));
  1074. }
  1075. /// <summary>
  1076. /// 成本修改团组信息
  1077. /// </summary>
  1078. /// <param name="dto"></param>
  1079. /// <returns></returns>
  1080. [HttpPost]
  1081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1082. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  1083. {
  1084. var jw = JsonView(false, "操作失败");
  1085. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  1086. if (di == null)
  1087. {
  1088. jw.Msg = "参数有误!";
  1089. return Ok(jw);
  1090. }
  1091. #region 添加出访起止时间
  1092. var startTime = new DateTime();
  1093. var endTime = new DateTime();
  1094. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1095. {
  1096. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1097. }
  1098. else
  1099. {
  1100. jw.Msg = "参数有误!";
  1101. return Ok(jw);
  1102. }
  1103. #endregion
  1104. di.VisitDate = startTime;
  1105. di.VisitPNumber = dto.VisitPNumber;
  1106. di.VisitDays = dto.VisitDays;
  1107. di.VisitStartDate = startTime;
  1108. di.VisitEndDate = endTime;
  1109. var count = _sqlSugar.Updateable(di)
  1110. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1111. .ExecuteCommand();
  1112. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1113. }
  1114. /// <summary>
  1115. /// 接团信息 编辑添加
  1116. /// 省份-城市 基础信息数据源
  1117. /// </summary>
  1118. /// <param name="dto"></param>
  1119. /// <returns></returns>
  1120. [HttpPost]
  1121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1122. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1123. {
  1124. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1125. string search = dto.Search;
  1126. var data = await _groupRepository.CityBasicSource();
  1127. int total = data.Length;
  1128. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1129. .Skip((pageIndex - 1) * pageSize)
  1130. .Take(pageSize)
  1131. .ToArray();
  1132. return Ok(JsonView(data, total));
  1133. }
  1134. /// <summary>
  1135. /// 接团信息 操作(增改)
  1136. /// </summary>
  1137. /// <param name="dto"></param>
  1138. /// <returns></returns>
  1139. [HttpPost]
  1140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1141. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1142. {
  1143. // 创建 Stopwatch 实例
  1144. Stopwatch stopwatch = Stopwatch.StartNew();
  1145. decimal ffrPrice = 0.00M;
  1146. DateTime? visitDt = null;
  1147. if (dto.Status == 2)
  1148. {
  1149. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1150. if (groupInfo != null)
  1151. {
  1152. ffrPrice = groupInfo.PaymentMoney;
  1153. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1154. }
  1155. }
  1156. var groupData = await _groupRepository.GroupOperation(dto);
  1157. if (groupData.Code != 0)
  1158. {
  1159. return Ok(JsonView(false, groupData.Msg));
  1160. }
  1161. int diId = 0;
  1162. try
  1163. {
  1164. //添加时 默认加入团组汇率
  1165. if (dto.Status == 1) //添加
  1166. {
  1167. diId = groupData.Data;
  1168. //添加默认币种
  1169. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1170. //默认分配权限
  1171. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1172. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1173. var _managerIds = new List<int>() { 22, 32, 21 };
  1174. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1175. if (userIds.Count > 0)
  1176. {
  1177. userIds.Add(208);
  1178. //创建团组管控
  1179. GroupStepForDelegation.CreateWorkStep(diId);
  1180. //发送消息
  1181. string groupName = dto.TeamName;
  1182. string createGroupUser = string.Empty;
  1183. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1184. if (userInfo != null) createGroupUser = userInfo.CnName;
  1185. string title = $"系统通知";
  1186. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1187. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1188. }
  1189. //默认创建倒推表
  1190. await _invertedListRep._Create(dto.UserId, diId);
  1191. //默认创建签证流程
  1192. await _visaProcessRep.Create(dto.UserId, diId);
  1193. //默认创建团组流程总览信息
  1194. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1195. }
  1196. else if (dto.Status == 2)
  1197. {
  1198. diId = dto.Id;
  1199. }
  1200. #region 签证人员团组时间通知
  1201. #region 计算出访起止时间
  1202. var startTime = new DateTime();
  1203. var endTime = new DateTime();
  1204. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1205. {
  1206. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1207. }
  1208. #endregion
  1209. #endregion
  1210. #region 团组操作默认添加/修改收款账单
  1211. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1212. {
  1213. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1214. .Where(x => x.IsDel == 0 &&
  1215. x.Diid == diId &&
  1216. x.Remark.Equals("预付款")
  1217. )
  1218. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1219. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1220. .FirstAsync();
  1221. ffrInfo = new Fin_ForeignReceivables()
  1222. {
  1223. Diid = diId,
  1224. PriceName = dto.ClientUnit,
  1225. Price = dto.PaymentMoney,
  1226. Count = 1,
  1227. Unit = $"元",
  1228. ItemSumPrice = dto.PaymentMoney,
  1229. Rate = 1.0000M,
  1230. Currency = 836,
  1231. AddingWay = 0,
  1232. CreateUserId = dto.UserId,
  1233. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1234. Remark = $"预付款"
  1235. };
  1236. if (ffrInfo == null) //Add
  1237. {
  1238. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1239. }
  1240. else //修改
  1241. {
  1242. await _sqlSugar.Updateable(ffrInfo)
  1243. .UpdateColumns(x => new
  1244. {
  1245. x.PriceName,
  1246. x.Price,
  1247. x.ItemSumPrice,
  1248. x.CreateTime,
  1249. x.CreateUserId
  1250. })
  1251. .WhereColumns(x => x.Id)
  1252. .ExecuteCommandAsync();
  1253. }
  1254. }
  1255. #endregion
  1256. if (diId > 0)
  1257. {
  1258. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1259. }
  1260. // 停止计时
  1261. stopwatch.Stop();
  1262. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1263. }
  1264. catch (Exception ex)
  1265. {
  1266. // 停止计时
  1267. stopwatch.Stop();
  1268. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1269. Logs(ex.Message);
  1270. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1271. }
  1272. // 停止计时
  1273. stopwatch.Stop();
  1274. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1275. }
  1276. /// <summary>
  1277. /// 接团流程操作(增改)
  1278. /// 安卓端使用 建团时添加客户名单
  1279. /// </summary>
  1280. /// <param name="dto"></param>
  1281. /// <returns></returns>
  1282. [HttpPost]
  1283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1284. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1285. {
  1286. #region 参数验证
  1287. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1288. #region 页面操作权限验证
  1289. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1290. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1291. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1292. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1293. #endregion
  1294. #endregion
  1295. try
  1296. {
  1297. //_sqlSugar.BeginTran();
  1298. decimal ffrPrice = 0.00M;
  1299. DateTime? visitDt = null;
  1300. if (dto.Status == 2)
  1301. {
  1302. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1303. if (groupInfo != null)
  1304. {
  1305. ffrPrice = groupInfo.PaymentMoney;
  1306. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1307. }
  1308. }
  1309. var _dto = new GroupOperationDto();
  1310. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1311. var groupData = await _groupRepository.GroupOperation(_dto);
  1312. if (groupData.Code != 0)
  1313. {
  1314. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1315. }
  1316. int diId = 0;
  1317. //添加时 默认加入团组汇率
  1318. if (dto.Status == 1) //添加
  1319. {
  1320. diId = groupData.Data;
  1321. //添加默认币种
  1322. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1323. //默认分配权限
  1324. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1325. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1326. var _managerIds = new List<int>() { 21, 22, 32 };
  1327. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1328. if (userIds.Count > 0)
  1329. {
  1330. userIds.Add(208);
  1331. //创建团组管控
  1332. GroupStepForDelegation.CreateWorkStep(diId);
  1333. //发送消息
  1334. string groupName = dto.TeamName;
  1335. string createGroupUser = string.Empty;
  1336. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1337. if (userInfo != null) createGroupUser = userInfo.CnName;
  1338. string title = $"系统通知";
  1339. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1340. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1341. }
  1342. #region 应用推送
  1343. try
  1344. {
  1345. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1346. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1347. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1348. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1349. {
  1350. var userList = new List<string>() { users.QiyeChatUserId };
  1351. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1352. }
  1353. }
  1354. catch (Exception ex)
  1355. {
  1356. }
  1357. #endregion
  1358. //默认创建倒推表
  1359. await _invertedListRep._Create(dto.UserId, diId);
  1360. //默认创建签证流程
  1361. await _visaProcessRep.Create(dto.UserId, diId);
  1362. //默认创建团组流程总览信息
  1363. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1364. }
  1365. if (dto.Status == 2)
  1366. {
  1367. diId = dto.Id;
  1368. if (diId == 0)
  1369. {
  1370. //_sqlSugar.RollbackTran();
  1371. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1372. }
  1373. }
  1374. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1375. if (viewData.Code != 0)
  1376. {
  1377. //_sqlSugar.RollbackTran();
  1378. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1379. }
  1380. #region 团组操作默认添加/修改收款账单
  1381. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1382. {
  1383. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1384. .Where(x => x.IsDel == 0 &&
  1385. x.Diid == diId &&
  1386. x.Remark.Equals("预付款")
  1387. )
  1388. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1389. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1390. .FirstAsync();
  1391. ffrInfo = new Fin_ForeignReceivables()
  1392. {
  1393. Diid = diId,
  1394. PriceName = dto.ClientUnit,
  1395. Price = dto.PaymentMoney,
  1396. Count = 1,
  1397. Unit = $"元",
  1398. ItemSumPrice = dto.PaymentMoney,
  1399. Rate = 1.0000M,
  1400. Currency = 836,
  1401. AddingWay = 0,
  1402. CreateUserId = dto.UserId,
  1403. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1404. Remark = $"预付款"
  1405. };
  1406. if (ffrInfo == null) //Add
  1407. {
  1408. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1409. }
  1410. else //修改
  1411. {
  1412. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1413. .UpdateColumns(x => new
  1414. {
  1415. x.PriceName,
  1416. x.Price,
  1417. x.ItemSumPrice,
  1418. x.CreateTime,
  1419. x.CreateUserId
  1420. })
  1421. .WhereColumns(x => x.Id)
  1422. .ExecuteCommandAsync();
  1423. }
  1424. }
  1425. #endregion
  1426. #region 签证人员团组时间通知
  1427. #region 计算出访起止时间
  1428. var startTime = new DateTime();
  1429. var endTime = new DateTime();
  1430. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1431. {
  1432. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1433. }
  1434. #endregion
  1435. if (diId > 0)
  1436. {
  1437. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1438. }
  1439. #endregion
  1440. //_sqlSugar.CommitTran();
  1441. return Ok(JsonView(true, "添加成功"));
  1442. }
  1443. catch (Exception ex)
  1444. {
  1445. _sqlSugar.RollbackTran();
  1446. return Ok(JsonView(false, ex.Message));
  1447. }
  1448. }
  1449. /// <summary>
  1450. /// 接团流程操作(增改)
  1451. /// 安卓端使用 建团时添加客户名单
  1452. /// </summary>
  1453. /// <param name="dto"></param>
  1454. /// <returns></returns>
  1455. [HttpPost]
  1456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1457. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1458. {
  1459. #region 参数验证
  1460. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1461. #region 页面操作权限验证
  1462. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1463. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1464. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1465. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1466. #endregion
  1467. #endregion
  1468. _sqlSugar.BeginTran();
  1469. decimal ffrPrice = 0.00M;
  1470. DateTime? visitDt = null;
  1471. if (dto.Status == 2)
  1472. {
  1473. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1474. if (groupInfo != null)
  1475. {
  1476. ffrPrice = groupInfo.PaymentMoney;
  1477. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1478. }
  1479. }
  1480. var _dto = new GroupOperationDto();
  1481. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1482. var groupData = await _groupRepository.GroupOperation(_dto);
  1483. if (groupData.Code != 0)
  1484. {
  1485. _sqlSugar.RollbackTran();
  1486. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1487. }
  1488. try
  1489. {
  1490. int diId = 0;
  1491. //添加时 默认加入团组汇率
  1492. if (dto.Status == 1) //添加
  1493. {
  1494. diId = groupData.Data;
  1495. //添加默认币种
  1496. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1497. //默认分配权限
  1498. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1499. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1500. var _managerIds = new List<int>() { 21, 22, 32 };
  1501. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1502. if (userIds.Count > 0)
  1503. {
  1504. userIds.Add(208);
  1505. //创建团组管控
  1506. GroupStepForDelegation.CreateWorkStep(diId);
  1507. //发送消息
  1508. string groupName = dto.TeamName;
  1509. string createGroupUser = string.Empty;
  1510. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1511. if (userInfo != null) createGroupUser = userInfo.CnName;
  1512. string title = $"系统通知";
  1513. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1514. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1515. }
  1516. #region 应用推送
  1517. try
  1518. {
  1519. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1520. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1521. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1522. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1523. {
  1524. var userList = new List<string>() { users.QiyeChatUserId };
  1525. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1526. }
  1527. }
  1528. catch (Exception ex)
  1529. {
  1530. _sqlSugar.CommitTran();
  1531. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1532. }
  1533. #endregion
  1534. //默认创建倒推表
  1535. await _invertedListRep._Create(dto.UserId, diId);
  1536. }
  1537. else if (dto.Status == 2)
  1538. {
  1539. diId = dto.Id;
  1540. if (diId == 0)
  1541. {
  1542. _sqlSugar.RollbackTran();
  1543. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1544. }
  1545. }
  1546. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1547. if (viewData.Code != 0)
  1548. {
  1549. _sqlSugar.RollbackTran();
  1550. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1551. }
  1552. #region 团组操作默认添加/修改收款账单
  1553. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1554. {
  1555. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1556. .Where(x => x.IsDel == 0 &&
  1557. x.Diid == diId &&
  1558. x.Remark.Equals("预付款")
  1559. )
  1560. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1561. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1562. .FirstAsync();
  1563. ffrInfo = new Fin_ForeignReceivables()
  1564. {
  1565. Diid = diId,
  1566. PriceName = dto.ClientUnit,
  1567. Price = dto.PaymentMoney,
  1568. Count = 1,
  1569. Unit = $"元",
  1570. ItemSumPrice = dto.PaymentMoney,
  1571. Rate = 1.0000M,
  1572. Currency = 836,
  1573. AddingWay = 0,
  1574. CreateUserId = dto.UserId,
  1575. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1576. Remark = $"预付款"
  1577. };
  1578. if (ffrInfo == null) //Add
  1579. {
  1580. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1581. }
  1582. else //修改
  1583. {
  1584. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1585. .UpdateColumns(x => new
  1586. {
  1587. x.PriceName,
  1588. x.Price,
  1589. x.ItemSumPrice,
  1590. x.CreateTime,
  1591. x.CreateUserId
  1592. })
  1593. .WhereColumns(x => x.Id)
  1594. .ExecuteCommandAsync();
  1595. }
  1596. }
  1597. #endregion
  1598. #region 签证人员团组时间通知
  1599. #region 计算出访起止时间
  1600. var startTime = new DateTime();
  1601. var endTime = new DateTime();
  1602. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1603. {
  1604. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1605. }
  1606. #endregion
  1607. if (diId > 0)
  1608. {
  1609. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1610. }
  1611. #endregion
  1612. _sqlSugar.CommitTran();
  1613. return Ok(JsonView(true));
  1614. }
  1615. catch (Exception ex)
  1616. {
  1617. _sqlSugar.RollbackTran();
  1618. return Ok(JsonView(false, ex.Message));
  1619. }
  1620. }
  1621. /// <summary>
  1622. /// 接团信息 操作(删除)
  1623. /// </summary>
  1624. /// <param name="dto"></param>
  1625. /// <returns></returns>
  1626. [HttpPost]
  1627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1628. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1629. {
  1630. var diId = dto.Id;
  1631. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1632. #region 删除 验证
  1633. /*
  1634. * 1、收款账单数据:0 条
  1635. * 2、收款退还数据:0 条
  1636. * 3、机票费用数据:0 条
  1637. * 4、签证费用数据:0 条
  1638. * 5、保险费用数据:0 条
  1639. * 6、酒店费用数据:0 条
  1640. * 7、公务出访数据:1 条
  1641. * 8、邀请公务活动费用数据:1 条
  1642. * 9、OP费用数据:5 条
  1643. * 10、其他费用数据:0 条
  1644. * 11、团组日付报销费用数据:0 条
  1645. *
  1646. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1647. */
  1648. //收款账单
  1649. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1650. //收款退还
  1651. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1652. //机票费用
  1653. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1654. //签证费用
  1655. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1656. //保险费用
  1657. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1658. //酒店费用
  1659. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1660. //公务出访
  1661. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1662. //邀请公务活动费用
  1663. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1664. //OP费用
  1665. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1666. //其他费用
  1667. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1668. //团组日付报销费用
  1669. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1670. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1671. if (feeCount > 0)
  1672. {
  1673. var delMsgTips = new StringBuilder();
  1674. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1675. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1676. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1677. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1678. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1679. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1680. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1681. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1682. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1683. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1684. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1685. delMsgTips.AppendLine($"");
  1686. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1687. return Ok(JsonView(false, delMsgTips.ToString()));
  1688. }
  1689. #endregion
  1690. var groupData = await _groupRepository.GroupDel(dto);
  1691. if (groupData.Code != 0)
  1692. {
  1693. return Ok(JsonView(false, groupData.Msg));
  1694. }
  1695. return Ok(JsonView(true));
  1696. }
  1697. /// <summary>
  1698. /// 获取团组销售报价号
  1699. /// 团组添加时 使用
  1700. /// </summary>
  1701. /// <returns></returns>
  1702. [HttpPost]
  1703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1704. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1705. {
  1706. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1707. if (groupData.Code != 0)
  1708. {
  1709. return Ok(JsonView(false, groupData.Msg));
  1710. }
  1711. object salesQuoteNo = new
  1712. {
  1713. SalesQuoteNo = groupData.Data
  1714. };
  1715. return Ok(JsonView(salesQuoteNo));
  1716. }
  1717. /// <summary>
  1718. /// 设置确认出团
  1719. /// </summary>
  1720. /// <param name="dto"></param>
  1721. /// <returns></returns>
  1722. [HttpPost]
  1723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1724. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1725. {
  1726. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1727. if (groupData.Code != 0)
  1728. {
  1729. return Ok(JsonView(false, groupData.Msg));
  1730. }
  1731. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1732. #region OA消息推送
  1733. try
  1734. {
  1735. string groupName = groupInfo.TeamName;
  1736. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1737. string title = $"系统通知";
  1738. string content = $"团组[{groupName}]已确认出团!";
  1739. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1740. }
  1741. catch (Exception ex)
  1742. {
  1743. }
  1744. #endregion
  1745. #region 应用推送
  1746. try
  1747. {
  1748. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1749. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1750. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1751. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1752. {
  1753. var userList = new List<string>() { users.QiyeChatUserId };
  1754. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1755. }
  1756. }
  1757. catch (Exception ex)
  1758. {
  1759. }
  1760. #endregion
  1761. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1762. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1763. }
  1764. /// <summary>
  1765. /// 获取团组名称data And 签证国别Data
  1766. /// </summary>
  1767. /// <param name="dto"></param>
  1768. /// <returns></returns>
  1769. [HttpPost]
  1770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1771. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1772. {
  1773. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1774. if (groupData.Code != 0)
  1775. {
  1776. return Ok(JsonView(false, groupData.Msg));
  1777. }
  1778. return Ok(JsonView(groupData.Data));
  1779. }
  1780. /// <summary>
  1781. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1782. /// </summary>
  1783. /// <returns></returns>
  1784. [HttpPost]
  1785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1786. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1787. {
  1788. try
  1789. {
  1790. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1791. if (groupData.Code != 0)
  1792. {
  1793. return Ok(JsonView(false, groupData.Msg));
  1794. }
  1795. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1796. }
  1797. catch (Exception ex)
  1798. {
  1799. return Ok(JsonView(false, ex.Message));
  1800. throw;
  1801. }
  1802. }
  1803. /// <summary>
  1804. /// 团组清单 Excel
  1805. /// </summary>
  1806. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1807. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1808. /// <returns></returns>
  1809. [HttpGet]
  1810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1811. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1812. {
  1813. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1814. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1815. if (!beginBool && !endBool)
  1816. {
  1817. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1818. }
  1819. string sql = string.Format(@"
  1820. SELECT
  1821. ROW_NUMBER,
  1822. Id,
  1823. SalesQuoteNo,
  1824. TourCode,
  1825. TeamTypeId,
  1826. TeamType,
  1827. TeamLevId,
  1828. TeamLev,
  1829. TeamName,
  1830. ClientName,
  1831. ClientUnit,
  1832. VisitDate,
  1833. VisitDays,
  1834. VisitPNumber,
  1835. JietuanOperatorId,
  1836. JietuanOperator,
  1837. IsSure,
  1838. CreateUserName,
  1839. IsBid
  1840. FROM
  1841. (
  1842. SELECT
  1843. ROW_NUMBER() OVER(
  1844. ORDER BY
  1845. gdi.VisitDate Desc
  1846. ) AS ROW_NUMBER,
  1847. gdi.Id,
  1848. SalesQuoteNo,
  1849. TourCode,
  1850. ssd.Id TeamTypeId,
  1851. ssd.Name TeamType,
  1852. ssd1.Id TeamLevId,
  1853. ssd1.Name TeamLev,
  1854. TeamName,
  1855. ClientName,
  1856. ClientUnit,
  1857. VisitDate,
  1858. VisitDays,
  1859. VisitPNumber,
  1860. JietuanOperator JietuanOperatorId,
  1861. su.CnName JietuanOperator,
  1862. IsSure,
  1863. gdi.CreateTime,
  1864. su1.CnName As CreateUserName,
  1865. gdi.IsBid
  1866. FROM
  1867. Grp_DelegationInfo gdi
  1868. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1869. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1870. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1871. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1872. WHERE
  1873. gdi.IsDel = 0
  1874. AND gdi.IsBid = 0
  1875. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1876. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1877. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1878. #region 处理所属部门
  1879. /*
  1880. * 1.sq 和 gyy 等显示 市场部
  1881. * 2.王鸽和主管及张总还有管理员号统一国交部
  1882. * 2-1. 4 管理员 ,21 张海麟
  1883. */
  1884. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1885. var userIds1 = new List<int>() { 4, 21 };
  1886. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1887. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1888. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1889. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1890. .ToListAsync();
  1891. var droupIds = groupList.Select(it => it.Id).ToList();
  1892. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1893. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1894. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1895. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1896. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1897. {
  1898. DiId = tcl.DiId,
  1899. LastName = dc.LastName,
  1900. FirstName = dc.FirstName,
  1901. Sex = dc.Sex,
  1902. Birthday = dc.BirthDay,
  1903. Company = cc.CompanyFullName,
  1904. Job = dc.Job,
  1905. CreateTime = tcl.CreateTime,
  1906. })
  1907. .ToList();
  1908. foreach (var item in groupList)
  1909. {
  1910. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1911. string groupFirstName = "";
  1912. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1913. if (currDatas.Any())
  1914. {
  1915. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1916. }
  1917. item.GroupFirst = groupFirstName;
  1918. }
  1919. #endregion
  1920. #region Excel
  1921. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1922. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1923. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1924. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1925. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1926. //载入模板
  1927. var designer = new WorkbookDesigner
  1928. {
  1929. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1930. };
  1931. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1932. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1933. dt.TableName = "GroupList";
  1934. designer.SetDataSource(dt);
  1935. designer.Process();
  1936. if (!Directory.Exists(savePath))
  1937. {
  1938. Directory.CreateDirectory(savePath);
  1939. }
  1940. string serverPath = $"{savePath}{fileName}";
  1941. designer.Workbook.Save(serverPath);
  1942. string rst = $"{servicePath}{ftpPath}{fileName}";
  1943. #endregion
  1944. return Ok(JsonView(true, "操作成功!", rst));
  1945. }
  1946. /// <summary>
  1947. /// 团组合同下载(1.付款80% 2.付全款)
  1948. /// </summary>
  1949. /// <param name="dto"></param>
  1950. /// <returns></returns>
  1951. /// <exception cref="Exception"></exception>
  1952. [HttpPost]
  1953. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1954. {
  1955. var jw = JsonView(false);
  1956. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1957. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1958. if (di == null)
  1959. {
  1960. jw.Msg = "团组Id有误!";
  1961. return Ok(jw);
  1962. }
  1963. #region 权限校验
  1964. var allDownFile = new List<int>() { 21 };
  1965. try
  1966. {
  1967. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1968. .First(x => x.Id == 1418 && x.IsDel == 0);
  1969. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1970. }
  1971. catch (Exception)
  1972. { }
  1973. var guojiaoDownFile = new List<int>() { 330, 383 };
  1974. var shichangDownFile = new List<int>() { 95 };
  1975. if (allDownFile.Contains(dto.UserId))
  1976. {
  1977. }
  1978. else if (guojiaoDownFile.Contains(dto.UserId))
  1979. {
  1980. var guojiaobuDi = new List<int>() { 4, 21 };
  1981. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1982. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1983. .Where((d, u) => u.Id == di.JietuanOperator)
  1984. .Select((d, u) => d.DepName)
  1985. .First();
  1986. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1987. {
  1988. jw.Msg = "暂无下载权限!";
  1989. return Ok(jw);
  1990. }
  1991. }
  1992. else if (shichangDownFile.Contains(dto.UserId))
  1993. {
  1994. var dic = new Dictionary<int, int[]>()
  1995. {
  1996. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1997. };
  1998. try
  1999. {
  2000. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  2001. if (sqSetting != null)
  2002. {
  2003. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  2004. foreach (var item in result.Keys)
  2005. {
  2006. if (dic.ContainsKey(item))
  2007. {
  2008. int[] dilatation = new int[dic[item].Length + result[item].Length];
  2009. Array.Copy(dic[item], dilatation, dic[item].Length);
  2010. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  2011. dic[item] = dilatation;
  2012. }
  2013. else
  2014. {
  2015. dic.Add(item, result[item]);
  2016. }
  2017. }
  2018. }
  2019. if (!dic[95].Contains(di.CreateUserId))
  2020. {
  2021. jw.Msg = "暂无下载权限!";
  2022. return Ok(jw);
  2023. }
  2024. }
  2025. catch (Exception)
  2026. { }
  2027. }
  2028. else if (dto.UserId == di.CreateUserId)
  2029. {
  2030. }
  2031. else
  2032. {
  2033. jw.Msg = "暂无下载权限!";
  2034. return Ok(jw);
  2035. }
  2036. #endregion
  2037. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  2038. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  2039. .ToListAsync();
  2040. if (!blackCodeList.Any())
  2041. {
  2042. jw.Msg = "该团无机票行程代码!";
  2043. return Ok(jw);
  2044. }
  2045. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  2046. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  2047. if (groupEnterExitCost == null)
  2048. {
  2049. jw.Msg = "暂无三公费用信息!";
  2050. return Ok(jw);
  2051. }
  2052. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  2053. rateList ??= new List<CurrencyInfo>();
  2054. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  2055. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  2056. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  2057. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  2058. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  2059. .Select((x, a, b) => new
  2060. {
  2061. x.Index,
  2062. itemName = a.Name,
  2063. CurrencyStr = b.Name,
  2064. x.Cost,
  2065. x.SubTotal,
  2066. x.Remark
  2067. })
  2068. .OrderBy((x) => x.Index)
  2069. .ToList();
  2070. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  2071. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  2072. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  2073. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  2074. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  2075. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  2076. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  2077. decimal subJJC = 0.00M,
  2078. subGWC = 0.00M,
  2079. subTDC = 0.00M;
  2080. //经济舱
  2081. if (groupEnterExitCost.SumJJC == 1)
  2082. {
  2083. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  2084. }
  2085. //公务舱
  2086. if (groupEnterExitCost.SumGWC == 1)
  2087. {
  2088. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  2089. }
  2090. //头等舱
  2091. if (groupEnterExitCost.SumTDC == 1)
  2092. {
  2093. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  2094. }
  2095. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  2096. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  2097. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  2098. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2099. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2100. .Select((x, s, dc, cc) => new GroupClints
  2101. {
  2102. Id = x.Id,
  2103. Name = s.Name,
  2104. IsAccompany = x.IsAccompany,
  2105. CompanyFullName = cc.CompanyFullName
  2106. })
  2107. .ToListAsync();
  2108. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2109. //获取舱位人数
  2110. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2111. .GroupBy(x => x.Name)
  2112. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2113. .ToList();
  2114. string cityPath = string.Empty;
  2115. string startCity = string.Empty;
  2116. string endCity = string.Empty;
  2117. foreach (var item in blackCodeList)
  2118. {
  2119. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2120. cityPath += city + "\r\n";
  2121. if (item.Equals(blackCodeList.First()))
  2122. {
  2123. var sp = city.Split('-');
  2124. startCity = sp[0];
  2125. endCity = sp[^1];
  2126. }
  2127. }
  2128. di.VisitCountry = Regex.Replace(di.VisitCountry, @"[|-]", "、");
  2129. var bookMarkDic = new Dictionary<string, string>
  2130. {
  2131. { "ClientUnit", di.ClientUnit },
  2132. { "VisitCountry", di.VisitCountry },
  2133. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2134. { "VisitPNumber", di.VisitPNumber.ToString() },
  2135. { "CityPath", cityPath },
  2136. { "StartCity", startCity },
  2137. { "EndCity", endCity },
  2138. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2139. };
  2140. Document doc = null;
  2141. var percentage = 0.8M;
  2142. var fileNameadd = "预付";
  2143. if (dto.FileType == 1)
  2144. {
  2145. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2146. }
  2147. else if (dto.FileType == 2)
  2148. {
  2149. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2150. percentage = 1;
  2151. fileNameadd = "全款";
  2152. }
  2153. else
  2154. {
  2155. throw new Exception("FileType有误!");
  2156. }
  2157. var builder = new DocumentBuilder(doc);
  2158. decimal totalPrice = 0.00M;
  2159. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2160. if (firstTable != null)
  2161. {
  2162. // 遍历表格的行和单元格
  2163. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2164. {
  2165. for (int i = 0; i < row.Cells.Count; i++)
  2166. {
  2167. var cell = row.Cells[i];
  2168. // 读取单元格内容
  2169. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2170. if (cellTextFirst.Contains("舱位"))
  2171. {
  2172. break;
  2173. }
  2174. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2175. {
  2176. if (i == 2)
  2177. {
  2178. if (cellTextFirst == "经济舱")
  2179. {
  2180. // 设置单元格内容
  2181. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2182. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2183. }
  2184. else
  2185. {
  2186. // 设置单元格内容
  2187. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2188. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2189. }
  2190. }
  2191. if (i == 3)
  2192. {
  2193. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2194. if (count != null)
  2195. {
  2196. // 设置单元格内容
  2197. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2198. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2199. }
  2200. }
  2201. if (i == 4)
  2202. {
  2203. var rowPrice = 0.00M;
  2204. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2205. count ??= 0;
  2206. if (cellTextFirst == "经济舱")
  2207. {
  2208. rowPrice = subJJC * (int)count;
  2209. }
  2210. else
  2211. {
  2212. rowPrice = subGWC * (int)count;
  2213. }
  2214. totalPrice += rowPrice;
  2215. // 设置单元格内容
  2216. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2217. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2218. }
  2219. }
  2220. }
  2221. }
  2222. }
  2223. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2224. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2225. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2226. //--合同表格部分
  2227. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2228. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2229. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2230. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2231. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2232. bookMarkDic.Add("CityPath1", cityPath);
  2233. bookMarkDic.Add("CityPath2", cityPath);
  2234. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2235. if (contractTable != null)
  2236. {
  2237. //数据源
  2238. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2239. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2240. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2241. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2242. .Select((it, y, s) => new
  2243. {
  2244. it.Cost,
  2245. it.SubTotal,
  2246. it.Type,
  2247. y.Id,
  2248. y.City,
  2249. s.Name,
  2250. CurrencyCodeCn = s.Remark
  2251. })
  2252. .ToList()
  2253. .Select(x => new
  2254. {
  2255. CurrencyCode = x.Name,
  2256. CityId = x.Id,
  2257. x.City,
  2258. di.VisitPNumber,
  2259. x.Type,
  2260. x.Cost,
  2261. x.SubTotal,
  2262. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2263. x.CurrencyCodeCn,
  2264. });
  2265. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2266. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2267. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2268. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2269. var tableSettings = new List<tableSetting>()
  2270. {
  2271. new(){ Index = 1 , Property = "City"},
  2272. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2273. new(){ Index = 3 , Property = "Cost"},
  2274. new(){ Index = 4 , Property = "VisitPNumber"},
  2275. //new tableSetting{ Index = 5 , Property = ""},
  2276. //new tableSetting{ Index = 6 , Property = ""},
  2277. new(){ Index = 7 , Property = "Rate"},
  2278. //new tableSetting{ Index = 8 , Property = ""},
  2279. };
  2280. //1.住宿费
  2281. int cloneRow = 8;
  2282. int startDayPrice = 8; //写入index
  2283. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2284. foreach (var dac in dac1)
  2285. {
  2286. var first = dac.First();
  2287. var dayCount = dac.Count();
  2288. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2289. for (int i = 1; i < row.Cells.Count; i++)
  2290. {
  2291. var cell = row.Cells[i];
  2292. var findProperty = tableSettings.Find(x => x.Index == i);
  2293. if (findProperty != null)
  2294. {
  2295. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2296. // 设置单元格内容
  2297. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2298. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2299. }
  2300. else
  2301. {
  2302. switch (i)
  2303. {
  2304. case 5:
  2305. cell.FirstParagraph.Runs.Clear();
  2306. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2307. break;
  2308. case 6:
  2309. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2310. cell.FirstParagraph.Runs.Clear();
  2311. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2312. break;
  2313. case 8:
  2314. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2315. cell.FirstParagraph.Runs.Clear();
  2316. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2317. ZSPriceSum += xiaojiRMB;
  2318. break;
  2319. default:
  2320. break;
  2321. }
  2322. }
  2323. }
  2324. startDayPrice++;
  2325. if (!dac1.Last().Equals(dac))
  2326. {
  2327. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2328. // 将克隆的行追加到原行后面
  2329. contractTable.Rows.Insert(startDayPrice, newRow);
  2330. }
  2331. else
  2332. {
  2333. cloneRow += dac1.Count + 1;
  2334. startDayPrice = cloneRow;
  2335. }
  2336. }
  2337. //2.伙食费
  2338. foreach (var dac in dac2)
  2339. {
  2340. var first = dac.First();
  2341. var dayCount = dac.Count();
  2342. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2343. for (int i = 1; i < row.Cells.Count; i++)
  2344. {
  2345. var cell = row.Cells[i];
  2346. var findProperty = tableSettings.Find(x => x.Index == i);
  2347. if (findProperty != null)
  2348. {
  2349. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2350. // 设置单元格内容
  2351. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2352. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2353. }
  2354. else
  2355. {
  2356. switch (i)
  2357. {
  2358. case 5:
  2359. cell.FirstParagraph.Runs.Clear();
  2360. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2361. break;
  2362. case 6:
  2363. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2364. cell.FirstParagraph.Runs.Clear();
  2365. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2366. break;
  2367. case 8:
  2368. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2369. cell.FirstParagraph.Runs.Clear();
  2370. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2371. HSPriceSum += xiaojiRMB;
  2372. break;
  2373. default:
  2374. break;
  2375. }
  2376. }
  2377. }
  2378. startDayPrice++;
  2379. if (!dac2.Last().Equals(dac))
  2380. {
  2381. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2382. // 将克隆的行追加到原行后面
  2383. contractTable.Rows.Insert(startDayPrice, newRow);
  2384. }
  2385. else
  2386. {
  2387. cloneRow += dac2.Count + 1;
  2388. startDayPrice = cloneRow;
  2389. }
  2390. }
  2391. //3.公杂费
  2392. foreach (var dac in dac3)
  2393. {
  2394. var first = dac.First();
  2395. var dayCount = dac.Count();
  2396. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2397. for (int i = 1; i < row.Cells.Count; i++)
  2398. {
  2399. var cell = row.Cells[i];
  2400. var findProperty = tableSettings.Find(x => x.Index == i);
  2401. if (findProperty != null)
  2402. {
  2403. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2404. // 设置单元格内容
  2405. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2406. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2407. }
  2408. else
  2409. {
  2410. switch (i)
  2411. {
  2412. case 5:
  2413. cell.FirstParagraph.Runs.Clear();
  2414. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2415. break;
  2416. case 6:
  2417. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2418. cell.FirstParagraph.Runs.Clear();
  2419. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2420. break;
  2421. case 8:
  2422. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2423. cell.FirstParagraph.Runs.Clear();
  2424. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2425. GZPriceSum += xiaojiRMB;
  2426. break;
  2427. default:
  2428. break;
  2429. }
  2430. }
  2431. }
  2432. startDayPrice++;
  2433. if (!dac3.Last().Equals(dac))
  2434. {
  2435. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2436. // 将克隆的行追加到原行后面
  2437. contractTable.Rows.Insert(startDayPrice, newRow);
  2438. }
  2439. else
  2440. {
  2441. cloneRow += dac3.Count + 1;
  2442. startDayPrice = cloneRow;
  2443. }
  2444. }
  2445. //合并单元格
  2446. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2447. {
  2448. var currentRow = contractTable.Rows[i];
  2449. var nextRow = contractTable.Rows[i + 1];
  2450. // 获取当前行和下一行的第一个单元格
  2451. Cell currentCell = currentRow.Cells[0];
  2452. Cell nextCell = nextRow.Cells[0];
  2453. // 检查单元格内容是否一致(去除尾部的换行符)
  2454. string currentText = currentCell.GetText().Trim();
  2455. string nextText = nextCell.GetText().Trim();
  2456. if (currentText == nextText)
  2457. {
  2458. // 如果当前单元格已经被合并,找到合并的起始单元格
  2459. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2460. {
  2461. // 找到合并的起始单元格
  2462. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2463. // 将下一行的单元格设置为合并的后续单元格
  2464. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2465. }
  2466. else
  2467. {
  2468. // 如果当前单元格是合并的起始单元格
  2469. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2470. // 将下一行的单元格设置为合并的后续单元格
  2471. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2472. }
  2473. }
  2474. else
  2475. {
  2476. // 如果内容不一致,重置当前单元格的合并属性
  2477. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2478. {
  2479. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2480. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2481. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2482. }
  2483. else
  2484. {
  2485. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2486. }
  2487. }
  2488. }
  2489. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2490. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2491. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2492. }
  2493. foreach (var bookmarkName in bookMarkDic.Keys)
  2494. {
  2495. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2496. if (bookmark != null)
  2497. {
  2498. if (bookmarkName == "ClientUnit")
  2499. {
  2500. // 移动到书签位置
  2501. builder.MoveTo(bookmark.BookmarkStart);
  2502. // 设置字体样式为下划线
  2503. builder.Font.Underline = Aspose.Words.Underline.Single;
  2504. // 插入书签值
  2505. builder.Write(bookMarkDic[bookmarkName]);
  2506. // 清除字体格式,避免影响后续文本
  2507. builder.Font.ClearFormatting();
  2508. }
  2509. else
  2510. {
  2511. builder.MoveToBookmark(bookmarkName);
  2512. builder.Write(bookMarkDic[bookmarkName]);
  2513. }
  2514. }
  2515. }
  2516. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2517. doc.Save(savePaht);
  2518. jw.Msg = "生成成功!";
  2519. jw.Code = 200;
  2520. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2521. return Ok(jw);
  2522. }
  2523. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2524. {
  2525. int index = rowIndex;
  2526. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2527. {
  2528. index--;
  2529. }
  2530. return index;
  2531. }
  2532. /// <summary>
  2533. /// 报批完成企微通知
  2534. /// </summary>
  2535. /// <param name="dto"></param>
  2536. /// <returns></returns>
  2537. [HttpPost]
  2538. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2539. {
  2540. int currUserId = dto.currUserId;
  2541. int diid = dto.diid;
  2542. var jw = JsonView(true);
  2543. var users = new List<string>();
  2544. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2545. .First(x => x.Id == 1460);
  2546. try
  2547. {
  2548. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2549. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2550. //添加分配人员
  2551. // 79 车/导游地接
  2552. // 80 签证
  2553. // 81 邀请/公务活动
  2554. var setdataids = new List<int>() { 79, 81 };
  2555. foreach (var groupModule in groupModuleOperators)
  2556. {
  2557. if (setdataids.Contains(groupModule.CTableId))
  2558. {
  2559. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2560. }
  2561. }
  2562. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2563. //消息通知成功 更改团组step、记录日志
  2564. if (res)
  2565. {
  2566. var groupStep = 0; //0-新建 1-企微消息通知
  2567. //更改团组step
  2568. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2569. .SetColumns(x => new Grp_DelegationInfo()
  2570. {
  2571. Step = 2
  2572. })
  2573. .Where(x => x.Id == diid && x.IsDel == 0)
  2574. .ExecuteCommandAsync();
  2575. if (updStatus > 0) groupStep = 2;
  2576. string groupStepLabel = groupStep switch
  2577. {
  2578. 1 => "新建",
  2579. 2 => "企微消息通知(报批)",
  2580. _ => "未设置"
  2581. };
  2582. //记录日志
  2583. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2584. .Where(x => x.Id == diid && x.IsDel == 0)
  2585. .Select(x => x.TeamName)
  2586. .First() ?? "-";
  2587. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2588. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2589. .Select(x => x.CnName)
  2590. .First() ?? "-";
  2591. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2592. //设置 签证流程初始值
  2593. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2594. }
  2595. }
  2596. catch (Exception ex)
  2597. {
  2598. return Ok(JsonView(false, ex.Message));
  2599. }
  2600. return Ok(jw);
  2601. }
  2602. #endregion
  2603. #region 团组&签证
  2604. #region 团组&签证 New
  2605. /// <summary>
  2606. /// 团组&签证 New
  2607. /// DeepSeek API:测试API连通性
  2608. /// </summary>
  2609. /// <param name="file">请求dto</param>
  2610. /// <returns></returns>
  2611. [HttpPost]
  2612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2613. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2614. {
  2615. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2616. }
  2617. /// <summary>
  2618. /// 团组&签证 New
  2619. /// DeepSeek API:检查可用端点
  2620. /// </summary>
  2621. /// <param name="file">请求dto</param>
  2622. /// <returns></returns>
  2623. [HttpPost]
  2624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2625. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2626. {
  2627. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2628. }
  2629. /// <summary>
  2630. /// 团组&签证 New
  2631. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2632. /// </summary>
  2633. /// <param name="visaFile">文件</param>
  2634. /// <param name="fileTypeId">
  2635. /// 1. 澳新签证个人申请表
  2636. /// 2. 出国个人申请表
  2637. /// 3. 美国签证个人申请表格
  2638. /// 4. 沙特个人信息表格
  2639. /// 5. 申根签证个人资料表
  2640. /// 6. 中文个人简历模板
  2641. /// </param>
  2642. /// <returns></returns>
  2643. [HttpPost]
  2644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2645. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2646. {
  2647. //文件验证
  2648. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2649. //var visaFiles = new VisaUploadFileTypeView();
  2650. //var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2651. //if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2652. //服务器存储文件
  2653. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2654. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2655. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2656. using (var stream = new FileStream(filePath, FileMode.Create))
  2657. {
  2658. await visaFile.CopyToAsync(stream);
  2659. }
  2660. //日志记录-上传文件
  2661. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2662. #region 上传文件到DeepSeekAPI
  2663. //IFormFile localFile = null;
  2664. ////获取项目中的cs文件
  2665. //try
  2666. //{
  2667. // _logger.LogInformation("读取并上传项目文件请求");
  2668. // // 1. 读取项目文件
  2669. // var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2670. // if (readResponse.SuccessCount == 0)
  2671. // {
  2672. // return Ok(JsonView(false, "读取项目文件失败"));
  2673. // }
  2674. // localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2675. //}
  2676. //catch (Exception ex)
  2677. //{
  2678. // _logger.LogError(ex, "读取项目文件失败");
  2679. // return Ok(JsonView(false, "读取项目文件失败"));
  2680. //}
  2681. //if (localFile == null)
  2682. //{
  2683. // return Ok(JsonView(false, "读取项目文件失败"));
  2684. //}
  2685. //var fileReq = new DeepSeekFileUploadRequest()
  2686. //{
  2687. // Files = new List<IFormFile> { localFile, visaFile },
  2688. //};
  2689. //var filesResult = new List<FileUploadResult>();
  2690. //try
  2691. //{
  2692. // _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2693. // filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2694. // // 需要等待处理完成
  2695. // if (fileReq.WaitForProcessing)
  2696. // {
  2697. // foreach (var result in filesResult)
  2698. // {
  2699. // if (result.Success)
  2700. // {
  2701. // try
  2702. // {
  2703. // var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2704. // result.Status = processedFile.Status;
  2705. // }
  2706. // catch (Exception ex)
  2707. // {
  2708. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2709. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2710. // }
  2711. // }
  2712. // }
  2713. // }
  2714. //}
  2715. //catch (Exception ex)
  2716. //{
  2717. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2718. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2719. //}
  2720. //#endregion
  2721. //if (filesResult == null || filesResult.Count < 1)
  2722. //{
  2723. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2724. //}
  2725. ////
  2726. //try
  2727. //{
  2728. // var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2729. // _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2730. // string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2731. // var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  2732. // return Ok(response);
  2733. //}
  2734. //catch (Exception ex)
  2735. //{
  2736. // _logger.LogError(ex, "使用文件聊天失败");
  2737. // return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2738. //}
  2739. #endregion
  2740. #region kimi API
  2741. //加载文件OpCarTouristGuideGroundContent
  2742. //kimi AI 识别文档返回json结果
  2743. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2744. var KiMiApi = new KiMiApiClient();
  2745. var files = new List<IFormFile>() { visaFile };
  2746. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2747. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2748. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2749. var seedMessage = string.Format(@"你是领事馆电子材料审核员,只关注 Word 里的表格,正文、页眉页脚、水印、批注全部忽略。
  2750. 任务:把表格里的每个可填字段转换成“标题:值”的键值对,标题用原文,值用原文,不翻译。
  2751. 规则如下:
  2752. 1. 行列对齐:先按视觉补齐所有合并单元格——纵向合并则重复上方单元格内容,横向合并则留空字符串;无线表按对齐虚拟列线。
  2753. 2. 单格内出现多个“□”时,把被勾选(☑、√、×、■)的选项原文输出;若没有任何勾选,该字段输出 null。
  2754. 3. 所有日期统一转 yyyy-mm-dd,原格式“1990年1月1日”→1990-01-01;若缺日/月,用-01补位。
  2755. 4. 电话、传真、手机号:输出连续数字,遇到“(0 )”或“-”一律删除,只保留 7~15 位数字;若缺区号,原样保留。
  2756. 5. 金额:保留原数字,如“3000”。
  2757. 6. 地址:省、市、区、街道、门牌、邮编用空格分隔,不省略。
  2758. 7. 若同一张表出现“现住址”“家庭地址”“单位地址”等多列,依次编号 address_home / address_unit / address_legal。
  2759. 8. 输出顺序:按表格从左到右、从上到下逐行扫描,字段名重复时加序号,如 child_name_1、child_name_2。
  2760. 9. 结果格式:每行一个键值对,字段名与值之间用英文冒号+空格分隔,不要表格 Markdown,不要多余说明。
  2761. 10. 文件命名空间:每份表的最前面加一行 filename 作为起始标记(例:出国个人申请表.doc)。
  2762. 11. 内容为空的字段,显示标题,记空值。
  2763. 12. 只返回json结果,不需要其他内容;json内容去掉换行。");
  2764. var messages = new List<SeedMessages>
  2765. {
  2766. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2767. new() { Role = KimiRole.user, Content = seedMessage }
  2768. };
  2769. messages.InsertRange(1, seedConter);
  2770. string jsonString = string.Empty;
  2771. object jsonData = null;
  2772. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2773. while (!isJson)
  2774. {
  2775. kimiAI_API_Index++;
  2776. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2777. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2778. jsonString += kimiApiResult_JObject["content"].ToString();
  2779. string startStr = "```json", endStr = "```";
  2780. // 判断并清除开头部分
  2781. if (jsonString.StartsWith(startStr))
  2782. {
  2783. jsonString = jsonString.Replace(startStr, "");
  2784. }
  2785. // 判断并清除结尾部分
  2786. if (jsonString.EndsWith(endStr))
  2787. {
  2788. jsonString = jsonString.Replace(endStr, "");
  2789. }
  2790. //验证json格式是否正确
  2791. try
  2792. {
  2793. jsonData = JsonDocument.Parse(jsonString);
  2794. isJson = true; // 如果解析成功,则是json格式
  2795. }
  2796. catch (Exception)
  2797. {
  2798. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2799. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2800. }
  2801. }
  2802. if (jsonData == null)
  2803. {
  2804. return Ok(JsonView(false, "kimi识别json转换失败。"));
  2805. }
  2806. var visaDetails = new VisaDetailsView();
  2807. //按照表格类型分别进行参数处理
  2808. // 1. 澳新签证个人申请表
  2809. // 2. 出国个人申请表
  2810. // 3. 美国签证个人申请表格
  2811. // 4. 沙特个人信息表格
  2812. // 5. 申根签证个人资料表
  2813. // 6. 中文个人简历模板
  2814. switch (fileTypeId)
  2815. {
  2816. //澳新签证个人申请表
  2817. case 1:
  2818. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2819. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2820. break;
  2821. //美国签证个人申请表格
  2822. case 3:
  2823. _logger.LogInformation("【签证上传文件操作信息】【美国签证个人申请表格】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2824. string name = (string)jsonData.GetType().GetProperty("姓名")!.GetValue(jsonData)!;
  2825. string passportNo = (string)jsonData.GetType().GetProperty("护照号码")!.GetValue(jsonData)!;
  2826. string passportPlace = (string)jsonData.GetType().GetProperty("护照签发地")!.GetValue(jsonData)!;
  2827. string idNo = (string)jsonData.GetType().GetProperty("身份证号码")!.GetValue(jsonData)!;
  2828. string maritalStatusText = (string)jsonData.GetType().GetProperty("婚姻状况")!.GetValue(jsonData)!;
  2829. int maritalStatus = maritalStatusText switch
  2830. {
  2831. "未设置" => 0,
  2832. "未婚" => 1,
  2833. "已婚" => 2,
  2834. "离异" => 3,
  2835. "丧偶" => 4,
  2836. _ => -1
  2837. };
  2838. string birthDay = (string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!;
  2839. DateTime.TryParse(birthDay, out DateTime birthDayDt);
  2840. string birthPlace = (string)jsonData.GetType().GetProperty("出生地点")!.GetValue(jsonData)!;
  2841. var birthDay1 = CommonFun.SplitProvinceCity(birthPlace);
  2842. string birthDay_mate = (string)jsonData.GetType().GetProperty("配偶出生日期")!.GetValue(jsonData)!;
  2843. DateTime.TryParse(birthDay_mate, out DateTime birthDayDt_mate);
  2844. string birthPlace_mate = (string)jsonData.GetType().GetProperty("配偶出生地")!.GetValue(jsonData)!;
  2845. var birthDay1_mate = CommonFun.SplitProvinceCity(birthPlace_mate);
  2846. var addressText = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  2847. var address = SplitAddressZip(addressText);
  2848. //美国驾照信息
  2849. string driveText = (string)jsonData.GetType().GetProperty("是否有美国驾照")!.GetValue(jsonData)!;
  2850. var driveInfo = LicenseParser(driveText);
  2851. //美国社会安全号或者纳税ID号
  2852. string ssnText = (string)jsonData.GetType().GetProperty("是否有美国社会安全号或者纳税ID号")!.GetValue(jsonData)!;
  2853. //单位信息
  2854. string clientName = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校")!.GetValue(jsonData)!;
  2855. string clientAddr = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校地址")!.GetValue(jsonData)!;//
  2856. var (hasSsnItin, number) = SsnItinParser(ssnText);
  2857. //婚姻相关
  2858. var WeddingText = (string)jsonData.GetType().GetProperty("若离婚,婚姻起止时间")!.GetValue(jsonData)!;
  2859. var (f, t) = WeddingParser(WeddingText);
  2860. //美国联系人电话和邮箱
  2861. var peText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  2862. var usa_phone = Regex.Match(peText ?? "", @"[\d-]+").Value; // 数字和中横线
  2863. var usa_email = Regex.Match(peText ?? "", @"[^@\s]+@[^@\s]+\.[^@\s]+").Value;
  2864. //赴美时间、停留时间处理
  2865. var usa_dateText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  2866. var (usa_d, usa_days) = TravelParser(usa_dateText);
  2867. //赴美同行人
  2868. string usaCmpNameText = (string)jsonData.GetType().GetProperty("赴美同行人")!.GetValue(jsonData)!;
  2869. string usaCmpName = string.Empty;
  2870. if (usaCmpNameText.Contains("是"))
  2871. {
  2872. var usaCmpNameTextSplit = usaCmpNameText.Replace(":", "-").Replace("", "-").Split("-");
  2873. if (usaCmpNameTextSplit.Length > 1)
  2874. {
  2875. usaCmpName = usaCmpNameTextSplit[1];
  2876. }
  2877. }
  2878. //是否丢失过护照
  2879. string loseCodeText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  2880. string loseCode = string.Empty;
  2881. if (loseCodeText.Contains("是"))
  2882. {
  2883. var loseCodeTextSplit = loseCodeText.Replace(":", "-").Replace("", "-").Split("-");
  2884. if (loseCodeTextSplit.Length > 1)
  2885. {
  2886. usaCmpName = loseCodeTextSplit[1];
  2887. }
  2888. }
  2889. //是否获得过美国签证
  2890. string usaVisaText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  2891. string usaVisaDateText = (string)jsonData.GetType().GetProperty("获得日期")!.GetValue(jsonData)!;
  2892. //DateTime usaVisaDate;
  2893. if (!string.IsNullOrEmpty(usaVisaDateText))
  2894. {
  2895. if (DateTime.TryParse(usaVisaDateText, out DateTime usaVisaDate))
  2896. {
  2897. visaDetails.ClientInfo.GetUSAVisaDate = usaVisaDate;
  2898. }
  2899. }
  2900. string usaFingerText = (string)jsonData.GetType().GetProperty("是否留过十指指纹")!.GetValue(jsonData)!;
  2901. int usaFinger = 0;
  2902. if (usaFingerText.Contains('是')) usaFinger = 1;
  2903. string usaLoseText = (string)jsonData.GetType().GetProperty("签证是否曾遗失")!.GetValue(jsonData)!;
  2904. int usaLose = 0;
  2905. if (usaLoseText.Contains("是")) usaLose = 1;
  2906. //是否曾抵达过美国
  2907. string usaHadArrival‌Text = (string)jsonData.GetType().GetProperty("是否曾抵达过美国")!.GetValue(jsonData)!;
  2908. var (usaHadArrivalf, usaHadArrivalD, usaHadArrivalDays) = TravelHadFlagParser(usaHadArrival‌Text);
  2909. //是否有被美国拒发签证的经历
  2910. string usaRejecteVisaTest = (string)jsonData.GetType().GetProperty("是否有被美国拒发签证的经历")!.GetValue(jsonData)!;
  2911. var (denied, rejectedDate, rejectedPlace, rejectedType) = VisaDenialParser(usaRejecteVisaTest);
  2912. if (denied)
  2913. {
  2914. visaDetails.ClientInfo.RejectedDate = rejectedDate;
  2915. visaDetails.ClientInfo.RejectedPlace = rejectedPlace;
  2916. visaDetails.ClientInfo.RejectedVisa = rejectedType;
  2917. }
  2918. //是否在申请或曾经申请过美国移民签证
  2919. string usaImmVisaText‌ = (string)jsonData.GetType().GetProperty("是否在申请或曾经申请过美国移民签证")!.GetValue(jsonData)!;
  2920. var (immDenied, immDate, immPlace, immType) = VisaDenialParser(usaImmVisaText‌);
  2921. if (immDenied)
  2922. {
  2923. visaDetails.ClientInfo.USAImmVisa‌Date = immDate;
  2924. visaDetails.ClientInfo.USAImmVisa‌Place = immPlace;
  2925. visaDetails.ClientInfo.USAImmVisa‌ = immType;
  2926. }
  2927. //在美直系
  2928. string usaImmedText‌ = (string)jsonData.GetType().GetProperty("是否有直系亲属在美国")!.GetValue(jsonData)!;
  2929. var (immedDenied, immedName, immedRel, immedStat) = FourFieldParser(usaImmedText‌);
  2930. if (immedDenied)
  2931. {
  2932. visaDetails.ClientInfo.USAImmedFamName = immedName;
  2933. visaDetails.ClientInfo.USAImmedFamRel = immedRel;
  2934. visaDetails.ClientInfo.USAImmedFamStat = immedStat;
  2935. }
  2936. //在美旁系
  2937. string usaUncleText‌ = (string)jsonData.GetType().GetProperty("是否有旁系亲属在美国")!.GetValue(jsonData)!;
  2938. var (uncleDenied, uncleName, uncleRel, uncleStat) = FourFieldParser(usaUncleText‌);
  2939. if (immedDenied)
  2940. {
  2941. visaDetails.ClientInfo.USAUncleFamName = uncleName;
  2942. visaDetails.ClientInfo.USAUncleFamRel = uncleName;
  2943. visaDetails.ClientInfo.USAUncleFamStat = uncleStat;
  2944. }
  2945. //服役时间 MilitaryParser
  2946. string militaryText‌ = (string)jsonData.GetType().GetProperty("是否曾参过军")!.GetValue(jsonData)!;
  2947. var (militaryH, militaryB, militaryR, militaryS, (militaryStart, militaryEnd)) = MilitaryParser(militaryText‌);
  2948. var militarys = new List<MilitaryInfo>();
  2949. if (militaryH)
  2950. {
  2951. militarys.Add(new()
  2952. {
  2953. MilBranch = militaryB,
  2954. MilRank = militaryR,
  2955. MilSkill = militaryS,
  2956. ServeTimeBegin = militaryStart,
  2957. ServeTimeEnd = militaryEnd,
  2958. });
  2959. }
  2960. //申请人父母信息 ParentParser
  2961. string fthMthText‌ = (string)jsonData.GetType().GetProperty("申请人父母信息")!.GetValue(jsonData)!;
  2962. if (!string.IsNullOrEmpty(fthMthText‌))
  2963. {
  2964. var (fName, fDob, mName, mDob) = ParentParser(fthMthText‌);
  2965. visaDetails.ClientInfo.FthName = fName;
  2966. visaDetails.ClientInfo.FthBirth = fDob;
  2967. visaDetails.ClientInfo.MthName = mName;
  2968. visaDetails.ClientInfo.MthBirth = mDob;
  2969. }
  2970. visaDetails.ClientInfo = new()
  2971. {
  2972. LastName = name.GetLastName(),
  2973. FirstName = name.GetFirstName(),
  2974. Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1,
  2975. OldName = (string)jsonData.GetType().GetProperty("曾用名")!.GetValue(jsonData)!,
  2976. BirthDay = birthDayDt,
  2977. BirthProvince = birthDay1.province,
  2978. BirthCity = birthDay1.city,
  2979. Address = address.address,
  2980. PostCodes = address.zipCode,
  2981. Marriage = maritalStatus,
  2982. MateName = (string)jsonData.GetType().GetProperty("配偶姓名")!.GetValue(jsonData)!,
  2983. MateBirthDay = birthDayDt_mate,
  2984. MateBirthCountry = birthDay1_mate.province,
  2985. MateBirthCity = birthDay1_mate.city,
  2986. USA_DLNo = driveInfo.number,
  2987. USA_DLPlace = driveInfo.place,
  2988. USA_SSNOrITIN = number,
  2989. Resident = CleanPrefix((string)jsonData.GetType().GetProperty("是否是其他国家的永久居民")!.GetValue(jsonData)!),
  2990. HasSocialAcc‌ = CleanPrefix((string)jsonData.GetType().GetProperty("近五年内是否使用过任何社交账号")!.GetValue(jsonData)!),
  2991. WeddingDate = f,
  2992. DivorceDate = t,
  2993. DivorceRsn = (string)jsonData.GetType().GetProperty("离婚原因")!.GetValue(jsonData)!,
  2994. Job = (string)jsonData.GetType().GetProperty("职务")!.GetValue(jsonData)!,
  2995. Wage = (string)jsonData.GetType().GetProperty("月薪")!.GetValue(jsonData)!,
  2996. WorkState = (string)jsonData.GetType().GetProperty("工作职责")!.GetValue(jsonData)!,
  2997. WorkDate = (string)jsonData.GetType().GetProperty("入职/入学时间(详细到月)")!.GetValue(jsonData)!,
  2998. USAAddress = (string)jsonData.GetType().GetProperty("请提供美国详细住址")!.GetValue(jsonData)!,
  2999. USAPurpose = (string)jsonData.GetType().GetProperty("赴美目的")!.GetValue(jsonData)!,
  3000. CostBearers = (string)jsonData.GetType().GetProperty("费用谁付")!.GetValue(jsonData)!,
  3001. USAContact = (string)jsonData.GetType().GetProperty("美国联系人或组织")!.GetValue(jsonData)!,
  3002. USAContactTel = usa_phone,
  3003. USAContactEmail = usa_email,
  3004. USADate = usa_d,
  3005. USADays = usa_days,
  3006. USAArrivalCity‌ = (string)jsonData.GetType().GetProperty("赴美的到达城市")!.GetValue(jsonData)!,
  3007. USADepartCity‌ = (string)jsonData.GetType().GetProperty("赴美的离开城市")!.GetValue(jsonData)!,
  3008. USAVisitSites‌ = (string)jsonData.GetType().GetProperty("计划在美国访问的景点")!.GetValue(jsonData)!,
  3009. USACmpName = usaCmpName,
  3010. USACmpRelation = (string)jsonData.GetType().GetProperty("同行人关系")!.GetValue(jsonData)!,
  3011. Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!,
  3012. ClientPhone = (string)jsonData.GetType().GetProperty("单位电话")!.GetValue(jsonData)!,
  3013. Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!,
  3014. Cntry5Y‌ = (string)jsonData.GetType().GetProperty("过去5年内到过的国家")!.GetValue(jsonData)!,
  3015. LangSkill‌ = (string)jsonData.GetType().GetProperty("面签时能流利交流的语言")!.GetValue(jsonData)!,
  3016. LoseCode = loseCode,
  3017. DenyNationRsn = (string)jsonData.GetType().GetProperty("曾被哪些国家拒签/拒签原因")!.GetValue(jsonData)!,
  3018. USAVisaCode = (string)jsonData.GetType().GetProperty("签证号码")!.GetValue(jsonData)!,
  3019. USAVisaCate = (string)jsonData.GetType().GetProperty("获签类型")!.GetValue(jsonData)!,
  3020. //GetUSAVisaDate = usaVisaDate,
  3021. USAFinger = usaFinger,
  3022. IsLose = usaLose,
  3023. USAHadArrival = usaHadArrivalD,
  3024. USAHadDays = usaHadArrivalDays,
  3025. ArmyState = JsonConvert.SerializeObject(militarys)
  3026. };
  3027. visaDetails.ClientCerts = new() {
  3028. new(){ SdId = 74,CertNo = passportNo,IDCardAddress = passportPlace },
  3029. new(){ SdId = 73,CertNo = idNo},
  3030. };
  3031. visaDetails.ClientCompany = new() { CompanyFullName = clientName, Address = clientAddr };
  3032. break;
  3033. //中文个人简历模板
  3034. case 6:
  3035. _logger.LogInformation("【签证上传文件操作信息】【中文个人简历模板】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3036. visaDetails.ClientInfo.LastName = (string)jsonData.GetType().GetProperty("姓名(中英文拼音)")!.GetValue(jsonData)!;
  3037. visaDetails.ClientInfo.Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1;
  3038. DateTime.TryParse((string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!, out DateTime birthDay11);
  3039. visaDetails.ClientInfo.BirthDay = birthDay11;
  3040. visaDetails.ClientInfo.BirthProvince = (string)jsonData.GetType().GetProperty("出生地")!.GetValue(jsonData)!;
  3041. visaDetails.ClientInfo.Address = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  3042. visaDetails.ClientInfo.Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!;
  3043. visaDetails.ClientInfo.TableOpTel = (string)jsonData.GetType().GetProperty("工作电话")!.GetValue(jsonData)!;
  3044. visaDetails.ClientInfo.Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!;
  3045. visaDetails.ClientInfo.Email = (string)jsonData.GetType().GetProperty("电子邮件")!.GetValue(jsonData)!;
  3046. //学校信息
  3047. visaDetails.ClientSchools.Add(new()
  3048. {
  3049. School = (string)jsonData.GetType().GetProperty("教育学校名称")!.GetValue(jsonData)!,
  3050. Education = (string)jsonData.GetType().GetProperty("教育学位")!.GetValue(jsonData)!,
  3051. Subject = (string)jsonData.GetType().GetProperty("教育专业")!.GetValue(jsonData)!,
  3052. Remark = (string)jsonData.GetType().GetProperty("教育论文题目/研究重点(硕士、博士)")!.GetValue(jsonData)!,
  3053. });
  3054. //工作信息
  3055. visaDetails.ClientCompany = new()
  3056. {
  3057. CompanyFullName = (string)jsonData.GetType().GetProperty("工作经历雇主")!.GetValue(jsonData)!,
  3058. };
  3059. visaDetails.ClientInfo.Job = (string)jsonData.GetType().GetProperty("工作经历职位或头衔职责")!.GetValue(jsonData)!;
  3060. break;
  3061. default:
  3062. break;
  3063. }
  3064. //数据提交
  3065. #region 数据提交
  3066. _sqlSugar.BeginTran();
  3067. // 客户公司表
  3068. var compId = UpsertReturnId<Crm_CustomerCompany>(visaDetails.ClientCompany, o => o.CompanyFullName);
  3069. if (compId < 1)
  3070. {
  3071. _sqlSugar.RollbackTran();
  3072. return Ok(JsonView(false, "公司信息更新失败!"));
  3073. }
  3074. visaDetails.ClientInfo.CrmCompanyId = compId;
  3075. // 客户资料表
  3076. var clientId = UpsertReturnId<Crm_DeleClient>(visaDetails.ClientInfo, o => new { o.LastName, o.FirstName });
  3077. if (clientId < 1)
  3078. {
  3079. _sqlSugar.RollbackTran();
  3080. return Ok(JsonView(false, "客户信息更新失败!"));
  3081. }
  3082. for (int i = 0; i < visaDetails.ClientFamilys.Count(); i++)
  3083. {
  3084. visaDetails.ClientFamilys[i].DcId = clientId;
  3085. }
  3086. for (int i = 0; i < visaDetails.ClientCerts.Count(); i++)
  3087. {
  3088. visaDetails.ClientCerts[i].DcId = clientId;
  3089. }
  3090. for (int i = 0; i < visaDetails.ClientSchools.Count(); i++)
  3091. {
  3092. visaDetails.ClientSchools[i].DcId = clientId;
  3093. }
  3094. // 客户家庭表
  3095. foreach (var item in visaDetails.ClientFamilys)
  3096. {
  3097. var famId = UpsertReturnId<Crm_VisaCustomerFamily>(item, o => o.Name);
  3098. if (famId < 1)
  3099. {
  3100. _sqlSugar.RollbackTran();
  3101. return Ok(JsonView(false, "客户家庭信息更新失败!"));
  3102. }
  3103. }
  3104. // 客户证件表
  3105. foreach (var item in visaDetails.ClientCerts)
  3106. {
  3107. var certId = UpsertReturnId<Crm_CustomerCert>(item, o => o.CertNo);
  3108. if (certId < 1)
  3109. {
  3110. _sqlSugar.RollbackTran();
  3111. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3112. }
  3113. }
  3114. // 客户学历表
  3115. foreach (var item in visaDetails.ClientSchools)
  3116. {
  3117. var schoolId = UpsertReturnId<Crm_VisaCustomerSchool>(item, o => o.School);
  3118. if (schoolId < 1)
  3119. {
  3120. _sqlSugar.RollbackTran();
  3121. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3122. }
  3123. }
  3124. _sqlSugar.CommitTran();
  3125. #endregion
  3126. #endregion
  3127. return Ok(JsonView(true, jsonString));
  3128. }
  3129. #region 扩展处理
  3130. // 从 Expression<Func<T,object>> 里取出属性名
  3131. static string GetPropName<T>(Expression<Func<T, object>> expr)
  3132. {
  3133. if (expr.Body is UnaryExpression ue) expr = Expression.Lambda<Func<T, object>>(ue.Operand, expr.Parameters);
  3134. return ((MemberExpression)expr.Body).Member.Name;
  3135. }
  3136. /// <summary>
  3137. /// 5.1.4.193 可用:存在更新(非NULL非空串),不存在插入,返回主键ID
  3138. /// </summary>
  3139. public int UpsertReturnId<T>(T entity, Expression<Func<T, object>> whereExpr) where T : class, new()
  3140. {
  3141. // 1. 空字符串→NULL,让后续忽略
  3142. foreach (var pi in typeof(T).GetProperties())
  3143. if (pi.PropertyType == typeof(string) &&
  3144. pi.GetValue(entity) is string s &&
  3145. string.IsNullOrWhiteSpace(s))
  3146. pi.SetValue(entity, null);
  3147. // 2. 从表达式里拿属性名
  3148. string propName = GetPropName(whereExpr);
  3149. var propValue = typeof(T).GetProperty(propName)?.GetValue(entity);
  3150. // 3. 判断存在
  3151. bool exists = _sqlSugar.Queryable<T>().Where(propName, propValue).Any();
  3152. // 4. 执行 Upsert
  3153. if (exists)
  3154. {
  3155. _sqlSugar.Updateable(entity)
  3156. .WhereColumns(propName) // 指定条件列
  3157. .IgnoreColumns(ignoreAllNullColumns: true) // 忽略 NULL
  3158. .ExecuteCommand();
  3159. }
  3160. else
  3161. {
  3162. _sqlSugar.Insertable(entity).ExecuteReturnIdentity();
  3163. }
  3164. // 5. 返回主键值(自增/雪花已回填)
  3165. var idProp = typeof(T).GetProperties()
  3166. .First(p => p.GetCustomAttributes<SugarColumn>()
  3167. .Any(a => a.IsPrimaryKey));
  3168. return (int)idProp.GetValue(entity)!;
  3169. }
  3170. /// <summary>
  3171. /// 地址喊邮编 相关处理
  3172. /// </summary>
  3173. public static (string address, string zipCode) SplitAddressZip(string? s)
  3174. {
  3175. if (string.IsNullOrWhiteSpace(s))
  3176. return ("", "");
  3177. ReadOnlySpan<char> src = s.AsSpan();
  3178. int i = src.IndexOf("邮编".AsSpan());
  3179. if (i < 0) // 没有“邮编”字样
  3180. return (src.Trim().ToString(), "");
  3181. ReadOnlySpan<char> addr = src[..i].TrimEnd();
  3182. ReadOnlySpan<char> zip = src[(i + 3)..].Trim(); // 跳过“邮编:”
  3183. // 可能只有“邮编:”而没有数字
  3184. return (addr.IsEmpty ? "" : addr.ToString(),
  3185. zip.IsEmpty ? "" : zip.ToString());
  3186. }
  3187. /// <summary>
  3188. /// 驾照相 关处理
  3189. /// </summary>
  3190. /// <param name="raw"></param>
  3191. /// <returns></returns>
  3192. public static (bool hasLicense, string number, string place) LicenseParser(string? raw)
  3193. {
  3194. if (string.IsNullOrWhiteSpace(raw))
  3195. return (false, "", "");
  3196. // 1. 是否持有
  3197. bool has = raw.StartsWith("是", System.StringComparison.OrdinalIgnoreCase) ||
  3198. raw.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3199. // 2. 去掉前缀,按空格切
  3200. ReadOnlySpan<char> s = raw.AsSpan();
  3201. int colon = s.IndexOf(':');
  3202. ReadOnlySpan<char> after = colon < 0 ? s : s[(colon + 1)..];
  3203. after = after.Trim();
  3204. int space = after.IndexOf(' ');
  3205. ReadOnlySpan<char> num = space < 0 ? after : after[..space];
  3206. ReadOnlySpan<char> st = space < 0 ? ReadOnlySpan<char>.Empty : after[(space + 1)..];
  3207. return (has, num.ToString().Trim(), st.ToString().Trim());
  3208. }
  3209. /// <summary>
  3210. /// 美国社会安全号或者纳税ID号 相关处理
  3211. /// </summary>
  3212. /// <param name="raw"></param>
  3213. /// <returns></returns>
  3214. public static (bool hasSsnItin, string number) SsnItinParser(string? raw)
  3215. {
  3216. if (string.IsNullOrWhiteSpace(raw))
  3217. return (false, "");
  3218. ReadOnlySpan<char> s = raw.AsSpan();
  3219. // 1. 是否持有
  3220. bool has = s.StartsWith("是", System.StringComparison.Ordinal) ||
  3221. s.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3222. // 2. 取号码(去掉前缀和空格)
  3223. int colon = s.IndexOf(':');
  3224. ReadOnlySpan<char> num = colon < 0
  3225. ? ReadOnlySpan<char>.Empty
  3226. : s[(colon + 1)..].Trim();
  3227. return (has, num.ToString());
  3228. }
  3229. /// <summary>
  3230. /// 取消开始的“是:”或者“是”或者“ :”
  3231. /// </summary>
  3232. /// <param name="raw"></param>
  3233. /// <returns></returns>
  3234. public static string CleanPrefix(string? raw)
  3235. {
  3236. if (string.IsNullOrWhiteSpace(raw)) return "";
  3237. // 跳过第一个“是”或“Y”
  3238. ReadOnlySpan<char> s = raw.AsSpan();
  3239. int start = 0;
  3240. if (s.StartsWith("是") || s.StartsWith("Y", StringComparison.OrdinalIgnoreCase))
  3241. start = 1;
  3242. // 跳过连续 : 或空格
  3243. while (start < s.Length && (s[start] == ':' || s[start] == ' '))
  3244. start++;
  3245. return s[start..].Trim().ToString();
  3246. }
  3247. /// <summary>
  3248. /// 婚姻起止时间处理
  3249. /// </summary>
  3250. /// <param name="raw"></param>
  3251. /// <returns></returns>
  3252. public static (DateTime? fromDate, DateTime? toDate) WeddingParser(string? raw)
  3253. {
  3254. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3255. Regex _clean = new(@"[\s~至]+", RegexOptions.Compiled);
  3256. // 1. 把所有“空格~至”统一成 '-'
  3257. string normalized = _clean.Replace(raw, "-");
  3258. // 2. 切两段
  3259. string[] parts = normalized.Split('-', StringSplitOptions.RemoveEmptyEntries);
  3260. if (parts.Length != 2) return (null, null);
  3261. // 3. 解析
  3262. bool ff = DateTime.TryParse(parts[0].Trim(), out var from);
  3263. bool tf = DateTime.TryParse(parts[1].Trim(), out var to);
  3264. return (tf ? from : null, tf ? to : null);
  3265. }
  3266. /// <summary>
  3267. /// 出行日期和天数处理
  3268. /// </summary>
  3269. /// <param name="raw"></param>
  3270. /// <returns></returns>
  3271. public static (DateTime? travelDate, int? days) TravelParser(string? raw)
  3272. {
  3273. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3274. // 切成两段:第一段日期,第二段天数
  3275. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3276. string[] parts = sep.Split(raw.Trim());
  3277. if (parts.Length < 2) return (null, null);
  3278. bool okDate = DateTime.TryParse(parts[0], out DateTime date);
  3279. bool okDays = int.TryParse(parts[1], out int days) && days > 0;
  3280. return (okDate ? date : null, okDays ? days : null);
  3281. }
  3282. /// <summary>
  3283. /// 是否曾抵达过美国
  3284. /// </summary>
  3285. /// <param name="raw"></param>
  3286. /// <returns></returns>
  3287. public static (bool hasTravel, string date, string days) TravelHadFlagParser(string? raw)
  3288. {
  3289. if (string.IsNullOrWhiteSpace(raw)) return (false, string.Empty, string.Empty);
  3290. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3291. // 1. 是否持有
  3292. bool has = raw.AsSpan().TrimStart().StartsWith("是") ||
  3293. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3294. // 2. 用非数字分隔符切成三段:第一段空,第二段日期,第三段天数
  3295. string[] parts = sep.Split(raw.Trim());
  3296. if (parts.Length < 3) return (has, string.Empty, string.Empty);
  3297. return (has, parts[1], parts[2]);
  3298. }
  3299. /// <summary>
  3300. /// 是否有被美国拒发签证的经历
  3301. /// </summary>
  3302. /// <param name="raw"></param>
  3303. /// <returns></returns>
  3304. public static (bool wasDenied, DateTime? date, string place, string visaType) VisaDenialParser(string? raw)
  3305. {
  3306. if (string.IsNullOrWhiteSpace(raw)) return (false, null, "", "");
  3307. bool denied = raw.AsSpan().TrimStart().StartsWith("有") ||
  3308. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3309. var parts = Regex.Split(raw.Trim(), @"[^0-9A-Za-z-]+");
  3310. if (parts.Length < 4) return (denied, null, "", "");
  3311. DateTime.TryParse(parts[1], out var dt); // ← 这里改为 DateTime
  3312. return (denied, dt, parts[2], parts[3]);
  3313. }
  3314. /// <summary>
  3315. /// 在美直系、旁系 处理
  3316. /// </summary>
  3317. /// <param name="raw"></param>
  3318. /// <returns></returns>
  3319. public static (bool flag, string name, string rel, string stat) FourFieldParser(string? raw)
  3320. {
  3321. if (string.IsNullOrWhiteSpace(raw)) return (false, "", "", "");
  3322. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3323. if (parts.Length < 4) return (false, "", "", "");
  3324. bool flag = parts[0] is "有" or "是" or "Y" or "Yes";
  3325. string name = parts[1];
  3326. string rel = parts[2];
  3327. string stat = parts[3];
  3328. return (flag, name, rel, stat);
  3329. }
  3330. /// <summary>
  3331. /// 服役时间处理
  3332. /// </summary>
  3333. /// <param name="raw"></param>
  3334. /// <returns></returns>
  3335. public static (bool hasService, string branch, string rank, string specialty, (DateTime? start, DateTime? end) period) MilitaryParser(string? raw)
  3336. {
  3337. const string fmt = "yyyy年MM月dd日";
  3338. if (string.IsNullOrWhiteSpace(raw))
  3339. return (false, "", "", "", (null, null));
  3340. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3341. if (parts.Length < 5) return (false, "", "", "", (null, null));
  3342. bool has = parts[0] is "是" or "Y" or "Yes";
  3343. string branch = parts[1];
  3344. string rank = parts[2];
  3345. string specialty = parts[3];
  3346. // 拼回时间字符串
  3347. string periodRaw = string.Join(" ", parts[4..]);
  3348. var span = periodRaw.AsSpan();
  3349. int zhi = span.IndexOf("至");
  3350. if (zhi < 0) return (has, branch, rank, specialty, (null, null));
  3351. var startStr = span.Slice(0, zhi).Trim();
  3352. var endStr = span.Slice(zhi + 1).Trim();
  3353. bool okStart = DateTime.TryParseExact(startStr.ToString(), fmt, null, DateTimeStyles.None, out var start);
  3354. bool okEnd = DateTime.TryParseExact(endStr.ToString(), fmt, null, DateTimeStyles.None, out var end);
  3355. return (has, branch, rank, specialty, (okStart ? start : null, okEnd ? end : null));
  3356. }
  3357. /// <summary>
  3358. /// 申请人父母信息
  3359. /// </summary>
  3360. /// <param name="raw"></param>
  3361. /// <returns></returns>
  3362. public static (string fatherName, DateTime? fatherDob, string motherName, DateTime? motherDob) ParentParser(string? raw)
  3363. {
  3364. const string fmt = "yyyy年MM月dd日";
  3365. if (string.IsNullOrWhiteSpace(raw)) return ("", null, "", null);
  3366. // 按空格切,去掉空元素
  3367. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3368. if (parts.Length < 4) return ("", null, "", null);
  3369. // 父亲
  3370. string fName = parts[0];
  3371. DateTime.TryParseExact(parts[1], fmt, null, DateTimeStyles.None, out var fDob);
  3372. // 母亲
  3373. string mName = parts[2];
  3374. DateTime.TryParseExact(parts[3], fmt, null, DateTimeStyles.None, out var mDob);
  3375. return (fName, fDob, mName, mDob);
  3376. }
  3377. public class VisaDetailsView
  3378. {
  3379. /// <summary>
  3380. /// 客户资料表
  3381. /// </summary>
  3382. public Crm_DeleClient ClientInfo { get; set; }
  3383. /// <summary>
  3384. /// 客户家庭表
  3385. /// </summary>
  3386. public List<Crm_VisaCustomerFamily> ClientFamilys { get; set; }
  3387. /// <summary>
  3388. /// 客户公司表
  3389. /// </summary>
  3390. public Crm_CustomerCompany ClientCompany { get; set; }
  3391. /// <summary>
  3392. /// 客户证件表
  3393. /// </summary>
  3394. public List<Crm_CustomerCert> ClientCerts { get; set; }
  3395. /// <summary>
  3396. /// 客户学历表
  3397. /// </summary>
  3398. public List<Crm_VisaCustomerSchool> ClientSchools { get; set; }
  3399. }
  3400. private int GetSuccessCount(List<FileUploadResult> results)
  3401. {
  3402. var count = 0;
  3403. foreach (var result in results)
  3404. {
  3405. if (result.Success) count++;
  3406. }
  3407. return count;
  3408. }
  3409. #endregion
  3410. /// <summary>
  3411. /// 根据团组Id获取签证客户信息List
  3412. /// </summary>
  3413. /// <param name="dto">请求dto</param>
  3414. /// <returns></returns>
  3415. [HttpPost]
  3416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3417. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  3418. {
  3419. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  3420. if (groupData.Code != 0)
  3421. {
  3422. return Ok(JsonView(false, groupData.Msg));
  3423. }
  3424. return Ok(JsonView(groupData.Data));
  3425. }
  3426. /// <summary>
  3427. /// IOS获取团组签证拍照上传进度01(团组列表)
  3428. /// </summary>
  3429. /// <param name="dto">请求dto</param>
  3430. /// <returns></returns>
  3431. [HttpPost]
  3432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3433. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  3434. {
  3435. if (dto == null)
  3436. {
  3437. return Ok(JsonView(false, "参数为空"));
  3438. }
  3439. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  3440. return Ok(JsonView(visaList));
  3441. }
  3442. /// <summary>
  3443. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  3444. /// </summary>
  3445. /// <returns></returns>
  3446. [HttpPost]
  3447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3448. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  3449. {
  3450. if (dto == null)
  3451. {
  3452. return Ok(JsonView(false, "请求错误:"));
  3453. }
  3454. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  3455. return Ok(JsonView(list));
  3456. }
  3457. /// <summary>
  3458. /// IOS获取团组签证拍照上传进度03(相册)
  3459. /// </summary>
  3460. /// <returns></returns>
  3461. [HttpPost]
  3462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3463. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  3464. {
  3465. if (dto == null)
  3466. {
  3467. return Ok(JsonView(false, "请求错误:"));
  3468. }
  3469. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  3470. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  3471. list.ForEach(s => s.url = url);
  3472. return Ok(JsonView(list));
  3473. }
  3474. /// <summary>
  3475. /// IOS获取团组签证拍照上传进度04(图片上传)
  3476. /// </summary>
  3477. /// <param name="dto"></param>
  3478. /// <returns></returns>
  3479. [HttpPost]
  3480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3481. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  3482. {
  3483. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  3484. //if (!string.IsNullOrEmpty(result))
  3485. //{
  3486. //}
  3487. //else {
  3488. // return Ok(JsonView(false, "上传失败"));
  3489. //}
  3490. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  3491. int sucNum = 0;
  3492. try
  3493. {
  3494. foreach (var item in dto.base64DataList)
  3495. {
  3496. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  3497. string result = DecodeBase64ToImage(item, imageName);
  3498. if (!string.IsNullOrEmpty(result))
  3499. {
  3500. var pic = new Grp_VisaProgressCustomerPicture
  3501. {
  3502. CreateUserId = dto.CreateUserId,
  3503. PicName = imageName,
  3504. PicPath = result,
  3505. VisaProgressCustomerId = dto.visaProgressCustomerId
  3506. };
  3507. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  3508. if (insertResult > 0)
  3509. {
  3510. sucNum++;
  3511. }
  3512. }
  3513. }
  3514. }
  3515. catch (Exception ex)
  3516. {
  3517. return Ok(JsonView(false, ex.Message));
  3518. }
  3519. string msg = string.Format(@"成功上传{0}张", sucNum);
  3520. return Ok(JsonView(true, msg));
  3521. }
  3522. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  3523. {
  3524. string filename = "";//声明一个string类型的相对路径
  3525. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  3526. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  3527. try//会有异常抛出,try,catch一下
  3528. {
  3529. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  3530. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  3531. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  3532. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  3533. //文件名称
  3534. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  3535. //上传的文件的路径
  3536. string filePath = "";
  3537. if (!Directory.Exists(fileDir))
  3538. {
  3539. Directory.CreateDirectory(fileDir);
  3540. }
  3541. //上传的文件的路径
  3542. filePath = fileDir + filename;
  3543. //string url = HttpRuntime.AppDomainAppPath.ToString();
  3544. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  3545. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  3546. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  3547. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  3548. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  3549. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  3550. ms.Close();//关闭当前流,并释放所有与之关联的资源
  3551. bitmap.Dispose();
  3552. }
  3553. catch (Exception e)
  3554. {
  3555. string massage = e.Message;
  3556. Logs("IOS图片上传Error:" + massage);
  3557. //filename = e.Message;
  3558. }
  3559. return filename;//返回相对路径
  3560. }
  3561. /// <summary>
  3562. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  3563. /// </summary>
  3564. /// <param name="dto"></param>
  3565. /// <returns></returns>
  3566. [HttpPost]
  3567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3568. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  3569. {
  3570. if (dto == null)
  3571. {
  3572. return Ok(JsonView(false, "请求错误:"));
  3573. }
  3574. string msg = "参数错误";
  3575. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  3576. {
  3577. try
  3578. {
  3579. //_delegationVisaRep.BeginTran();
  3580. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  3581. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  3582. .Where(s => s.Id == dto.visaProgressCustomerId)
  3583. .ExecuteCommandAsync();
  3584. if (updCount > 0 && dto.publishCode == 1)
  3585. {
  3586. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  3587. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  3588. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  3589. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  3590. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  3591. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  3592. if (groupData == null)
  3593. {
  3594. _delegationVisaRep.RollbackTran();
  3595. }
  3596. string title = string.Format(@"[签证进度更新]");
  3597. string content = string.Format(@"测试文本");
  3598. bool rst = await _message.AddMsg(new MessageDto()
  3599. {
  3600. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  3601. IssuerId = dto.publisher,
  3602. Title = title,
  3603. Content = content,
  3604. ReleaseTime = DateTime.Now,
  3605. UIdList = new List<int> {
  3606. 234
  3607. }
  3608. });
  3609. if (rst)
  3610. {
  3611. return Ok(JsonView(true, "发送通知成功"));
  3612. }
  3613. }
  3614. //_delegationVisaRep.CommitTran();
  3615. }
  3616. catch (Exception)
  3617. {
  3618. //_delegationVisaRep.RollbackTran();
  3619. }
  3620. }
  3621. return Ok(JsonView(true, msg));
  3622. }
  3623. #endregion
  3624. #endregion
  3625. #region 团组任务分配
  3626. /// <summary>
  3627. /// 团组任务分配初始化
  3628. /// </summary>
  3629. /// <returns></returns>
  3630. [HttpPost]
  3631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3632. public async Task<IActionResult> GetTaskAssignmen()
  3633. {
  3634. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  3635. if (groupData.Code != 0)
  3636. {
  3637. return Ok(JsonView(false, groupData.Msg));
  3638. }
  3639. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3640. }
  3641. /// <summary>
  3642. /// 团组任务分配查询
  3643. /// </summary>
  3644. /// <param name="dto"></param>
  3645. /// <returns></returns>
  3646. [HttpPost]
  3647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3648. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  3649. {
  3650. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  3651. if (groupData.Code != 0)
  3652. {
  3653. return Ok(JsonView(false, groupData.Msg));
  3654. }
  3655. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3656. }
  3657. /// <summary>
  3658. /// 团组任务分配操作
  3659. /// </summary>
  3660. /// <param name="dto"></param>
  3661. /// <returns></returns>
  3662. [HttpPost]
  3663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3664. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  3665. {
  3666. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  3667. if (groupData.Code != 0)
  3668. {
  3669. return Ok(JsonView(false, groupData.Msg));
  3670. }
  3671. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3672. }
  3673. /// <summary>
  3674. /// 团组任务分配
  3675. /// 批量分配
  3676. /// 查询团组
  3677. /// </summary>
  3678. /// <param name="dto"></param>
  3679. /// <returns></returns>
  3680. [HttpPost]
  3681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3682. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  3683. {
  3684. //参数验证
  3685. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3686. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  3687. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  3688. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  3689. }
  3690. /// <summary>
  3691. /// 团组任务分配
  3692. /// 批量分配
  3693. /// </summary>
  3694. /// <param name="dto"></param>
  3695. /// <returns></returns>
  3696. [HttpPost]
  3697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3698. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  3699. {
  3700. //参数验证
  3701. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  3702. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  3703. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  3704. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  3705. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  3706. }
  3707. #endregion
  3708. #region 团组费用审核
  3709. /// <summary>
  3710. /// 费用审核
  3711. /// 团组列表 Page
  3712. /// </summary>
  3713. /// <param name="_dto">团组列表请求dto</param>
  3714. /// <returns></returns>
  3715. [HttpPost]
  3716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3717. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  3718. {
  3719. #region 参数验证
  3720. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3721. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3722. #region 页面操作权限验证
  3723. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3724. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3725. #endregion
  3726. #endregion
  3727. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  3728. {
  3729. string sqlWhere = string.Empty;
  3730. if (_dto.IsSure == 0) //未完成
  3731. {
  3732. sqlWhere += string.Format(@" And IsSure = 0");
  3733. }
  3734. else if (_dto.IsSure == 1) //已完成
  3735. {
  3736. sqlWhere += string.Format(@" And IsSure = 1");
  3737. }
  3738. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  3739. {
  3740. string tj = _dto.SearchCriteria;
  3741. 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}%')",
  3742. tj, tj, tj, tj, tj);
  3743. }
  3744. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3745. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  3746. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3747. From (
  3748. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  3749. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  3750. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  3751. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3752. From Grp_DelegationInfo gdi
  3753. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3754. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3755. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3756. Where gdi.IsDel = 0 {0}
  3757. ) temp ", sqlWhere);
  3758. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3759. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  3760. var _view = new
  3761. {
  3762. PageFuncAuth = pageFunAuthView,
  3763. Data = _DelegationList
  3764. };
  3765. return Ok(JsonView(true, "查询成功!", _view, total));
  3766. }
  3767. else
  3768. {
  3769. return Ok(JsonView(false, "查询失败"));
  3770. }
  3771. }
  3772. /// <summary>
  3773. /// 获取团组费用审核
  3774. /// </summary>
  3775. /// <param name="_dto"></param>
  3776. /// <returns></returns>
  3777. [HttpPost]
  3778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3779. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  3780. {
  3781. try
  3782. {
  3783. #region 参数验证
  3784. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3785. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3786. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  3787. #region 页面操作权限验证
  3788. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3789. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3790. #endregion
  3791. #endregion
  3792. var _view = new Grp_CreditCardPaymentView();
  3793. var clientNameList = GetSimplClientList(_dto.DiId);
  3794. #region 费用清单
  3795. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  3796. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  3797. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  3798. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  3799. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  3800. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  3801. /*
  3802. * 76://酒店预订
  3803. */
  3804. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3805. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3806. /*
  3807. * 79://车/导游地接
  3808. */
  3809. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3810. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3811. /*
  3812. * 80: //签证
  3813. */
  3814. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3815. /*
  3816. *81: //邀请/公务活动
  3817. */
  3818. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3819. /*
  3820. * 82: //团组客户保险
  3821. */
  3822. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3823. /*
  3824. * Lable = 85 机票预订
  3825. */
  3826. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3827. /*
  3828. * 85 机票预定
  3829. */
  3830. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3831. /*
  3832. * 98 其他款项
  3833. */
  3834. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3835. /*
  3836. * 285:收款退还
  3837. */
  3838. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3839. /*
  3840. * 1015: //超支费用
  3841. */
  3842. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3843. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  3844. /*
  3845. * 币种信息
  3846. */
  3847. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  3848. /*
  3849. * 车/导游地接 费用类型
  3850. */
  3851. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  3852. /*
  3853. * 车/导游地接 费用类型
  3854. */
  3855. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  3856. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  3857. /*
  3858. * 用户信息
  3859. */
  3860. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  3861. /*
  3862. * 费用模块
  3863. */
  3864. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  3865. string priceModule = string.Empty;
  3866. if (sdPriceName != null)
  3867. {
  3868. priceModule = sdPriceName.Name;
  3869. }
  3870. /*
  3871. * 成本信息
  3872. */
  3873. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  3874. decimal _groupRate = 0.0000M;
  3875. string _groupCurrencyCode = "-";
  3876. if (groupCost != null)
  3877. {
  3878. _groupRate = groupCost.Rate;
  3879. if (int.TryParse(groupCost.Currency, out int _currency))
  3880. {
  3881. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  3882. }
  3883. else _groupCurrencyCode = groupCost.Currency;
  3884. }
  3885. string costContentSql = $"Select * From Grp_GroupCost";
  3886. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  3887. //处理日期为空的天数
  3888. for (int i = 0; i < groupCostDetails.Count; i++)
  3889. if (i != 0)
  3890. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  3891. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  3892. /*
  3893. * 处理详情数据
  3894. */
  3895. foreach (var entity in entityList)
  3896. {
  3897. var _detail = new Grp_CreditCardPaymentDetailView
  3898. {
  3899. Id = entity.Id,
  3900. PriceName = priceModule,
  3901. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  3902. };
  3903. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3904. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3905. //处理金额
  3906. if (entity.CTable == 1015)
  3907. {
  3908. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3909. if (czInfo != null)
  3910. {
  3911. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3912. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3913. }
  3914. }
  3915. /*
  3916. * 应付款金额
  3917. */
  3918. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3919. string PaymentCurrency_WaitPay = "Unknown";
  3920. string hotelCurrncyCode = "Unknown";
  3921. string hotelCurrncyName = "Unknown";
  3922. if (sdPaymentCurrency_WaitPay != null)
  3923. {
  3924. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3925. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3926. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3927. if (hotelCurrncyCode.Equals("CNY"))
  3928. {
  3929. entity.DayRate = 1.0000M;
  3930. }
  3931. }
  3932. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3933. /*
  3934. * 此次付款金额
  3935. */
  3936. decimal CurrPayStr = 0.00M,
  3937. OriginalCurrPay = 0.00M;
  3938. if (entity.PayPercentage == 0)
  3939. {
  3940. if (entity.PayThenMoney != 0)
  3941. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3942. }
  3943. else
  3944. {
  3945. if (entity.PayMoney != 0)
  3946. {
  3947. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3948. }
  3949. }
  3950. //if (_dto.Label == 79)
  3951. //{
  3952. // string original = string.Empty;
  3953. // if (hotelCurrncyCode.Equals("CNY"))
  3954. // {
  3955. // OriginalCurrPay = CurrPayStr;
  3956. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3957. // }
  3958. // else
  3959. // {
  3960. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3961. // //760 EUR(7600.00 CNY)
  3962. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3963. // }
  3964. //}
  3965. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3966. string original = string.Empty;
  3967. if (hotelCurrncyCode.Equals("CNY"))
  3968. {
  3969. OriginalCurrPay = CurrPayStr;
  3970. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3971. }
  3972. else
  3973. {
  3974. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3975. //760 EUR(7600.00 CNY)
  3976. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3977. }
  3978. /*
  3979. * 剩余尾款
  3980. */
  3981. decimal BalanceStr = 0;
  3982. if (CurrPayStr != 0)
  3983. {
  3984. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3985. BalanceStr = 0;
  3986. else
  3987. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3988. }
  3989. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3990. /*
  3991. * Bus名称
  3992. */
  3993. _detail.BusName = "待增加";
  3994. /*
  3995. *费用所属
  3996. */
  3997. switch (entity.CTable)
  3998. {
  3999. case 76://酒店预订
  4000. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4001. if (hotelReservations != null)
  4002. {
  4003. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  4004. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  4005. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  4006. string roomFeeStr = "", roomFeestr1 = "";
  4007. //是否比较房型价格
  4008. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  4009. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  4010. roomFeeStr += $"<br/>";
  4011. var roomTotal = 0.00M;
  4012. if (hotelReservations.SingleRoomPrice > 0)
  4013. {
  4014. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  4015. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4016. //__isSingle = true;
  4017. roomTotal += fee;
  4018. }
  4019. if (hotelReservations.DoubleRoomPrice > 0)
  4020. {
  4021. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  4022. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4023. // __isDouble = true;
  4024. roomTotal += fee;
  4025. }
  4026. if (hotelReservations.SuiteRoomPrice > 0)
  4027. {
  4028. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  4029. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4030. //__isSuite = true;
  4031. roomTotal += fee;
  4032. }
  4033. if (hotelReservations.OtherRoomPrice > 0)
  4034. {
  4035. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  4036. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4037. //__isOther = true;
  4038. roomTotal += fee;
  4039. }
  4040. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  4041. else roomFeeStr += " 0.00 * 0";
  4042. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  4043. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  4044. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  4045. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  4046. /*
  4047. * 费用类型
  4048. * 1:房费
  4049. * 2:早餐
  4050. * 3:地税
  4051. * 4:城市税
  4052. * </summary>
  4053. */
  4054. //地税
  4055. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  4056. if (governmentRentData != null)
  4057. {
  4058. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  4059. governmentRentFee = governmentRentData.Price;
  4060. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  4061. if (governmentRentCurrData != null)
  4062. {
  4063. governmentRentCode = governmentRentCurrData.Name;
  4064. governmentRentName = $"({governmentRentCurrData.Remark})";
  4065. }
  4066. }
  4067. //城市税
  4068. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  4069. if (cityTaxData != null)
  4070. {
  4071. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  4072. cityTaxFee = cityTaxData.Price;
  4073. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  4074. if (cityTaxCurrData != null)
  4075. {
  4076. cityTaxCode = cityTaxCurrData.Name;
  4077. cityTaxName = $"({cityTaxCurrData.Remark})";
  4078. }
  4079. }
  4080. //酒店早餐
  4081. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  4082. if (breakfastData != null)
  4083. {
  4084. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  4085. breakfastFee = breakfastData.Price;
  4086. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  4087. if (breakfastCurrData != null)
  4088. {
  4089. breakfastCode = breakfastCurrData.Name;
  4090. breakfastName = $"({breakfastCurrData.Remark})";
  4091. }
  4092. }
  4093. //房间费用
  4094. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  4095. if (roomData != null)
  4096. {
  4097. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  4098. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  4099. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  4100. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  4101. roomFee = roomData.Price;
  4102. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  4103. if (roomCurrData != null)
  4104. {
  4105. roomCode = roomCurrData.Name;
  4106. roomName = $"({roomCurrData.Remark})";
  4107. }
  4108. }
  4109. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  4110. string hotelCostStr = "";
  4111. decimal hotelCsotTotal = 0.00M;
  4112. if (groupCost != null)
  4113. {
  4114. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  4115. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  4116. }
  4117. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  4118. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  4119. string hotelCost_day = "";
  4120. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  4121. foreach (var item in hotelCostDetails1)
  4122. {
  4123. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  4124. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  4125. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  4126. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  4127. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  4128. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  4129. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  4130. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  4131. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  4132. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  4133. hotelCost_day += @$"<br/>";
  4134. }
  4135. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  4136. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  4137. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  4138. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  4139. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  4140. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  4141. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  4142. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  4143. $"房间说明: {hotelReservations.Remark} <br/>" +
  4144. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  4145. $"{hotelBreakfastStr}" +
  4146. $"{hotelGovernmentRentStr}" +
  4147. $"{hotelCityTaxStr}";
  4148. _detail.PriceNameContent = hotelReservations.HotelName;
  4149. }
  4150. break;
  4151. case 79://车/导游地接
  4152. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4153. if (touristGuideGroundReservations != null)
  4154. {
  4155. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  4156. {
  4157. _detail.BusName = touristGuideGroundReservations.BusName;
  4158. }
  4159. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  4160. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  4161. //if (isInt)
  4162. //{
  4163. // var cityInfo = cityData.Find(it => it.Id == cityId);
  4164. // if (cityInfo != null)
  4165. // {
  4166. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  4167. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  4168. // if (carFeeItem != null)
  4169. // {
  4170. // nameContent += $@"({carFeeItem.Name})";
  4171. // }
  4172. // _detail.PriceNameContent = nameContent;
  4173. // }
  4174. //}
  4175. //else
  4176. //{
  4177. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  4178. //}
  4179. var touristGuideGroundReservationsContents =
  4180. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  4181. var opContent_sb = new StringBuilder();
  4182. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  4183. opContent_sb.AppendLine(contetTitle);
  4184. foreach (var item in touristGuideGroundReservationsContents)
  4185. {
  4186. string typeName = "Unknown";
  4187. string carCurrencyCode = "Unknown";
  4188. string carCurrencyName = "Unknown";
  4189. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  4190. if (carTypeData != null) typeName = carTypeData.Name;
  4191. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  4192. if (currencyData != null)
  4193. {
  4194. carCurrencyCode = currencyData.Name;
  4195. carCurrencyName = currencyData.Remark;
  4196. }
  4197. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  4198. bool IsCurrencyAgreement = false;
  4199. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  4200. string opCostStr = string.Empty;
  4201. decimal opCostTypePrice = 0.00M;
  4202. #region 处理成本各项费用
  4203. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  4204. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  4205. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  4206. costOPFeeCNY = 0.00M, //团组成本 op费用
  4207. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  4208. if (opCost.Count > 0)
  4209. {
  4210. switch (item.SId)
  4211. {
  4212. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  4213. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  4214. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  4215. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  4216. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  4217. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  4218. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  4219. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  4220. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  4221. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  4222. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  4223. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  4224. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  4225. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  4226. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  4227. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  4228. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  4229. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  4230. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  4231. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  4232. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  4233. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  4234. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  4235. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  4236. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  4237. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  4238. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  4239. }
  4240. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  4241. costOPFeeCNY = opCostTypePrice * _groupRate;
  4242. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  4243. }
  4244. #endregion
  4245. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  4246. aduitOPFeeCNY = item.Price * entity.DayRate;
  4247. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  4248. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  4249. $"{opTypeStr} {opCostStr}<br/>" +
  4250. $"明细:{item.PriceContent ?? "-"}<br/>" +
  4251. $"备注:{item.Remark ?? "-"}<br/><br/>";
  4252. if (entity.IsAuditGM != 3) //状态 != 自动审核
  4253. {
  4254. if (IsCurrencyAgreement)
  4255. {
  4256. if (item.Price > opCostTypePrice)
  4257. {
  4258. opContent_sb.Append("<span style='color:red;'>");
  4259. opContent_sb.Append(opContent);
  4260. opContent_sb.Append("</span>");
  4261. opContent_sb.AppendLine();
  4262. }
  4263. else
  4264. {
  4265. opContent_sb.Append(opContent);
  4266. opContent_sb.AppendLine();
  4267. }
  4268. }
  4269. else
  4270. {
  4271. //验证是否超成本 按付款比例计算
  4272. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  4273. {
  4274. opContent_sb.Append("<span style='color:red;'>");
  4275. opContent_sb.Append(opContent);
  4276. opContent_sb.Append("</span>");
  4277. opContent_sb.AppendLine();
  4278. }
  4279. else
  4280. {
  4281. opContent_sb.Append(opContent);
  4282. opContent_sb.AppendLine();
  4283. }
  4284. }
  4285. }
  4286. else
  4287. {
  4288. opContent_sb.Append(opContent);
  4289. opContent_sb.AppendLine();
  4290. }
  4291. }
  4292. _detail.PriceMsgContent = opContent_sb.ToString();
  4293. }
  4294. break;
  4295. case 80: //签证
  4296. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  4297. if (visaInfo != null)
  4298. {
  4299. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  4300. _detail.PriceNameContent = visaInfo.VisaDescription;
  4301. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  4302. }
  4303. break;
  4304. case 81: //邀请/公务活动
  4305. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  4306. if (_ioa != null)
  4307. {
  4308. string inviteCurrName = "Unknown", //邀请费用币种 Name
  4309. inviteCurrCode = "Unknown", //邀请费用币种 Code
  4310. sendCurrName = "Unknown", //快递费用币种 Name
  4311. sendCurrCode = "Unknown", //快递费用币种 Code
  4312. eventsCurrName = "Unknown", //公务活动费币种 Name
  4313. eventsCurrCode = "Unknown", //公务活动费币种 Code
  4314. translateCurrName = "Unknown", //公务翻译费 Name
  4315. translateCurrCode = "Unknown"; //公务翻译费 Code
  4316. #region 处理费用币种
  4317. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  4318. if (inviteCurrData != null)
  4319. {
  4320. inviteCurrName = inviteCurrData.Remark;
  4321. inviteCurrCode = inviteCurrData.Name;
  4322. }
  4323. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  4324. if (sendCurrData != null)
  4325. {
  4326. sendCurrName = sendCurrData.Remark;
  4327. sendCurrCode = sendCurrData.Name;
  4328. }
  4329. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  4330. if (eventsCurrData != null)
  4331. {
  4332. eventsCurrName = eventsCurrData.Remark;
  4333. eventsCurrCode = eventsCurrData.Name;
  4334. }
  4335. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  4336. if (translateCurrData != null)
  4337. {
  4338. translateCurrName = translateCurrData.Remark;
  4339. translateCurrCode = translateCurrData.Name;
  4340. }
  4341. #endregion
  4342. _detail.PriceNameContent = _ioa.InviterArea;
  4343. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  4344. List<string> priceExpNames = new List<string>();
  4345. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  4346. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  4347. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  4348. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  4349. if (priceExpNames != null && priceExpNames.Count > 0)
  4350. {
  4351. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  4352. }
  4353. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  4354. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  4355. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  4356. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  4357. $@"备注:" + _ioa.Remark + "<br/>";
  4358. }
  4359. break;
  4360. case 82: //团组客户保险
  4361. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  4362. if (customers != null)
  4363. {
  4364. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  4365. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  4366. }
  4367. break;
  4368. case 85: //机票预订
  4369. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4370. if (jpRes != null)
  4371. {
  4372. string FlightsDescription = jpRes.FlightsDescription;
  4373. string PriceDescription = jpRes.PriceDescription;
  4374. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  4375. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  4376. }
  4377. break;
  4378. case 98://其他款项
  4379. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  4380. if (gdpRes != null)
  4381. {
  4382. //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/";
  4383. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  4384. //{
  4385. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  4386. //}
  4387. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  4388. _detail.PriceNameContent = gdpRes.PriceName;
  4389. }
  4390. break;
  4391. case 285://收款退还
  4392. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  4393. if (refundAndOtherMoney != null)
  4394. {
  4395. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  4396. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  4397. }
  4398. break;
  4399. case 751://酒店早餐
  4400. break;
  4401. case 1015://超支费用
  4402. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  4403. if (groupExtraCost != null)
  4404. {
  4405. _detail.PriceNameContent = groupExtraCost.PriceName;
  4406. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  4407. }
  4408. break;
  4409. default:
  4410. break;
  4411. }
  4412. /*
  4413. * 申请人
  4414. */
  4415. string operatorName = " - ";
  4416. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  4417. if (_opUser != null)
  4418. {
  4419. operatorName = _opUser.CnName;
  4420. }
  4421. _detail.OperatorName = operatorName;
  4422. /*
  4423. * 审核人
  4424. */
  4425. string auditOperatorName = " - ";
  4426. if (entity.IsAuditGM != 0)
  4427. {
  4428. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  4429. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  4430. else
  4431. {
  4432. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  4433. if (_adUser != null)
  4434. {
  4435. auditOperatorName = _adUser.CnName;
  4436. }
  4437. }
  4438. }
  4439. _detail.AuditOperatorName = auditOperatorName;
  4440. /*
  4441. * 超预算比例
  4442. */
  4443. string overBudgetStr = "";
  4444. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  4445. else if (entity.ExceedBudget == 0)
  4446. {
  4447. if (entity.CTable == 76 || entity.CTable == 79)
  4448. {
  4449. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  4450. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  4451. }
  4452. else
  4453. {
  4454. overBudgetStr = "未超预算";
  4455. }
  4456. }
  4457. else overBudgetStr = entity.ExceedBudget.ToString("P");
  4458. _detail.OverBudget = overBudgetStr;
  4459. decimal auditFee = 0.00M; //已审核金额 人名币
  4460. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  4461. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  4462. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  4463. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  4464. {
  4465. auditedFeeOriginal = entity.PayMoney;
  4466. auditFee = CurrPayStr;
  4467. }
  4468. else if (entity.IsAuditGM == 0)
  4469. {
  4470. unAuditFeeCNY = CurrPayStr;
  4471. unAuditFeeOriginal = OriginalCurrPay;
  4472. OriginalCurrPay = 0.00M;
  4473. }
  4474. /*
  4475. * 费用总计
  4476. */
  4477. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  4478. {
  4479. CurrencyId = entity.PaymentCurrency,
  4480. CurrencyName = PaymentCurrency_WaitPay,
  4481. AmountPayable = entity.PayMoney,
  4482. ThisPayment = OriginalCurrPay,
  4483. BalancePayment = BalanceStr,
  4484. AuditedFunds = auditFee,
  4485. AuditedFundsOriginal = auditedFeeOriginal,
  4486. UnAuditFundsCNY = unAuditFeeCNY,
  4487. UnAuditFundsOriginal = unAuditFeeOriginal
  4488. });
  4489. _detail.IsAuditGM = entity.IsAuditGM;
  4490. detailList.Add(_detail);
  4491. }
  4492. #endregion
  4493. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  4494. /*
  4495. * 下方描述处理
  4496. */
  4497. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  4498. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  4499. if (ccpCurrencyPrice != null)
  4500. {
  4501. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  4502. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  4503. }
  4504. else
  4505. {
  4506. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  4507. }
  4508. string amountPayableStr = string.Format(@"应付款总金额: ");
  4509. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  4510. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  4511. string auditedFundsStr = string.Format(@"已审费用总额: ");
  4512. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  4513. foreach (var item in nonDuplicat)
  4514. {
  4515. var currencyName = item.CurrencyName;
  4516. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  4517. if (strs.Count > 0)
  4518. {
  4519. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  4520. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  4521. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  4522. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  4523. //单独处理此次付款金额
  4524. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4525. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  4526. //单独处理已审核费用
  4527. //if (item.CurrencyId == 836) //人民币
  4528. //{
  4529. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  4530. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  4531. //}
  4532. //else
  4533. //{
  4534. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  4535. //}
  4536. if (currencyName.Equals("CNY"))
  4537. {
  4538. //已审核费用
  4539. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4540. //未审核费用
  4541. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  4542. }
  4543. else
  4544. {
  4545. //已审核费用
  4546. 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"));
  4547. //未审核费用
  4548. 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"));
  4549. }
  4550. }
  4551. }
  4552. _view.TotalStr1 = amountPayableStr[..^1];
  4553. _view.TotalStr2 = thisPaymentStr[..^1];
  4554. _view.TotalStr3 = balancePaymentStr[..^1];
  4555. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  4556. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  4557. var _view1 = new
  4558. {
  4559. PageFuncAuth = pageFunAuthView,
  4560. Data = _view
  4561. };
  4562. return Ok(JsonView(_view1));
  4563. }
  4564. catch (Exception ex)
  4565. {
  4566. return Ok(JsonView(false, ex.Message));
  4567. }
  4568. }
  4569. /// <summary>
  4570. /// 费用审核
  4571. /// 修改团组费用审核状态
  4572. /// </summary>
  4573. /// <param name="_dto">参数Json字符串</param>
  4574. /// <returns></returns>
  4575. [HttpPost]
  4576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4577. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  4578. {
  4579. #region 参数验证
  4580. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4581. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  4582. #endregion
  4583. #region 页面操作权限验证
  4584. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4585. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  4586. #endregion
  4587. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  4588. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  4589. DateTime dtNow = DateTime.Now;
  4590. _groupRepository.BeginTran();
  4591. int rst = 0;
  4592. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  4593. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  4594. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4595. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  4596. var msgDatas = new List<dynamic>();
  4597. var dic_ccp_user = new Dictionary<int, int>() { };
  4598. foreach (var item in idList)
  4599. {
  4600. int CreditId = int.Parse(item);
  4601. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  4602. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  4603. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  4604. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  4605. .Where(s => s.Id == CreditId)
  4606. .ExecuteCommandAsync();
  4607. if (result < 1)
  4608. {
  4609. rst = -1;
  4610. _groupRepository.RollbackTran();
  4611. return Ok(JsonView(false, "操作失败并回滚!"));
  4612. }
  4613. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  4614. if (creditData != null)
  4615. {
  4616. #region 应用通知配置
  4617. try
  4618. {
  4619. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  4620. }
  4621. catch (Exception ex)
  4622. {
  4623. }
  4624. #endregion
  4625. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  4626. string groupNameStr = string.Empty;
  4627. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  4628. if (groupData != null) groupNameStr = groupData.TeamName;
  4629. string creditTypeStr = string.Empty;
  4630. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  4631. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  4632. string creditCurrency = string.Empty;
  4633. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  4634. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  4635. if (creditCurrency.Equals("CNY"))
  4636. {
  4637. creditData.DayRate = 1.0000M;
  4638. }
  4639. if (creditData.PayPercentage == 0.00M)
  4640. {
  4641. creditData.PayPercentage = 100M;
  4642. }
  4643. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  4644. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  4645. string msgContent = "";
  4646. if (creditCurrency.Equals("CNY"))
  4647. {
  4648. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  4649. }
  4650. else
  4651. {
  4652. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  4653. }
  4654. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  4655. }
  4656. }
  4657. if (rst == 0)
  4658. {
  4659. _groupRepository.CommitTran();
  4660. foreach (var item in msgDatas)
  4661. {
  4662. //发送消息
  4663. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  4664. }
  4665. #region 应用推送
  4666. try
  4667. {
  4668. foreach (var ccpId in dic_ccp_user.Keys)
  4669. {
  4670. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  4671. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  4672. }
  4673. }
  4674. catch (Exception)
  4675. {
  4676. }
  4677. #endregion
  4678. return Ok(JsonView(true, "操作成功!"));
  4679. }
  4680. return Ok(JsonView(false, "操作失败!"));
  4681. }
  4682. /// <summary>
  4683. /// 费用审核
  4684. /// 其他款项 文件下载
  4685. /// </summary>
  4686. /// <param name="id">其他款项 主键编号</param>
  4687. /// <returns></returns>
  4688. [HttpGet("{id}")]
  4689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4690. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  4691. {
  4692. //网站域名
  4693. 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/";
  4694. var otherInfo = await _decreasePaymentsRep._sqlSugar
  4695. .Queryable<Grp_DecreasePayments>()
  4696. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  4697. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  4698. .Select((x, y) => new
  4699. {
  4700. x.Id,
  4701. x.FilePath
  4702. })
  4703. .FirstAsync();
  4704. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  4705. {
  4706. var url = $"{baseUrl}{otherInfo.FilePath}";
  4707. return Ok(JsonView(true, "操作成功!", url));
  4708. }
  4709. return Ok(JsonView(false, "暂无附件"));
  4710. }
  4711. #endregion
  4712. #region 机票费用录入
  4713. /// <summary>
  4714. /// 机票录入当前登录人可操作团组
  4715. /// </summary>
  4716. /// <param name="dto"></param>
  4717. /// <returns></returns>
  4718. [HttpPost]
  4719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4720. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  4721. {
  4722. try
  4723. {
  4724. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  4725. if (groupData.Code != 0)
  4726. {
  4727. return Ok(JsonView(false, groupData.Msg));
  4728. }
  4729. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4730. }
  4731. catch (Exception ex)
  4732. {
  4733. return Ok(JsonView(false, ex.Message));
  4734. }
  4735. }
  4736. /// <summary>
  4737. /// 机票费用录入列表
  4738. /// </summary>
  4739. /// <param name="dto"></param>
  4740. /// <returns></returns>
  4741. [HttpPost]
  4742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4743. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  4744. {
  4745. try
  4746. {
  4747. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  4748. if (groupData.Code != 0)
  4749. {
  4750. return Ok(JsonView(false, groupData.Msg));
  4751. }
  4752. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4753. }
  4754. catch (Exception ex)
  4755. {
  4756. return Ok(JsonView(false, ex.Message));
  4757. throw;
  4758. }
  4759. }
  4760. /// <summary>
  4761. /// 根据id查询费用录入信息
  4762. /// </summary>
  4763. /// <param name="dto"></param>
  4764. /// <returns></returns>
  4765. [HttpPost]
  4766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4767. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  4768. {
  4769. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  4770. if (groupData.Code != 0)
  4771. {
  4772. return Ok(JsonView(false, groupData.Msg));
  4773. }
  4774. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4775. }
  4776. /// <summary>
  4777. /// 机票费用录入操作(Status:1.新增,2.修改)
  4778. /// </summary>
  4779. /// <param name="dto"></param>
  4780. /// <returns></returns>
  4781. [HttpPost]
  4782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4783. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  4784. {
  4785. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  4786. if (groupData.Code != 0)
  4787. {
  4788. return Ok(JsonView(false, groupData.Msg));
  4789. }
  4790. #region 应用推送
  4791. try
  4792. {
  4793. var diId = dto.AirTicketResOpData.DiId;
  4794. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4795. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4796. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4797. //自动审核
  4798. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4799. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4800. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4801. $"GroupId:{diId};airId:{dataId};",
  4802. status,
  4803. auditMsg);
  4804. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4805. //2024-10-21 新增LZ UID
  4806. var userIds = new List<int>() { 21 };
  4807. string title = $"系统通知";
  4808. string content = "";
  4809. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4810. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4811. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4812. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4813. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4814. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4815. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4816. }
  4817. catch (Exception ex)
  4818. {
  4819. }
  4820. #endregion
  4821. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4822. }
  4823. /// <summary>
  4824. /// 机票费用自动审核 AI识别方式
  4825. /// </summary>
  4826. /// <returns></returns>
  4827. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4828. {
  4829. var ecoTypeIds = new List<int>() {
  4830. 459, //超经舱
  4831. 460, //经济舱
  4832. 1430, //公务舱(实际经济舱)
  4833. 1432, //头等舱(实际经济舱)
  4834. };
  4835. var bizTypeIds = new List<int>() {
  4836. 457, //头等舱
  4837. 458, //公务舱
  4838. 1431, //头等舱(实际公务舱)
  4839. };
  4840. var auditFeeTypeIds = new List<int>() { };
  4841. auditFeeTypeIds.AddRange(ecoTypeIds);
  4842. auditFeeTypeIds.AddRange(bizTypeIds);
  4843. int currModule = 85;
  4844. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4845. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4846. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4847. .Select((x, y) => new
  4848. {
  4849. x.Id,
  4850. CcpId = y.Id,
  4851. x.FlightsDate,
  4852. x.PrePrice,
  4853. x.CType,
  4854. x.ClientNum,
  4855. x.DIId
  4856. })
  4857. .FirstAsync();
  4858. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4859. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4860. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4861. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4862. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4863. var groupCostContents = await _sqlSugar
  4864. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4865. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4866. .ToListAsync();
  4867. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4868. //处理 成本详细信息日期为空 填装费用信息
  4869. var airFeeLabel = new StringBuilder();
  4870. airFeeLabel.AppendLine("费用成本:");
  4871. for (int i = 0; i < groupCostContents.Count; i++)
  4872. {
  4873. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4874. {
  4875. int index = i - 1;
  4876. if (index >= 0)
  4877. {
  4878. groupCostContents[i].Date = groupCostContents[index].Date;
  4879. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4880. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4881. }
  4882. }
  4883. else
  4884. {
  4885. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4886. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4887. }
  4888. var item = groupCostContents[i];
  4889. airFeeLabel.AppendLine($"{item.Date}");
  4890. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4891. }
  4892. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4893. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4894. //访问Kimi AI 返回价格结果
  4895. var msgs = new List<SeedMessages>()
  4896. {
  4897. new ()
  4898. {
  4899. Role = KimiRole.user,
  4900. Content = airFeeLabel.ToString()
  4901. }
  4902. };
  4903. var client = new KiMiApiClient();
  4904. var kimiApiResult = await client.SeedMessage(msgs);
  4905. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  4906. string clients = kimiApiResult_JObject["content"].ToString();
  4907. decimal ecoPri_kimiAI = 0.00M,
  4908. bizPri_kimiAI = 0.00M;
  4909. //单个价格: 经济舱价格
  4910. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  4911. //价格文本包含/:/前经济舱价格 /后公务舱价格
  4912. if (clients.Contains('/'))
  4913. {
  4914. var priArray = clients.Split('/');
  4915. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4916. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4917. }
  4918. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4919. var isAutoAudit = false;
  4920. //价格验证处理
  4921. //经济舱
  4922. if (ecoTypeIds.Contains(airInfo.CType))
  4923. {
  4924. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4925. }
  4926. //公务舱
  4927. else if (bizTypeIds.Contains(airInfo.CType))
  4928. {
  4929. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4930. }
  4931. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4932. //是否执行自动审核
  4933. if (isAutoAudit)
  4934. {
  4935. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4936. .SetColumns(x => x.IsAuditGM == 3)
  4937. .SetColumns(x => x.AuditGMOperate == 4)
  4938. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4939. .Where(x => x.Id == airInfo.CcpId)
  4940. .ExecuteCommandAsync();
  4941. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4942. }
  4943. return (false, "当前费用超过成本费用,不可自动审核!");
  4944. }
  4945. /// <summary>
  4946. /// 机票费用录入
  4947. /// 自动审核测试 - AI 识别
  4948. /// </summary>
  4949. /// <param name="groupId"></param>
  4950. /// <param name="Id"></param>
  4951. /// <returns></returns>
  4952. [HttpPost]
  4953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4954. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4955. {
  4956. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4957. return Ok(JsonView(status, msg));
  4958. }
  4959. /// <summary>
  4960. /// 根据舱位类型查询接团客户名单信息
  4961. /// </summary>
  4962. /// <param name="dto"></param>
  4963. /// <returns></returns>
  4964. [HttpPost]
  4965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4966. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4967. {
  4968. try
  4969. {
  4970. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4971. if (crm_Groups.Count != 0)
  4972. {
  4973. var Customer = new List<dynamic>();
  4974. foreach (var item in crm_Groups)
  4975. {
  4976. var data = new
  4977. {
  4978. item.Id,
  4979. item.Pinyin,
  4980. Name = item.LastName + item.FirstName
  4981. };
  4982. Customer.Add(data);
  4983. }
  4984. return Ok(JsonView(true, "查询成功!", Customer));
  4985. }
  4986. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4987. }
  4988. catch (Exception ex)
  4989. {
  4990. return Ok(JsonView(false, "程序错误!"));
  4991. throw;
  4992. }
  4993. }
  4994. /// <summary>
  4995. /// 根据团号获取客户信息
  4996. /// </summary>
  4997. /// <param name="dto"></param>
  4998. /// <returns></returns>
  4999. [HttpPost]
  5000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5001. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  5002. {
  5003. var jw = JsonView(false);
  5004. if (dto.DIID < 1)
  5005. {
  5006. jw.Msg += "请输入正确的diid";
  5007. return Ok(jw);
  5008. }
  5009. var arr = GetSimplClientList(dto.DIID);
  5010. jw = JsonView(true, "获取成功!", arr);
  5011. return Ok(jw);
  5012. }
  5013. private List<SimplClientInfo> GetSimplClientList(int diId)
  5014. {
  5015. 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);
  5016. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  5017. foreach (var item in arr)
  5018. {
  5019. EncryptionProcessor.DecryptProperties(item);
  5020. }
  5021. return arr;
  5022. }
  5023. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  5024. {
  5025. string result = origin;
  5026. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  5027. {
  5028. string[] temparr = origin.Split(',');
  5029. string fistrStr = temparr[0];
  5030. int count = temparr.Length;
  5031. bool success = int.TryParse(fistrStr, out int tempId);
  5032. if (success)
  5033. {
  5034. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  5035. if (tempInfo != null)
  5036. {
  5037. if (count > 1)
  5038. {
  5039. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  5040. }
  5041. else
  5042. {
  5043. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  5044. }
  5045. }
  5046. }
  5047. }
  5048. return result;
  5049. }
  5050. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  5051. {
  5052. string result = origin;
  5053. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  5054. {
  5055. string[] temparr = origin.Split(',');
  5056. result = "";
  5057. foreach (var item in temparr)
  5058. {
  5059. bool success = int.TryParse(item, out int tempId);
  5060. if (success)
  5061. {
  5062. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  5063. if (tempInfo != null)
  5064. {
  5065. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  5066. }
  5067. }
  5068. }
  5069. }
  5070. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  5071. return result;
  5072. }
  5073. /// <summary>
  5074. /// 机票费用录入,删除
  5075. /// </summary>
  5076. /// <param name="dto"></param>
  5077. /// <returns></returns>
  5078. [HttpPost]
  5079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5080. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  5081. {
  5082. try
  5083. {
  5084. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5085. if (res)
  5086. {
  5087. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  5088. {
  5089. IsDel = 1,
  5090. DeleteUserId = dto.DeleteUserId,
  5091. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5092. }).ExecuteCommandAsync();
  5093. return Ok(JsonView(true, "删除成功!"));
  5094. }
  5095. return Ok(JsonView(false, "删除失败!"));
  5096. }
  5097. catch (Exception ex)
  5098. {
  5099. return Ok(JsonView(false, "程序错误!"));
  5100. throw;
  5101. }
  5102. }
  5103. /// <summary>
  5104. /// 导出机票录入报表
  5105. /// </summary>
  5106. /// <param name="dto"></param>
  5107. /// <returns></returns>
  5108. [HttpPost]
  5109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5110. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  5111. {
  5112. try
  5113. {
  5114. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  5115. if (groupData.Code != 0)
  5116. {
  5117. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5118. }
  5119. else
  5120. {
  5121. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  5122. if (AirTicketReservations.Count != 0)
  5123. {
  5124. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  5125. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  5126. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  5127. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  5128. var designer = new WorkbookDesigner
  5129. {
  5130. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  5131. };
  5132. decimal countCost = 0;
  5133. foreach (var item in AirTicketReservations)
  5134. {
  5135. #region 处理客人姓名
  5136. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  5137. item.ClientName = clientNames;
  5138. #endregion
  5139. if (item.BankType == "其他")
  5140. {
  5141. item.BankNo = "--";
  5142. }
  5143. else
  5144. {
  5145. if (!string.IsNullOrEmpty(item.BankType))
  5146. {
  5147. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  5148. }
  5149. }
  5150. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  5151. item.Price = System.Decimal.Round(item.Price, 2);
  5152. countCost += Convert.ToDecimal(item.Price);
  5153. }
  5154. designer.SetDataSource("Export", AirTicketReservations);
  5155. designer.SetDataSource("ExportDiCode", diCode);
  5156. designer.SetDataSource("ExportDiName", diName);
  5157. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  5158. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  5159. designer.Process();
  5160. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  5161. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  5162. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  5163. return Ok(JsonView(true, "成功", url = rst));
  5164. }
  5165. else
  5166. {
  5167. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  5168. }
  5169. }
  5170. }
  5171. catch (Exception ex)
  5172. {
  5173. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  5174. throw;
  5175. }
  5176. }
  5177. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  5178. /// <summary>
  5179. /// 行程单导出
  5180. /// </summary>
  5181. /// <param name="dto"></param>
  5182. /// <returns></returns>
  5183. [HttpPost]
  5184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5185. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  5186. {
  5187. try
  5188. {
  5189. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  5190. if (groupData.Code != 0)
  5191. {
  5192. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5193. }
  5194. else
  5195. {
  5196. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  5197. if (dto.Language == "CN")
  5198. {
  5199. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  5200. var builder = new DocumentBuilder(doc);
  5201. int tableIndex = 0;//表格索引
  5202. //得到文档中的第一个表格
  5203. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5204. foreach (var item in _AirTicketReservations)
  5205. {
  5206. #region 处理固定数据
  5207. string[] FlightsCode = item.FlightsCode.Split('/');
  5208. if (FlightsCode.Length != 0)
  5209. {
  5210. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5211. if (_AirCompany != null)
  5212. {
  5213. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5214. }
  5215. else
  5216. {
  5217. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5218. }
  5219. }
  5220. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5221. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5222. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5223. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5224. string name = "";
  5225. foreach (string clientName in nameArray)
  5226. {
  5227. if (!name.Contains(clientName))
  5228. {
  5229. name += clientName + ",";
  5230. }
  5231. }
  5232. if (!string.IsNullOrWhiteSpace(name))
  5233. {
  5234. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5235. }
  5236. else
  5237. {
  5238. table.Range.Bookmarks["ClientName"].Text = "--";
  5239. }
  5240. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5241. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5242. table.Range.Bookmarks["JointTicket"].Text = "--";
  5243. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5244. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5245. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5246. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5247. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5248. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5249. #endregion
  5250. #region 循环数据处理
  5251. var airs = new List<AirInfo>();
  5252. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5253. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5254. for (int i = 0; i < FlightsCode.Length; i++)
  5255. {
  5256. var air = new AirInfo();
  5257. string[] tempstr = DayArray[i]
  5258. .Replace("\r\n", string.Empty)
  5259. .Replace("\\r\\n", string.Empty)
  5260. .TrimStart().TrimEnd()
  5261. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5262. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5263. string starCity = "";
  5264. if (star_Three != null)
  5265. {
  5266. starCity = star_Three.AirPort;
  5267. }
  5268. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5269. string EndCity = "";
  5270. if (End_Three != null)
  5271. {
  5272. EndCity = End_Three.AirPort;
  5273. }
  5274. air.Destination = starCity + "/" + EndCity;
  5275. air.Flight = FlightsCode[i];
  5276. air.SeatingClass = item.CTypeName;
  5277. string dateTime = tempstr[2];
  5278. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5279. air.FlightDate = DateTemp;
  5280. air.DepartureTime = tempstr[5];
  5281. air.LandingTime = tempstr[6];
  5282. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5283. air.TicketStatus = "--";
  5284. air.Luggage = "--";
  5285. air.DepartureTerminal = "--";
  5286. air.LandingTerminal = "--";
  5287. airs.Add(air);
  5288. }
  5289. int row = 13;
  5290. for (int i = 0; i < airs.Count; i++)
  5291. {
  5292. if (airs.Count > 2)
  5293. {
  5294. for (int j = 0; j < airs.Count - 2; j++)
  5295. {
  5296. var CopyRow = table.Rows[12].Clone(true);
  5297. table.Rows.Add(CopyRow);
  5298. }
  5299. }
  5300. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5301. int index = 0;
  5302. foreach (PropertyInfo property in properties)
  5303. {
  5304. string value = property.GetValue(airs[i]).ToString();
  5305. Cell ishcel0 = table.Rows[row].Cells[index];
  5306. var p = new Paragraph(doc);
  5307. string s = value;
  5308. p.AppendChild(new Run(doc, s));
  5309. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5310. ishcel0.AppendChild(p);
  5311. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5312. index++;
  5313. }
  5314. row++;
  5315. }
  5316. #endregion
  5317. var lastParagraph = new Paragraph(doc);
  5318. //第一个表格末尾加段落
  5319. table.ParentNode.InsertAfter(lastParagraph, table);
  5320. //复制第一个表格
  5321. Table cloneTable = (Table)table.Clone(true);
  5322. //在文档末尾段落后面加入复制的表格
  5323. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5324. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5325. {
  5326. int rownewsIndex = 13;
  5327. for (int i = 0; i < 2; i++)
  5328. {
  5329. var CopyRow = table.Rows[12].Clone(true);
  5330. table.Rows.RemoveAt(13);
  5331. table.Rows.Add(CopyRow);
  5332. rownewsIndex++;
  5333. }
  5334. }
  5335. else
  5336. {
  5337. table.Rows.RemoveAt(12);
  5338. }
  5339. cloneTable.Rows.RemoveAt(12);
  5340. }
  5341. if (_AirTicketReservations.Count != 0)
  5342. {
  5343. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5344. if (FlightsCode.Length != 0)
  5345. {
  5346. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5347. if (_AirCompany != null)
  5348. {
  5349. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5350. }
  5351. else
  5352. {
  5353. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5354. }
  5355. }
  5356. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5357. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5358. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5359. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5360. string name = "";
  5361. foreach (string clientName in nameArray)
  5362. {
  5363. if (!name.Contains(clientName))
  5364. {
  5365. name += clientName + ",";
  5366. }
  5367. }
  5368. if (!string.IsNullOrWhiteSpace(name))
  5369. {
  5370. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5371. }
  5372. else
  5373. {
  5374. table.Range.Bookmarks["ClientName"].Text = "--";
  5375. }
  5376. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5377. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5378. table.Range.Bookmarks["JointTicket"].Text = "--";
  5379. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5380. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5381. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5382. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5383. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5384. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5385. }
  5386. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5387. //保存合并后的文档
  5388. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  5389. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5390. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5391. return Ok(JsonView(true, "成功!", rst));
  5392. }
  5393. else
  5394. {
  5395. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  5396. var builder = new DocumentBuilder(doc);
  5397. int tableIndex = 0;//表格索引
  5398. //得到文档中的第一个表格
  5399. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5400. var texts = new List<string>();
  5401. foreach (var item in _AirTicketReservations)
  5402. {
  5403. string[] FlightsCode = item.FlightsCode.Split('/');
  5404. if (FlightsCode.Length != 0)
  5405. {
  5406. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5407. if (_AirCompany != null)
  5408. {
  5409. if (!transDic.ContainsKey(_AirCompany.CnName))
  5410. {
  5411. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  5412. }
  5413. }
  5414. else
  5415. {
  5416. if (!transDic.ContainsKey("--"))
  5417. {
  5418. transDic.Add("--", "--");
  5419. }
  5420. }
  5421. }
  5422. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5423. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5424. string name = "";
  5425. foreach (string clientName in nameArray)
  5426. {
  5427. name += clientName + ",";
  5428. }
  5429. if (!texts.Contains(name))
  5430. {
  5431. texts.Add(name);
  5432. }
  5433. var airs = new List<AirInfo>();
  5434. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5435. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5436. for (int i = 0; i < FlightsCode.Length; i++)
  5437. {
  5438. var air = new AirInfo();
  5439. string[] tempstr = DayArray[i]
  5440. .Replace("\r\n", string.Empty)
  5441. .Replace("\\r\\n", string.Empty)
  5442. .TrimStart().TrimEnd()
  5443. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5444. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5445. if (star_Three != null)
  5446. {
  5447. if (!transDic.ContainsKey(star_Three.AirPort))
  5448. {
  5449. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  5450. }
  5451. }
  5452. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5453. if (End_Three != null)
  5454. {
  5455. if (!transDic.ContainsKey(End_Three.AirPort))
  5456. {
  5457. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  5458. }
  5459. }
  5460. if (!texts.Contains(item.CTypeName))
  5461. {
  5462. texts.Add(item.CTypeName);
  5463. }
  5464. }
  5465. }
  5466. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5467. if (transData.Count > 0)
  5468. {
  5469. foreach (TranslateResult item in transData)
  5470. {
  5471. if (!transDic.ContainsKey(item.Query))
  5472. {
  5473. transDic.Add(item.Query, item.Translation);
  5474. }
  5475. }
  5476. }
  5477. foreach (var item in _AirTicketReservations)
  5478. {
  5479. #region 处理固定数据
  5480. string[] FlightsCode = item.FlightsCode.Split('/');
  5481. if (FlightsCode.Length != 0)
  5482. {
  5483. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5484. if (_AirCompany != null)
  5485. {
  5486. string str = "--";
  5487. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5488. if (!string.IsNullOrEmpty(translateResult))
  5489. {
  5490. str = translateResult;
  5491. str = _airTicketResRep.Processing(str);
  5492. }
  5493. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5494. }
  5495. else
  5496. {
  5497. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5498. }
  5499. }
  5500. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5501. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5502. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5503. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5504. string names = "";
  5505. foreach (string clientName in nameArray)
  5506. {
  5507. names += clientName + ",";
  5508. }
  5509. if (!string.IsNullOrWhiteSpace(names))
  5510. {
  5511. string str = "--";
  5512. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5513. if (!string.IsNullOrEmpty(translateResult))
  5514. {
  5515. str = translateResult;
  5516. str = _airTicketResRep.Processing(str);
  5517. }
  5518. table.Range.Bookmarks["ClientName"].Text = str;
  5519. }
  5520. else
  5521. {
  5522. table.Range.Bookmarks["ClientName"].Text = "--";
  5523. }
  5524. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5525. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5526. table.Range.Bookmarks["JointTicket"].Text = "--";
  5527. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5528. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5529. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5530. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5531. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5532. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5533. #endregion
  5534. #region 循环数据处理
  5535. var airs = new List<AirInfo>();
  5536. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5537. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5538. for (int i = 0; i < FlightsCode.Length; i++)
  5539. {
  5540. var air = new AirInfo();
  5541. string[] tempstr = DayArray[i]
  5542. .Replace("\r\n", string.Empty)
  5543. .Replace("\\r\\n", string.Empty)
  5544. .TrimStart().TrimEnd()
  5545. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5546. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5547. string starCity = "";
  5548. if (star_Three != null)
  5549. {
  5550. string str2 = "--";
  5551. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  5552. if (!string.IsNullOrEmpty(translateResult2))
  5553. {
  5554. str2 = translateResult2;
  5555. str2 = _airTicketResRep.Processing(str2);
  5556. }
  5557. starCity = str2;
  5558. }
  5559. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5560. string EndCity = "";
  5561. if (End_Three != null)
  5562. {
  5563. string str1 = "--";
  5564. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  5565. if (!string.IsNullOrEmpty(translateResult1))
  5566. {
  5567. str1 = translateResult1;
  5568. str1 = _airTicketResRep.Processing(str1);
  5569. }
  5570. EndCity = str1;
  5571. }
  5572. air.Destination = starCity + "/" + EndCity;
  5573. air.Flight = FlightsCode[i];
  5574. string str = "--";
  5575. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  5576. if (!string.IsNullOrEmpty(translateResult))
  5577. {
  5578. str = translateResult;
  5579. str = _airTicketResRep.Processing(str);
  5580. }
  5581. air.SeatingClass = str;
  5582. string dateTime = tempstr[2];
  5583. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5584. air.FlightDate = DateTemp;
  5585. air.DepartureTime = tempstr[5];
  5586. air.LandingTime = tempstr[6];
  5587. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5588. air.TicketStatus = "--";
  5589. air.Luggage = "--";
  5590. air.DepartureTerminal = "--";
  5591. air.LandingTerminal = "--";
  5592. airs.Add(air);
  5593. }
  5594. int row = 13;
  5595. for (int i = 0; i < airs.Count; i++)
  5596. {
  5597. if (airs.Count > 2)
  5598. {
  5599. for (int j = 0; j < airs.Count - 2; j++)
  5600. {
  5601. var CopyRow = table.Rows[12].Clone(true);
  5602. table.Rows.Add(CopyRow);
  5603. }
  5604. }
  5605. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5606. int index = 0;
  5607. foreach (PropertyInfo property in properties)
  5608. {
  5609. string value = property.GetValue(airs[i]).ToString();
  5610. Cell ishcel0 = table.Rows[row].Cells[index];
  5611. var p = new Paragraph(doc);
  5612. string s = value;
  5613. p.AppendChild(new Run(doc, s));
  5614. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5615. ishcel0.AppendChild(p);
  5616. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5617. //ishcel0.CellFormat.VerticalAlignment=
  5618. index++;
  5619. }
  5620. row++;
  5621. }
  5622. #endregion
  5623. var lastParagraph = new Paragraph(doc);
  5624. //第一个表格末尾加段落
  5625. table.ParentNode.InsertAfter(lastParagraph, table);
  5626. //复制第一个表格
  5627. Table cloneTable = (Table)table.Clone(true);
  5628. //在文档末尾段落后面加入复制的表格
  5629. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5630. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5631. {
  5632. int rownewsIndex = 13;
  5633. for (int i = 0; i < 2; i++)
  5634. {
  5635. var CopyRow = table.Rows[12].Clone(true);
  5636. table.Rows.RemoveAt(13);
  5637. table.Rows.Add(CopyRow);
  5638. rownewsIndex++;
  5639. }
  5640. }
  5641. else
  5642. {
  5643. table.Rows.RemoveAt(12);
  5644. }
  5645. cloneTable.Rows.RemoveAt(12);
  5646. }
  5647. if (_AirTicketReservations.Count != 0)
  5648. {
  5649. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5650. if (FlightsCode.Length != 0)
  5651. {
  5652. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5653. if (_AirCompany != null)
  5654. {
  5655. string str = "--";
  5656. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5657. if (!string.IsNullOrEmpty(translateResult))
  5658. {
  5659. str = translateResult;
  5660. str = _airTicketResRep.Processing(str);
  5661. }
  5662. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5663. }
  5664. else
  5665. {
  5666. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5667. }
  5668. }
  5669. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5670. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5671. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5672. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5673. string names = "";
  5674. foreach (string clientName in nameArray)
  5675. {
  5676. names += clientName + ",";
  5677. }
  5678. if (!string.IsNullOrWhiteSpace(names))
  5679. {
  5680. string str = "--";
  5681. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5682. if (!string.IsNullOrEmpty(translateResult))
  5683. {
  5684. str = translateResult;
  5685. str = _airTicketResRep.Processing(str);
  5686. }
  5687. table.Range.Bookmarks["ClientName"].Text = str;
  5688. }
  5689. else
  5690. {
  5691. table.Range.Bookmarks["ClientName"].Text = "--";
  5692. }
  5693. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5694. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5695. table.Range.Bookmarks["JointTicket"].Text = "--";
  5696. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5697. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5698. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5699. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5700. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5701. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5702. }
  5703. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5704. //保存合并后的文档
  5705. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  5706. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5707. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5708. return Ok(JsonView(true, "成功!", rst));
  5709. }
  5710. }
  5711. }
  5712. catch (Exception ex)
  5713. {
  5714. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  5715. throw;
  5716. }
  5717. }
  5718. #endregion
  5719. #region 团组增减款项 --> 其他款项
  5720. /// <summary>
  5721. /// 团组增减款项下拉框绑定
  5722. /// </summary>
  5723. /// <param name="dto"></param>
  5724. /// <returns></returns>
  5725. [HttpPost]
  5726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5727. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  5728. {
  5729. #region 参数验证
  5730. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5731. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  5732. #endregion
  5733. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  5734. }
  5735. /// <summary>
  5736. /// 根据团组Id查询团组增减款项
  5737. /// </summary>
  5738. /// <param name="dto"></param>
  5739. /// <returns></returns>
  5740. [HttpPost]
  5741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5742. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  5743. {
  5744. #region 参数验证
  5745. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5746. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5747. #endregion
  5748. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  5749. }
  5750. /// <summary>
  5751. /// 团组增减款项操作(Status:1.新增,2.修改)
  5752. /// </summary>
  5753. /// <param name="dto"></param>
  5754. /// <returns></returns>
  5755. [HttpPost]
  5756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5757. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  5758. {
  5759. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  5760. if (groupData.Code != 200)
  5761. {
  5762. return Ok(JsonView(false, groupData.Msg));
  5763. }
  5764. #region 应用推送
  5765. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  5766. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5767. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5768. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  5769. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  5770. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  5771. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  5772. if (recheck)
  5773. {
  5774. //自动审核
  5775. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  5776. }
  5777. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5778. //2024-10-21 新增LZ UID
  5779. var userIds = new List<int>() { 21 };
  5780. string title = $"系统通知";
  5781. string content = "";
  5782. var diId = dto.DiId;
  5783. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5784. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5785. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5786. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5787. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5788. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  5789. #endregion
  5790. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5791. }
  5792. /// <summary>
  5793. /// 团组增减款项操作 删除
  5794. /// </summary>
  5795. /// <param name="dto"></param>
  5796. /// <returns></returns>
  5797. [HttpPost]
  5798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5799. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5800. {
  5801. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5802. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5803. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5804. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5805. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5806. }
  5807. /// <summary>
  5808. /// 根据团组增减款项Id查询
  5809. /// </summary>
  5810. /// <param name="dto"></param>
  5811. /// <returns></returns>
  5812. [HttpPost]
  5813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5814. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5815. {
  5816. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5817. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5818. }
  5819. /// <summary>
  5820. /// 查询供应商名称
  5821. /// </summary>
  5822. /// <param name="dto"></param>
  5823. /// <returns></returns>
  5824. [HttpPost]
  5825. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5826. {
  5827. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5828. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5829. ?? new List<Grp_DecreasePayments>();
  5830. dbResult = dbResult.Distinct(new
  5831. ProductComparer()).ToList();
  5832. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5833. {
  5834. x.Id,
  5835. x.SupplierAddress,
  5836. x.SupplierArea,
  5837. x.SupplierContact,
  5838. x.SupplierContactNumber,
  5839. x.SupplierEmail,
  5840. x.SupplierName,
  5841. x.SupplierSocialAccount,
  5842. x.SupplierTypeId,
  5843. }).ToList());
  5844. return Ok(jw);
  5845. }
  5846. /// <summary>
  5847. /// 团组增减款项 OTA匹配
  5848. /// </summary>
  5849. /// <param name="file"></param>
  5850. /// <returns></returns>
  5851. [HttpPost]
  5852. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5853. {
  5854. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5855. string fileName = file.FileName;
  5856. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5857. {
  5858. return Ok(JsonView(false, "请上传Excel文件!"));
  5859. }
  5860. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5861. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5862. if (!Directory.Exists(path))
  5863. {
  5864. Directory.CreateDirectory(path);
  5865. }
  5866. var filePath = @$"{path}/{fileName}";
  5867. //保存文件
  5868. using (FileStream fs = System.IO.File.Create(filePath))
  5869. {
  5870. file.CopyTo(fs);
  5871. fs.Flush();
  5872. }
  5873. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5874. //读取ExcelFile
  5875. DataTable dt = ConvertExcelToDataTable(filePath);
  5876. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5877. dt.TableName = "TB";
  5878. //修改table列名
  5879. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5880. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5881. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5882. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5883. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5884. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5885. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5886. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5887. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5888. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5889. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5890. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5891. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5892. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5893. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5894. var otaOrderNos = new List<string>();
  5895. foreach (DataRow item in dt.Rows)
  5896. {
  5897. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5898. }
  5899. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5900. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  5901. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  5902. .Select((dp, di) => new
  5903. {
  5904. dp.PriceName,
  5905. dp.OTAOrderNo,
  5906. dp.FeeTotal,
  5907. di.TeamName,
  5908. })
  5909. .ToListAsync();
  5910. foreach (DataRow item in dt.Rows)
  5911. {
  5912. var otaOrderNo = item["OTAOrderNo"].ToString();
  5913. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5914. if (oaData == null) continue;
  5915. item["GroupName"] = oaData.TeamName;
  5916. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5917. }
  5918. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5919. var pairs = new Dictionary<string, object>();
  5920. var datas = new List<DataTable>
  5921. {
  5922. dt
  5923. };
  5924. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5925. return Ok(JsonView(true, "操作成功", new { url }));
  5926. }
  5927. #region
  5928. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5929. {
  5930. // 创建Workbook对象
  5931. var workbook = new Workbook(excelFilePath);
  5932. // 获取第一个工作表
  5933. var worksheet = workbook.Worksheets[0];
  5934. // 将工作表转换为DataTable
  5935. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5936. return dataTable;
  5937. }
  5938. #endregion
  5939. /// <summary>
  5940. /// 世运会数据
  5941. /// </summary>
  5942. /// <returns></returns>
  5943. [HttpGet]
  5944. public IActionResult WorldGamesData()
  5945. {
  5946. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5947. var groupMenu = setData.GroupBy(x => x.T0);
  5948. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5949. foreach (var item in groupMenu)
  5950. {
  5951. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5952. {
  5953. Data = new SetDataView
  5954. {
  5955. Name = item.Key
  5956. },
  5957. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5958. });
  5959. }
  5960. return Ok(JsonView(true, "success", resultArr));
  5961. }
  5962. #endregion
  5963. #region 文件上传、删除
  5964. /// <summary>
  5965. /// region 文件上传 可以带参数
  5966. /// </summary>
  5967. /// <param name="file"></param>
  5968. /// <returns></returns>
  5969. [HttpPost]
  5970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5971. public async Task<IActionResult> UploadProject(IFormFile file)
  5972. {
  5973. //var TypeName = Request.Headers["TypeName"].ToString();
  5974. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5975. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5976. ////文件名称
  5977. //string projectFileName = file.FileName;
  5978. ////上传的文件的路径
  5979. //string filePath = $"{fileDir}/{projectFileName}";
  5980. //if (TypeName == "A")//A代表团组增减款项
  5981. //{
  5982. // filePath = fileDir + $@"\团组增减款项相关文件";
  5983. // if (!Directory.Exists(filePath))
  5984. // {
  5985. // Directory.CreateDirectory(filePath);
  5986. // }
  5987. // //上传的文件的路径
  5988. // filePath += $@"\{projectFileName}";
  5989. //}
  5990. //else if (TypeName == "B")//B代表商邀相关文件
  5991. //{
  5992. // //上传的文件的路径
  5993. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5994. // if (!Directory.Exists(filePath))
  5995. // {
  5996. // Directory.CreateDirectory(filePath);
  5997. // }
  5998. // //上传的文件的路径
  5999. // filePath = $@"\{projectFileName}";
  6000. //}
  6001. //try
  6002. //{
  6003. // using (FileStream fs = System.IO.File.Create(filePath))
  6004. // {
  6005. // file.CopyTo(fs);
  6006. // fs.Flush();
  6007. // }
  6008. //}
  6009. //catch (Exception ex)
  6010. //{
  6011. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  6012. //}
  6013. //return Ok(JsonView(true, "上传成功!", projectFileName));
  6014. try
  6015. {
  6016. var TypeName = Request.Headers["TypeName"].ToString();
  6017. if (file != null)
  6018. {
  6019. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6020. //文件名称
  6021. string projectFileName = file.FileName;
  6022. //上传的文件的路径
  6023. string filePath = $"{fileDir}/{projectFileName}";
  6024. if (TypeName == "A")//A代表团组增减款项
  6025. {
  6026. if (!Directory.Exists(fileDir))
  6027. {
  6028. Directory.CreateDirectory(fileDir);
  6029. }
  6030. //上传的文件的路径
  6031. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  6032. }
  6033. else if (TypeName == "B")//B代表商邀相关文件
  6034. {
  6035. if (!Directory.Exists(fileDir))
  6036. {
  6037. Directory.CreateDirectory(fileDir);
  6038. }
  6039. //上传的文件的路径
  6040. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6041. }
  6042. using (FileStream fs = System.IO.File.Create(filePath))
  6043. {
  6044. file.CopyTo(fs);
  6045. fs.Flush();
  6046. }
  6047. return Ok(JsonView(true, "上传成功!", projectFileName));
  6048. }
  6049. else
  6050. {
  6051. return Ok(JsonView(false, "上传失败!"));
  6052. }
  6053. }
  6054. catch (Exception ex)
  6055. {
  6056. return Ok(JsonView(false, ex.Message));
  6057. }
  6058. }
  6059. /// <summary>
  6060. /// 删除指定文件
  6061. /// </summary>
  6062. /// <param name="dto"></param>
  6063. /// <returns></returns>
  6064. [HttpPost]
  6065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6066. public async Task<IActionResult> DelFile(DelFileDto dto)
  6067. {
  6068. try
  6069. {
  6070. var TypeName = Request.Headers["TypeName"].ToString();
  6071. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  6072. string filePath = "";
  6073. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6074. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  6075. int id = 0;
  6076. if (TypeName == "A")
  6077. {
  6078. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  6079. // 删除该文件
  6080. System.IO.File.Delete(filePath);
  6081. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  6082. .Where(a => a.Id == dto.Id)
  6083. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  6084. .ExecuteCommandAsync();
  6085. }
  6086. else if (TypeName == "B")
  6087. {
  6088. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  6089. // 删除该文件
  6090. System.IO.File.Delete(filePath);
  6091. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  6092. if (info != null)
  6093. {
  6094. string[] files = Array.Empty<string>();
  6095. if (!string.IsNullOrEmpty(info.Attachment))
  6096. {
  6097. try
  6098. {
  6099. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  6100. }
  6101. catch (Exception)
  6102. {
  6103. files = new List<string>() { info.Attachment }.ToArray();
  6104. }
  6105. }
  6106. if (files.Length > 0)
  6107. {
  6108. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  6109. string filePath2 = string.Empty;
  6110. if (files1.Length > 0)
  6111. {
  6112. filePath2 = JsonConvert.SerializeObject(files1);
  6113. }
  6114. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6115. .Where(a => a.Id == dto.Id)
  6116. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  6117. .ExecuteCommandAsync();
  6118. }
  6119. }
  6120. }
  6121. if (id != 0)
  6122. {
  6123. return Ok(JsonView(true, "成功!"));
  6124. }
  6125. else
  6126. {
  6127. return Ok(JsonView(false, "失败!"));
  6128. }
  6129. }
  6130. catch (Exception ex)
  6131. {
  6132. return Ok(JsonView(false, "程序错误!"));
  6133. throw;
  6134. }
  6135. }
  6136. /// <summary>
  6137. /// 文件上传多个文件 可以带参数
  6138. /// </summary>
  6139. /// <param name="files"></param>
  6140. /// <returns></returns>
  6141. [HttpPost]
  6142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6143. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  6144. {
  6145. try
  6146. {
  6147. var TypeName = Request.Headers["TypeName"].ToString();
  6148. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  6149. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  6150. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6151. var filePahts = new List<string>();
  6152. foreach (var file in files)
  6153. {
  6154. //文件名称
  6155. string projectFileName = file.FileName;
  6156. //上传的文件的路径
  6157. string filePath = $"{fileDir}/{projectFileName}";
  6158. if (TypeName == "A")//A代表团组增减款项
  6159. {
  6160. if (!Directory.Exists(fileDir))
  6161. {
  6162. Directory.CreateDirectory(fileDir);
  6163. }
  6164. //上传的文件的路径
  6165. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  6166. }
  6167. else if (TypeName == "B")//B代表商邀相关文件
  6168. {
  6169. if (!Directory.Exists(fileDir))
  6170. {
  6171. Directory.CreateDirectory(fileDir);
  6172. }
  6173. //上传的文件的路径
  6174. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6175. }
  6176. using (FileStream fs = System.IO.File.Create(filePath))
  6177. {
  6178. file.CopyTo(fs);
  6179. fs.Flush();
  6180. }
  6181. filePahts.Add(projectFileName);
  6182. }
  6183. return Ok(JsonView(true, "上传成功!", filePahts));
  6184. }
  6185. catch (Exception ex)
  6186. {
  6187. return Ok(JsonView(false, ex.Message));
  6188. }
  6189. }
  6190. #endregion
  6191. #region 商邀费用录入
  6192. /// <summary>
  6193. /// 根据团组Id查询商邀费用列表
  6194. /// </summary>
  6195. /// <param name="dto"></param>
  6196. /// <returns></returns>
  6197. [HttpPost]
  6198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6199. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  6200. {
  6201. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  6202. if (groupData.Code != 0)
  6203. {
  6204. return Ok(JsonView(false, groupData.Msg));
  6205. }
  6206. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6207. }
  6208. /// <summary>
  6209. /// 商邀费用列表
  6210. /// 下载文件
  6211. /// </summary>
  6212. /// <param name="id"></param>
  6213. /// <returns></returns>
  6214. [HttpGet("{id}")]
  6215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6216. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  6217. {
  6218. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  6219. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  6220. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  6221. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  6222. var filePaths = new List<string>();
  6223. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  6224. try
  6225. {
  6226. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  6227. }
  6228. catch (Exception ex)
  6229. {
  6230. filePaths.Add(info.Attachment);
  6231. }
  6232. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  6233. for (int i = 0; i < filePaths.Count; i++)
  6234. {
  6235. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  6236. }
  6237. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  6238. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  6239. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  6240. {
  6241. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  6242. {
  6243. foreach (string filePath in filePaths)
  6244. {
  6245. if (System.IO.File.Exists(filePath))
  6246. {
  6247. // 获取文件名
  6248. string fileName = Path.GetFileName(filePath);
  6249. // 将文件添加到ZIP归档中
  6250. zipArchive.CreateEntryFromFile(filePath, fileName);
  6251. }
  6252. }
  6253. }
  6254. }
  6255. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  6256. }
  6257. /// <summary>
  6258. /// 商邀费用 Info Page 基础数据源
  6259. /// </summary>
  6260. /// <returns></returns>
  6261. [HttpPost]
  6262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6263. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  6264. {
  6265. try
  6266. {
  6267. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  6268. if (groupData.Code != 0)
  6269. {
  6270. return Ok(JsonView(false, groupData.Msg));
  6271. }
  6272. return Ok(JsonView(true, "操作成功", groupData.Data));
  6273. }
  6274. catch (Exception ex)
  6275. {
  6276. return Ok(JsonView(false, ex.Message));
  6277. throw;
  6278. }
  6279. }
  6280. /// <summary>
  6281. /// 根据商邀费用ID查询C表和商邀费用数据
  6282. /// </summary>
  6283. /// <param name="dto"></param>
  6284. /// <returns></returns>
  6285. [HttpPost]
  6286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6287. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  6288. {
  6289. try
  6290. {
  6291. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  6292. if (groupData.Code != 0)
  6293. {
  6294. return Ok(JsonView(false, groupData.Msg));
  6295. }
  6296. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6297. }
  6298. catch (Exception ex)
  6299. {
  6300. return Ok(JsonView(false, ex.Message));
  6301. throw;
  6302. }
  6303. }
  6304. /// <summary>
  6305. /// 商邀费用录入操作(Status:1.新增,2.修改)
  6306. /// </summary>
  6307. /// <param name="dto"></param>
  6308. /// <returns></returns>
  6309. [HttpPost]
  6310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6311. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  6312. {
  6313. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  6314. if (groupData.Code != 0)
  6315. {
  6316. return Ok(JsonView(false, groupData.Msg));
  6317. }
  6318. #region 应用推送
  6319. try
  6320. {
  6321. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6322. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6323. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6324. //2024-10-21 新增LZ UID
  6325. var userIds = new List<int>() { 21 };
  6326. string title = $"系统通知";
  6327. string content = "";
  6328. var diId = dto.DiId;
  6329. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6330. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6331. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6332. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6333. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6334. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  6335. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6336. }
  6337. catch (Exception ex)
  6338. {
  6339. }
  6340. #endregion
  6341. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6342. }
  6343. /// <summary>
  6344. /// 商邀删除
  6345. /// </summary>
  6346. /// <param name="dto"></param>
  6347. /// <returns></returns>
  6348. [HttpPost]
  6349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6350. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  6351. {
  6352. try
  6353. {
  6354. _sqlSugar.BeginTran();
  6355. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6356. .SetColumns(it => new Grp_InvitationOfficialActivities()
  6357. {
  6358. IsDel = 1,
  6359. DeleteUserId = dto.DeleteUserId,
  6360. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6361. })
  6362. .Where(it => it.Id == dto.Id)
  6363. .ExecuteCommand();
  6364. if (res1 > 0)
  6365. {
  6366. int _diId = 0;
  6367. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  6368. if (_ioaInfo != null)
  6369. {
  6370. _diId = _ioaInfo.DiId;
  6371. }
  6372. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6373. .SetColumns(a => new Grp_CreditCardPayment()
  6374. {
  6375. IsDel = 1,
  6376. DeleteUserId = dto.DeleteUserId,
  6377. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6378. })
  6379. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  6380. .ExecuteCommand();
  6381. if (res2 > 0)
  6382. {
  6383. _sqlSugar.CommitTran();
  6384. return Ok(JsonView(true, "删除成功!"));
  6385. }
  6386. }
  6387. _sqlSugar.RollbackTran();
  6388. return Ok(JsonView(false, "删除失败"));
  6389. }
  6390. catch (Exception ex)
  6391. {
  6392. _sqlSugar.RollbackTran();
  6393. return Ok(JsonView(false, ex.Message));
  6394. }
  6395. }
  6396. #endregion
  6397. #region 票据上传
  6398. /// <summary>
  6399. /// 团组模块文件上传
  6400. /// </summary>
  6401. /// <param name="dto"></param>
  6402. /// <returns></returns>
  6403. [HttpPost]
  6404. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  6405. {
  6406. var jw = JsonView(false);
  6407. long M = 1024 * 1024;
  6408. if (dto.Files == null || dto.Files.Count == 0)
  6409. {
  6410. jw.Msg = "无文件信息!";
  6411. return Ok(jw);
  6412. }
  6413. if (dto.Files.Sum(x => x.Length) > 20 * M)
  6414. {
  6415. jw.Msg = "文件大小超过20M!";
  6416. return Ok(jw);
  6417. }
  6418. //var nameSp = dto.File.FileName.Split(".");
  6419. //if (nameSp.Length < 2)
  6420. //{
  6421. // jw.Msg = "拓展名称有误!";
  6422. // return Ok(jw);
  6423. //}
  6424. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  6425. //if (!existsName.Contains(nameSp[1].ToUpper()))
  6426. //{
  6427. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  6428. // return Ok(jw);
  6429. //}
  6430. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  6431. if (Ctable == null)
  6432. {
  6433. jw.Msg = "Ctable指向有误!";
  6434. return Ok(jw);
  6435. }
  6436. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6437. if (groupInfo == null)
  6438. {
  6439. jw.Msg = "团组信息不存在!";
  6440. return Ok(jw);
  6441. }
  6442. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  6443. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6444. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6445. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6446. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  6447. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  6448. try
  6449. {
  6450. if (!Directory.Exists(fileBase))
  6451. {
  6452. Directory.CreateDirectory(fileBase);
  6453. }
  6454. var saveArr = new List<Grp_GroupModelFile>();
  6455. foreach (var fileStream in dto.Files)
  6456. {
  6457. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  6458. var file = new Grp_GroupModelFile()
  6459. {
  6460. Cid = dto.Cid,
  6461. CreateTime = DateTime.Now,
  6462. CreateUserId = dto.Userid,
  6463. Ctable = dto.Ctable,
  6464. Diid = dto.Diid,
  6465. IsDel = 0,
  6466. FilePath = saveFilePath,
  6467. FileName = fileStream.FileName
  6468. };
  6469. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6470. {
  6471. fileStream.CopyTo(fs);
  6472. fs.Flush();
  6473. }
  6474. saveArr.Add(file);
  6475. }
  6476. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  6477. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  6478. jw = JsonView(true, "保存成功!", new
  6479. {
  6480. count = addResult,
  6481. filesName = saveArr.Select(x => x.FileName)
  6482. });
  6483. }
  6484. catch (Exception ex)
  6485. {
  6486. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  6487. {
  6488. count = 0,
  6489. filesName = Array.Empty<string>(),
  6490. });
  6491. }
  6492. return Ok(jw);
  6493. }
  6494. /// <summary>
  6495. /// 查询各模块已保存文件
  6496. /// </summary>
  6497. /// <param name="dto"></param>
  6498. /// <returns></returns>
  6499. [HttpPost]
  6500. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  6501. {
  6502. var expression = Expressionable.Create<Grp_GroupModelFile>()
  6503. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  6504. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  6505. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  6506. {
  6507. expression = Expressionable.Create<Grp_GroupModelFile>()
  6508. .And(x => visaIds.Contains(x.CreateUserId));
  6509. }
  6510. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  6511. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  6512. .Where(expression.ToExpression())
  6513. .ToList();
  6514. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  6515. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  6516. {
  6517. x.FileName,
  6518. x.Id,
  6519. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  6520. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  6521. })));
  6522. }
  6523. /// <summary>
  6524. /// 下载该团组下的所有文件
  6525. /// </summary>
  6526. /// <param name="dto"></param>
  6527. /// <returns></returns>
  6528. [HttpPost]
  6529. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  6530. {
  6531. var jw = JsonView(false);
  6532. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6533. if (groupInfo == null)
  6534. {
  6535. jw.Msg = "团组信息不存在!";
  6536. return Ok(jw);
  6537. }
  6538. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  6539. var isModule = Convert.ToBoolean(dto.isModule);
  6540. var Zips = new Dictionary<string, Stream>();
  6541. var io = new IOOperatorHelper();
  6542. if (isModule)
  6543. {
  6544. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  6545. foreach (var moduleArr in moduleGroup)
  6546. {
  6547. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  6548. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6549. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6550. var chiZips = new Dictionary<string, Stream>();
  6551. foreach (var item in moduleArr)
  6552. {
  6553. if (System.IO.File.Exists(item.FilePath))
  6554. {
  6555. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6556. {
  6557. byte[] bytes = new byte[fileStream.Length];
  6558. fileStream.Read(bytes, 0, bytes.Length);
  6559. fileStream.Close();
  6560. Stream stream = new MemoryStream(bytes);
  6561. chiZips.Add(item.FileName, stream);
  6562. }
  6563. }
  6564. }
  6565. if (chiZips.Count > 0)
  6566. {
  6567. var byts = io.ConvertZipStream(chiZips);
  6568. Stream stream = new MemoryStream(byts);
  6569. Zips.Add(key.Name + "_.zip", stream);
  6570. }
  6571. }
  6572. }
  6573. else
  6574. {
  6575. foreach (var item in dbQuery)
  6576. {
  6577. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6578. {
  6579. byte[] bytes = new byte[fileStream.Length];
  6580. fileStream.Read(bytes, 0, bytes.Length);
  6581. fileStream.Close();
  6582. var stream = new MemoryStream(bytes);
  6583. while (Zips.ContainsKey(item.FileName))
  6584. {
  6585. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6586. }
  6587. Zips.Add(item.FileName, stream);
  6588. }
  6589. }
  6590. }
  6591. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6592. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6593. if (Zips.Count > 0)
  6594. {
  6595. var byts = io.ConvertZipStream(Zips);
  6596. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6597. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  6598. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  6599. }
  6600. else
  6601. {
  6602. jw.Msg = "暂无生成文件!";
  6603. }
  6604. return Ok(jw);
  6605. }
  6606. /// <summary>
  6607. /// 下载该团组下此模块的所有文件
  6608. /// </summary>
  6609. /// <param name="dto"></param>
  6610. /// <returns></returns>
  6611. [HttpPost]
  6612. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  6613. {
  6614. var jw = JsonView(false);
  6615. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6616. if (groupInfo == null)
  6617. {
  6618. jw.Msg = "团组信息不存在!";
  6619. return Ok(jw);
  6620. }
  6621. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  6622. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  6623. && x.IsDel == 0);
  6624. if (key == null)
  6625. {
  6626. jw.Msg = "Ctable指向错误!";
  6627. return Ok(jw);
  6628. }
  6629. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6630. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6631. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6632. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6633. var io = new IOOperatorHelper();
  6634. var Zips = new Dictionary<string, Stream>();
  6635. foreach (var item in dbQuery)
  6636. {
  6637. if (System.IO.File.Exists(item.FilePath))
  6638. {
  6639. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6640. {
  6641. byte[] bytes = new byte[fileStream.Length];
  6642. fileStream.Read(bytes, 0, bytes.Length);
  6643. fileStream.Close();
  6644. var stream = new MemoryStream(bytes);
  6645. while (Zips.ContainsKey(item.FileName))
  6646. {
  6647. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6648. }
  6649. Zips.Add(item.FileName, stream);
  6650. }
  6651. }
  6652. }
  6653. if (Zips.Count > 0)
  6654. {
  6655. var byts = io.ConvertZipStream(Zips);
  6656. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6657. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  6658. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  6659. }
  6660. else
  6661. {
  6662. jw.Msg = "暂无生成文件!";
  6663. }
  6664. return Ok(jw);
  6665. }
  6666. /// <summary>
  6667. /// 删除该团组下的指定文件
  6668. /// </summary>
  6669. /// <param name="dto"></param>
  6670. /// <returns></returns>
  6671. [HttpPost]
  6672. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  6673. {
  6674. var jw = JsonView(false);
  6675. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6676. if (sing == null)
  6677. {
  6678. jw.Msg = "暂无";
  6679. return Ok(jw);
  6680. }
  6681. if (System.IO.File.Exists(sing.FilePath))
  6682. {
  6683. try
  6684. {
  6685. System.IO.File.Delete(sing.FilePath);
  6686. }
  6687. catch (Exception ex)
  6688. {
  6689. jw.Msg = "删除失败!" + ex.Message;
  6690. return Ok(jw);
  6691. }
  6692. }
  6693. sing.IsDel = 1;
  6694. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6695. sing.DeleteUserId = dto.UserId;
  6696. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  6697. jw = JsonView(true, "删除成功!");
  6698. return Ok(jw);
  6699. }
  6700. #endregion
  6701. #region 共享文件上传
  6702. /// <summary>
  6703. /// 共享文件数据初始化
  6704. /// </summary>
  6705. /// <returns></returns>
  6706. [HttpGet]
  6707. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  6708. {
  6709. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  6710. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  6711. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  6712. .Select(x => x.Id)
  6713. .ToList()
  6714. .Contains(userid);
  6715. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  6716. .Where(x => x.STid == 111 && x.IsDel == 0)
  6717. .Select(x => new
  6718. {
  6719. x.Name,
  6720. x.Id,
  6721. }).ToList();
  6722. if (isMarketingDepartment)
  6723. {
  6724. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  6725. }
  6726. if (portType == 1)
  6727. {
  6728. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  6729. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  6730. .Where(x => x.IsDel == 0)
  6731. .OrderByDescending(x => x.VisitDate)
  6732. .Select(x => new
  6733. {
  6734. x.TeamName,
  6735. x.Id,
  6736. x.CityId,
  6737. })
  6738. .ToList()
  6739. .Select(x =>
  6740. {
  6741. var provinceId = x.CityId;
  6742. var isDefualtVal = true;
  6743. if (provinceId > 0)
  6744. {
  6745. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  6746. if (parentId != null)
  6747. {
  6748. isDefualtVal = false;
  6749. provinceId = (int)parentId;
  6750. }
  6751. }
  6752. if (isDefualtVal)
  6753. {
  6754. provinceId = 122; //默认四川
  6755. }
  6756. return new
  6757. {
  6758. x.TeamName,
  6759. x.Id,
  6760. provinceId,
  6761. };
  6762. })
  6763. .ToList();
  6764. return Ok(JsonView(true, "SUCCESS!", new
  6765. {
  6766. dropDownType,
  6767. dropDownGroupList,
  6768. isMarketingDepartment
  6769. }));
  6770. }
  6771. else if (portType == 2 || portType == 3)
  6772. {
  6773. return Ok(JsonView(true, "SUCCESS!", new
  6774. {
  6775. dropDownType,
  6776. isMarketingDepartment
  6777. }));
  6778. }
  6779. else
  6780. {
  6781. return Ok(JsonView(false, "portType有误!"));
  6782. }
  6783. }
  6784. /// <summary>
  6785. /// 共享文件上传
  6786. /// </summary>
  6787. /// <param name="dto"></param>
  6788. /// <returns></returns>
  6789. [HttpPost]
  6790. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  6791. {
  6792. var isGroup = new List<int> { 1412 };
  6793. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  6794. {
  6795. return Ok(JsonView(false, "该文件需要关联团组!"));
  6796. }
  6797. if (dto.Files == null || dto.Files.Count == 0)
  6798. {
  6799. return Ok(JsonView(false, "无文件信息!"));
  6800. }
  6801. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6802. {
  6803. return Ok(JsonView(false, "文件大小超过20M!"));
  6804. }
  6805. if (dto.Userid < 1)
  6806. {
  6807. return Ok(JsonView(false, "请传入有效的Userid!"));
  6808. }
  6809. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6810. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6811. .Select((u, j) => new
  6812. {
  6813. u.CnName,
  6814. UserId = u.Id,
  6815. j.JobName,
  6816. })
  6817. .First();
  6818. if (jobInfo == null)
  6819. {
  6820. return Ok(JsonView(false, "请传入有效的Userid!"));
  6821. }
  6822. var commonFileExtensions = new List<string>
  6823. {
  6824. // 文本文件
  6825. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6826. // 图片文件
  6827. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6828. // 视频文件
  6829. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6830. // 音频文件
  6831. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6832. // 压缩文件
  6833. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6834. // 数据文件
  6835. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6836. };
  6837. try
  6838. {
  6839. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6840. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6841. commonFileExtensions.AddRange(settingExtend);
  6842. }
  6843. catch (Exception)
  6844. { }
  6845. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6846. if (setdata == null)
  6847. {
  6848. return Ok(JsonView(false, "请传入有效的FileType!"));
  6849. }
  6850. var insertList = new List<Grp_GroupShareFile>();
  6851. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6852. if (!Directory.Exists(winPath))
  6853. {
  6854. Directory.CreateDirectory(winPath);
  6855. }
  6856. foreach (var item in dto.Files)
  6857. {
  6858. var houzui = Path.GetExtension(item.FileName);
  6859. if (!commonFileExtensions.Contains(houzui))
  6860. {
  6861. return Ok(JsonView(false, "未知后缀名称!"));
  6862. }
  6863. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6864. var saveFilePath = winPath + fileName;
  6865. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6866. {
  6867. item.CopyTo(fs);
  6868. fs.Flush();
  6869. }
  6870. var fileDetail = new Grp_GroupShareFile()
  6871. {
  6872. CreateUserId = dto.Userid,
  6873. CreateTime = DateTime.Now,
  6874. UploadJob = jobInfo.JobName,
  6875. FileName = fileName,
  6876. FileType = dto.FileType,
  6877. Diid = dto.Diid,
  6878. FilePath = winPath + fileName,
  6879. };
  6880. insertList.Add(fileDetail);
  6881. }
  6882. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6883. return Ok(JsonView(true, "保存成功!"));
  6884. }
  6885. /// <summary>
  6886. /// 查询共享文件列表
  6887. /// </summary>
  6888. /// <param name="dto"></param>
  6889. /// <returns></returns>
  6890. [HttpPost]
  6891. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6892. {
  6893. var isGroup = new List<int> { 1412 };
  6894. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6895. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6896. .And(x => x.Diid == dto.Diid)
  6897. .And(x => x.FileType == dto.FileType)
  6898. .And(x => x.IsDel == 0)
  6899. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6900. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  6901. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  6902. int totalCount = 0;
  6903. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  6904. .Where(queryExpression.ToExpression())
  6905. .OrderBy(x => x.UploadJob)
  6906. .Select(x => new
  6907. {
  6908. x.Id,
  6909. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  6910. x.FileName,
  6911. x.FileType,
  6912. x.CreateTime,
  6913. })
  6914. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6915. return Ok(JsonView(true, "SUCCESS!", new
  6916. {
  6917. FileList = dbQuery,
  6918. dto.PageSize,
  6919. dto.PageIndex,
  6920. totalCount
  6921. }));
  6922. }
  6923. /// <summary>
  6924. /// 删除共享文件模块下的指定文件
  6925. /// </summary>
  6926. /// <param name="dto"></param>
  6927. /// <returns></returns>
  6928. [HttpPost]
  6929. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6930. {
  6931. var jw = JsonView(false);
  6932. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6933. if (sing == null)
  6934. {
  6935. jw.Msg = "暂无文件信息!";
  6936. return Ok(jw);
  6937. }
  6938. if (sing.CreateUserId != dto.UserId)
  6939. {
  6940. jw.Msg = "只能删除自己上传的文件!";
  6941. return Ok(jw);
  6942. }
  6943. if (System.IO.File.Exists(sing.FilePath))
  6944. {
  6945. try
  6946. {
  6947. System.IO.File.Delete(sing.FilePath);
  6948. }
  6949. catch (Exception ex)
  6950. {
  6951. jw.Msg = "删除失败!" + ex.Message;
  6952. return Ok(jw);
  6953. }
  6954. }
  6955. sing.IsDel = 1;
  6956. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6957. sing.DeleteUserId = dto.UserId;
  6958. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6959. jw = JsonView(true, "删除成功!");
  6960. return Ok(jw);
  6961. }
  6962. #endregion
  6963. #region 团组英文资料
  6964. /// <summary>
  6965. /// 查询团组英文所有资料
  6966. /// </summary>
  6967. /// <param name="dto"></param>
  6968. /// <returns></returns>
  6969. [HttpPost]
  6970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6971. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6972. {
  6973. try
  6974. {
  6975. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6976. if (groupData.Code != 0)
  6977. {
  6978. return Ok(JsonView(false, groupData.Msg));
  6979. }
  6980. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6981. }
  6982. catch (Exception ex)
  6983. {
  6984. return Ok(JsonView(false, ex.Message));
  6985. throw;
  6986. }
  6987. }
  6988. /// <summary>
  6989. /// 团组英文资料操作(Status:1.新增,2.修改)
  6990. /// </summary>
  6991. /// <param name="dto"></param>
  6992. /// <returns></returns>
  6993. [HttpPost]
  6994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6995. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6996. {
  6997. try
  6998. {
  6999. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  7000. if (groupData.Code != 0)
  7001. {
  7002. return Ok(JsonView(false, groupData.Msg));
  7003. }
  7004. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7005. }
  7006. catch (Exception ex)
  7007. {
  7008. return Ok(JsonView(false, ex.Message));
  7009. throw;
  7010. }
  7011. }
  7012. /// <summary>
  7013. /// 团组英文资料Id查询数据
  7014. /// </summary>
  7015. /// <param name="dto"></param>
  7016. /// <returns></returns>
  7017. [HttpPost]
  7018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7019. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  7020. {
  7021. try
  7022. {
  7023. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  7024. if (_DelegationEnData != null)
  7025. {
  7026. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  7027. }
  7028. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  7029. }
  7030. catch (Exception ex)
  7031. {
  7032. return Ok(JsonView(false, "程序错误!"));
  7033. throw;
  7034. }
  7035. }
  7036. /// <summary>
  7037. /// 团组英文资料删除
  7038. /// </summary>
  7039. /// <param name="dto"></param>
  7040. /// <returns></returns>
  7041. [HttpPost]
  7042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7043. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  7044. {
  7045. try
  7046. {
  7047. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  7048. if (!res)
  7049. {
  7050. return Ok(JsonView(false, "删除失败"));
  7051. }
  7052. return Ok(JsonView(true, "删除成功!"));
  7053. }
  7054. catch (Exception ex)
  7055. {
  7056. return Ok(JsonView(false, ex.Message));
  7057. throw;
  7058. }
  7059. }
  7060. #endregion
  7061. #region 导出邀请函
  7062. /// <summary>
  7063. /// 导出邀请函页面初始化
  7064. /// </summary>
  7065. /// <param name="dto"></param>
  7066. /// <returns></returns>
  7067. [HttpPost]
  7068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7069. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  7070. {
  7071. try
  7072. {
  7073. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  7074. var crm_Deles = new List<Crm_DeleClient>();
  7075. if (dto.DiId == 0)
  7076. {
  7077. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  7078. }
  7079. else
  7080. {
  7081. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  7082. }
  7083. return Ok(JsonView(true, "查询成功!", new
  7084. {
  7085. deleClient = crm_Deles,
  7086. delegations = grp_Delegations
  7087. }));
  7088. }
  7089. catch (Exception ex)
  7090. {
  7091. return Ok(JsonView(false, "程序错误!"));
  7092. throw;
  7093. }
  7094. }
  7095. /// <summary>
  7096. /// 导出邀请函
  7097. /// </summary>
  7098. /// <param name="dto"></param>
  7099. /// <returns></returns>
  7100. [HttpPost]
  7101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7102. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  7103. {
  7104. #region 参数验证
  7105. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7106. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7107. #endregion
  7108. try
  7109. {
  7110. var transDic = new Dictionary<string, string>();
  7111. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  7112. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  7113. From Grp_TourClientList tcl
  7114. Left Join
  7115. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  7116. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  7117. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  7118. From Crm_DeleClient dc
  7119. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  7120. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  7121. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  7122. Where dc.IsDel = 0) temp
  7123. On temp.DcId =tcl.ClientId
  7124. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  7125. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  7126. var texts = new List<string>();
  7127. if (datas.Count != 0)
  7128. {
  7129. foreach (TourClientListDetailsView item in datas)
  7130. {
  7131. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  7132. {
  7133. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  7134. }
  7135. else
  7136. {
  7137. string name = item.LastName + item.FirstName;
  7138. texts.Add(name);
  7139. }
  7140. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  7141. {
  7142. if (!transDic.ContainsKey(item.Job))
  7143. {
  7144. texts.Add(item.Job);
  7145. }
  7146. }
  7147. if (!string.IsNullOrEmpty(item.CompanyFullName))
  7148. {
  7149. texts.Add(item.CompanyFullName);
  7150. }
  7151. }
  7152. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  7153. if (transData.Count > 0)
  7154. {
  7155. foreach (TranslateResult item in transData)
  7156. {
  7157. if (!transDic.ContainsKey(item.Query))
  7158. {
  7159. transDic.Add(item.Query, item.Translation);
  7160. }
  7161. }
  7162. }
  7163. var list = new List<GuestList>();
  7164. foreach (var dele in datas)
  7165. {
  7166. var guestList = new GuestList();
  7167. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  7168. {
  7169. guestList.Name = dele.Pinyin;
  7170. }
  7171. else
  7172. {
  7173. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  7174. guestList.Name = Name;
  7175. }
  7176. if (dele.Sex == 0)
  7177. {
  7178. guestList.Sex = "Male";
  7179. }
  7180. else if (dele.Sex == 1)
  7181. {
  7182. guestList.Sex = "Female";
  7183. }
  7184. guestList.DOB = dele.BirthDay.Replace('-', '.');
  7185. if (!string.IsNullOrEmpty(dele.Job))
  7186. {
  7187. guestList.Job = dele.Job;
  7188. }
  7189. list.Add(guestList);
  7190. }
  7191. //载入模板
  7192. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  7193. var builder = new DocumentBuilder(doc);
  7194. //获取word里所有表格
  7195. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7196. //获取所填表格的序数
  7197. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7198. var rowStart = tableOne.Rows[0]; //获取第1行
  7199. //循环赋值
  7200. for (int i = 0; i < list.Count; i++)
  7201. {
  7202. builder.MoveToCell(0, i + 1, 0, 0);
  7203. builder.Write(list[i].Name.ToString());
  7204. builder.MoveToCell(0, i + 1, 1, 0);
  7205. builder.Write(list[i].Sex.ToString());
  7206. builder.MoveToCell(0, i + 1, 2, 0);
  7207. builder.Write(list[i].DOB.ToString());
  7208. builder.MoveToCell(0, i + 1, 3, 0);
  7209. builder.Write(list[i].Job.ToString());
  7210. }
  7211. //删除多余行
  7212. while (tableOne.Rows.Count > list.Count + 1)
  7213. {
  7214. tableOne.Rows.RemoveAt(list.Count + 1);
  7215. }
  7216. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7217. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  7218. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  7219. doc.Save(filePath);
  7220. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  7221. return Ok(JsonView(true, "操作成功!", Url));
  7222. }
  7223. else
  7224. {
  7225. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  7226. }
  7227. }
  7228. catch (Exception ex)
  7229. {
  7230. return Ok(JsonView(false, ex.Message));
  7231. throw;
  7232. }
  7233. }
  7234. #endregion
  7235. #region 团组经理模块 出入境费用
  7236. /// <summary>
  7237. /// 团组模块 - 出入境费用 - 省份基础数据源
  7238. /// </summary>
  7239. /// <returns></returns>
  7240. [HttpGet]
  7241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7242. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  7243. {
  7244. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  7245. }
  7246. /// <summary>
  7247. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  7248. /// </summary>
  7249. /// <param name="dto"></param>
  7250. /// <returns></returns>
  7251. [HttpPost]
  7252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7253. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  7254. {
  7255. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  7256. var groupNamFirst = groupNameData.FirstOrDefault();
  7257. //SetDataInfoView
  7258. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7259. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7260. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7261. //验证城市归属并给默认值
  7262. int provinceId = 122;
  7263. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  7264. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7265. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7266. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7267. return Ok(JsonView(true, "查询成功!", new
  7268. {
  7269. GroupNameData = groupNameData,
  7270. CurrencyData = _CurrencyData,
  7271. WordTypeData = wordTypeData,
  7272. ExcelTypeData = excelTypeData,
  7273. CurrencyInit = _currencyInfos,
  7274. ViewPermissionData = viewPermissionData
  7275. }));
  7276. }
  7277. /// <summary>
  7278. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  7279. /// </summary>
  7280. /// <returns></returns>
  7281. [HttpGet("{provinceId}")]
  7282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7283. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  7284. {
  7285. //验证城市归属并给默认值
  7286. if (provinceId < 1) provinceId = 122;
  7287. /*
  7288. * 122 四川
  7289. * 108 贵州
  7290. * 103 重庆
  7291. * 132 云南
  7292. */
  7293. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7294. return Ok(JsonView(true, "查询成功!", new
  7295. {
  7296. WordTypeData = wordTypeData,
  7297. ExcelTypeData = excelTypeData,
  7298. }));
  7299. }
  7300. /// <summary>
  7301. /// 团组模块 - 出入境费用
  7302. /// 实时汇率 tips
  7303. /// 签证费用 tips
  7304. /// 机票费用 tips
  7305. /// </summary>
  7306. /// <returns></returns>
  7307. [HttpPost]
  7308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7309. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  7310. {
  7311. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  7312. //默认币种显示
  7313. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  7314. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  7315. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  7316. return Ok(JsonView(true, "查询成功!", new
  7317. {
  7318. //GroupNameData = groupNameData.Data,
  7319. visaData = visaData.Data,
  7320. airData,
  7321. reteInfos
  7322. }));
  7323. }
  7324. /// <summary>
  7325. /// 团组模块 - 出入境费用 - Info
  7326. /// </summary>
  7327. /// <param name="dto"></param>
  7328. /// <returns></returns>
  7329. [HttpPost]
  7330. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  7331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7332. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  7333. {
  7334. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7335. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7336. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  7337. }
  7338. /// <summary>
  7339. /// 团组模块 - 出入境费用 - 设置view权限
  7340. /// </summary>
  7341. /// <returns></returns>
  7342. [HttpPost]
  7343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7344. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  7345. {
  7346. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7347. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7348. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7349. var permissions = new List<Grp_EnterExitCostPermission>();
  7350. foreach (var userId in dto.UserIds)
  7351. {
  7352. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  7353. }
  7354. if (permissions.Any())
  7355. {
  7356. _sqlSugar.BeginTran();
  7357. try
  7358. {
  7359. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  7360. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7361. if (result < 1)
  7362. {
  7363. _sqlSugar.RollbackTran();
  7364. return Ok(JsonView(false));
  7365. }
  7366. }
  7367. catch (Exception ex)
  7368. {
  7369. _sqlSugar.RollbackTran();
  7370. return Ok(JsonView(false, ex.Message));
  7371. }
  7372. _sqlSugar.CommitTran();
  7373. return Ok(JsonView(true));
  7374. }
  7375. return Ok(JsonView(false));
  7376. }
  7377. /// <summary>
  7378. /// 团组模块 - 出入境费用 - Add And Update
  7379. /// </summary>
  7380. /// <returns></returns>
  7381. [HttpPost]
  7382. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  7383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7384. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  7385. {
  7386. try
  7387. {
  7388. var rateRecords = new List<RateRecordInfo>();
  7389. #region 汇率保存前存储
  7390. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  7391. if (info != null)
  7392. {
  7393. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  7394. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  7395. {
  7396. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  7397. {
  7398. CurrencyCode = x.CurrencyCode,
  7399. CurrencyName = x.CurrencyName,
  7400. UpdatePreRate = x.Rate,
  7401. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  7402. }).ToList();
  7403. }
  7404. else
  7405. {
  7406. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7407. {
  7408. CurrencyCode = x.CurrencyCode,
  7409. CurrencyName = x.CurrencyName,
  7410. UpdatePreRate = 0.00M,
  7411. UpdateBreRate = x.Rate
  7412. }).ToList();
  7413. }
  7414. }
  7415. else
  7416. {
  7417. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7418. {
  7419. CurrencyCode = x.CurrencyCode,
  7420. CurrencyName = x.CurrencyName,
  7421. UpdatePreRate = 0.00M,
  7422. UpdateBreRate = x.Rate
  7423. }).ToList();
  7424. }
  7425. #endregion
  7426. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7427. if (dto.DayOtherPriceData.Any())
  7428. {
  7429. var inserList = dto.DayOtherPriceData
  7430. .Where(x => x.Id == 0)
  7431. .Select(x => new Grp_DayOtherPrice
  7432. {
  7433. Cost = x.Cost,
  7434. Id = x.Id,
  7435. CreateTime = DateTime.Now,
  7436. CreateUserId = dto.UserId,
  7437. Currency = x.Currency,
  7438. Diid = x.DiId,
  7439. Index = x.Index,
  7440. IsDel = 0,
  7441. SetDataId = x.SetDataId,
  7442. SubTotal = x.SubTotal,
  7443. Remark = x.Remark
  7444. })
  7445. .ToList();
  7446. var updateList = dto.DayOtherPriceData
  7447. .Where(x => x.Id != 0)
  7448. .Select(x => new Grp_DayOtherPrice
  7449. {
  7450. Cost = x.Cost,
  7451. Id = x.Id,
  7452. CreateTime = DateTime.Now,
  7453. CreateUserId = dto.UserId,
  7454. Currency = x.Currency,
  7455. Diid = x.DiId,
  7456. Index = x.Index,
  7457. IsDel = 0,
  7458. SetDataId = x.SetDataId,
  7459. SubTotal = x.SubTotal,
  7460. Remark = x.Remark
  7461. })
  7462. .ToList();
  7463. //添加
  7464. _sqlSugar.BeginTran();
  7465. if (inserList.Any())
  7466. {
  7467. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  7468. }
  7469. if (updateList.Any())
  7470. {
  7471. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  7472. }
  7473. _sqlSugar.CommitTran();
  7474. }
  7475. if (data.Code != 0)
  7476. {
  7477. return Ok(JsonView(false, data.Msg));
  7478. }
  7479. //生成默认文件pdf并且通知人员
  7480. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7481. {
  7482. DiId = dto.DiId,
  7483. ExportType = 1,
  7484. SubTypeId = 1005
  7485. }, "pdf");
  7486. //发送通知
  7487. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7488. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7489. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  7490. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  7491. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7492. //汇率信息记录
  7493. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7494. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  7495. //汇率验证、反推
  7496. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  7497. if (isSendMsg)
  7498. {
  7499. //消息推送
  7500. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  7501. }
  7502. #region //日志汇率记录
  7503. //按照已使用币种记录
  7504. if (checkCurrencys != null && checkCurrencys.Count > 0)
  7505. {
  7506. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  7507. //汇率记录中加入实时汇率
  7508. if (liveRates != null && liveRates.Count > 0)
  7509. {
  7510. foreach (var item in rateRecords)
  7511. {
  7512. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  7513. }
  7514. }
  7515. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  7516. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  7517. var logContent = new StringBuilder();
  7518. foreach (var item in rateRecords)
  7519. {
  7520. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  7521. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  7522. logContent.AppendLine(msg);
  7523. }
  7524. _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());
  7525. }
  7526. #endregion
  7527. return Ok(JsonView(true, data.Msg, data.Data));
  7528. }
  7529. catch (Exception ex)
  7530. {
  7531. return Ok(JsonView(false, ex.Message));
  7532. }
  7533. }
  7534. /// <summary>
  7535. /// 团组模块 - 出入境费用 - Confirm 费用
  7536. /// </summary>
  7537. /// <returns></returns>
  7538. [HttpPost]
  7539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7540. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  7541. {
  7542. //TODO:测试完毕需把对应的用户ID更改
  7543. //1、数据表添加字段
  7544. //2、更改字段接口()
  7545. var _view = await _enterExitCostRep.ConfirmCost(dto);
  7546. //3、确认成功 给财务发送消息
  7547. if (_view.Code == 200)
  7548. {
  7549. if (dto.Type == 1)
  7550. {
  7551. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  7552. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  7553. }
  7554. }
  7555. return Ok(_view);
  7556. }
  7557. /// <summary>
  7558. /// 团组模块 - 出入境费用 - File download
  7559. /// </summary>
  7560. /// <param name="dto"></param>
  7561. /// <returns></returns>
  7562. [HttpPost]
  7563. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  7564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7565. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  7566. {
  7567. try
  7568. {
  7569. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7570. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7571. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7572. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7573. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7574. 3 团组成员名单 1 团组成员名单", ""));
  7575. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  7576. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7577. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  7578. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  7579. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7580. //数据源
  7581. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7582. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7583. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7584. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7585. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7586. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7587. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7588. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  7589. .Select((x, a, b) => new
  7590. {
  7591. x.Index,
  7592. itemName = a.Name,
  7593. CurrencyStr = b.Name,
  7594. x.Cost,
  7595. x.SubTotal,
  7596. x.Remark
  7597. })
  7598. .OrderBy((x) => x.Index)
  7599. .ToList(); //其他款项费用
  7600. var peiceItemCurrencys = new List<string>();
  7601. if (_DayAndCosts.Any())
  7602. {
  7603. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7604. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7605. }
  7606. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7607. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7608. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7609. {
  7610. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7611. }
  7612. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7613. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  7614. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  7615. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  7616. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  7617. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  7618. .Select((tcl, dc, cc) => new ClientInfo
  7619. {
  7620. LastName = dc.LastName,
  7621. FirstName = dc.FirstName,
  7622. Sex = dc.Sex,
  7623. Birthday = dc.BirthDay,
  7624. Company = cc.CompanyFullName,
  7625. Job = dc.Job
  7626. })
  7627. .ToList();
  7628. foreach (var item in DeleClientList)
  7629. {
  7630. EncryptionProcessor.DecryptProperties(item);
  7631. }
  7632. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  7633. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7634. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7635. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7636. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  7637. if (dto.ExportType == 1) //明细表
  7638. {
  7639. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7640. {
  7641. //获取模板
  7642. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7643. //载入模板
  7644. var doc = new Document(tempPath);
  7645. var builder = new DocumentBuilder(doc);
  7646. var dic = new Dictionary<string, string>();
  7647. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7648. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7649. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7650. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7651. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7652. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7653. //境内费用(其他费用)
  7654. if (_EnterExitCosts.ChoiceOne == 1)
  7655. {
  7656. string row1_1 = "";
  7657. if (_EnterExitCosts.Visa > 0)
  7658. {
  7659. //insidePayTotal += _EnterExitCosts.Visa;
  7660. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  7661. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7662. //{
  7663. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7664. //}
  7665. }
  7666. string row1_2 = "";
  7667. if (_EnterExitCosts.YiMiao > 0)
  7668. {
  7669. //insidePayTotal += _EnterExitCosts.YiMiao;
  7670. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  7671. }
  7672. if (_EnterExitCosts.HeSuan > 0)
  7673. {
  7674. //insidePayTotal += _EnterExitCosts.HeSuan;
  7675. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  7676. }
  7677. if (_EnterExitCosts.Service > 0)
  7678. {
  7679. //insidePayTotal += _EnterExitCosts.Service;
  7680. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  7681. }
  7682. string row1_3 = "";
  7683. if (_EnterExitCosts.Safe > 0)
  7684. {
  7685. //insidePayTotal += _EnterExitCosts.Safe;
  7686. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  7687. }
  7688. if (_EnterExitCosts.Ticket > 0)
  7689. {
  7690. //insidePayTotal += _EnterExitCosts.Ticket;
  7691. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  7692. }
  7693. string row1 = "";
  7694. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7695. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7696. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7697. row1 += $"备注:{_EnterExitCosts.Remark}";
  7698. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7699. dic.Add("Row1Str", row1);
  7700. }
  7701. string airTotalStr = string.Empty,
  7702. airPriceStr = string.Empty;
  7703. //经济舱
  7704. if (_EnterExitCosts.SumJJC == 1)
  7705. {
  7706. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  7707. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  7708. }
  7709. //公务舱
  7710. if (_EnterExitCosts.SumGWC == 1)
  7711. {
  7712. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  7713. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  7714. }
  7715. //头等舱
  7716. if (_EnterExitCosts.SumTDC == 1)
  7717. {
  7718. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  7719. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  7720. }
  7721. //汇率描述
  7722. string rateStr = "";
  7723. if (peiceItemCurrencyInfos.Any())
  7724. {
  7725. rateStr = "\r\n汇率描述:";
  7726. foreach (var item in peiceItemCurrencyInfos)
  7727. {
  7728. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  7729. }
  7730. }
  7731. string twoItemRemark = "备注:";
  7732. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7733. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7734. dic.Add("AirTotalStr", airTotalStr);
  7735. dic.Add("AirPriceStr", airPriceStr);
  7736. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7737. dic.Add("TwoItemRemark", twoItemRemark);
  7738. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7739. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7740. int table1Row = 0,
  7741. table2Row = 0,
  7742. table3Row = 0,
  7743. table4Row = 0,
  7744. table5Row = 0;
  7745. //住宿费
  7746. if (_EnterExitCosts.ChoiceThree == 1)
  7747. {
  7748. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7749. table1Row = dac1.Count;
  7750. #region 填充word表格内容
  7751. for (int i = 0; i < dac1.Count; i++)
  7752. {
  7753. Grp_DayAndCost dac = dac1[i];
  7754. if (dac == null) continue;
  7755. builder.MoveToCell(0, i, 0, 0);
  7756. builder.Write("第" + dac.Days.ToString() + "晚:");
  7757. builder.MoveToCell(0, i, 1, 0);
  7758. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7759. //builder.Write(dac.Place == null ? "" : dac.Place);
  7760. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7761. builder.MoveToCell(0, i, 2, 0);
  7762. builder.Write("费用标准:");
  7763. string curr = "";
  7764. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7765. if (currData != null)
  7766. {
  7767. curr = currData.Name;
  7768. }
  7769. builder.MoveToCell(0, i, 3, 0);
  7770. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7771. builder.MoveToCell(0, i, 4, 0);
  7772. builder.Write("费用小计:");
  7773. builder.MoveToCell(0, i, 5, 0);
  7774. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7775. }
  7776. #endregion
  7777. }
  7778. else dic.Add("SubZS", "0.00");
  7779. //删除多余行
  7780. while (table1.Rows.Count > table1Row)
  7781. {
  7782. table1.Rows.RemoveAt(table1Row);
  7783. }
  7784. //伙食费
  7785. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7786. if (_EnterExitCosts.ChoiceFour == 1)
  7787. {
  7788. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7789. table2Row = dac2.Count;
  7790. #region 填充word表格内容
  7791. for (int i = 0; i < dac2.Count; i++)
  7792. {
  7793. Grp_DayAndCost dac = dac2[i];
  7794. if (dac == null) continue;
  7795. builder.MoveToCell(1, i, 0, 0);
  7796. builder.Write("第" + dac.Days.ToString() + "天:");
  7797. builder.MoveToCell(1, i, 1, 0);
  7798. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7799. builder.MoveToCell(1, i, 2, 0);
  7800. builder.Write("费用标准:");
  7801. string curr = "";
  7802. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7803. if (currData != null)
  7804. {
  7805. curr = currData.Name;
  7806. }
  7807. builder.MoveToCell(1, i, 3, 0);
  7808. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7809. builder.MoveToCell(1, i, 4, 0);
  7810. builder.Write("费用小计:");
  7811. builder.MoveToCell(1, i, 5, 0);
  7812. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7813. }
  7814. #endregion
  7815. }
  7816. else dic.Add("SubHS", "0.00");
  7817. //删除多余行
  7818. while (table2.Rows.Count > table2Row)
  7819. {
  7820. table2.Rows.RemoveAt(table2Row);
  7821. }
  7822. //公杂费
  7823. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7824. if (_EnterExitCosts.ChoiceFive == 1)
  7825. {
  7826. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7827. table3Row = dac3.Count;
  7828. #region 填充word表格内容
  7829. for (int i = 0; i < dac3.Count; i++)
  7830. {
  7831. Grp_DayAndCost dac = dac3[i];
  7832. if (dac == null) continue;
  7833. builder.MoveToCell(2, i, 0, 0);
  7834. builder.Write("第" + dac.Days.ToString() + "天:");
  7835. builder.MoveToCell(2, i, 1, 0);
  7836. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7837. builder.MoveToCell(2, i, 2, 0);
  7838. builder.Write("费用标准:");
  7839. string curr = "";
  7840. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7841. if (currData != null)
  7842. {
  7843. curr = currData.Name;
  7844. }
  7845. builder.MoveToCell(2, i, 3, 0);
  7846. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7847. builder.MoveToCell(2, i, 4, 0);
  7848. builder.Write("费用小计:");
  7849. builder.MoveToCell(2, i, 5, 0);
  7850. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7851. }
  7852. //删除多余行
  7853. while (table3.Rows.Count > table3Row)
  7854. {
  7855. table3.Rows.RemoveAt(table3Row);
  7856. }
  7857. #endregion
  7858. }
  7859. else dic.Add("SubGZF", "0.00");
  7860. //删除多余行
  7861. while (table3.Rows.Count > table3Row)
  7862. {
  7863. table3.Rows.RemoveAt(table3Row);
  7864. }
  7865. //培训费
  7866. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7867. if (_EnterExitCosts.ChoiceSix == 1)
  7868. {
  7869. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7870. dic.Add("SubPX", pxStr);
  7871. table4Row = dac4.Count;
  7872. #region 填充word表格内容
  7873. for (int i = 0; i < dac4.Count; i++)
  7874. {
  7875. Grp_DayAndCost dac = dac4[i];
  7876. if (dac == null) continue;
  7877. builder.MoveToCell(3, i, 0, 0);
  7878. builder.Write("第" + dac.Days.ToString() + "天:");
  7879. builder.MoveToCell(3, i, 1, 0);
  7880. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7881. builder.MoveToCell(3, i, 2, 0);
  7882. builder.Write("费用标准:");
  7883. string curr = "";
  7884. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7885. if (currData != null)
  7886. {
  7887. curr = currData.Name;
  7888. }
  7889. builder.MoveToCell(3, i, 3, 0);
  7890. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7891. builder.MoveToCell(3, i, 4, 0);
  7892. builder.Write("费用小计:");
  7893. builder.MoveToCell(3, i, 5, 0);
  7894. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7895. }
  7896. #endregion
  7897. }
  7898. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7899. //删除多余行
  7900. while (table4.Rows.Count > table4Row)
  7901. {
  7902. table4.Rows.RemoveAt(table4Row);
  7903. }
  7904. //其他费用
  7905. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7906. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7907. {
  7908. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  7909. dic.Add("titleQi", qtStr);
  7910. table5Row = dac5.Count;
  7911. #region 填充word表格内容
  7912. for (int i = 0; i < dac5.Count; i++)
  7913. {
  7914. var dac = dac5[i];
  7915. if (dac == null) continue;
  7916. builder.MoveToCell(4, i, 0, 0);
  7917. builder.Write("第" + dac.Index.ToString() + "项:");
  7918. builder.MoveToCell(4, i, 1, 0);
  7919. builder.Write(dac.itemName);
  7920. builder.MoveToCell(4, i, 2, 0);
  7921. builder.Write("费用标准:");
  7922. builder.MoveToCell(4, i, 3, 0);
  7923. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7924. builder.MoveToCell(4, i, 4, 0);
  7925. builder.Write("费用小计:");
  7926. builder.MoveToCell(4, i, 5, 0);
  7927. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7928. builder.MoveToCell(4, i, 6, 0);
  7929. builder.Write("备注:");
  7930. builder.MoveToCell(4, i, 7, 0);
  7931. builder.Write(dac.Remark);
  7932. }
  7933. #endregion
  7934. }
  7935. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7936. //删除多余行
  7937. while (table5.Rows.Count > table5Row)
  7938. {
  7939. table5.Rows.RemoveAt(table5Row);
  7940. }
  7941. //加上其他费用
  7942. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7943. decimal subJJC = 0.00M,
  7944. subGWC = 0.00M,
  7945. subTDC = 0.00M;
  7946. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7947. string totalLabel = string.Format("全部费用总计:");
  7948. //经济舱
  7949. if (_EnterExitCosts.SumJJC == 1)
  7950. {
  7951. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7952. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7953. }
  7954. //公务舱
  7955. if (_EnterExitCosts.SumGWC == 1)
  7956. {
  7957. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7958. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7959. }
  7960. //头等舱
  7961. if (_EnterExitCosts.SumTDC == 1)
  7962. {
  7963. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7964. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7965. }
  7966. //TotalLabel
  7967. dic.Add("TotalLabel", totalLabel);
  7968. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7969. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7970. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7971. #region 填充word模板书签内容
  7972. foreach (var key in dic.Keys)
  7973. {
  7974. Bookmark bookmark = doc.Range.Bookmarks[key];
  7975. if (bookmark != null)
  7976. {
  7977. builder.MoveToBookmark(key);
  7978. builder.Write(dic[key]);
  7979. }
  7980. }
  7981. #endregion
  7982. #region 设置页眉
  7983. string userLabel = string.Empty;
  7984. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7985. if (currUserInfo != null)
  7986. {
  7987. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7988. if (userInfo != null)
  7989. {
  7990. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7991. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7992. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7993. }
  7994. }
  7995. //设置页脚
  7996. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7997. #endregion
  7998. var guid = CommonFun.GUID.Substring(0, 8);
  7999. //文件名
  8000. string strFileName = CommonFun.ValidFileName($"{_DelegationInfo.TeamName}出入境费用{guid}.docx");
  8001. AsposeHelper.removewatermark_v2180();
  8002. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8003. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8004. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8005. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8006. }
  8007. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8008. {
  8009. //获取模板
  8010. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8011. //载入模板
  8012. var doc = new Document(tempPath);
  8013. var builder = new DocumentBuilder(doc);
  8014. var dic = new Dictionary<string, string>();
  8015. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8016. {
  8017. var list = new List<string>();
  8018. try
  8019. {
  8020. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8021. foreach (var item in spilitArr)
  8022. {
  8023. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8024. var depCode = spDotandEmpty[2].Substring(0, 3);
  8025. var arrCode = spDotandEmpty[2].Substring(3, 3);
  8026. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  8027. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  8028. list.Add(depName);
  8029. list.Add(arrName);
  8030. }
  8031. list = list.Distinct().ToList();
  8032. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8033. }
  8034. catch (Exception)
  8035. {
  8036. dic.Add("ReturnCode", "行程录入不正确!");
  8037. }
  8038. }
  8039. else
  8040. {
  8041. dic.Add("ReturnCode", "未录入行程!");
  8042. }
  8043. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8044. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8045. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8046. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8047. {
  8048. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8049. dic.Add("Day", sp.Days.ToString());
  8050. }
  8051. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8052. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8053. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8054. //dic.Add("Names", Names);
  8055. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8056. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8057. decimal dac1totalPrice = 0.00M;
  8058. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8059. foreach (var dac in dac1)
  8060. {
  8061. if (dac.SubTotal == 0.00M)
  8062. {
  8063. continue;
  8064. }
  8065. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8066. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8067. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8068. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8069. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8070. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8071. builder.Write(currency);//币种
  8072. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8073. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8074. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8075. builder.Write("");//人数
  8076. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8077. builder.Write("");//天数
  8078. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8079. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8080. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8081. decimal rate = 0.00M;
  8082. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8083. builder.Write(rate.ToString("#0.0000"));//汇率
  8084. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8085. decimal rbmPrice = dac.SubTotal;
  8086. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8087. accommodationStartIndex++;
  8088. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8089. }
  8090. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8091. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8092. {
  8093. table1.Rows.RemoveAt(i - 1);
  8094. foodandotherStartIndex--;
  8095. }
  8096. if (dac2.Count == dac3.Count)//国家 币种 金额
  8097. {
  8098. for (int i = 0; i < dac2.Count; i++)
  8099. {
  8100. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8101. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8102. }
  8103. }
  8104. decimal dac2totalPrice = 0.00M;
  8105. foreach (var dac in dac2)
  8106. {
  8107. if (dac.SubTotal == 0)
  8108. {
  8109. continue;
  8110. }
  8111. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8112. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8113. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8114. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8115. builder.Write(currency);//币种
  8116. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8117. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8118. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8119. builder.Write("");//人数
  8120. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8121. builder.Write("");//天数
  8122. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8123. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8124. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8125. decimal rate = 0.00M;
  8126. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8127. builder.Write(rate.ToString("#0.0000"));//汇率
  8128. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8129. decimal rbmPrice = dac.SubTotal;
  8130. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8131. foodandotherStartIndex++;
  8132. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8133. }
  8134. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8135. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8136. {
  8137. table1.Rows.RemoveAt(i - 1);
  8138. }
  8139. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8140. string otherFeeStr = "";
  8141. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  8142. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  8143. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  8144. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8145. foreach (var otherInfo in dac5)
  8146. {
  8147. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8148. }
  8149. #endregion
  8150. if (otherFeeStr.Length > 0)
  8151. {
  8152. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8153. otherFeeStr = $"({otherFeeStr})";
  8154. dic.Add("OtherFeeStr", otherFeeStr);
  8155. }
  8156. //总计
  8157. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8158. //国际旅费
  8159. string outsideAir = string.Empty;
  8160. string allPriceAir = string.Empty;
  8161. if (_EnterExitCosts.SumJJC == 1)
  8162. {
  8163. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8164. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8165. }
  8166. if (_EnterExitCosts.SumGWC == 1)
  8167. {
  8168. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8169. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8170. }
  8171. if (_EnterExitCosts.SumTDC == 1)
  8172. {
  8173. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8174. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8175. }
  8176. dic.Add("InTravelPrice", $"({outsideAir})");
  8177. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8178. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8179. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8180. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8181. foreach (var key in dic.Keys)
  8182. {
  8183. builder.MoveToBookmark(key);
  8184. builder.Write(dic[key]);
  8185. }
  8186. //模板文件名
  8187. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8188. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8189. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8190. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8191. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8192. }
  8193. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8194. {
  8195. //获取模板
  8196. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8197. //载入模板
  8198. var designer = new WorkbookDesigner
  8199. {
  8200. Workbook = new Workbook(tempPath)
  8201. };
  8202. var dic = new Dictionary<string, string>();
  8203. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8204. {
  8205. var list = new List<string>();
  8206. try
  8207. {
  8208. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8209. foreach (var item in spilitArr)
  8210. {
  8211. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8212. var depCode = spDotandEmpty[2].Substring(0, 3);
  8213. var arrCode = spDotandEmpty[2].Substring(3, 3);
  8214. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  8215. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  8216. list.Add(depName);
  8217. list.Add(arrName);
  8218. }
  8219. list = list.Distinct().ToList();
  8220. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8221. }
  8222. catch (Exception)
  8223. {
  8224. dic.Add("ReturnCode", "行程录入不正确!");
  8225. }
  8226. }
  8227. else
  8228. {
  8229. dic.Add("ReturnCode", "未录入行程!");
  8230. }
  8231. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8232. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8233. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8234. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8235. {
  8236. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8237. dic.Add("Day", sp.Days.ToString());
  8238. }
  8239. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8240. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8241. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8242. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  8243. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  8244. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  8245. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  8246. designer.SetDataSource("Name", Names);
  8247. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  8248. designer.SetDataSource("Day", dic["Day"] + "天");
  8249. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  8250. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  8251. int startIndex = 10;
  8252. const int startIndexcopy = 10;
  8253. if (dac2.Count == dac3.Count)//国家 币种 金额
  8254. {
  8255. for (int i = 0; i < dac2.Count; i++)
  8256. {
  8257. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8258. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8259. }
  8260. }
  8261. var dtdac1 = new DataTable();
  8262. var place = new List<string>();
  8263. dtdac1.Columns.AddRange(new DataColumn[] {
  8264. new(){ ColumnName = "city"},
  8265. new(){ ColumnName = "curr"},
  8266. new(){ ColumnName = "criterion"},
  8267. new(){ ColumnName = "number",DataType = typeof(int)},
  8268. new(){ ColumnName = "day",DataType = typeof(int)},
  8269. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8270. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8271. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8272. });
  8273. var dtdac2 = new DataTable();
  8274. dtdac2.Columns.AddRange(new DataColumn[] {
  8275. new(){ ColumnName = "city"},
  8276. new(){ ColumnName = "curr"},
  8277. new(){ ColumnName = "criterion"},
  8278. new(){ ColumnName = "number",DataType = typeof(int)},
  8279. new(){ ColumnName = "day",DataType = typeof(int)},
  8280. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8281. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8282. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8283. });
  8284. dtdac1.TableName = "tb1";
  8285. dtdac2.TableName = "tb2";
  8286. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8287. foreach (var item in dac1)
  8288. {
  8289. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8290. if (place.Contains(item.Place))
  8291. {
  8292. continue;
  8293. }
  8294. DataRow row = dtdac1.NewRow();
  8295. row["city"] = item.Place;
  8296. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8297. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8298. row["curr"] = currency;
  8299. row["rate"] = rate.ToString("#0.0000");
  8300. row["criterion"] = item.Cost.ToString("#0.00");
  8301. row["number"] = 1;
  8302. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8303. //row["costRMB"] = rbmPrice;
  8304. dtdac1.Rows.Add(row);
  8305. place.Add(item.Place);
  8306. }
  8307. place = new List<string>();
  8308. foreach (var item in dac2)
  8309. {
  8310. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8311. if (place.Contains(item.Place))
  8312. {
  8313. continue;
  8314. }
  8315. DataRow row = dtdac2.NewRow();
  8316. row["city"] = item.Place;
  8317. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8318. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8319. row["curr"] = currency;
  8320. row["rate"] = rate.ToString("#0.0000");
  8321. row["criterion"] = item.Cost.ToString("#0.00");
  8322. row["number"] = 1;
  8323. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8324. //row["cost"] = item.SubTotal;
  8325. //row["costRMB"] = rbmPrice;
  8326. dtdac2.Rows.Add(row);
  8327. place.Add(item.Place);
  8328. //dac2totalPrice += rbmPrice;
  8329. }
  8330. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8331. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8332. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8333. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8334. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8335. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8336. string cell4Str1 = string.Empty;
  8337. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8338. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8339. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8340. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8341. string cellStr = $" 5.其他费用(";
  8342. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8343. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8344. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8345. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8346. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8347. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8348. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8349. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8350. foreach (var otherInfo in dac5)
  8351. {
  8352. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8353. }
  8354. #endregion
  8355. if (cellStr.Length > 8)
  8356. {
  8357. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8358. }
  8359. cellStr += ")";
  8360. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8361. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8362. decimal pxFee = dac4.Sum(it => it.Cost);
  8363. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8364. string celllastStr1 = "";
  8365. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8366. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8367. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8368. celllastStr1 += $",国际旅费 元";
  8369. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8370. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8371. designer.SetDataSource("cell4Str", cell4Str);
  8372. designer.SetDataSource("cellStr", cellStr);
  8373. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8374. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8375. designer.SetDataSource("celllastStr", celllastStr);
  8376. Workbook wb = designer.Workbook;
  8377. var sheet = wb.Worksheets[0];
  8378. //绑定datatable数据集
  8379. designer.SetDataSource(dtdac1);
  8380. designer.SetDataSource(dtdac2);
  8381. designer.Process();
  8382. var rowStart = dtdac1.Rows.Count;
  8383. while (rowStart > 0)
  8384. {
  8385. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8386. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8387. startIndex++;
  8388. rowStart--;
  8389. }
  8390. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8391. startIndex += 1; //总计行
  8392. rowStart = dtdac2.Rows.Count;
  8393. while (rowStart > 0)
  8394. {
  8395. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8396. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8397. startIndex++;
  8398. rowStart--;
  8399. }
  8400. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8401. wb.CalculateFormula(true);
  8402. //模板文件名
  8403. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8404. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8405. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8406. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8407. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8408. }
  8409. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8410. {
  8411. //获取模板
  8412. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8413. //载入模板
  8414. var doc = new Document(tempPath);
  8415. var builder = new DocumentBuilder(doc);
  8416. var dic = new Dictionary<string, string>
  8417. {
  8418. { "GroupName", _DelegationInfo.TeamName },
  8419. { "ClientUnit", _DelegationInfo.ClientUnit }
  8420. };
  8421. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8422. string missionLeaderJob = "";//负责人job
  8423. //int groupNumber = 0; //团人数
  8424. if (DeleClientList.Count > 0)
  8425. {
  8426. missionLeader = DeleClientList[0]?.Name ?? "";
  8427. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  8428. }
  8429. dic.Add("MissionLeader", missionLeader); //团负责人
  8430. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  8431. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  8432. #region MyRegion
  8433. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8434. //{
  8435. // List<string> list = new List<string>();
  8436. // try
  8437. // {
  8438. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8439. // foreach (var item in spilitArr)
  8440. // {
  8441. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8442. // var depCode = spDotandEmpty[2].Substring(0, 3);
  8443. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  8444. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  8445. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  8446. // list.Add(depName);
  8447. // list.Add(arrName);
  8448. // }
  8449. // list = list.Distinct().ToList();
  8450. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8451. // }
  8452. // catch (Exception)
  8453. // {
  8454. // dic.Add("ReturnCode", "行程录入不正确!");
  8455. // }
  8456. //}
  8457. //else
  8458. //{
  8459. // dic.Add("ReturnCode", "未录入行程!");
  8460. //}
  8461. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  8462. dic.Add("ReturnCode", string.Join("、", countrys));
  8463. #endregion
  8464. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8465. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8466. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8467. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8468. //{
  8469. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8470. // dic.Add("Day", sp.Days.ToString());
  8471. //}
  8472. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  8473. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8474. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8475. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8476. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8477. //培训人员名单
  8478. int cultivateRowIndex = 7;
  8479. foreach (var item in DeleClientList)
  8480. {
  8481. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  8482. builder.Write(item.Name);
  8483. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  8484. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  8485. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  8486. string birthDay = "";
  8487. if (item.Birthday != null)
  8488. {
  8489. DateTime dt = Convert.ToDateTime(item.Birthday);
  8490. birthDay = $"{dt.Year}.{dt.Month}";
  8491. }
  8492. builder.Write(birthDay);
  8493. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  8494. builder.Write(item.Company);
  8495. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  8496. builder.Write(item.Job);
  8497. cultivateRowIndex++;
  8498. }
  8499. //删除多余行
  8500. //cultivateRowIndex -= 2;
  8501. int delRows = 10 + 7 - cultivateRowIndex;
  8502. if (delRows > 0)
  8503. {
  8504. for (int i = 0; i < delRows; i++)
  8505. {
  8506. table1.Rows.RemoveAt(cultivateRowIndex);
  8507. //cultivateRowIndex++;
  8508. }
  8509. }
  8510. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8511. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8512. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8513. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8514. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8515. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8516. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8517. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8518. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8519. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8520. //其他费用
  8521. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8522. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8523. //其他费用合计
  8524. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8525. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8526. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8527. //公务舱合计
  8528. //国际旅费
  8529. //string outsideJJ = "";
  8530. //string allPriceJJ = "";
  8531. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8532. {
  8533. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8534. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8535. }
  8536. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8537. {
  8538. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8539. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8540. }
  8541. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8542. {
  8543. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8544. dic.Add("AirFeeTotal", airFeeTotalStr);
  8545. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8546. dic.Add("FeeTotal", feeTotalStr);
  8547. }
  8548. foreach (var key in dic.Keys)
  8549. {
  8550. builder.MoveToBookmark(key);
  8551. builder.Write(dic[key]);
  8552. }
  8553. //模板文件名
  8554. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8555. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8556. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8557. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8558. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8559. }
  8560. }
  8561. else if (dto.ExportType == 2) //表格
  8562. {
  8563. //利用键值对存放数据
  8564. Dictionary<string, string> dic = new Dictionary<string, string>();
  8565. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8566. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8567. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8568. dic.Add("Day", sp.Days.ToString());
  8569. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8570. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  8571. {
  8572. //获取模板
  8573. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  8574. //载入模板
  8575. var doc = new Document(tempPath);
  8576. var builder = new DocumentBuilder(doc);
  8577. dic.Add("TeamName", _DelegationInfo.TeamName);
  8578. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8579. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  8580. string missionLeaderName = "",
  8581. missionLeaderJob = "";
  8582. if (DeleClientList.Count > 0)
  8583. {
  8584. missionLeaderName = DeleClientList[0].Name;
  8585. missionLeaderJob = DeleClientList[0].Job;
  8586. }
  8587. dic.Add("MissionLeaderName", missionLeaderName);
  8588. dic.Add("MissionLeaderJob", missionLeaderJob);
  8589. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  8590. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  8591. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8592. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8593. int rowCount = 10;//总人数行
  8594. int startRowIndex = 7; //起始行
  8595. for (int i = 0; i < DeleClientList.Count; i++)
  8596. {
  8597. builder.MoveToCell(0, startRowIndex, 0, 0);
  8598. builder.Write(DeleClientList[i].Name); //出国人员姓名
  8599. builder.MoveToCell(0, startRowIndex, 1, 0);
  8600. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8601. builder.Write(sex);//性别
  8602. builder.MoveToCell(0, startRowIndex, 2, 0);
  8603. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  8604. builder.MoveToCell(0, startRowIndex, 3, 0);
  8605. builder.Write(DeleClientList[i].Company);//工作单位
  8606. builder.MoveToCell(0, startRowIndex, 4, 0);
  8607. builder.Write(DeleClientList[i].Job);//职务及级别
  8608. builder.MoveToCell(0, startRowIndex, 5, 0);
  8609. builder.Write("");//人员属性
  8610. builder.MoveToCell(0, startRowIndex, 6, 0);
  8611. builder.Write("");//上次出国时间
  8612. startRowIndex++;
  8613. }
  8614. int nullRow = rowCount - DeleClientList.Count;//空行
  8615. for (int i = 0; i < nullRow; i++)
  8616. {
  8617. table1.Rows.Remove(table1.Rows[startRowIndex]);
  8618. }
  8619. foreach (var key in dic.Keys)
  8620. {
  8621. builder.MoveToBookmark(key);
  8622. builder.Write(dic[key]);
  8623. }
  8624. //模板文件名
  8625. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  8626. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8627. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8628. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  8629. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  8630. }
  8631. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  8632. {
  8633. //获取模板
  8634. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  8635. //载入模板
  8636. var doc = new Document(tempPath);
  8637. var builder = new DocumentBuilder(doc);
  8638. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  8639. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  8640. dic.Add("Names", Names);
  8641. int accommodationRows = 12;
  8642. //int foodandotherRows = 12;
  8643. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8644. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8645. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8646. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8647. int accommodationStartIndex = 6;
  8648. decimal dac1totalPrice = 0.00M;
  8649. foreach (var dac in dac1)
  8650. {
  8651. if (dac.SubTotal == 0)
  8652. {
  8653. continue;
  8654. }
  8655. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8656. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8657. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8658. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8659. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8660. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8661. builder.Write(currency);//币种
  8662. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8663. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8664. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8665. builder.Write("");//人数
  8666. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8667. builder.Write("");//天数
  8668. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8669. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8670. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8671. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8672. builder.Write(rate.ToString("#0.0000"));//汇率
  8673. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8674. decimal rbmPrice = rate * dac.SubTotal;
  8675. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8676. accommodationStartIndex++;
  8677. dac1totalPrice += rbmPrice;
  8678. }
  8679. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8680. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8681. builder.Write("小计");
  8682. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8683. builder.Write(dac1totalPrice.ToString("#0.00"));
  8684. accommodationStartIndex++;
  8685. int nullRow = accommodationRows - dac1.Count;
  8686. //删除空行
  8687. //if (nullRow > 0)
  8688. //{
  8689. // int rowIndex = accommodationStartIndex;
  8690. // for (int i = 0; i < nullRow; i++)
  8691. // {
  8692. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  8693. // row.Remove();
  8694. // rowIndex++;
  8695. // }
  8696. //}
  8697. if (dac2.Count == dac3.Count)//国家 币种 金额
  8698. {
  8699. for (int i = 0; i < dac2.Count; i++)
  8700. {
  8701. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8702. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8703. }
  8704. }
  8705. int foodandotherStartIndex = 19;//
  8706. decimal dac2totalPrice = 0.00M;
  8707. foreach (var dac in dac2)
  8708. {
  8709. if (dac.SubTotal == 0)
  8710. {
  8711. continue;
  8712. }
  8713. //foodandotherStartIndex = 12;
  8714. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8715. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8716. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8717. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8718. builder.Write(currency);//币种
  8719. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8720. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8721. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8722. builder.Write("");//人数
  8723. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8724. builder.Write("");//天数
  8725. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8726. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8727. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8728. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8729. builder.Write(rate.ToString("#0.0000"));//汇率
  8730. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8731. decimal rbmPrice = rate * dac.SubTotal;
  8732. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8733. foodandotherStartIndex++;
  8734. dac2totalPrice += rbmPrice;
  8735. }
  8736. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8737. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8738. //删除空行
  8739. //if (dac2.Count < foodandotherRows)
  8740. //{
  8741. // while (table2.Rows.Count > dac2.Count)
  8742. // {
  8743. // table2.Rows.RemoveAt(dac2.Count);
  8744. // }
  8745. //}
  8746. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8747. string otherFeeStr = "";
  8748. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8749. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8750. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8751. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8752. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8753. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8754. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8755. foreach (var otherInfo in dac5)
  8756. {
  8757. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8758. }
  8759. #endregion
  8760. if (otherFeeStr.Length > 0)
  8761. {
  8762. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8763. otherFeeStr = $"({otherFeeStr})";
  8764. dic.Add("OtherFeeStr", otherFeeStr);
  8765. }
  8766. foreach (var key in dic.Keys)
  8767. {
  8768. builder.MoveToBookmark(key);
  8769. builder.Write(dic[key]);
  8770. }
  8771. //模板文件名
  8772. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8773. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8774. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8775. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8776. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8777. }
  8778. }
  8779. else if (dto.ExportType == 3)
  8780. {
  8781. if (dto.SubTypeId == 1) //团组成员名单
  8782. {
  8783. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  8784. //获取模板
  8785. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  8786. //载入模板
  8787. var doc = new Document(tempPath);
  8788. var builder = new DocumentBuilder(doc);
  8789. //获取word里所有表格
  8790. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8791. //获取所填表格的序数
  8792. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8793. var rowStart = tableOne.Rows[0]; //获取第1行
  8794. //循环赋值
  8795. for (int i = 0; i < DeleClientList.Count; i++)
  8796. {
  8797. builder.MoveToCell(0, i + 1, 0, 0);
  8798. builder.Write(DeleClientList[i].Name);
  8799. builder.MoveToCell(0, i + 1, 1, 0);
  8800. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8801. builder.Write(sex);
  8802. builder.MoveToCell(0, i + 1, 2, 0);
  8803. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8804. builder.MoveToCell(0, i + 1, 3, 0);
  8805. builder.Write(DeleClientList[i].Company);
  8806. builder.MoveToCell(0, i + 1, 4, 0);
  8807. builder.Write(DeleClientList[i].Job);
  8808. }
  8809. //删除多余行
  8810. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8811. {
  8812. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8813. }
  8814. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8815. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8816. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8817. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8818. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8819. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8820. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8821. }
  8822. }
  8823. return Ok(JsonView(400, "操作失败!", ""));
  8824. }
  8825. catch (Exception ex)
  8826. {
  8827. return Ok(JsonView(400, ex.Message, ""));
  8828. }
  8829. }
  8830. /// <summary>
  8831. /// 获取三公费用标准city
  8832. /// </summary>
  8833. /// <param name="placeData"></param>
  8834. /// <param name="nationalTravelFeeId"></param>
  8835. /// <returns></returns>
  8836. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8837. {
  8838. string _city = string.Empty;
  8839. if (placeData.Count < 1) return _city;
  8840. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8841. if (data == null) return _city;
  8842. string country = data.Country;
  8843. string city = data.City;
  8844. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8845. else _city = city;
  8846. return _city;
  8847. }
  8848. ///// <summary>
  8849. ///// 团组模块 - 出入境费用 - 明细表导出
  8850. ///// </summary>
  8851. ///// <returns></returns>
  8852. //[HttpPost]
  8853. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8854. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8855. //{
  8856. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8857. // if (data.Code != 0)
  8858. // {
  8859. // return Ok(JsonView(false, data.Msg));
  8860. // }
  8861. // return Ok(JsonView(true, data.Msg, data.Data));
  8862. //}
  8863. /// <summary>
  8864. /// 团组模块 - 出入境费用 - 一键清空
  8865. /// </summary>
  8866. /// <returns></returns>
  8867. [HttpPost]
  8868. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8870. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8871. {
  8872. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8873. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8874. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8875. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8876. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8877. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8878. .SetColumns(x => new Grp_DayOtherPrice
  8879. {
  8880. IsDel = 1,
  8881. DeleteUserId = dto.UserId,
  8882. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8883. })
  8884. .ExecuteCommandAsync();
  8885. if (_view.Code == 0)
  8886. {
  8887. return Ok(JsonView(true, "操作成功"));
  8888. }
  8889. return Ok(JsonView(false, "操作失败"));
  8890. }
  8891. /// <summary>
  8892. /// 团组模块 - 出入境费用 - 子项删除
  8893. /// </summary>
  8894. /// <returns></returns>
  8895. [HttpPost]
  8896. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8898. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8899. {
  8900. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8901. if (data.Code != 0)
  8902. {
  8903. return Ok(JsonView(false, data.Msg));
  8904. }
  8905. return Ok(JsonView(true, "操作成功!", data.Data));
  8906. }
  8907. /// <summary>
  8908. /// 删除三公其他费用
  8909. /// </summary>
  8910. /// <param name="dto"></param>
  8911. /// <returns></returns>
  8912. [HttpPost]
  8913. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8914. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8915. {
  8916. var jw = JsonView(false, "删除失败!");
  8917. var data = new Grp_DayOtherPrice()
  8918. {
  8919. Id = dto.Id,
  8920. IsDel = 1,
  8921. DeleteUserId = dto.DeleteUserId,
  8922. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8923. };
  8924. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8925. if (del > 0)
  8926. {
  8927. jw.Code = 200;
  8928. jw.Msg = "删除成功!";
  8929. }
  8930. return Ok(jw);
  8931. }
  8932. /// <summary>
  8933. /// 团组模块 - 出入境国家费用标准 List
  8934. /// </summary>
  8935. /// <returns></returns>
  8936. [HttpPost]
  8937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8938. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8939. {
  8940. int provinceId = dto.ProvinceId;
  8941. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8942. var nftData = await _sqlSugar
  8943. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8944. JoinType.Left, ntf.Currency == sd1.Id,
  8945. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8946. JoinType.Left, ntf.ProvinceId == c.Id
  8947. ))
  8948. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8949. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8950. {
  8951. Id = ntf.Id,
  8952. ProvinceId = ntf.ProvinceId,
  8953. ProvinceName = c.Name_CN,
  8954. Continent = ntf.Continent,
  8955. Country = ntf.Country,
  8956. City = ntf.City,
  8957. Currency = ntf.Currency,
  8958. CurrencyCode = sd1.Name,
  8959. CurrencyName = sd1.Remark,
  8960. RoomCost = ntf.RoomCost,
  8961. FoodCost = ntf.FoodCost,
  8962. PublicCost = ntf.PublicCost,
  8963. LastUpdateUserId = ntf.LastUpdateUserId,
  8964. LastUpdateUserName = u.CnName,
  8965. LastUpdateTime = ntf.LastUpdateTime
  8966. })
  8967. .ToListAsync();
  8968. return Ok(JsonView(true, "查询成功!", nftData));
  8969. }
  8970. /// <summary>
  8971. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8972. /// </summary>
  8973. /// <returns></returns>
  8974. [HttpPost]
  8975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8976. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8977. {
  8978. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8979. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8980. List<string> countryData = new List<string>();
  8981. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8982. countryData = countryData.Distinct().ToList();
  8983. List<dynamic> dataSource = new List<dynamic>();
  8984. foreach (var item in countryData)
  8985. {
  8986. var cityData1 = new List<string>();
  8987. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8988. var countryData2 = new
  8989. {
  8990. CountryName = item,
  8991. CityData = cityData1
  8992. };
  8993. if (!dataSource.Contains(countryData2))
  8994. {
  8995. dataSource.Add(countryData2);
  8996. }
  8997. }
  8998. return Ok(JsonView(true, "查询成功!", dataSource));
  8999. }
  9000. /// <summary>
  9001. /// 团组模块 - 出入境国家费用标准 Page List
  9002. /// </summary>
  9003. /// <returns></returns>
  9004. [HttpPost]
  9005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9006. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  9007. {
  9008. int portId = dto.PortType,
  9009. pageIndex = dto.PageIndex,
  9010. pageSize = dto.PageSize;
  9011. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  9012. if (pageIndex == 0) pageIndex = 1;
  9013. if (pageSize == 0) pageSize = 10;
  9014. RefAsync<int> total = 0;
  9015. var nationalTravelFeeData = await _sqlSugar
  9016. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  9017. JoinType.Left, ntf.Currency == sd1.Id,
  9018. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  9019. JoinType.Left, ntf.ProvinceId == sd2.Id
  9020. ))
  9021. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  9022. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  9023. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  9024. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  9025. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  9026. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  9027. {
  9028. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  9029. Id = ntf.Id,
  9030. ProvinceId = ntf.ProvinceId,
  9031. ProvinceName = sd2.Name_CN,
  9032. Continent = ntf.Continent,
  9033. Country = ntf.Country,
  9034. City = ntf.City,
  9035. Currency = ntf.Currency,
  9036. CurrencyCode = sd1.Name,
  9037. CurrencyName = sd1.Remark,
  9038. RoomCost = ntf.RoomCost,
  9039. FoodCost = ntf.FoodCost,
  9040. PublicCost = ntf.PublicCost,
  9041. LastUpdateUserId = ntf.LastUpdateUserId,
  9042. LastUpdateUserName = u.CnName,
  9043. LastUpdateTime = ntf.LastUpdateTime,
  9044. Remark = ntf.Remark
  9045. })
  9046. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9047. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  9048. }
  9049. /// <summary>
  9050. /// 团组模块 - 出入境国家费用标准 根据城市查询
  9051. /// </summary>
  9052. /// <returns></returns>
  9053. [HttpPost]
  9054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9055. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  9056. {
  9057. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  9058. int portId = dto.PortType;
  9059. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  9060. string whereSql = string.Empty;
  9061. if (!string.IsNullOrEmpty(dto.Country))
  9062. {
  9063. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  9064. }
  9065. if (!string.IsNullOrEmpty(dto.City))
  9066. {
  9067. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  9068. }
  9069. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  9070. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  9071. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  9072. From Grp_NationalTravelFee gntf
  9073. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  9074. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  9075. Where gntf.Isdel = 0 {0} ", whereSql);
  9076. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  9077. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  9078. }
  9079. /// <summary>
  9080. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  9081. /// </summary>
  9082. /// <returns></returns>
  9083. [HttpPost]
  9084. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9085. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  9086. {
  9087. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  9088. }
  9089. /// <summary>
  9090. /// 团组模块 - 出入境国家费用标准 - Del
  9091. /// </summary>
  9092. /// <returns></returns>
  9093. [HttpPost]
  9094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9095. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  9096. {
  9097. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  9098. {
  9099. Id = dto.Id,
  9100. DeleteUserId = dto.DeleteUserId,
  9101. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9102. IsDel = 1
  9103. };
  9104. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  9105. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  9106. .WhereColumns(it => new { it.Id })
  9107. .ExecuteCommandAsync();
  9108. if (delStatus <= 0)
  9109. {
  9110. return Ok(JsonView(false, "删除失败!"));
  9111. }
  9112. return Ok(JsonView(true, "操作成功!"));
  9113. }
  9114. /// <summary>
  9115. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  9116. /// 注:Get 请求Headers 加 Token
  9117. /// </summary>
  9118. /// <param name="groupId"></param>
  9119. /// <returns></returns>
  9120. [HttpGet("{groupId}")]
  9121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9122. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  9123. {
  9124. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  9125. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  9126. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  9127. data.ForEach(x =>
  9128. {
  9129. x.CreateUserId = _currUserInfo.UserId;
  9130. });
  9131. if (data.Any())
  9132. {
  9133. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  9134. if (add > 0)
  9135. {
  9136. return Ok(JsonView(true, "操作成功!"));
  9137. }
  9138. }
  9139. return Ok(JsonView(false, "未操作!"));
  9140. }
  9141. #endregion
  9142. #region 团组经理模块 出入境费用-草稿
  9143. /// <summary>
  9144. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  9145. /// </summary>
  9146. /// <returns></returns>
  9147. [HttpGet]
  9148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9149. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  9150. {
  9151. var provData = await _groupRepository.ProvinceBasicSource();
  9152. return Ok(JsonView(true, "查询成功!", provData));
  9153. }
  9154. /// <summary>
  9155. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  9156. /// </summary>
  9157. /// <returns></returns>
  9158. [HttpGet("{provinceId}")]
  9159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9160. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  9161. {
  9162. //验证城市归属并给默认值
  9163. if (provinceId < 1) provinceId = 122;
  9164. /*
  9165. * 122 四川
  9166. * 108 贵州
  9167. * 103 重庆
  9168. * 132 云南
  9169. */
  9170. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  9171. return Ok(JsonView(true, "查询成功!", new
  9172. {
  9173. WordTypeData = wordTypeData,
  9174. ExcelTypeData = excelTypeData,
  9175. }));
  9176. }
  9177. /// <summary>
  9178. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  9179. /// </summary>
  9180. /// <returns></returns>
  9181. [HttpPost]
  9182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9183. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  9184. {
  9185. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9186. .Where(x => x.IsDel == 0)
  9187. .OrderByDescending(x => x.CreateTime)
  9188. .Select(x => new { x.Id, x.DraftName })
  9189. .ToListAsync();
  9190. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9191. //SetDataInfoView
  9192. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  9193. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  9194. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  9195. int provinceId = dto.ProvinceId;
  9196. if (provinceId < 1) provinceId = 122;
  9197. /*
  9198. * 122 四川
  9199. * 108 贵州
  9200. * 103 重庆
  9201. * 132 云南
  9202. */
  9203. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  9204. //默认币种显示
  9205. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  9206. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9207. return Ok(JsonView(true, "查询成功!", new
  9208. {
  9209. DraftNameDatas = draftNameDatas,
  9210. CurrencyData = _CurrencyData,
  9211. WordTypeData = wordTypeData,
  9212. ExcelTypeData = excelTypeData,
  9213. CurrencyInit = _currencyInfos,
  9214. ViewPermissionData = viewPermissionData
  9215. }));
  9216. }
  9217. /// <summary>
  9218. /// 团组模块 - 出入境费用-草稿
  9219. /// 实时汇率 tips
  9220. /// 机票费用 tips
  9221. /// </summary>
  9222. /// <returns></returns>
  9223. [HttpPost]
  9224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9225. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  9226. {
  9227. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  9228. return Ok(JsonView(true, "查询成功!", new
  9229. {
  9230. //GroupNameData = groupNameData.Data,
  9231. //visaData = visaData.Data,
  9232. //airData = airData.Data,
  9233. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  9234. }));
  9235. }
  9236. /// <summary>
  9237. /// 团组模块 - 出入境费用-草稿
  9238. /// 签证费用 tips
  9239. /// </summary>
  9240. /// <returns></returns>
  9241. [HttpPost]
  9242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9243. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  9244. {
  9245. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9246. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9247. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9248. .Select(x => x.NationalTravelFeeId)
  9249. .Distinct()
  9250. .ToListAsync();
  9251. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9252. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9253. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9254. .Select(x => x.Country)
  9255. .Distinct()
  9256. .ToArrayAsync();
  9257. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9258. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9259. return Ok(JsonView(true, "查询成功!", new
  9260. {
  9261. totalAmt,
  9262. remark
  9263. }));
  9264. }
  9265. /// <summary>
  9266. /// 团组模块 - 出入境费用-草稿 - Info
  9267. /// </summary>
  9268. /// <returns></returns>
  9269. [HttpPost]
  9270. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  9271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9272. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  9273. {
  9274. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  9275. }
  9276. /// <summary>
  9277. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  9278. /// </summary>
  9279. /// <returns></returns>
  9280. [HttpPost]
  9281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9282. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  9283. {
  9284. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9285. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  9286. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9287. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9288. foreach (var userId in dto.UserIds)
  9289. {
  9290. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9291. }
  9292. if (permissions.Any())
  9293. {
  9294. _sqlSugar.BeginTran();
  9295. try
  9296. {
  9297. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9298. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9299. if (result < 1)
  9300. {
  9301. _sqlSugar.RollbackTran();
  9302. return Ok(JsonView(false));
  9303. }
  9304. }
  9305. catch (Exception ex)
  9306. {
  9307. _sqlSugar.RollbackTran();
  9308. return Ok(JsonView(false, ex.Message));
  9309. }
  9310. _sqlSugar.CommitTran();
  9311. return Ok(JsonView(true));
  9312. }
  9313. return Ok(JsonView(false));
  9314. }
  9315. /// <summary>
  9316. /// 团组模块 - 出入境费用-草稿 - Add And Update
  9317. /// </summary>
  9318. /// <returns></returns>
  9319. [HttpPost]
  9320. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  9321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9322. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  9323. {
  9324. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  9325. if (data.Code != 0)
  9326. {
  9327. return Ok(JsonView(false, data.Msg));
  9328. }
  9329. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  9330. //汇率信息记录
  9331. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  9332. return Ok(JsonView(true, data.Msg, data.Data));
  9333. }
  9334. /// <summary>
  9335. /// 团组模块 - 出入境费用-草稿 - File downlaod
  9336. /// </summary>
  9337. /// <param name="dto"></param>
  9338. /// <returns></returns>
  9339. [HttpPost]
  9340. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  9341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9342. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  9343. {
  9344. try
  9345. {
  9346. var id = dto.Id;
  9347. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  9348. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  9349. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  9350. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  9351. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  9352. 3 团组成员名单 1 团组成员名单", ""));
  9353. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  9354. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  9355. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  9356. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  9357. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  9358. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  9359. //数据源
  9360. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  9361. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  9362. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  9363. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  9364. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9365. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  9366. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  9367. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  9368. .Select((x, a, b) => new
  9369. {
  9370. x.Index,
  9371. itemName = a.Name,
  9372. CurrencyStr = b.Name,
  9373. x.Cost,
  9374. x.SubTotal,
  9375. x.Remark
  9376. })
  9377. .OrderBy((x) => x.Index)
  9378. .ToList(); //其他款项费用
  9379. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9380. var peiceItemCurrencys = new List<string>();
  9381. if (_DayAndCosts.Any())
  9382. {
  9383. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  9384. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  9385. }
  9386. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  9387. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  9388. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  9389. {
  9390. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  9391. }
  9392. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  9393. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  9394. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  9395. if (dto.ExportType == 1) //明细表
  9396. {
  9397. if (dto.SubTypeId == 1005) //1005(默认明细表)
  9398. {
  9399. //获取模板
  9400. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  9401. //载入模板
  9402. Document doc = new Document(tempPath);
  9403. DocumentBuilder builder = new DocumentBuilder(doc);
  9404. //利用键值对存放数据
  9405. Dictionary<string, string> dic = new Dictionary<string, string>();
  9406. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  9407. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  9408. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  9409. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  9410. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  9411. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  9412. //境内费用(其他费用)
  9413. if (_EnterExitCosts.ChoiceOne == 1)
  9414. {
  9415. string row1_1 = "";
  9416. if (_EnterExitCosts.Visa > 0)
  9417. {
  9418. //insidePayTotal += _EnterExitCosts.Visa;
  9419. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  9420. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  9421. //{
  9422. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  9423. //}
  9424. }
  9425. string row1_2 = "";
  9426. if (_EnterExitCosts.YiMiao > 0)
  9427. {
  9428. //insidePayTotal += _EnterExitCosts.YiMiao;
  9429. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  9430. }
  9431. if (_EnterExitCosts.HeSuan > 0)
  9432. {
  9433. //insidePayTotal += _EnterExitCosts.HeSuan;
  9434. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  9435. }
  9436. if (_EnterExitCosts.Service > 0)
  9437. {
  9438. //insidePayTotal += _EnterExitCosts.Service;
  9439. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  9440. }
  9441. string row1_3 = "";
  9442. if (_EnterExitCosts.Safe > 0)
  9443. {
  9444. //insidePayTotal += _EnterExitCosts.Safe;
  9445. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  9446. }
  9447. if (_EnterExitCosts.Ticket > 0)
  9448. {
  9449. //insidePayTotal += _EnterExitCosts.Ticket;
  9450. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  9451. }
  9452. string row1 = "";
  9453. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  9454. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  9455. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  9456. row1 += $"备注:{_EnterExitCosts.Remark}";
  9457. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  9458. dic.Add("Row1Str", row1);
  9459. }
  9460. string airTotalStr = string.Empty,
  9461. airPriceStr = string.Empty;
  9462. //经济舱
  9463. if (_EnterExitCosts.SumJJC == 1)
  9464. {
  9465. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  9466. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  9467. }
  9468. //公务舱
  9469. if (_EnterExitCosts.SumGWC == 1)
  9470. {
  9471. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  9472. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  9473. }
  9474. //头等舱
  9475. if (_EnterExitCosts.SumTDC == 1)
  9476. {
  9477. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  9478. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  9479. }
  9480. //汇率描述
  9481. string rateStr = "";
  9482. if (peiceItemCurrencyInfos.Any())
  9483. {
  9484. rateStr = "\r\n汇率描述:";
  9485. foreach (var item in peiceItemCurrencyInfos)
  9486. {
  9487. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  9488. }
  9489. }
  9490. string twoItemRemark = "备注:";
  9491. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  9492. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  9493. dic.Add("AirTotalStr", airTotalStr);
  9494. dic.Add("AirPriceStr", airPriceStr);
  9495. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9496. dic.Add("TwoItemRemark", twoItemRemark);
  9497. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9498. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9499. int table1Row = 0,
  9500. table2Row = 0,
  9501. table3Row = 0,
  9502. table4Row = 0,
  9503. table5Row = 0;
  9504. //住宿费
  9505. if (_EnterExitCosts.ChoiceThree == 1)
  9506. {
  9507. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  9508. table1Row = dac1.Count;
  9509. #region 填充word表格内容
  9510. for (int i = 0; i < dac1.Count; i++)
  9511. {
  9512. var dac = dac1[i];
  9513. if (dac == null) continue;
  9514. builder.MoveToCell(0, i, 0, 0);
  9515. builder.Write("第" + dac.Days.ToString() + "晚:");
  9516. builder.MoveToCell(0, i, 1, 0);
  9517. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  9518. //builder.Write(dac.Place == null ? "" : dac.Place);
  9519. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9520. builder.MoveToCell(0, i, 2, 0);
  9521. builder.Write("费用标准:");
  9522. string curr = "";
  9523. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9524. if (currData != null)
  9525. {
  9526. curr = currData.Name;
  9527. }
  9528. builder.MoveToCell(0, i, 3, 0);
  9529. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9530. builder.MoveToCell(0, i, 4, 0);
  9531. builder.Write("费用小计:");
  9532. builder.MoveToCell(0, i, 5, 0);
  9533. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9534. }
  9535. #endregion
  9536. }
  9537. else dic.Add("SubZS", "0.00");
  9538. //删除多余行
  9539. while (table1.Rows.Count > table1Row)
  9540. {
  9541. table1.Rows.RemoveAt(table1Row);
  9542. }
  9543. //伙食费
  9544. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  9545. if (_EnterExitCosts.ChoiceFour == 1)
  9546. {
  9547. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  9548. table2Row = dac2.Count;
  9549. #region 填充word表格内容
  9550. for (int i = 0; i < dac2.Count; i++)
  9551. {
  9552. var dac = dac2[i];
  9553. if (dac == null) continue;
  9554. builder.MoveToCell(1, i, 0, 0);
  9555. builder.Write("第" + dac.Days.ToString() + "天:");
  9556. builder.MoveToCell(1, i, 1, 0);
  9557. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9558. builder.MoveToCell(1, i, 2, 0);
  9559. builder.Write("费用标准:");
  9560. string curr = "";
  9561. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9562. if (currData != null)
  9563. {
  9564. curr = currData.Name;
  9565. }
  9566. builder.MoveToCell(1, i, 3, 0);
  9567. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9568. builder.MoveToCell(1, i, 4, 0);
  9569. builder.Write("费用小计:");
  9570. builder.MoveToCell(1, i, 5, 0);
  9571. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9572. }
  9573. #endregion
  9574. }
  9575. else dic.Add("SubHS", "0.00");
  9576. //删除多余行
  9577. while (table2.Rows.Count > table2Row)
  9578. {
  9579. table2.Rows.RemoveAt(table2Row);
  9580. }
  9581. //公杂费
  9582. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  9583. if (_EnterExitCosts.ChoiceFive == 1)
  9584. {
  9585. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  9586. table3Row = dac3.Count;
  9587. #region 填充word表格内容
  9588. for (int i = 0; i < dac3.Count; i++)
  9589. {
  9590. var dac = dac3[i];
  9591. if (dac == null) continue;
  9592. builder.MoveToCell(2, i, 0, 0);
  9593. builder.Write("第" + dac.Days.ToString() + "天:");
  9594. builder.MoveToCell(2, i, 1, 0);
  9595. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9596. builder.MoveToCell(2, i, 2, 0);
  9597. builder.Write("费用标准:");
  9598. string curr = "";
  9599. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9600. if (currData != null)
  9601. {
  9602. curr = currData.Name;
  9603. }
  9604. builder.MoveToCell(2, i, 3, 0);
  9605. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9606. builder.MoveToCell(2, i, 4, 0);
  9607. builder.Write("费用小计:");
  9608. builder.MoveToCell(2, i, 5, 0);
  9609. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9610. }
  9611. //删除多余行
  9612. while (table3.Rows.Count > table3Row)
  9613. {
  9614. table3.Rows.RemoveAt(table3Row);
  9615. }
  9616. #endregion
  9617. }
  9618. else dic.Add("SubGZF", "0.00");
  9619. //删除多余行
  9620. while (table3.Rows.Count > table3Row)
  9621. {
  9622. table3.Rows.RemoveAt(table3Row);
  9623. }
  9624. //培训费
  9625. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  9626. if (_EnterExitCosts.ChoiceSix == 1)
  9627. {
  9628. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  9629. dic.Add("SubPX", pxStr);
  9630. table4Row = dac4.Count;
  9631. #region 填充word表格内容
  9632. for (int i = 0; i < dac4.Count; i++)
  9633. {
  9634. var dac = dac4[i];
  9635. if (dac == null) continue;
  9636. builder.MoveToCell(3, i, 0, 0);
  9637. builder.Write("第" + dac.Days.ToString() + "天:");
  9638. builder.MoveToCell(3, i, 1, 0);
  9639. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9640. builder.MoveToCell(3, i, 2, 0);
  9641. builder.Write("费用标准:");
  9642. string curr = "";
  9643. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9644. if (currData != null)
  9645. {
  9646. curr = currData.Name;
  9647. }
  9648. builder.MoveToCell(3, i, 3, 0);
  9649. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9650. builder.MoveToCell(3, i, 4, 0);
  9651. builder.Write("费用小计:");
  9652. builder.MoveToCell(3, i, 5, 0);
  9653. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9654. }
  9655. #endregion
  9656. }
  9657. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  9658. //删除多余行
  9659. while (table4.Rows.Count > table4Row)
  9660. {
  9661. table4.Rows.RemoveAt(table4Row);
  9662. }
  9663. //其他费用
  9664. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  9665. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  9666. {
  9667. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  9668. dic.Add("titleQi", qtStr);
  9669. table5Row = dac5.Count;
  9670. #region 填充word表格内容
  9671. for (int i = 0; i < dac5.Count; i++)
  9672. {
  9673. var dac = dac5[i];
  9674. if (dac == null) continue;
  9675. builder.MoveToCell(4, i, 0, 0);
  9676. builder.Write("第" + dac.Index.ToString() + "项:");
  9677. builder.MoveToCell(4, i, 1, 0);
  9678. builder.Write(dac.itemName);
  9679. builder.MoveToCell(4, i, 2, 0);
  9680. builder.Write("费用标准:");
  9681. builder.MoveToCell(4, i, 3, 0);
  9682. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  9683. builder.MoveToCell(4, i, 4, 0);
  9684. builder.Write("费用小计:");
  9685. builder.MoveToCell(4, i, 5, 0);
  9686. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9687. builder.MoveToCell(4, i, 6, 0);
  9688. builder.Write("备注:");
  9689. builder.MoveToCell(4, i, 7, 0);
  9690. builder.Write(dac.Remark);
  9691. }
  9692. #endregion
  9693. }
  9694. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  9695. //删除多余行
  9696. while (table5.Rows.Count > table5Row)
  9697. {
  9698. table5.Rows.RemoveAt(table5Row);
  9699. }
  9700. //加上其他费用
  9701. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  9702. decimal subJJC = 0.00M,
  9703. subGWC = 0.00M,
  9704. subTDC = 0.00M;
  9705. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  9706. string totalLabel = string.Format("全部费用总计:");
  9707. //经济舱
  9708. if (_EnterExitCosts.SumJJC == 1)
  9709. {
  9710. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  9711. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  9712. }
  9713. //公务舱
  9714. if (_EnterExitCosts.SumGWC == 1)
  9715. {
  9716. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  9717. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  9718. }
  9719. //头等舱
  9720. if (_EnterExitCosts.SumTDC == 1)
  9721. {
  9722. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9723. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  9724. }
  9725. //TotalLabel
  9726. dic.Add("TotalLabel", totalLabel);
  9727. #region 填充word模板书签内容
  9728. foreach (var key in dic.Keys)
  9729. {
  9730. Bookmark bookmark = doc.Range.Bookmarks[key];
  9731. if (bookmark != null)
  9732. {
  9733. builder.MoveToBookmark(key);
  9734. builder.Write(dic[key]);
  9735. }
  9736. }
  9737. #endregion
  9738. //文件名
  9739. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  9740. strFileName = CommonFun.ValidFileName(strFileName);
  9741. AsposeHelper.removewatermark_v2180();
  9742. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9743. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9744. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9745. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9746. }
  9747. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  9748. {
  9749. //获取模板
  9750. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  9751. //载入模板
  9752. Document doc = new Document(tempPath);
  9753. DocumentBuilder builder = new DocumentBuilder(doc);
  9754. Dictionary<string, string> dic = new Dictionary<string, string>();
  9755. string returnCodeLabel = string.Empty;
  9756. if (nationalTravelFeeData.Any())
  9757. {
  9758. List<string> list = new List<string>();
  9759. foreach (var item in nationalTravelFeeData)
  9760. {
  9761. list.Add($"{item.Country}({item.City})");
  9762. }
  9763. list = list.Distinct().ToList();
  9764. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9765. }
  9766. var countryLabel = string.Empty;
  9767. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9768. if (countryData.Any())
  9769. {
  9770. countryLabel = string.Join("、", countryData);
  9771. }
  9772. dic.Add("ReturnCodeAir", returnCodeLabel);
  9773. dic.Add("VisitStartDate", "-");
  9774. dic.Add("VisitEndDate", "-");
  9775. dic.Add("Day", "-");
  9776. dic.Add("VisitCountry", countryLabel);
  9777. dic.Add("ClientUnit", "-");
  9778. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  9779. //dic.Add("Names", Names);
  9780. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9781. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9782. decimal dac1totalPrice = 0.00M;
  9783. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  9784. foreach (var dac in dac1)
  9785. {
  9786. if (dac.SubTotal == 0.00M)
  9787. {
  9788. continue;
  9789. }
  9790. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  9791. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  9792. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  9793. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9794. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  9795. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9796. builder.Write(currency);//币种
  9797. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  9798. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9799. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9800. builder.Write("");//人数
  9801. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9802. builder.Write("");//天数
  9803. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9804. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9805. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9806. decimal rate = 0.00M;
  9807. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9808. builder.Write(rate.ToString("#0.0000"));//汇率
  9809. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9810. decimal rbmPrice = dac.SubTotal;
  9811. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9812. accommodationStartIndex++;
  9813. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9814. }
  9815. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9816. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9817. {
  9818. table1.Rows.RemoveAt(i - 1);
  9819. foodandotherStartIndex--;
  9820. }
  9821. if (dac2.Count == dac3.Count)//国家 币种 金额
  9822. {
  9823. for (int i = 0; i < dac2.Count; i++)
  9824. {
  9825. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9826. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9827. }
  9828. }
  9829. decimal dac2totalPrice = 0.00M;
  9830. foreach (var dac in dac2)
  9831. {
  9832. if (dac.SubTotal == 0)
  9833. {
  9834. continue;
  9835. }
  9836. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9837. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9838. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9839. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9840. builder.Write(currency);//币种
  9841. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9842. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9843. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9844. builder.Write("");//人数
  9845. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9846. builder.Write("");//天数
  9847. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9848. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9849. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9850. decimal rate = 0.00M;
  9851. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9852. builder.Write(rate.ToString("#0.0000"));//汇率
  9853. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9854. decimal rbmPrice = dac.SubTotal;
  9855. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9856. foodandotherStartIndex++;
  9857. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9858. }
  9859. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9860. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9861. {
  9862. table1.Rows.RemoveAt(i - 1);
  9863. }
  9864. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9865. string otherFeeStr = "";
  9866. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9867. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9868. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9869. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9870. foreach (var otherInfo in dac5)
  9871. {
  9872. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9873. }
  9874. #endregion
  9875. if (otherFeeStr.Length > 0)
  9876. {
  9877. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9878. otherFeeStr = $"({otherFeeStr})";
  9879. dic.Add("OtherFeeStr", otherFeeStr);
  9880. }
  9881. //总计
  9882. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9883. //国际旅费
  9884. string outsideAir = string.Empty;
  9885. string allPriceAir = string.Empty;
  9886. if (_EnterExitCosts.SumJJC == 1)
  9887. {
  9888. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9889. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9890. }
  9891. if (_EnterExitCosts.SumGWC == 1)
  9892. {
  9893. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9894. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9895. }
  9896. if (_EnterExitCosts.SumTDC == 1)
  9897. {
  9898. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9899. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9900. }
  9901. dic.Add("InTravelPrice", $"({outsideAir})");
  9902. dic.Add("FinalSumPrice", $"({allPriceAir})");
  9903. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  9904. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  9905. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  9906. foreach (var key in dic.Keys)
  9907. {
  9908. builder.MoveToBookmark(key);
  9909. builder.Write(dic[key]);
  9910. }
  9911. //模板文件名
  9912. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9913. strFileName = CommonFun.ValidFileName(strFileName);
  9914. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9915. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9916. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9917. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9918. }
  9919. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9920. {
  9921. //获取模板
  9922. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9923. //载入模板
  9924. WorkbookDesigner designer = new WorkbookDesigner();
  9925. designer.Workbook = new Workbook(tempPath);
  9926. Dictionary<string, string> dic = new Dictionary<string, string>();
  9927. string returnCodeLabel = string.Empty;
  9928. if (nationalTravelFeeData.Any())
  9929. {
  9930. List<string> list = new List<string>();
  9931. foreach (var item in nationalTravelFeeData)
  9932. {
  9933. list.Add($"{item.Country}({item.City})");
  9934. }
  9935. list = list.Distinct().ToList();
  9936. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9937. }
  9938. var countryLabel = string.Empty;
  9939. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9940. if (countryData.Any())
  9941. {
  9942. countryLabel = string.Join("、", countryData);
  9943. }
  9944. dic.Add("ReturnCodeAir", returnCodeLabel);
  9945. dic.Add("VisitStartDate", "-");
  9946. dic.Add("VisitEndDate", "-");
  9947. dic.Add("Day", "0");
  9948. dic.Add("VisitCountry", countryLabel);
  9949. dic.Add("ClientUnit", "-");
  9950. designer.SetDataSource("ClientUnit", "-");
  9951. designer.SetDataSource("VisitCountry", countryLabel);
  9952. designer.SetDataSource("Group", "-");
  9953. designer.SetDataSource("ClientUnitTitle", "-");
  9954. designer.SetDataSource("Name", "-");
  9955. designer.SetDataSource("VisitStartDate", "-");
  9956. designer.SetDataSource("Day", "0");
  9957. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9958. designer.SetDataSource("ReturnCodeAir", "-");
  9959. int startIndex = 10;
  9960. const int startIndexcopy = 10;
  9961. if (dac2.Count == dac3.Count)//国家 币种 金额
  9962. {
  9963. for (int i = 0; i < dac2.Count; i++)
  9964. {
  9965. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9966. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9967. }
  9968. }
  9969. DataTable dtdac1 = new DataTable();
  9970. List<string> place = new List<string>();
  9971. dtdac1.Columns.AddRange(new DataColumn[] {
  9972. new DataColumn(){ ColumnName = "city"},
  9973. new DataColumn(){ ColumnName = "curr"},
  9974. new DataColumn(){ ColumnName = "criterion"},
  9975. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9976. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9977. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9978. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9979. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9980. });
  9981. DataTable dtdac2 = new DataTable();
  9982. dtdac2.Columns.AddRange(new DataColumn[] {
  9983. new DataColumn(){ ColumnName = "city"},
  9984. new DataColumn(){ ColumnName = "curr"},
  9985. new DataColumn(){ ColumnName = "criterion"},
  9986. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9987. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9988. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9989. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9990. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9991. });
  9992. dtdac1.TableName = "tb1";
  9993. dtdac2.TableName = "tb2";
  9994. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9995. foreach (var item in dac1)
  9996. {
  9997. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9998. if (place.Contains(item.Place))
  9999. {
  10000. continue;
  10001. }
  10002. DataRow row = dtdac1.NewRow();
  10003. row["city"] = item.Place;
  10004. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10005. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10006. row["curr"] = currency;
  10007. row["rate"] = rate.ToString("#0.0000");
  10008. row["criterion"] = item.Cost.ToString("#0.00");
  10009. row["number"] = 1;
  10010. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10011. //row["costRMB"] = rbmPrice;
  10012. dtdac1.Rows.Add(row);
  10013. place.Add(item.Place);
  10014. }
  10015. place = new List<string>();
  10016. foreach (var item in dac2)
  10017. {
  10018. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  10019. if (place.Contains(item.Place))
  10020. {
  10021. continue;
  10022. }
  10023. DataRow row = dtdac2.NewRow();
  10024. row["city"] = item.Place;
  10025. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10026. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10027. row["curr"] = currency;
  10028. row["rate"] = rate.ToString("#0.0000");
  10029. row["criterion"] = item.Cost.ToString("#0.00");
  10030. row["number"] = 1;
  10031. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10032. //row["cost"] = item.SubTotal;
  10033. //row["costRMB"] = rbmPrice;
  10034. dtdac2.Rows.Add(row);
  10035. place.Add(item.Place);
  10036. //dac2totalPrice += rbmPrice;
  10037. }
  10038. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  10039. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  10040. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10041. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  10042. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  10043. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  10044. string cell4Str1 = string.Empty;
  10045. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  10046. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  10047. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  10048. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  10049. string cellStr = $" 5.其他费用(";
  10050. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  10051. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  10052. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  10053. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  10054. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  10055. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  10056. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  10057. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  10058. foreach (var otherInfo in dac5)
  10059. {
  10060. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  10061. }
  10062. #endregion
  10063. if (cellStr.Length > 8)
  10064. {
  10065. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  10066. }
  10067. cellStr += ")";
  10068. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  10069. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  10070. decimal pxFee = dac4.Sum(it => it.Cost);
  10071. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  10072. string celllastStr1 = "";
  10073. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  10074. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  10075. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  10076. celllastStr1 += $",国际旅费 元";
  10077. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  10078. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  10079. designer.SetDataSource("cell4Str", cell4Str);
  10080. designer.SetDataSource("cellStr", cellStr);
  10081. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  10082. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  10083. designer.SetDataSource("celllastStr", celllastStr);
  10084. Workbook wb = designer.Workbook;
  10085. var sheet = wb.Worksheets[0];
  10086. //绑定datatable数据集
  10087. designer.SetDataSource(dtdac1);
  10088. designer.SetDataSource(dtdac2);
  10089. designer.Process();
  10090. var rowStart = dtdac1.Rows.Count;
  10091. while (rowStart > 0)
  10092. {
  10093. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  10094. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10095. startIndex++;
  10096. rowStart--;
  10097. }
  10098. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  10099. startIndex += 1; //总计行
  10100. rowStart = dtdac2.Rows.Count;
  10101. while (rowStart > 0)
  10102. {
  10103. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  10104. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10105. startIndex++;
  10106. rowStart--;
  10107. }
  10108. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  10109. wb.CalculateFormula(true);
  10110. //模板文件名
  10111. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10112. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10113. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10114. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10115. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10116. }
  10117. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  10118. {
  10119. //获取模板
  10120. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  10121. //载入模板
  10122. Document doc = new Document(tempPath);
  10123. DocumentBuilder builder = new DocumentBuilder(doc);
  10124. Dictionary<string, string> dic = new Dictionary<string, string>();
  10125. dic.Add("GroupName", "-");
  10126. dic.Add("ClientUnit", "-");
  10127. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  10128. //string missionLeaderJob = "";//负责人job
  10129. //int groupNumber = 0; //团人数
  10130. dic.Add("MissionLeader", "-"); //团负责人
  10131. dic.Add("MissionLeaderJob", "-"); //团负责人job
  10132. dic.Add("GroupNumber", "0"); //团人数
  10133. dic.Add("Day", "0");
  10134. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  10135. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10136. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10137. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10138. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  10139. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  10140. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  10141. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  10142. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  10143. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  10144. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  10145. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  10146. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  10147. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  10148. //其他费用
  10149. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  10150. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  10151. //其他费用合计
  10152. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  10153. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  10154. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  10155. //公务舱合计
  10156. //国际旅费
  10157. //string outsideJJ = "";
  10158. //string allPriceJJ = "";
  10159. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  10160. {
  10161. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  10162. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  10163. }
  10164. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  10165. {
  10166. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  10167. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  10168. }
  10169. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  10170. {
  10171. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  10172. dic.Add("AirFeeTotal", airFeeTotalStr);
  10173. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  10174. dic.Add("FeeTotal", feeTotalStr);
  10175. }
  10176. foreach (var key in dic.Keys)
  10177. {
  10178. builder.MoveToBookmark(key);
  10179. builder.Write(dic[key]);
  10180. }
  10181. //模板文件名
  10182. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  10183. strFileName = CommonFun.ValidFileName(strFileName);
  10184. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10185. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10186. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10187. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10188. }
  10189. }
  10190. else if (dto.ExportType == 2) //表格
  10191. {
  10192. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10193. }
  10194. else if (dto.ExportType == 3)
  10195. {
  10196. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10197. }
  10198. return Ok(JsonView(400, "只可导出明细表!", ""));
  10199. }
  10200. catch (Exception ex)
  10201. {
  10202. return Ok(JsonView(400, ex.Message, ""));
  10203. }
  10204. }
  10205. /// <summary>
  10206. /// 获取三公费用标准city
  10207. /// </summary>
  10208. /// <param name="placeData"></param>
  10209. /// <param name="nationalTravelFeeId"></param>
  10210. /// <returns></returns>
  10211. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  10212. {
  10213. string _city = string.Empty;
  10214. if (!placeData.Any()) return _city;
  10215. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  10216. if (data == null) return _city;
  10217. string country = data.Country;
  10218. string city = data.City;
  10219. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  10220. else _city = city;
  10221. return _city;
  10222. }
  10223. /// <summary>
  10224. /// 团组模块 - 出入境费用-草稿 - 一键清空
  10225. /// </summary>
  10226. /// <returns></returns>
  10227. [HttpPost]
  10228. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10230. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  10231. {
  10232. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  10233. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  10234. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  10235. if (_view.Code == 0)
  10236. {
  10237. return Ok(JsonView(true, "操作成功"));
  10238. }
  10239. return Ok(JsonView(false, "操作失败"));
  10240. }
  10241. /// <summary>
  10242. /// 团组模块 - 出入境费用-草稿 - 子项删除
  10243. /// </summary>
  10244. /// <returns></returns>
  10245. [HttpPost]
  10246. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10248. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10249. {
  10250. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10251. if (data.Code != 0)
  10252. {
  10253. return Ok(JsonView(false, data.Msg));
  10254. }
  10255. return Ok(JsonView(true, "操作成功!", data.Data));
  10256. }
  10257. /// <summary>
  10258. /// 三公其他费用草稿 删除
  10259. /// </summary>
  10260. /// <param name="dto"></param>
  10261. /// <returns></returns>
  10262. [HttpPost]
  10263. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10264. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  10265. {
  10266. var jw = JsonView(false, "删除失败!");
  10267. var data = new Grp_DayOtherPriceDraft()
  10268. {
  10269. Id = dto.Id,
  10270. IsDel = 1,
  10271. DeleteUserId = dto.DeleteUserId,
  10272. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10273. };
  10274. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10275. if (del > 0)
  10276. {
  10277. jw.Code = 200;
  10278. jw.Msg = "删除成功!";
  10279. }
  10280. return Ok(jw);
  10281. }
  10282. /// <summary>
  10283. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  10284. /// </summary>
  10285. /// <returns></returns>
  10286. [HttpPost]
  10287. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  10288. {
  10289. var jw = JsonView(false);
  10290. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  10291. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  10292. jw.Code = StatusCodes.Status200OK;
  10293. jw.Msg = "操作成功!";
  10294. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  10295. return Ok(jw);
  10296. }
  10297. /// <summary>
  10298. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  10299. /// </summary>
  10300. /// <param name="dto"></param>
  10301. /// <returns></returns>
  10302. [HttpPost]
  10303. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  10304. {
  10305. int userId = dto.UserId,
  10306. portId = dto.PortType,
  10307. groupId = dto.GroupId,
  10308. draftId = dto.DraftId;
  10309. _portTypeData.Add(1);
  10310. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10311. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  10312. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  10313. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  10314. _sqlSugar.BeginTran();
  10315. try
  10316. {
  10317. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  10318. if (draftDatas == null)
  10319. {
  10320. _sqlSugar.RollbackTran();
  10321. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  10322. }
  10323. //验证可覆盖已有数据 两边创建人需为同一人;
  10324. int draftCreateUserId = draftDatas.CreateUserId,
  10325. formalCreateUserId = 0;
  10326. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10327. if (formalData != null)
  10328. {
  10329. formalCreateUserId = formalData.CreateUserId;
  10330. if (draftCreateUserId != formalCreateUserId)
  10331. {
  10332. _sqlSugar.RollbackTran();
  10333. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  10334. }
  10335. }
  10336. //默认添加查看、编辑权限(创建人、自己)
  10337. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  10338. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10339. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10340. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  10341. newExterData.DiId = groupId;
  10342. newExterData.CreateUserId = userId;
  10343. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  10344. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  10345. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  10346. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  10347. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  10348. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10349. //数据如果存在执行删除
  10350. if (enterExitCostInfo != null)
  10351. {
  10352. _sqlSugar.Updateable<Grp_EnterExitCost>()
  10353. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  10354. .Where(x => x.Id == enterExitCostInfo.Id)
  10355. .ExecuteCommand();
  10356. _sqlSugar.Updateable<Grp_DayAndCost>()
  10357. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10358. .Where(x => x.DiId == groupId)
  10359. .ExecuteCommand();
  10360. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  10361. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10362. .Where(x => x.Diid == groupId)
  10363. .ExecuteCommand();
  10364. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  10365. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10366. .Where(x => x.GroupId == groupId)
  10367. .ExecuteCommand();
  10368. }
  10369. //执行insert
  10370. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  10371. if (insertId < 1)
  10372. {
  10373. _sqlSugar.RollbackTran();
  10374. return Ok(JsonView(false, "草稿数据导入失败!"));
  10375. }
  10376. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  10377. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  10378. #region 默认添加权限
  10379. #endregion
  10380. _sqlSugar.CommitTran();
  10381. //执行操作之后
  10382. //生成默认文件pdf并且通知人员
  10383. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10384. {
  10385. DiId = groupId,
  10386. ExportType = 1,
  10387. SubTypeId = 1005
  10388. }, "pdf");
  10389. //发送通知
  10390. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10391. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  10392. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  10393. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  10394. //汇率信息记录
  10395. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  10396. return Ok(JsonView(true));
  10397. }
  10398. catch (Exception ex)
  10399. {
  10400. _sqlSugar.RollbackTran();
  10401. return Ok(JsonView(false, ex.Message));
  10402. }
  10403. }
  10404. #endregion
  10405. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  10406. /// <summary>
  10407. /// 获取币种基础数据(含逻辑处理)
  10408. /// </summary>
  10409. /// <returns></returns>
  10410. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  10411. {
  10412. return await GeneralMethod.EnterExitCostInitRate();
  10413. }
  10414. /// <summary>
  10415. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10416. /// </summary>
  10417. /// <returns></returns>
  10418. [HttpPost]
  10419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10420. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  10421. {
  10422. //验证城市归属并给默认值
  10423. int provinceId = dto.ProvinceId;
  10424. if (provinceId < 1) provinceId = 122;
  10425. var dataSource = await _sqlSugar
  10426. .Queryable<Sys_SetData>()
  10427. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10428. .ToListAsync();
  10429. var fileTypes = new List<EecSetDataInfoView>();
  10430. //三公费用-Word明细类型
  10431. var wordTypeData = dataSource
  10432. .Where(it => it.STid == 72)
  10433. .Select(x => new EecSetDataInfoView
  10434. {
  10435. ParentId = 1,
  10436. Id = x.Id,
  10437. Name = x.Name
  10438. })
  10439. .ToArray();
  10440. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  10441. var excelTypeData = dataSource
  10442. .Where(it => it.STid == 73)
  10443. .Select(x => new EecSetDataInfoView
  10444. {
  10445. ParentId = 2,
  10446. Id = x.Id,
  10447. Name = x.Name
  10448. })
  10449. .ToArray();
  10450. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  10451. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  10452. fileTypes.Add(groupNameList);
  10453. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  10454. //默认币种显示
  10455. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10456. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10457. return Ok(JsonView(true, "查询成功!", new
  10458. {
  10459. FileTypeData = fileTypes,
  10460. CurrencyInit = _currencyInfos,
  10461. viewPermissionData = viewPermissionData
  10462. }));
  10463. }
  10464. /// <summary>
  10465. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  10466. /// </summary>
  10467. /// <returns></returns>
  10468. [HttpPost]
  10469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10470. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  10471. {
  10472. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10473. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10474. RefAsync<int> total = 0;
  10475. int diId = 0;
  10476. var status = int.TryParse(dto.GroupName, out diId);
  10477. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  10478. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10479. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10480. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10481. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10482. .OrderByDescending(x => x.VisitStartDate)
  10483. .Select(x => new EnterExitCostMobileGroupView()
  10484. {
  10485. Id = x.Id,
  10486. GroupName = x.TeamName,
  10487. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  10488. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  10489. ProvinceId = x.CityId
  10490. })
  10491. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10492. //处理省份Id
  10493. if (data.Any())
  10494. {
  10495. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  10496. if (provCityDatas.Any())
  10497. {
  10498. foreach (var item in data)
  10499. {
  10500. var provinceId = item.ProvinceId;
  10501. var isDefualtVal = true;
  10502. if (provinceId > 0)
  10503. {
  10504. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  10505. if (parentId != null)
  10506. {
  10507. isDefualtVal = false;
  10508. item.ProvinceId = (int)parentId;
  10509. }
  10510. }
  10511. if (isDefualtVal)
  10512. {
  10513. item.ProvinceId = 122; //默认四川
  10514. }
  10515. }
  10516. }
  10517. }
  10518. //处理是否显示
  10519. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  10520. {
  10521. foreach (var item in data)
  10522. {
  10523. item.IsView = true;
  10524. }
  10525. }
  10526. return Ok(JsonView(true, "查询成功!", data, total));
  10527. }
  10528. /// <summary>
  10529. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  10530. /// </summary>
  10531. /// <returns></returns>
  10532. [HttpPost]
  10533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10534. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  10535. {
  10536. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10537. RefAsync<int> total = 0;
  10538. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10539. .Where(x => x.IsDel == 0 && x.STid == 66)
  10540. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10541. .Select(x => new
  10542. {
  10543. id = x.Id,
  10544. name = x.Name,
  10545. remark = x.Remark,
  10546. })
  10547. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10548. return Ok(JsonView(true, "查询成功!", data, total));
  10549. }
  10550. /// <summary>
  10551. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10552. /// </summary>
  10553. /// <returns></returns>
  10554. [HttpPost]
  10555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10556. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  10557. {
  10558. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10559. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10560. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  10561. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10562. var groupOtherRateData = groupRateData.TeamRates;
  10563. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10564. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10565. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10566. groupOtherRateData = groupOtherRateData
  10567. .Select(x => new TeamRateDescAddCurrencyIdView
  10568. {
  10569. CurrencyId = x.CurrencyId,
  10570. CurrencyName = x.CurrencyName,
  10571. CurrencyCode = x.CurrencyCode,
  10572. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10573. }).ToList();
  10574. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10575. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10576. }
  10577. /// <summary>
  10578. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  10579. /// </summary>
  10580. /// <returns></returns>
  10581. [HttpPost]
  10582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10583. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  10584. {
  10585. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10586. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10587. var tipsData = new List<int>() { 1, 2, 3 };
  10588. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10589. if (dto.TipsType == 1)
  10590. {
  10591. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10592. }
  10593. else if (dto.TipsType == 2)
  10594. {
  10595. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  10596. return Ok(JsonView(true, "查询成功!", visaData.Data));
  10597. }
  10598. else if (dto.TipsType == 3)
  10599. {
  10600. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  10601. return Ok(JsonView(true, "查询成功!", airData));
  10602. }
  10603. return Ok(JsonView(false));
  10604. }
  10605. /// <summary>
  10606. /// 团组模块 - 出入境国家费用标准-移动端 List
  10607. /// </summary>
  10608. /// <returns></returns>
  10609. [HttpPost]
  10610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10611. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  10612. {
  10613. Stopwatch sw = new Stopwatch();
  10614. sw.Start();
  10615. int provinceId = dto.ProvinceId;
  10616. if (provinceId < 1) provinceId = 122; // 默认四川
  10617. RefAsync<int> total = 0;
  10618. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10619. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  10620. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  10621. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  10622. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  10623. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  10624. .Select((ntf, sd, u, sd1) => new
  10625. {
  10626. Id = ntf.Id,
  10627. Area = $"{ntf.Country}-{ntf.City}",
  10628. Currency = ntf.Currency,
  10629. CurrencyCode = sd.Name,
  10630. CurrencyName = sd.Remark,
  10631. RoomCost = ntf.RoomCost,
  10632. FoodCost = ntf.FoodCost,
  10633. PublicCost = ntf.PublicCost,
  10634. TrainCost = ntf.TrainCost,
  10635. LastUpdateUserId = ntf.LastUpdateUserId,
  10636. LastUpdateUserName = u.CnName,
  10637. LastUpdateTime = ntf.LastUpdateTime
  10638. })
  10639. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10640. sw.Stop();
  10641. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  10642. }
  10643. /// <summary>
  10644. /// 团组模块 - 出入境费用-移动端 - Info
  10645. /// </summary>
  10646. /// <returns></returns>
  10647. [HttpPost]
  10648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10649. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  10650. {
  10651. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10652. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10653. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10654. return Ok(data);
  10655. }
  10656. /// <summary>
  10657. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  10658. /// </summary>
  10659. /// <returns></returns>
  10660. [HttpPost]
  10661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10662. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  10663. {
  10664. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10665. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10666. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10667. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10668. var mobileInfo = new EnterExitCostMobileParentInfoView();
  10669. mobileInfo.DiId = dto.DiId;
  10670. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10671. if (eecInfo == null) return Ok(mobileInfo);
  10672. //验证查看权限
  10673. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  10674. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  10675. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  10676. mobileInfo.IsAssignPerm = isSet;
  10677. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  10678. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10679. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10680. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10681. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10682. {
  10683. SubId = dac.Id,
  10684. DiId = dac.DiId,
  10685. Type = dac.Type,
  10686. Days = dac.Days,
  10687. NationalTravelFeeId = dac.NationalTravelFeeId,
  10688. Arae = $"{ntf.Country}-{ntf.City}",
  10689. Cost = dac.Cost,
  10690. Currency = dac.Currency,
  10691. CurrencyName = sd.Name,
  10692. SubTotal = dac.SubTotal,
  10693. })
  10694. .ToList();
  10695. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10696. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10697. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10698. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10699. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10700. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10701. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10702. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10703. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10704. //其他款项
  10705. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10706. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10707. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10708. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10709. .OrderBy((dop, sd1, sd2) => dop.Index)
  10710. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10711. {
  10712. SubId = dop.Id,
  10713. DiId = dop.Diid,
  10714. Index = dop.Index,
  10715. SetDataId = dop.SetDataId,
  10716. SetDataName = sd1.Name,
  10717. Cost = dop.Cost,
  10718. Currency = dop.Currency,
  10719. CurrencyName = sd2.Remark,
  10720. SubTotal = dop.SubTotal,
  10721. Remark = dop.Remark,
  10722. })
  10723. .ToArray();
  10724. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10725. return Ok(mobileInfo);
  10726. }
  10727. /// <summary>
  10728. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  10729. /// </summary>
  10730. /// <returns></returns>
  10731. [HttpPost]
  10732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10733. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  10734. {
  10735. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10736. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10737. //验证查看权限
  10738. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  10739. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  10740. var userIds = await _sqlSugar
  10741. .Queryable<Grp_EnterExitCostPermission>()
  10742. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  10743. .Select(x => x.UserId)
  10744. .ToArrayAsync();
  10745. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  10746. var perUsersView = new List<dynamic>();
  10747. foreach (var item in perUsers)
  10748. {
  10749. bool isView1 = false;
  10750. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10751. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10752. }
  10753. return Ok(JsonView(perUsersView));
  10754. }
  10755. /// <summary>
  10756. /// 团组模块 - 出入境费用-移动端 - SubInfo
  10757. /// </summary>
  10758. /// <returns></returns>
  10759. [HttpPost]
  10760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10761. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  10762. {
  10763. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10764. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10765. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10766. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10767. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10768. //验证查看权限
  10769. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  10770. //if (!isView) return Ok(JsonView(false, msg));
  10771. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10772. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10773. var subType = dto.SubType;
  10774. if (subType == 1) //1:境内费用
  10775. {
  10776. var oneData = new ChoiceOneMobileSubInfoView()
  10777. {
  10778. Id = eecInfo.Id,
  10779. ChoiceOne = eecInfo.ChoiceOne,
  10780. ChoiceOneTotalCost = eecInfo.InsidePay,
  10781. Visa = eecInfo.Visa,
  10782. VisaRemark = eecInfo.VisaRemark,
  10783. YiMiao = eecInfo.YiMiao,
  10784. HeSuan = eecInfo.HeSuan,
  10785. Service = eecInfo.Service,
  10786. Ticket = eecInfo.Ticket,
  10787. Safe = eecInfo.Safe,
  10788. FirstItemRemark = eecInfo.FirstItemRemark
  10789. };
  10790. return Ok(JsonView(oneData));
  10791. }
  10792. else if (subType == 2) //2:国际旅费
  10793. {
  10794. var twoData = new ChoiceTwoMobileSubInfoView()
  10795. {
  10796. Id = eecInfo.Id,
  10797. ChoiceTwoJJ = eecInfo.SumJJC,
  10798. OutsideJJPay = eecInfo.OutsideJJPay,
  10799. ChoiceTwoGW = eecInfo.SumGWC,
  10800. OutsideGWPay = eecInfo.OutsideGWPay,
  10801. ChoiceTwoTD = eecInfo.SumTDC,
  10802. OutsideTDPay = eecInfo.OutsideTDPay,
  10803. AirJJ = eecInfo.AirJJ,
  10804. AirGW = eecInfo.AirGW,
  10805. AirTD = eecInfo.AirTD,
  10806. CityTranffic = eecInfo.CityTranffic,
  10807. TwoItemRemark = eecInfo.TwoItemRemark
  10808. };
  10809. return Ok(JsonView(twoData));
  10810. }
  10811. else if (subType == 3) //3:住宿费
  10812. {
  10813. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10814. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10815. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10816. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10817. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10818. {
  10819. SubId = dac.Id,
  10820. DiId = dac.DiId,
  10821. Type = dac.Type,
  10822. Days = dac.Days,
  10823. NationalTravelFeeId = dac.NationalTravelFeeId,
  10824. Arae = $"{ntf.Country}-{ntf.City}",
  10825. Cost = dac.Cost,
  10826. Currency = dac.Currency,
  10827. CurrencyName = sd.Name,
  10828. SubTotal = dac.SubTotal,
  10829. })
  10830. .ToArray();
  10831. var data = new ChoiceMobileSubInfo3To6View()
  10832. {
  10833. ParentId = eecInfo.Id,
  10834. Choice = eecInfo.ChoiceThree,
  10835. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10836. Details = dayAndCostDatas
  10837. };
  10838. return Ok(JsonView(data));
  10839. }
  10840. else if (subType == 4) //4:伙食费
  10841. {
  10842. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10843. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10844. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10845. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10846. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10847. {
  10848. SubId = dac.Id,
  10849. DiId = dac.DiId,
  10850. Type = dac.Type,
  10851. Days = dac.Days,
  10852. NationalTravelFeeId = dac.NationalTravelFeeId,
  10853. Arae = $"{ntf.Country}-{ntf.City}",
  10854. Cost = dac.Cost,
  10855. Currency = dac.Currency,
  10856. CurrencyName = sd.Name,
  10857. SubTotal = dac.SubTotal,
  10858. })
  10859. .ToArray();
  10860. var data = new ChoiceMobileSubInfo3To6View()
  10861. {
  10862. ParentId = eecInfo.Id,
  10863. Choice = eecInfo.ChoiceFour,
  10864. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10865. Details = dayAndCostDatas
  10866. };
  10867. return Ok(JsonView(data));
  10868. }
  10869. else if (subType == 5) //5:公杂费
  10870. {
  10871. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10872. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10873. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10874. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10875. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10876. {
  10877. SubId = dac.Id,
  10878. DiId = dac.DiId,
  10879. Type = dac.Type,
  10880. Days = dac.Days,
  10881. NationalTravelFeeId = dac.NationalTravelFeeId,
  10882. Arae = $"{ntf.Country}-{ntf.City}",
  10883. Cost = dac.Cost,
  10884. Currency = dac.Currency,
  10885. CurrencyName = sd.Name,
  10886. SubTotal = dac.SubTotal,
  10887. })
  10888. .ToArray();
  10889. var data = new ChoiceMobileSubInfo3To6View()
  10890. {
  10891. ParentId = eecInfo.Id,
  10892. Choice = eecInfo.ChoiceFive,
  10893. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10894. Details = dayAndCostDatas
  10895. };
  10896. return Ok(JsonView(data));
  10897. }
  10898. else if (subType == 6) //6:培训费
  10899. {
  10900. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10901. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10902. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10903. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  10904. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10905. {
  10906. SubId = dac.Id,
  10907. DiId = dac.DiId,
  10908. Type = dac.Type,
  10909. Days = dac.Days,
  10910. NationalTravelFeeId = dac.NationalTravelFeeId,
  10911. Arae = $"{ntf.Country}-{ntf.City}",
  10912. Cost = dac.Cost,
  10913. Currency = dac.Currency,
  10914. CurrencyName = sd.Name,
  10915. SubTotal = dac.SubTotal,
  10916. })
  10917. .ToArray();
  10918. var data = new ChoiceMobileSubInfo3To6View()
  10919. {
  10920. ParentId = eecInfo.Id,
  10921. Choice = eecInfo.ChoiceSix,
  10922. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10923. Details = dayAndCostDatas
  10924. };
  10925. return Ok(JsonView(data));
  10926. }
  10927. else if (subType == 7) //7:其他
  10928. {
  10929. //其他款项
  10930. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10931. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10932. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10933. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10934. .OrderBy((dop, sd1, sd2) => dop.Index)
  10935. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10936. {
  10937. SubId = dop.Id,
  10938. DiId = dop.Diid,
  10939. Index = dop.Index,
  10940. SetDataId = dop.SetDataId,
  10941. SetDataName = sd1.Name,
  10942. Cost = dop.Cost,
  10943. Currency = dop.Currency,
  10944. CurrencyName = sd2.Name,
  10945. SubTotal = dop.SubTotal,
  10946. Remark = dop.Remark,
  10947. })
  10948. .ToArray();
  10949. var data = new ChoiceSevenMobileSubInfoView()
  10950. {
  10951. ParentId = eecInfo.Id,
  10952. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10953. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10954. Details = otherData
  10955. };
  10956. return Ok(JsonView(data));
  10957. }
  10958. return Ok(JsonView(false));
  10959. }
  10960. #region op
  10961. ///// <summary>
  10962. ///// 移动端更新费用消息通知
  10963. ///// </summary>
  10964. ///// <param name="diid"></param>
  10965. ///// <param name="id"></param>
  10966. ///// <param name="currUserId"></param>
  10967. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10968. //{
  10969. // try
  10970. // {
  10971. // ////生成默认文件pdf并且通知人员
  10972. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10973. // //{
  10974. // // DiId = diid,
  10975. // // ExportType = 1,
  10976. // // SubTypeId = 1005
  10977. // //}, "pdf");
  10978. // ////发送通知
  10979. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10980. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10981. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10982. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10983. // ////汇率信息记录
  10984. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10985. // }
  10986. // catch (Exception ex)
  10987. // {
  10988. // //记录日志
  10989. // throw;
  10990. // }
  10991. //}
  10992. /// <summary>
  10993. /// 验证出入境费用数据是否存在
  10994. /// 不存在添加
  10995. /// </summary>
  10996. /// <param name="diId"></param>
  10997. /// <param name="currUserId"></param>
  10998. /// <returns></returns>
  10999. /// <exception cref="CustomException"></exception>
  11000. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  11001. {
  11002. var parentId = 0;
  11003. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11004. if (info != null)
  11005. {
  11006. parentId = info.Id;
  11007. }
  11008. else
  11009. {
  11010. var currencys = await EnterExitCostMobileGetCurrencyInit();
  11011. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11012. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11013. parentId = addId;
  11014. }
  11015. return parentId;
  11016. }
  11017. /// <summary>
  11018. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  11019. /// </summary>
  11020. /// <returns></returns>
  11021. [HttpPost]
  11022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11023. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  11024. {
  11025. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11026. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11027. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11028. //验证编辑权限
  11029. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11030. //if (!isEdit) return Ok(JsonView(false, msg));
  11031. var permissions = new List<Grp_EnterExitCostPermission>();
  11032. foreach (var userId in dto.UserIds)
  11033. {
  11034. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  11035. }
  11036. if (permissions.Any())
  11037. {
  11038. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11039. {
  11040. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11041. }
  11042. _sqlSugar.BeginTran();
  11043. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  11044. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11045. if (result < 1)
  11046. {
  11047. _sqlSugar.RollbackTran();
  11048. return Ok(JsonView(false));
  11049. }
  11050. _sqlSugar.CommitTran();
  11051. return Ok(JsonView(true));
  11052. }
  11053. return Ok(JsonView(false));
  11054. }
  11055. /// <summary>
  11056. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  11057. /// </summary>
  11058. /// <returns></returns>
  11059. [HttpPost]
  11060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11061. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  11062. {
  11063. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11064. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11065. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11066. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11067. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11068. int id = dto.Id;
  11069. if (id <= 0) //add
  11070. {
  11071. //int provinceId = dto.ProvinceId;
  11072. int groupId = dto.DiId;
  11073. //if (provinceId < 1) provinceId = 122;
  11074. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  11075. info.LastUpdateUserId = dto.CurrUserId;
  11076. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11077. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  11078. if (add < 1) return Ok(JsonView(false));
  11079. id = add;
  11080. }
  11081. else //update
  11082. {
  11083. ////验证编辑权限
  11084. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11085. //if (!isEdit) return Ok(JsonView(false, msg));
  11086. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  11087. {
  11088. CurrencyRemark = currencyStr,
  11089. LastUpdateUserId = dto.CurrUserId,
  11090. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11091. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  11092. if (upd < 1) return Ok(JsonView(false));
  11093. }
  11094. #region 汇率变更时更改币种相关费用
  11095. var opDayCosts = new List<Grp_DayAndCost>();
  11096. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  11097. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11098. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  11099. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11100. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  11101. .Select((dac, sd) => new
  11102. {
  11103. dac.Id,
  11104. dac.DiId,
  11105. CurrencyCode = sd.Name,
  11106. dac.Cost
  11107. })
  11108. .ToList();
  11109. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  11110. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11111. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  11112. .Select((dop, sd) => new
  11113. {
  11114. dop.Id,
  11115. dop.Diid,
  11116. CurrencyCode = sd.Name,
  11117. dop.Cost
  11118. })
  11119. .ToList();
  11120. if (dayCosts.Count > 0)
  11121. {
  11122. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11123. foreach (var dc in new_dayCosts)
  11124. {
  11125. var thisCurrency = dc.Key.ToUpper();
  11126. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11127. if (thisRate == 0.00M) continue;
  11128. foreach (var dcSub in dc)
  11129. {
  11130. opDayCosts.Add(new Grp_DayAndCost()
  11131. {
  11132. Id = dcSub.Id,
  11133. DiId = dcSub.DiId,
  11134. Cost = dcSub.Cost,
  11135. SubTotal = dcSub.Cost * thisRate,
  11136. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11137. });
  11138. }
  11139. }
  11140. if (opDayCosts.Count > 0)
  11141. {
  11142. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11143. }
  11144. }
  11145. if (dayOtherCosts.Count > 0)
  11146. {
  11147. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11148. foreach (var dc in new_dayOtherCosts)
  11149. {
  11150. var thisCurrency = dc.Key.ToUpper();
  11151. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11152. if (thisRate == 0.00M) continue;
  11153. foreach (var dcSub in dc)
  11154. {
  11155. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  11156. {
  11157. Id = dcSub.Id,
  11158. Diid = dcSub.Diid,
  11159. Cost = dcSub.Cost,
  11160. SubTotal = dcSub.Cost * thisRate,
  11161. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11162. });
  11163. }
  11164. }
  11165. if (opDayOtherCosts.Count > 0)
  11166. {
  11167. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11168. }
  11169. }
  11170. #endregion
  11171. //消息通知
  11172. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11173. //汇率信息记录
  11174. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11175. return Ok(JsonView(new { parentId = id }));
  11176. }
  11177. /// <summary>
  11178. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  11179. /// </summary>
  11180. /// <returns></returns>
  11181. [HttpPost]
  11182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11183. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  11184. {
  11185. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11186. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11187. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11188. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11189. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  11190. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  11191. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11192. int id = dto.Id;
  11193. if (id <= 0) //add
  11194. {
  11195. checkboxInfo.CreateUserId = dto.CurrUserId;
  11196. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11197. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11198. if (add < 1) return Ok(JsonView(false));
  11199. }
  11200. else //update
  11201. {
  11202. ////验证编辑权限
  11203. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11204. //if (!isEdit) return Ok(JsonView(false, msg));
  11205. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11206. .UpdateColumns(x => new
  11207. {
  11208. x.ChoiceOne,
  11209. x.ChoiceTwo,
  11210. x.SumJJC,
  11211. x.SumGWC,
  11212. x.SumTDC,
  11213. x.ChoiceThree,
  11214. x.ChoiceFour,
  11215. x.ChoiceFive,
  11216. x.ChoiceSix,
  11217. x.OtherExpenses_Checked
  11218. })
  11219. .Where(x => x.Id == id)
  11220. .ExecuteCommandAsync();
  11221. if (upd < 1) return Ok(JsonView(false));
  11222. }
  11223. return Ok(JsonView(new { parentId = id }));
  11224. }
  11225. /// <summary>
  11226. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  11227. /// </summary>
  11228. /// <returns></returns>
  11229. [HttpPost]
  11230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11231. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  11232. {
  11233. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  11234. // if (provinceId < 1) provinceId = 122;
  11235. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11236. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11237. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11238. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11239. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11240. var checkboxInfo = new Grp_EnterExitCost()
  11241. {
  11242. Id = id,
  11243. //ProvinceId = provinceId,
  11244. DiId = diId,
  11245. CreateUserId = currUserId,
  11246. LastUpdateUserId = dto.CurrUserId,
  11247. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11248. };
  11249. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11250. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11251. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11252. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11253. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11254. if (id <= 0) //add
  11255. {
  11256. checkboxInfo.CreateUserId = dto.CurrUserId;
  11257. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11258. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11259. if (add < 1) return Ok(JsonView(false));
  11260. }
  11261. else //update
  11262. {
  11263. ////验证编辑权限
  11264. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11265. //if (!isEdit) return Ok(JsonView(false, msg));
  11266. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  11267. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  11268. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  11269. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11270. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11271. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11272. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11273. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11274. .Where(x => x.Id == id)
  11275. .ExecuteCommandAsync();
  11276. if (upd < 1) return Ok(JsonView(false));
  11277. }
  11278. return Ok(JsonView(new { parentId = id }));
  11279. }
  11280. /// <summary>
  11281. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  11282. /// </summary>
  11283. /// <returns></returns>
  11284. [HttpPost]
  11285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11286. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  11287. {
  11288. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11289. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11290. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11291. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11292. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11293. info.FirstItemRemark = dto.FirstItemRemark;
  11294. info.LastUpdateUserId = dto.CurrUserId;
  11295. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11296. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11297. int id = dto.Id;
  11298. if (id <= 0) //add
  11299. {
  11300. info.CreateUserId = dto.CurrUserId;
  11301. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11302. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11303. if (add < 1) return Ok(JsonView(false));
  11304. id = add;
  11305. }
  11306. else //update
  11307. {
  11308. ////验证编辑权限
  11309. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11310. //if (!isEdit) return Ok(JsonView(false, msg));
  11311. var upd = await _sqlSugar.Updateable(info)
  11312. .UpdateColumns(x => new
  11313. {
  11314. x.ChoiceOne,
  11315. x.InsidePay,
  11316. x.VisaRemark,
  11317. x.Visa,
  11318. x.Service,
  11319. x.Safe,
  11320. x.Ticket,
  11321. x.HeSuan,
  11322. x.YiMiao,
  11323. x.FirstItemRemark,
  11324. x.LastUpdateUserId,
  11325. x.LastUpdateTime
  11326. })
  11327. .Where(x => x.Id == id)
  11328. .ExecuteCommandAsync();
  11329. if (upd < 1) return Ok(JsonView(false));
  11330. }
  11331. //消息通知
  11332. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11333. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11334. }
  11335. /// <summary>
  11336. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  11337. /// </summary>
  11338. /// <returns></returns>
  11339. [HttpPost]
  11340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11341. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  11342. {
  11343. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11344. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11345. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11346. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11347. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11348. info.DiId = dto.DiId;
  11349. //info.ProvinceId = dto.ProvinceId;
  11350. info.OutsideJJPay = dto.OutsideJJPay;
  11351. info.OutsideGWPay = dto.OutsideGWPay;
  11352. info.OutsideTDPay = dto.OutsideTDPay;
  11353. info.AirJJ = dto.AirJJ;
  11354. info.AirGW = dto.AirGW;
  11355. info.AirTD = dto.AirTD;
  11356. info.CityTranffic = dto.CityTranffic;
  11357. info.TwoItemRemark = dto.TwoItemRemark;
  11358. info.SumJJC = dto.ChoiceTwoJJ;
  11359. info.SumGWC = dto.ChoiceTwoGW;
  11360. info.SumTDC = dto.ChoiceTwoTD;
  11361. info.LastUpdateUserId = dto.CurrUserId;
  11362. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11363. int id = dto.Id;
  11364. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11365. if (id <= 0) //add i
  11366. {
  11367. info.CreateUserId = dto.CurrUserId;
  11368. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11369. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11370. if (addId <= 0) return Ok(JsonView(false));
  11371. id = addId;
  11372. }
  11373. else //update
  11374. {
  11375. ////验证编辑权限
  11376. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11377. //if (!isEdit) return Ok(JsonView(false, msg));
  11378. var upd = await _sqlSugar.Updateable(info)
  11379. .UpdateColumns(x => new
  11380. {
  11381. x.SumJJC,
  11382. x.OutsideJJPay,
  11383. x.SumGWC,
  11384. x.OutsideGWPay,
  11385. x.SumTDC,
  11386. x.OutsideTDPay,
  11387. x.AirJJ,
  11388. x.AirGW,
  11389. x.AirTD,
  11390. x.CityTranffic,
  11391. x.TwoItemRemark,
  11392. x.LastUpdateTime,
  11393. x.LastUpdateUserId
  11394. })
  11395. .Where(x => x.Id == id)
  11396. .ExecuteCommandAsync();
  11397. if (upd < 1) return Ok(JsonView(false));
  11398. }
  11399. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11400. gwcItemTotal = info.AirGW + info.CityTranffic;
  11401. tdcItemTotal = info.AirTD + info.CityTranffic;
  11402. //消息通知
  11403. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11404. return Ok(JsonView(new
  11405. {
  11406. parentId = id,
  11407. choiceTwoJJ = dto.ChoiceTwoJJ,
  11408. jjcItemTotal = jjcItemTotal,
  11409. choiceTwoGW = dto.ChoiceTwoGW,
  11410. gwcItemTotal = gwcItemTotal,
  11411. choiceTwoTD = dto.ChoiceTwoTD,
  11412. tdcItemTotal = tdcItemTotal
  11413. }));
  11414. }
  11415. /// <summary>
  11416. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11417. /// </summary>
  11418. /// <returns></returns>
  11419. [HttpPost]
  11420. [ApiExplorerSettings(IgnoreApi = true)]
  11421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11422. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  11423. {
  11424. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11425. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11426. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11427. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11428. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11429. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11430. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  11431. var infos = infos1.Select(x => new Grp_DayAndCost
  11432. {
  11433. Id = x.Id,
  11434. DiId = dto.DiId,
  11435. Type = dto.FeeType,
  11436. Days = x.Days,
  11437. NationalTravelFeeId = x.NationalTravelFeeId,
  11438. Cost = x.Cost,
  11439. Currency = x.Currency,
  11440. SubTotal = x.SubTotal,
  11441. CreateUserId = dto.CurrUserId
  11442. })
  11443. .ToList();
  11444. var adds = infos.Where(x => x.Id <= 0).ToList();
  11445. var upds = infos.Where(x => x.Id > 0).ToList();
  11446. if (adds.Count > 0)
  11447. {
  11448. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11449. if (add < 1) return Ok(JsonView(false));
  11450. }
  11451. if (upds.Count > 0)
  11452. {
  11453. var upd = await _sqlSugar.Updateable(adds)
  11454. .UpdateColumns(x => new
  11455. {
  11456. x.Days,
  11457. x.NationalTravelFeeId,
  11458. x.Cost,
  11459. x.Currency,
  11460. x.SubTotal
  11461. })
  11462. .WhereColumns(x => new { x.Id })
  11463. .ExecuteCommandAsync();
  11464. if (upd < 1) return Ok(JsonView(false));
  11465. }
  11466. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11467. //消息通知
  11468. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11469. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11470. return Ok(JsonView(new { itemTotal = itemTotal }));
  11471. }
  11472. /// <summary>
  11473. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11474. /// </summary>
  11475. /// <returns></returns>
  11476. [HttpPost]
  11477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11478. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  11479. {
  11480. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11481. int subId = dto.SubId, feeType = dto.FeeType;
  11482. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11483. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11484. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11485. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11486. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  11487. subInfo.Id = subId;
  11488. subInfo.DiId = dto.DiId;
  11489. if (feeType == 3) subInfo.Type = 1;
  11490. else if (feeType == 4) subInfo.Type = 2;
  11491. else if (feeType == 5) subInfo.Type = 3;
  11492. else if (feeType == 6) subInfo.Type = 4;
  11493. subInfo.CreateUserId = dto.CurrUserId;
  11494. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  11495. if (parentId < 1) return Ok(JsonView(false));
  11496. //子表op
  11497. if (subId < 1)
  11498. {
  11499. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11500. if (subAdd < 1) return Ok(JsonView(false));
  11501. }
  11502. else
  11503. {
  11504. ////验证编辑权限
  11505. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11506. //if (!isEdit) return Ok(JsonView(false, msg));
  11507. var subUpd = await _sqlSugar.Updateable(subInfo)
  11508. .UpdateColumns(x => new
  11509. {
  11510. x.Days,
  11511. x.NationalTravelFeeId,
  11512. x.Cost,
  11513. x.Currency,
  11514. x.SubTotal
  11515. })
  11516. .WhereColumns(x => new { x.Id })
  11517. .ExecuteCommandAsync();
  11518. if (subUpd < 1) return Ok(JsonView(false));
  11519. }
  11520. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  11521. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  11522. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11523. }
  11524. /// <summary>
  11525. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  11526. /// </summary>
  11527. /// <returns></returns>
  11528. [HttpPost]
  11529. [ApiExplorerSettings(IgnoreApi = true)]
  11530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11531. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  11532. {
  11533. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11534. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11535. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11536. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  11537. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  11538. {
  11539. Id = x.Id,
  11540. Diid = dto.DiId,
  11541. SetDataId = x.SetDataId,
  11542. Index = x.Index,
  11543. Cost = x.Cost,
  11544. Currency = x.Currency,
  11545. SubTotal = x.SubTotal,
  11546. CreateUserId = dto.CurrUserId,
  11547. Remark = x.Remark
  11548. }).ToList();
  11549. var adds = infos.Where(x => x.Id <= 0).ToList();
  11550. var upds = infos.Where(x => x.Id > 0).ToList();
  11551. if (adds.Count > 0)
  11552. {
  11553. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11554. if (add < 1) return Ok(JsonView(false));
  11555. }
  11556. if (upds.Count > 0)
  11557. {
  11558. var upd = await _sqlSugar.Updateable(adds)
  11559. .UpdateColumns(x => new
  11560. {
  11561. x.Index,
  11562. x.SetDataId,
  11563. x.Cost,
  11564. x.Currency,
  11565. x.SubTotal,
  11566. x.Remark
  11567. })
  11568. .WhereColumns(x => new { x.Id })
  11569. .ExecuteCommandAsync();
  11570. if (upd < 1) return Ok(JsonView(false));
  11571. }
  11572. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  11573. //消息通知
  11574. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11575. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11576. return Ok(JsonView(new { itemTotal = itemTotal }));
  11577. }
  11578. /// <summary>
  11579. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  11580. /// </summary>
  11581. /// <returns></returns>
  11582. [HttpPost]
  11583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11584. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  11585. {
  11586. int subId = dto.SubId;
  11587. int diId = dto.Diid;
  11588. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11589. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11590. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11591. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  11592. subInfo.Id = subId;
  11593. subInfo.Diid = dto.Diid;
  11594. subInfo.CreateUserId = dto.CurrUserId;
  11595. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  11596. if (parentId < 1) return Ok(JsonView(false));
  11597. #region 子表op
  11598. if (subId < 1)//add
  11599. {
  11600. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11601. if (subAdd < 1) return Ok(JsonView(false));
  11602. }
  11603. else //upd
  11604. {
  11605. ////验证编辑权限
  11606. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  11607. //if (!isEdit) return Ok(JsonView(false, msg));
  11608. var subUpd = await _sqlSugar.Updateable(subInfo)
  11609. .UpdateColumns(x => new
  11610. {
  11611. x.Index,
  11612. x.SetDataId,
  11613. x.Cost,
  11614. x.Currency,
  11615. x.SubTotal,
  11616. x.Remark
  11617. })
  11618. .WhereColumns(x => new { x.Id })
  11619. .ExecuteCommandAsync();
  11620. if (subUpd < 1) return Ok(JsonView(false));
  11621. }
  11622. #endregion
  11623. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  11624. //消息通知
  11625. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11626. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11627. }
  11628. /// <summary>
  11629. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  11630. /// </summary>
  11631. /// <returns></returns>
  11632. [HttpPost]
  11633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11634. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  11635. {
  11636. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  11637. if (data.Code != 0)
  11638. {
  11639. return Ok(JsonView(false, data.Msg));
  11640. }
  11641. return Ok(JsonView(true, "操作成功!", data.Data));
  11642. }
  11643. /// <summary>
  11644. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  11645. /// </summary>
  11646. /// <param name="dto"></param>
  11647. /// <returns></returns>
  11648. [HttpPost]
  11649. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  11650. {
  11651. var data = new Grp_DayOtherPrice()
  11652. {
  11653. Id = dto.Id,
  11654. IsDel = 1,
  11655. DeleteUserId = dto.DeleteUserId,
  11656. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11657. };
  11658. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11659. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11660. return Ok(JsonView(false, "删除失败!"));
  11661. }
  11662. #endregion
  11663. #endregion
  11664. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  11665. /// <summary>
  11666. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  11667. /// </summary>
  11668. /// <returns></returns>
  11669. [HttpGet]
  11670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11671. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  11672. {
  11673. var provData = await _groupRepository.ProvinceBasicSource();
  11674. return Ok(JsonView(true, "查询成功!", provData));
  11675. }
  11676. /// <summary>
  11677. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  11678. /// </summary>
  11679. /// <returns></returns>
  11680. [HttpPost]
  11681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11682. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  11683. {
  11684. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11685. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11686. RefAsync<int> total = 0;
  11687. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  11688. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  11689. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  11690. .Select(x => new
  11691. {
  11692. Id = x.Id,
  11693. DraftName = x.DraftName,
  11694. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  11695. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  11696. .Any()
  11697. })
  11698. .OrderByDescending(x => x.Id)
  11699. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11700. return Ok(JsonView(true, "查询成功!", data, total));
  11701. }
  11702. /// <summary>
  11703. /// 出入境费用-草稿 移动端
  11704. /// 获取币种基础数据(含逻辑处理)
  11705. /// </summary>
  11706. /// <returns></returns>
  11707. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  11708. {
  11709. return await GeneralMethod.EnterExitCostInitRate();
  11710. }
  11711. /// <summary>
  11712. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  11713. /// </summary>
  11714. /// <returns></returns>
  11715. [HttpPost]
  11716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11717. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  11718. {
  11719. //验证城市归属并给默认值
  11720. int provinceId = dto.ProvinceId;
  11721. if (provinceId < 1) provinceId = 122;
  11722. var dataSource = await _sqlSugar
  11723. .Queryable<Sys_SetData>()
  11724. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  11725. .ToListAsync();
  11726. //三公费用-Word明细类型
  11727. var wordTypeData = dataSource.Where(it => it.STid == 72)
  11728. .Select(x => new SetDataInfoView
  11729. {
  11730. Id = x.Id,
  11731. Name = x.Name,
  11732. Remark = x.Remark
  11733. })
  11734. .ToList();
  11735. //三公费用-Excel明细类型
  11736. var excelTypeData = dataSource.Where(it => it.STid == 73)
  11737. .Select(x => new SetDataInfoView
  11738. {
  11739. Id = x.Id,
  11740. Name = x.Name,
  11741. Remark = x.Remark
  11742. })
  11743. .ToList();
  11744. //默认币种显示
  11745. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  11746. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  11747. return Ok(JsonView(true, "查询成功!", new
  11748. {
  11749. WordTypeData = wordTypeData,
  11750. ExcelTypeData = excelTypeData,
  11751. CurrencyInit = _currencyInfos,
  11752. viewPermissionData = viewPermissionData
  11753. }));
  11754. }
  11755. /// <summary>
  11756. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  11757. /// </summary>
  11758. /// <returns></returns>
  11759. [HttpPost]
  11760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11761. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  11762. {
  11763. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11764. RefAsync<int> total = 0;
  11765. int diId = 0;
  11766. var status = int.TryParse(dto.GroupName, out diId);
  11767. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  11768. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  11769. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  11770. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  11771. .OrderByDescending(x => x.VisitStartDate)
  11772. .Select(x => new
  11773. {
  11774. Id = x.Id,
  11775. GroupName = x.TeamName
  11776. })
  11777. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11778. return Ok(JsonView(true, "查询成功!", data, total));
  11779. }
  11780. /// <summary>
  11781. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  11782. /// </summary>
  11783. /// <returns></returns>
  11784. [HttpPost]
  11785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11786. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  11787. {
  11788. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11789. RefAsync<int> total = 0;
  11790. var data = await _sqlSugar.Queryable<Sys_SetData>()
  11791. .Where(x => x.IsDel == 0 && x.STid == 66)
  11792. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  11793. .Select(x => new
  11794. {
  11795. id = x.Id,
  11796. name = x.Name,
  11797. remark = x.Remark,
  11798. })
  11799. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11800. return Ok(JsonView(true, "查询成功!", data, total));
  11801. }
  11802. /// <summary>
  11803. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11804. /// </summary>
  11805. /// <returns></returns>
  11806. [HttpPost]
  11807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11808. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11809. {
  11810. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11811. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11812. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11813. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11814. var groupOtherRateData = groupRateData.TeamRates;
  11815. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11816. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11817. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11818. groupOtherRateData = groupOtherRateData
  11819. .Select(x => new TeamRateDescAddCurrencyIdView
  11820. {
  11821. CurrencyId = x.CurrencyId,
  11822. CurrencyName = x.CurrencyName,
  11823. CurrencyCode = x.CurrencyCode,
  11824. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11825. }).ToList();
  11826. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11827. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11828. }
  11829. /// <summary>
  11830. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11831. /// </summary>
  11832. /// <returns></returns>
  11833. [HttpPost]
  11834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11835. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11836. {
  11837. int portType = dto.PortType;
  11838. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11839. var tipsData = new List<int>() { 1, 2, 3 };
  11840. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11841. if (dto.TipsType == 1)
  11842. {
  11843. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11844. }
  11845. else if (dto.TipsType == 2)
  11846. {
  11847. if (portType == 2)
  11848. {
  11849. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11850. }
  11851. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11852. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11853. .Select(x => x.NationalTravelFeeId)
  11854. .Distinct()
  11855. .ToListAsync();
  11856. if (portType == 2)
  11857. {
  11858. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11859. }
  11860. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11861. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11862. .Select(x => x.Country)
  11863. .Distinct()
  11864. .ToArrayAsync();
  11865. if (portType == 2)
  11866. {
  11867. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11868. }
  11869. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11870. return Ok(JsonView(true, "查询成功!", new
  11871. {
  11872. totalAmt = totalAmt,
  11873. remark = remark
  11874. }));
  11875. }
  11876. else if (dto.TipsType == 3)
  11877. {
  11878. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11879. }
  11880. return Ok(JsonView(false));
  11881. }
  11882. /// <summary>
  11883. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11884. /// </summary>
  11885. /// <returns></returns>
  11886. [HttpPost]
  11887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11888. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11889. {
  11890. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11891. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11892. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11893. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11894. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11895. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11896. var info = new Grp_EnterExitCostDraft()
  11897. {
  11898. ProvinceId = dto.ProvinceId,
  11899. DraftName = dto.DraftName,
  11900. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  11901. CreateUserId = dto.CurrUserId
  11902. };
  11903. _sqlSugar.BeginTran();
  11904. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11905. if (draftId < 1)
  11906. {
  11907. _sqlSugar.RollbackTran();
  11908. return Ok(JsonView(false, "草稿创建失败!"));
  11909. }
  11910. //添加默认权限
  11911. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  11912. _sqlSugar.CommitTran();
  11913. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11914. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11915. mobileInfo.Id = draftId;
  11916. mobileInfo.DraftName = dto.DraftName;
  11917. mobileInfo.Currencys = rateInfos;
  11918. mobileInfo.IsAssignPerm = assignPerm;
  11919. return Ok(JsonView(mobileInfo));
  11920. }
  11921. /// <summary>
  11922. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11923. /// </summary>
  11924. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11925. /// <summary>
  11926. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11927. /// </summary>
  11928. /// <returns></returns>
  11929. [HttpPost]
  11930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11931. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11932. {
  11933. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11934. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11935. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11936. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11937. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11938. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11939. //验证查看编辑权限
  11940. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11941. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11942. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11943. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11944. mobileInfo.IsAssignPerm = assignPerm;
  11945. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11946. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11947. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11948. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11949. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11950. {
  11951. ParentId = dac.ParentId,
  11952. SubId = dac.Id,
  11953. Type = dac.Type,
  11954. Days = dac.Days,
  11955. NationalTravelFeeId = dac.NationalTravelFeeId,
  11956. Arae = $"{ntf.Country}-{ntf.City}",
  11957. Cost = dac.Cost,
  11958. Currency = dac.Currency,
  11959. CurrencyName = sd.Name,
  11960. SubTotal = dac.SubTotal,
  11961. })
  11962. .ToList();
  11963. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11964. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11965. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11966. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11967. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11968. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11969. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11970. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11971. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11972. //其他款项
  11973. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11974. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11975. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11976. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11977. .OrderBy((dop, sd1, sd2) => dop.Index)
  11978. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11979. {
  11980. ParentId = dop.ParentId,
  11981. SubId = dop.Id,
  11982. Index = dop.Index,
  11983. SetDataId = dop.SetDataId,
  11984. SetDataName = sd1.Name,
  11985. Cost = dop.Cost,
  11986. Currency = dop.Currency,
  11987. CurrencyName = sd2.Remark,
  11988. SubTotal = dop.SubTotal,
  11989. Remark = dop.Remark,
  11990. })
  11991. .ToArray();
  11992. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11993. return Ok(mobileInfo);
  11994. }
  11995. /// <summary>
  11996. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11997. /// </summary>
  11998. /// <returns></returns>
  11999. [HttpPost]
  12000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12001. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  12002. {
  12003. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12004. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12005. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12006. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  12007. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  12008. //验证查看编辑权限
  12009. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12010. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12011. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  12012. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  12013. var subType = dto.SubType;
  12014. if (subType == 1) //1:境内费用
  12015. {
  12016. var oneData = new ChoiceOneMobileSubInfoView()
  12017. {
  12018. Id = eecInfo.Id,
  12019. ChoiceOne = eecInfo.ChoiceOne,
  12020. ChoiceOneTotalCost = eecInfo.InsidePay,
  12021. Visa = eecInfo.Visa,
  12022. VisaRemark = eecInfo.VisaRemark,
  12023. YiMiao = eecInfo.YiMiao,
  12024. HeSuan = eecInfo.HeSuan,
  12025. Service = eecInfo.Service,
  12026. Ticket = eecInfo.Ticket,
  12027. Safe = eecInfo.Safe,
  12028. FirstItemRemark = eecInfo.FirstItemRemark
  12029. };
  12030. return Ok(JsonView(oneData));
  12031. }
  12032. else if (subType == 2) //2:国际旅费
  12033. {
  12034. var twoData = new ChoiceTwoMobileSubInfoView()
  12035. {
  12036. Id = eecInfo.Id,
  12037. ChoiceTwoJJ = eecInfo.SumJJC,
  12038. OutsideJJPay = eecInfo.OutsideJJPay,
  12039. ChoiceTwoGW = eecInfo.SumGWC,
  12040. OutsideGWPay = eecInfo.OutsideGWPay,
  12041. ChoiceTwoTD = eecInfo.SumTDC,
  12042. OutsideTDPay = eecInfo.OutsideTDPay,
  12043. AirJJ = eecInfo.AirJJ,
  12044. AirGW = eecInfo.AirGW,
  12045. AirTD = eecInfo.AirTD,
  12046. CityTranffic = eecInfo.CityTranffic,
  12047. TwoItemRemark = eecInfo.TwoItemRemark
  12048. };
  12049. return Ok(JsonView(twoData));
  12050. }
  12051. else if (subType == 3) //3:住宿费
  12052. {
  12053. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12054. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12055. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12056. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  12057. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12058. {
  12059. ParentId = dac.ParentId,
  12060. SubId = dac.Id,
  12061. Type = dac.Type,
  12062. Days = dac.Days,
  12063. NationalTravelFeeId = dac.NationalTravelFeeId,
  12064. Arae = $"{ntf.Country}-{ntf.City}",
  12065. Cost = dac.Cost,
  12066. Currency = dac.Currency,
  12067. CurrencyName = sd.Name,
  12068. SubTotal = dac.SubTotal,
  12069. })
  12070. .ToArray();
  12071. var data = new ChoiceDraftMobileSubInfo3To6View()
  12072. {
  12073. ParentId = eecInfo.Id,
  12074. Choice = eecInfo.ChoiceThree,
  12075. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12076. Details = dayAndCostDatas
  12077. };
  12078. return Ok(JsonView(data));
  12079. }
  12080. else if (subType == 4) //4:伙食费
  12081. {
  12082. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12083. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12084. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12085. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  12086. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12087. {
  12088. ParentId = dac.ParentId,
  12089. SubId = dac.Id,
  12090. Type = dac.Type,
  12091. Days = dac.Days,
  12092. NationalTravelFeeId = dac.NationalTravelFeeId,
  12093. Arae = $"{ntf.Country}-{ntf.City}",
  12094. Cost = dac.Cost,
  12095. Currency = dac.Currency,
  12096. CurrencyName = sd.Name,
  12097. SubTotal = dac.SubTotal,
  12098. })
  12099. .ToArray();
  12100. var data = new ChoiceDraftMobileSubInfo3To6View()
  12101. {
  12102. ParentId = eecInfo.Id,
  12103. Choice = eecInfo.ChoiceFour,
  12104. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12105. Details = dayAndCostDatas
  12106. };
  12107. return Ok(JsonView(data));
  12108. }
  12109. else if (subType == 5) //5:公杂费
  12110. {
  12111. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12112. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12113. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12114. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  12115. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12116. {
  12117. ParentId = dac.ParentId,
  12118. SubId = dac.Id,
  12119. Type = dac.Type,
  12120. Days = dac.Days,
  12121. NationalTravelFeeId = dac.NationalTravelFeeId,
  12122. Arae = $"{ntf.Country}-{ntf.City}",
  12123. Cost = dac.Cost,
  12124. Currency = dac.Currency,
  12125. CurrencyName = sd.Name,
  12126. SubTotal = dac.SubTotal,
  12127. })
  12128. .ToArray();
  12129. var data = new ChoiceDraftMobileSubInfo3To6View()
  12130. {
  12131. ParentId = eecInfo.Id,
  12132. Choice = eecInfo.ChoiceFive,
  12133. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12134. Details = dayAndCostDatas
  12135. };
  12136. return Ok(JsonView(data));
  12137. }
  12138. else if (subType == 6) //6:培训费
  12139. {
  12140. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12141. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12142. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12143. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  12144. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12145. {
  12146. ParentId = dac.ParentId,
  12147. SubId = dac.Id,
  12148. Type = dac.Type,
  12149. Days = dac.Days,
  12150. NationalTravelFeeId = dac.NationalTravelFeeId,
  12151. Arae = $"{ntf.Country}-{ntf.City}",
  12152. Cost = dac.Cost,
  12153. Currency = dac.Currency,
  12154. CurrencyName = sd.Name,
  12155. SubTotal = dac.SubTotal,
  12156. })
  12157. .ToArray();
  12158. var data = new ChoiceDraftMobileSubInfo3To6View()
  12159. {
  12160. ParentId = eecInfo.Id,
  12161. Choice = eecInfo.ChoiceSix,
  12162. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12163. Details = dayAndCostDatas
  12164. };
  12165. return Ok(JsonView(data));
  12166. }
  12167. else if (subType == 7) //7:其他
  12168. {
  12169. //其他款项
  12170. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12171. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12172. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12173. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12174. .OrderBy((dop, sd1, sd2) => dop.Index)
  12175. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  12176. {
  12177. ParentId = dop.ParentId,
  12178. SubId = dop.Id,
  12179. Index = dop.Index,
  12180. SetDataId = dop.SetDataId,
  12181. SetDataName = sd1.Name,
  12182. Cost = dop.Cost,
  12183. Currency = dop.Currency,
  12184. CurrencyName = sd2.Name,
  12185. SubTotal = dop.SubTotal,
  12186. Remark = dop.Remark,
  12187. })
  12188. .ToArray();
  12189. var data = new ChoiceSevenDraftMobileSubInfoView()
  12190. {
  12191. ParentId = eecInfo.Id,
  12192. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  12193. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  12194. Details = otherData
  12195. };
  12196. return Ok(JsonView(data));
  12197. }
  12198. return Ok(JsonView(false));
  12199. }
  12200. #region op
  12201. ///// <summary>
  12202. ///// 移动端更新费用消息通知
  12203. ///// </summary>
  12204. ///// <param name="draftId"></param>
  12205. ///// <param name="id"></param>
  12206. ///// <param name="currUserId"></param>
  12207. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  12208. //{
  12209. // try
  12210. // {
  12211. // ////生成默认文件pdf并且通知人员
  12212. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  12213. // //{
  12214. // // DiId = draftId,
  12215. // // ExportType = 1,
  12216. // // SubTypeId = 1005
  12217. // //}, "pdf");
  12218. // ////发送通知
  12219. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  12220. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  12221. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  12222. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  12223. // ////汇率信息记录
  12224. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  12225. // }
  12226. // catch (Exception ex)
  12227. // {
  12228. // //记录日志
  12229. // throw;
  12230. // }
  12231. //}
  12232. /// <summary>
  12233. /// 验证出入境费用数据是否存在
  12234. /// 不存在添加
  12235. /// </summary>
  12236. /// <param name="draftId"></param>
  12237. /// <param name="currUserId"></param>
  12238. /// <returns></returns>
  12239. /// <exception cref="CustomException"></exception>
  12240. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  12241. {
  12242. var parentId = 0;
  12243. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  12244. if (info != null) parentId = info.Id;
  12245. else
  12246. {
  12247. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  12248. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  12249. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  12250. parentId = addId;
  12251. }
  12252. return parentId;
  12253. }
  12254. /// <summary>
  12255. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  12256. /// </summary>
  12257. /// <returns></returns>
  12258. [HttpPost]
  12259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12260. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  12261. {
  12262. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12263. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12264. //验证查看权限
  12265. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12266. if (!isView) return Ok(JsonView(false, _viewPermStr));
  12267. var userIds = await _sqlSugar
  12268. .Queryable<Grp_EnterExitCostDraftPermission>()
  12269. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  12270. .Select(x => x.UserId)
  12271. .ToArrayAsync();
  12272. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  12273. var perUsersView = new List<dynamic>();
  12274. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  12275. var viewPermissionData = new List<PermissionViewUserview>();
  12276. if (feeBasePerm.Any())
  12277. {
  12278. foreach (var item in feeBasePerm)
  12279. {
  12280. if (item.Users.Any())
  12281. {
  12282. viewPermissionData.AddRange(item.Users);
  12283. }
  12284. }
  12285. }
  12286. foreach (var item in perUsers)
  12287. {
  12288. bool isView1 = false;
  12289. if (userIds.Any(x => x == item.Id)) isView1 = true;
  12290. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  12291. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  12292. }
  12293. return Ok(JsonView(perUsersView));
  12294. }
  12295. /// <summary>
  12296. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  12297. /// </summary>
  12298. /// <returns></returns>
  12299. [HttpPost]
  12300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12301. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  12302. {
  12303. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12304. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12305. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  12306. //验证查看编辑权限
  12307. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12308. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12309. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  12310. foreach (var userId in dto.UserIds)
  12311. {
  12312. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  12313. }
  12314. if (permissions.Any())
  12315. {
  12316. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  12317. {
  12318. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  12319. }
  12320. _sqlSugar.BeginTran();
  12321. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  12322. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  12323. if (result < 1)
  12324. {
  12325. _sqlSugar.RollbackTran();
  12326. return Ok(JsonView(false));
  12327. }
  12328. _sqlSugar.CommitTran();
  12329. return Ok(JsonView(true));
  12330. }
  12331. return Ok(JsonView(false));
  12332. }
  12333. /// <summary>
  12334. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  12335. /// </summary>
  12336. /// <returns></returns>
  12337. [HttpPost]
  12338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12339. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  12340. {
  12341. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12342. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12343. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12344. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  12345. int id = dto.DraftId;
  12346. if (id <= 0) //add
  12347. {
  12348. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12349. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12350. if (add < 1) return Ok(JsonView(false));
  12351. id = add;
  12352. }
  12353. else //update
  12354. {
  12355. //验证查看编辑权限
  12356. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12357. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12358. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12359. if (upd < 1) return Ok(JsonView(false));
  12360. }
  12361. return Ok(JsonView(new { parentId = id }));
  12362. }
  12363. /// <summary>
  12364. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  12365. /// </summary>
  12366. /// <returns></returns>
  12367. [HttpPost]
  12368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12369. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  12370. {
  12371. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12372. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12373. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12374. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  12375. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  12376. int id = dto.DraftId;
  12377. if (id <= 0) //add
  12378. {
  12379. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12380. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12381. if (add < 1) return Ok(JsonView(false));
  12382. id = add;
  12383. }
  12384. else //update
  12385. {
  12386. //验证查看编辑权限
  12387. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12388. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12389. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12390. if (upd < 1) return Ok(JsonView(false));
  12391. }
  12392. #region 汇率变更时更改币种相关费用
  12393. var opDayCosts = new List<Grp_DayAndCostDraft>();
  12394. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  12395. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  12396. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12397. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  12398. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  12399. .Select((dac, sd) => new
  12400. {
  12401. dac.Id,
  12402. dac.ParentId,
  12403. CurrencyCode = sd.Name,
  12404. dac.Cost
  12405. })
  12406. .ToList();
  12407. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12408. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  12409. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12410. .Select((dop, sd) => new
  12411. {
  12412. dop.Id,
  12413. dop.ParentId,
  12414. CurrencyCode = sd.Name,
  12415. dop.Cost
  12416. })
  12417. .ToList();
  12418. if (dayCosts.Count > 0)
  12419. {
  12420. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12421. foreach (var dc in new_dayCosts)
  12422. {
  12423. var thisCurrency = dc.Key.ToUpper();
  12424. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12425. if (thisRate == 0.00M) continue;
  12426. foreach (var dcSub in dc)
  12427. {
  12428. opDayCosts.Add(new Grp_DayAndCostDraft()
  12429. {
  12430. Id = dcSub.Id,
  12431. ParentId = dcSub.ParentId,
  12432. Cost = dcSub.Cost,
  12433. SubTotal = dcSub.Cost * thisRate,
  12434. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  12435. });
  12436. }
  12437. }
  12438. if (opDayCosts.Count > 0)
  12439. {
  12440. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12441. }
  12442. }
  12443. if (dayOtherCosts.Count > 0)
  12444. {
  12445. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12446. foreach (var dc in new_dayOtherCosts)
  12447. {
  12448. var thisCurrency = dc.Key.ToUpper();
  12449. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12450. if (thisRate == 0.00M) continue;
  12451. foreach (var dcSub in dc)
  12452. {
  12453. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  12454. {
  12455. Id = dcSub.Id,
  12456. ParentId = dcSub.ParentId,
  12457. Cost = dcSub.Cost,
  12458. SubTotal = dcSub.Cost * thisRate,
  12459. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  12460. });
  12461. }
  12462. }
  12463. if (opDayOtherCosts.Count > 0)
  12464. {
  12465. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12466. }
  12467. }
  12468. #endregion
  12469. ////消息通知
  12470. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12471. ////汇率信息记录
  12472. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  12473. return Ok(JsonView(new { parentId = id }));
  12474. }
  12475. /// <summary>
  12476. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  12477. /// </summary>
  12478. /// <returns></returns>
  12479. [HttpPost]
  12480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12481. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  12482. {
  12483. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12484. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12485. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12486. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12487. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12488. int id = dto.DraftId;
  12489. if (id <= 0) //add
  12490. {
  12491. checkboxInfo.ProvinceId = dto.ProvinceId;
  12492. checkboxInfo.CreateUserId = dto.CurrUserId;
  12493. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  12494. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12495. if (add < 1) return Ok(JsonView(false));
  12496. }
  12497. else //update
  12498. {
  12499. var upd = await _sqlSugar.Updateable(checkboxInfo)
  12500. .UpdateColumns(x => new
  12501. {
  12502. x.ChoiceOne,
  12503. x.ChoiceTwo,
  12504. x.SumJJC,
  12505. x.SumGWC,
  12506. x.SumTDC,
  12507. x.ChoiceThree,
  12508. x.ChoiceFour,
  12509. x.ChoiceFive,
  12510. x.ChoiceSix,
  12511. x.OtherExpenses_Checked
  12512. })
  12513. .Where(x => x.Id == id)
  12514. .ExecuteCommandAsync();
  12515. if (upd < 1) return Ok(JsonView(false));
  12516. }
  12517. return Ok(JsonView(new { parentId = id }));
  12518. }
  12519. /// <summary>
  12520. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  12521. /// </summary>
  12522. /// <returns></returns>
  12523. [HttpPost]
  12524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12525. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  12526. {
  12527. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  12528. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  12529. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12530. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12531. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12532. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  12533. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12534. var checkboxInfo = new Grp_EnterExitCostDraft()
  12535. {
  12536. Id = draftId,
  12537. ProvinceId = dto.ProvinceId,
  12538. CreateUserId = currUserId
  12539. };
  12540. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  12541. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  12542. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  12543. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  12544. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  12545. if (draftId <= 0) //add
  12546. {
  12547. checkboxInfo.CreateUserId = dto.CurrUserId;
  12548. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12549. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12550. if (add < 1) return Ok(JsonView(false));
  12551. }
  12552. else //update
  12553. {
  12554. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  12555. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  12556. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  12557. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  12558. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  12559. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  12560. .Where(x => x.Id == draftId)
  12561. .ExecuteCommandAsync();
  12562. if (upd < 1) return Ok(JsonView(false));
  12563. }
  12564. return Ok(JsonView(new { parentId = draftId }));
  12565. }
  12566. /// <summary>
  12567. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  12568. /// </summary>
  12569. /// <returns></returns>
  12570. [HttpPost]
  12571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12572. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  12573. {
  12574. int id = dto.DraftId, currUserId = dto.CurrUserId;
  12575. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12576. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12577. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12578. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12579. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12580. info.ProvinceId = dto.ProvinceId;
  12581. info.FirstItemRemark = dto.FirstItemRemark;
  12582. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  12583. if (id <= 0) //add
  12584. {
  12585. info.CreateUserId = dto.CurrUserId;
  12586. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12587. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12588. if (add < 1) return Ok(JsonView(false));
  12589. id = add;
  12590. }
  12591. else //update
  12592. {
  12593. var upd = await _sqlSugar.Updateable(info)
  12594. .UpdateColumns(x => new
  12595. {
  12596. x.ChoiceOne,
  12597. x.InsidePay,
  12598. x.VisaRemark,
  12599. x.Visa,
  12600. x.Service,
  12601. x.Safe,
  12602. x.Ticket,
  12603. x.HeSuan,
  12604. x.YiMiao,
  12605. x.FirstItemRemark
  12606. })
  12607. .Where(x => x.Id == id)
  12608. .ExecuteCommandAsync();
  12609. if (upd < 1) return Ok(JsonView(false));
  12610. }
  12611. ////消息通知
  12612. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12613. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  12614. }
  12615. /// <summary>
  12616. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  12617. /// </summary>
  12618. /// <returns></returns>
  12619. [HttpPost]
  12620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12621. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  12622. {
  12623. int id = dto.DraftId;
  12624. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12625. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12626. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12627. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12628. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12629. info.ProvinceId = dto.ProvinceId;
  12630. info.OutsideJJPay = dto.OutsideJJPay;
  12631. info.OutsideGWPay = dto.OutsideGWPay;
  12632. info.OutsideTDPay = dto.OutsideTDPay;
  12633. info.AirJJ = dto.AirJJ;
  12634. info.AirGW = dto.AirGW;
  12635. info.AirTD = dto.AirTD;
  12636. info.CityTranffic = dto.CityTranffic;
  12637. info.TwoItemRemark = dto.TwoItemRemark;
  12638. info.SumJJC = dto.ChoiceTwoJJ;
  12639. info.SumGWC = dto.ChoiceTwoGW;
  12640. info.SumTDC = dto.ChoiceTwoTD;
  12641. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  12642. if (id <= 0) //add
  12643. {
  12644. info.CreateUserId = dto.CurrUserId;
  12645. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12646. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12647. if (addId <= 0) return Ok(JsonView(false));
  12648. id = addId;
  12649. }
  12650. else //update
  12651. {
  12652. var upd = await _sqlSugar.Updateable(info)
  12653. .UpdateColumns(x => new
  12654. {
  12655. x.SumJJC,
  12656. x.OutsideJJPay,
  12657. x.SumGWC,
  12658. x.OutsideGWPay,
  12659. x.SumTDC,
  12660. x.OutsideTDPay,
  12661. x.AirJJ,
  12662. x.AirGW,
  12663. x.AirTD,
  12664. x.CityTranffic,
  12665. x.TwoItemRemark
  12666. })
  12667. .Where(x => x.Id == id)
  12668. .ExecuteCommandAsync();
  12669. if (upd < 1) return Ok(JsonView(false));
  12670. }
  12671. jjcItemTotal = info.AirJJ + info.CityTranffic;
  12672. gwcItemTotal = info.AirGW + info.CityTranffic;
  12673. tdcItemTotal = info.AirTD + info.CityTranffic;
  12674. ////消息通知
  12675. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12676. return Ok(JsonView(new
  12677. {
  12678. parentId = id,
  12679. choiceTwoJJ = dto.ChoiceTwoJJ,
  12680. jjcItemTotal = jjcItemTotal,
  12681. choiceTwoGW = dto.ChoiceTwoGW,
  12682. gwcItemTotal = gwcItemTotal,
  12683. choiceTwoTD = dto.ChoiceTwoTD,
  12684. tdcItemTotal = tdcItemTotal
  12685. }));
  12686. }
  12687. /// <summary>
  12688. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  12689. /// </summary>
  12690. /// <returns></returns>
  12691. [HttpPost]
  12692. [ApiExplorerSettings(IgnoreApi = true)]
  12693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12694. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  12695. {
  12696. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12697. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12698. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12699. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  12700. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  12701. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12702. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  12703. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  12704. {
  12705. Id = x.Id,
  12706. ParentId = dto.DraftId,
  12707. Type = dto.FeeType,
  12708. Days = x.Days,
  12709. NationalTravelFeeId = x.NationalTravelFeeId,
  12710. Cost = x.Cost,
  12711. Currency = x.Currency,
  12712. SubTotal = x.SubTotal,
  12713. CreateUserId = dto.CurrUserId
  12714. })
  12715. .ToList();
  12716. var adds = infos.Where(x => x.Id <= 0).ToList();
  12717. var upds = infos.Where(x => x.Id > 0).ToList();
  12718. if (adds.Count > 0)
  12719. {
  12720. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12721. if (add < 1) return Ok(JsonView(false));
  12722. }
  12723. if (upds.Count > 0)
  12724. {
  12725. var upd = await _sqlSugar.Updateable(adds)
  12726. .UpdateColumns(x => new
  12727. {
  12728. x.Days,
  12729. x.NationalTravelFeeId,
  12730. x.Cost,
  12731. x.Currency,
  12732. x.SubTotal
  12733. })
  12734. .WhereColumns(x => new { x.Id })
  12735. .ExecuteCommandAsync();
  12736. if (upd < 1) return Ok(JsonView(false));
  12737. }
  12738. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  12739. ////消息通知
  12740. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  12741. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12742. return Ok(JsonView(new { itemTotal = itemTotal }));
  12743. }
  12744. /// <summary>
  12745. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  12746. /// </summary>
  12747. /// <returns></returns>
  12748. [HttpPost]
  12749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12750. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  12751. {
  12752. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  12753. int subId = dto.SubId, feeType = dto.FeeType;
  12754. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12755. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12756. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12757. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12758. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  12759. subInfo.Id = subId;
  12760. subInfo.ParentId = dto.DraftId;
  12761. if (feeType == 3) subInfo.Type = 1;
  12762. else if (feeType == 4) subInfo.Type = 2;
  12763. else if (feeType == 5) subInfo.Type = 3;
  12764. else if (feeType == 6) subInfo.Type = 4;
  12765. subInfo.CreateUserId = dto.CurrUserId;
  12766. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  12767. if (parentId < 1) return Ok(JsonView(false));
  12768. //子表op
  12769. if (subId < 1)
  12770. {
  12771. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12772. if (subAdd < 1) return Ok(JsonView(false));
  12773. }
  12774. else
  12775. {
  12776. var subUpd = await _sqlSugar.Updateable(subInfo)
  12777. .UpdateColumns(x => new
  12778. {
  12779. x.Days,
  12780. x.NationalTravelFeeId,
  12781. x.Cost,
  12782. x.Currency,
  12783. x.SubTotal
  12784. })
  12785. .WhereColumns(x => new { x.Id })
  12786. .ExecuteCommandAsync();
  12787. if (subUpd < 1) return Ok(JsonView(false));
  12788. }
  12789. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  12790. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12791. }
  12792. /// <summary>
  12793. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  12794. /// </summary>
  12795. /// <returns></returns>
  12796. [HttpPost]
  12797. [ApiExplorerSettings(IgnoreApi = true)]
  12798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12799. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12800. {
  12801. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12802. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12803. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12804. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12805. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12806. {
  12807. Id = x.Id,
  12808. ParentId = dto.DraftId,
  12809. SetDataId = x.SetDataId,
  12810. Index = x.Index,
  12811. Cost = x.Cost,
  12812. Currency = x.Currency,
  12813. SubTotal = x.SubTotal,
  12814. CreateUserId = dto.CurrUserId,
  12815. Remark = x.Remark
  12816. }).ToList();
  12817. var adds = infos.Where(x => x.Id <= 0).ToList();
  12818. var upds = infos.Where(x => x.Id > 0).ToList();
  12819. if (adds.Count > 0)
  12820. {
  12821. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12822. if (add < 1) return Ok(JsonView(false));
  12823. }
  12824. if (upds.Count > 0)
  12825. {
  12826. var upd = await _sqlSugar.Updateable(adds)
  12827. .UpdateColumns(x => new
  12828. {
  12829. x.Index,
  12830. x.SetDataId,
  12831. x.Cost,
  12832. x.Currency,
  12833. x.SubTotal,
  12834. x.Remark
  12835. })
  12836. .WhereColumns(x => new { x.Id })
  12837. .ExecuteCommandAsync();
  12838. if (upd < 1) return Ok(JsonView(false));
  12839. }
  12840. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12841. //消息通知
  12842. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12843. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12844. return Ok(JsonView(new { itemTotal = itemTotal }));
  12845. }
  12846. /// <summary>
  12847. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12848. /// </summary>
  12849. /// <returns></returns>
  12850. [HttpPost]
  12851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12852. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12853. {
  12854. int subId = dto.SubId, id = dto.DraftId;
  12855. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12856. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12857. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12858. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12859. subInfo.Id = subId;
  12860. subInfo.ParentId = id;
  12861. subInfo.CreateUserId = dto.CurrUserId;
  12862. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12863. if (parentId < 1) return Ok(JsonView(false));
  12864. #region 子表op
  12865. if (subId < 1)//add
  12866. {
  12867. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12868. if (subAdd < 1) return Ok(JsonView(false));
  12869. }
  12870. else //upd
  12871. {
  12872. var subUpd = await _sqlSugar.Updateable(subInfo)
  12873. .UpdateColumns(x => new
  12874. {
  12875. x.Index,
  12876. x.SetDataId,
  12877. x.Cost,
  12878. x.Currency,
  12879. x.SubTotal,
  12880. x.Remark
  12881. })
  12882. .WhereColumns(x => new { x.Id })
  12883. .ExecuteCommandAsync();
  12884. if (subUpd < 1) return Ok(JsonView(false));
  12885. }
  12886. #endregion
  12887. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12888. ////消息通知
  12889. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12890. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12891. }
  12892. /// <summary>
  12893. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12894. /// </summary>
  12895. /// <returns></returns>
  12896. [HttpPost]
  12897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12898. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12899. {
  12900. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12901. if (data.Code != 0)
  12902. {
  12903. return Ok(JsonView(false, data.Msg));
  12904. }
  12905. return Ok(JsonView(true, "操作成功!", data.Data));
  12906. }
  12907. /// <summary>
  12908. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  12909. /// </summary>
  12910. /// <param name="dto"></param>
  12911. /// <returns></returns>
  12912. [HttpPost]
  12913. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12914. {
  12915. var data = new Grp_DayOtherPriceDraft()
  12916. {
  12917. Id = dto.Id,
  12918. IsDel = 1,
  12919. DeleteUserId = dto.DeleteUserId,
  12920. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12921. };
  12922. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12923. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12924. return Ok(JsonView(false, "删除失败!"));
  12925. }
  12926. #endregion
  12927. #endregion
  12928. #region 团组经理模块 出入境费用报价表
  12929. /// <summary>
  12930. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12931. /// </summary>
  12932. /// <returns></returns>
  12933. [HttpPost]
  12934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12935. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12936. {
  12937. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12938. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12939. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12940. initRates.Insert(0, cnyInfo);
  12941. liveRates.Insert(0, cnyInfo);
  12942. return Ok(JsonView(true, "查询成功!", new
  12943. {
  12944. InitRates = initRates,
  12945. LiveRates = liveRates
  12946. }));
  12947. }
  12948. /// <summary>
  12949. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12950. /// </summary>
  12951. /// <returns></returns>
  12952. [HttpPost]
  12953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12954. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12955. {
  12956. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12957. }
  12958. /// <summary>
  12959. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12960. /// </summary>
  12961. /// <returns></returns>
  12962. [HttpPost]
  12963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12964. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12965. {
  12966. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12967. }
  12968. /// <summary>
  12969. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12970. /// </summary>
  12971. /// <returns></returns>
  12972. [HttpPost]
  12973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12974. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12975. {
  12976. int groupId = dto.DiId,
  12977. currUserId = dto.CurrUserId;
  12978. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12979. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12980. //验证报价数据是否存在
  12981. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12982. if (isNull != null)
  12983. {
  12984. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12985. if (!info1.Rates.Any())
  12986. {
  12987. var rates = await GeneralMethod.EnterExitCostInitRate();
  12988. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12989. info1.Rates = rates.ToArray();
  12990. }
  12991. return Ok(JsonView(info1));
  12992. }
  12993. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12994. result.GroupId = groupId;
  12995. //处理报价名称
  12996. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12997. if (groupInfo != null)
  12998. {
  12999. var visitCountry = groupInfo.VisitCountry;
  13000. if (!string.IsNullOrEmpty(visitCountry))
  13001. {
  13002. string quoteName = string.Empty;
  13003. if (visitCountry.Contains("|"))
  13004. {
  13005. var countrys = visitCountry.Split("|");
  13006. quoteName = string.Join("、", countrys);
  13007. }
  13008. else quoteName = visitCountry;
  13009. quoteName += $"团组报价表";
  13010. result.Name = quoteName;
  13011. }
  13012. }
  13013. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  13014. if (info.Code != StatusCodes.Status200OK)
  13015. {
  13016. if (!result.Rates.Any())
  13017. {
  13018. var rates = await GeneralMethod.EnterExitCostInitRate();
  13019. result.Rates = rates.ToArray();
  13020. }
  13021. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  13022. }
  13023. var infoView = info.Data as EnterExitCostInfoView;
  13024. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  13025. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  13026. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  13027. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  13028. var eecRates = infoView.Currencys;
  13029. //默认添加人名币
  13030. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  13031. {
  13032. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13033. }
  13034. //处理团组人数
  13035. int pplNum = 1;
  13036. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  13037. var views = new List<QuoteSubItemInfo>();
  13038. #region 数据填充
  13039. var intTravelCosts = new List<QuoteSubItemInfo>();
  13040. #region 机票费用 1354
  13041. int intTravelIndex = 1;
  13042. if (infoView.SumJJC == 1)
  13043. {
  13044. intTravelCosts.Add(new QuoteSubItemInfo
  13045. {
  13046. ItemId = 1354,
  13047. Index = intTravelIndex,
  13048. FeeName = "经济舱",
  13049. UnitPrice = infoView.AirJJ,
  13050. Currency = "CNY",
  13051. Quantity = 1,
  13052. PplNum = 1,
  13053. TotalAmt = infoView.AirJJ,
  13054. Remark = "",
  13055. });
  13056. intTravelIndex++;
  13057. }
  13058. if (infoView.SumGWC == 1)
  13059. {
  13060. intTravelCosts.Add(new QuoteSubItemInfo
  13061. {
  13062. ItemId = 1354,
  13063. Index = intTravelIndex,
  13064. FeeName = "公务舱",
  13065. UnitPrice = infoView.AirGW,
  13066. Currency = "CNY",
  13067. Quantity = 1,
  13068. PplNum = 1,
  13069. TotalAmt = infoView.AirGW,
  13070. Remark = "",
  13071. });
  13072. intTravelIndex++;
  13073. }
  13074. if (infoView.SumTDC == 1)
  13075. {
  13076. intTravelCosts.Add(new QuoteSubItemInfo
  13077. {
  13078. ItemId = 1354,
  13079. Index = intTravelIndex,
  13080. FeeName = "头等舱",
  13081. UnitPrice = infoView.AirTD,
  13082. Currency = "CNY",
  13083. Quantity = 1,
  13084. PplNum = 1,
  13085. TotalAmt = infoView.AirTD,
  13086. Remark = "",
  13087. });
  13088. intTravelIndex++;
  13089. }
  13090. intTravelCosts.Add(new QuoteSubItemInfo
  13091. {
  13092. ItemId = 1354,
  13093. Index = intTravelIndex,
  13094. FeeName = "城市间交通费用",
  13095. UnitPrice = infoView.CityTranffic,
  13096. Currency = "CNY",
  13097. Quantity = 1,
  13098. PplNum = pplNum,
  13099. TotalAmt = infoView.CityTranffic * pplNum,
  13100. Remark = "",
  13101. });
  13102. views.AddRange(intTravelCosts);
  13103. #endregion
  13104. var accomCosts = new List<QuoteSubItemInfo>();
  13105. #region 住宿费 1355
  13106. if (infoView.QuarterageData.Any())
  13107. {
  13108. int accomIndex = 1;
  13109. int accomItemTypeId = 1355;
  13110. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  13111. foreach (var item in groupData)
  13112. {
  13113. string feeName = string.Empty;
  13114. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13115. if (countryInfo != null)
  13116. {
  13117. feeName = countryInfo.Country;
  13118. var city = countryInfo.City;
  13119. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13120. {
  13121. feeName += $"-{city}";
  13122. }
  13123. }
  13124. var hotelInfo = item.FirstOrDefault();
  13125. if (hotelInfo == null) continue;
  13126. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  13127. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13128. int quantity = item.ToList().Count;
  13129. accomCosts.Add(new QuoteSubItemInfo
  13130. {
  13131. ItemId = accomItemTypeId,
  13132. Index = accomIndex,
  13133. FeeName = feeName,
  13134. UnitPrice = hotelInfo.Cost,
  13135. Currency = thisCurrency,
  13136. Quantity = quantity,
  13137. PplNum = pplNum,
  13138. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  13139. Remark = "",
  13140. });
  13141. accomIndex++;
  13142. }
  13143. views.AddRange(accomCosts);
  13144. }
  13145. #endregion
  13146. var mealCosts = new List<QuoteSubItemInfo>();
  13147. #region 餐饮费 1356
  13148. if (infoView.BoardWagesData.Any())
  13149. {
  13150. var mealIndex = 1;
  13151. int mealItemTypeId = 1356;
  13152. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  13153. foreach (var item in groupData)
  13154. {
  13155. string feeName = string.Empty;
  13156. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13157. if (countryInfo != null)
  13158. {
  13159. feeName = countryInfo.Country;
  13160. var city = countryInfo.City;
  13161. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13162. {
  13163. feeName += $"-{city}";
  13164. }
  13165. }
  13166. var mealInfo = item.FirstOrDefault();
  13167. if (mealInfo == null) continue;
  13168. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  13169. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13170. int quantity = item.ToList().Count;
  13171. mealCosts.Add(new QuoteSubItemInfo
  13172. {
  13173. ItemId = mealItemTypeId,
  13174. Index = mealIndex,
  13175. FeeName = feeName,
  13176. UnitPrice = mealInfo.Cost,
  13177. Currency = thisCurrency,
  13178. Quantity = quantity,
  13179. PplNum = pplNum,
  13180. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  13181. Remark = "",
  13182. });
  13183. mealIndex++;
  13184. }
  13185. views.AddRange(mealCosts);
  13186. }
  13187. #endregion
  13188. var miscCosts = new List<QuoteSubItemInfo>();
  13189. #region 公杂费 1364
  13190. if (infoView.MiscellaneousFeeData.Any())
  13191. {
  13192. var miscIndex = 1;
  13193. int miscItemTypeId = 1364;
  13194. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  13195. foreach (var item in groupData)
  13196. {
  13197. string feeName = string.Empty;
  13198. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13199. if (countryInfo != null)
  13200. {
  13201. feeName = countryInfo.Country;
  13202. var city = countryInfo.City;
  13203. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13204. {
  13205. feeName += $"-{city}";
  13206. }
  13207. }
  13208. var miscInfo = item.FirstOrDefault();
  13209. if (miscInfo == null) continue;
  13210. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  13211. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13212. int quantity = item.ToList().Count;
  13213. miscCosts.Add(new QuoteSubItemInfo
  13214. {
  13215. ItemId = miscItemTypeId,
  13216. Index = miscIndex,
  13217. FeeName = feeName,
  13218. UnitPrice = miscInfo.Cost,
  13219. Currency = thisCurrency,
  13220. Quantity = quantity,
  13221. PplNum = pplNum,
  13222. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  13223. Remark = "",
  13224. });
  13225. miscIndex++;
  13226. }
  13227. views.AddRange(miscCosts);
  13228. }
  13229. #endregion
  13230. #region 签证+保险 1362
  13231. int visaInsIndex = 1;
  13232. int visaInsItemTypeId = 1362;
  13233. if (infoView.Visa > 0)
  13234. {
  13235. views.Add(new QuoteSubItemInfo()
  13236. {
  13237. ItemId = visaInsItemTypeId,
  13238. Index = visaInsIndex,
  13239. FeeName = $"签证",
  13240. UnitPrice = infoView.Visa,
  13241. Currency = $"CNY",
  13242. Quantity = 1,
  13243. PplNum = pplNum,
  13244. TotalAmt = infoView.Visa * pplNum,
  13245. Remark = "",
  13246. });
  13247. visaInsIndex++;
  13248. }
  13249. if (infoView.Safe > 0)
  13250. {
  13251. views.Add(new QuoteSubItemInfo()
  13252. {
  13253. ItemId = visaInsItemTypeId,
  13254. Index = visaInsIndex,
  13255. FeeName = $"保险",
  13256. UnitPrice = infoView.Safe,
  13257. Currency = $"CNY",
  13258. Quantity = 1,
  13259. PplNum = pplNum,
  13260. TotalAmt = infoView.Safe * pplNum,
  13261. Remark = "",
  13262. });
  13263. }
  13264. #endregion
  13265. #region 服务费 1363
  13266. int serviceFeeIndex = 1;
  13267. int serviceFeeItemTypeId = 1363;
  13268. if (infoView.Service > 0)
  13269. {
  13270. views.Add(new QuoteSubItemInfo()
  13271. {
  13272. ItemId = serviceFeeItemTypeId,
  13273. Index = serviceFeeIndex,
  13274. FeeName = $"服务费",
  13275. UnitPrice = infoView.Service,
  13276. Currency = $"CNY",
  13277. Quantity = 1,
  13278. PplNum = pplNum,
  13279. TotalAmt = infoView.Service * pplNum,
  13280. Remark = "",
  13281. });
  13282. }
  13283. #endregion
  13284. #endregion
  13285. if (result.FeeItems.Any())
  13286. {
  13287. result.FeeItems.Select(x =>
  13288. {
  13289. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  13290. if (feeInfos.Any()) x.Infos = feeInfos;
  13291. return x;
  13292. }
  13293. ).OrderBy(x => x.Index)
  13294. .ToList();
  13295. if (!result.Rates.Any())
  13296. {
  13297. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  13298. else
  13299. {
  13300. var rates = await GeneralMethod.EnterExitCostInitRate();
  13301. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13302. result.Rates = rates.ToArray();
  13303. }
  13304. }
  13305. }
  13306. return Ok(JsonView(result));
  13307. }
  13308. /// <summary>
  13309. /// 团组模块 - 出入境费用报价表 - Info
  13310. /// </summary>
  13311. /// <returns></returns>
  13312. [HttpPost]
  13313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13314. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  13315. {
  13316. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  13317. if (!info.Rates.Any())
  13318. {
  13319. var rates = await GeneralMethod.EnterExitCostInitRate();
  13320. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13321. info.Rates = rates.ToArray();
  13322. }
  13323. return Ok(JsonView(info));
  13324. }
  13325. /// <summary>
  13326. /// 团组模块 - 出入境费用报价表 - OP
  13327. /// </summary>
  13328. /// <returns></returns>
  13329. [HttpPost]
  13330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13331. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  13332. {
  13333. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  13334. }
  13335. /// <summary>
  13336. /// 团组模块 - 出入境费用报价表 - 删除 项
  13337. /// </summary>
  13338. /// <returns></returns>
  13339. [HttpPost]
  13340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13341. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  13342. {
  13343. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13344. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13345. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  13346. }
  13347. /// <summary>
  13348. /// 团组模块 - 出入境费用报价表 - 导出
  13349. /// </summary>
  13350. /// <returns></returns>
  13351. [HttpPost]
  13352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13353. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  13354. {
  13355. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13356. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13357. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  13358. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  13359. var rates = info.Rates;
  13360. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  13361. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  13362. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  13363. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  13364. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  13365. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  13366. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  13367. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  13368. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  13369. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  13370. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  13371. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  13372. //获取模板
  13373. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  13374. var designer = new WorkbookDesigner();
  13375. designer.Workbook = new Workbook(tempPath);
  13376. designer.SetDataSource("QuoteName", info.Name);
  13377. designer.SetDataSource("CompanyTitle", "公司名称");
  13378. designer.SetDataSource("CompanyLabel", "");
  13379. #region 国际旅费
  13380. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  13381. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  13382. {
  13383. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  13384. var label = new StringBuilder();
  13385. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  13386. if (infos.Any())
  13387. {
  13388. label.Append(infos.Sum(x => x.PplNum));
  13389. label.Append("人全程机票:");
  13390. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  13391. label.AppendLine("元");
  13392. }
  13393. foreach (var item in intTravelCosts.Infos)
  13394. {
  13395. label.Append(item.FeeName);
  13396. label.Append(":");
  13397. label.Append(item.UnitPrice.TruncDecimals(2));
  13398. label.Append("元/人*");
  13399. label.Append(item.PplNum);
  13400. label.AppendLine("人");
  13401. }
  13402. if (label.HasValue())
  13403. {
  13404. label.Append("\r\n以上小计:");
  13405. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  13406. label.Append("元");
  13407. }
  13408. designer.SetDataSource("IntTravelLabel", label.ToString());
  13409. }
  13410. #endregion
  13411. #region 住宿费
  13412. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  13413. if (accomCosts != null && accomCosts.Infos.Any())
  13414. {
  13415. string currencyName = string.Empty,
  13416. countryName = string.Empty;
  13417. decimal rate = 1.0000M;
  13418. var label = new StringBuilder();
  13419. label.AppendLine("全程五星酒店,每人1间房");
  13420. foreach (var item in accomCosts.Infos)
  13421. {
  13422. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  13423. string name = string.Empty, thisCountryName = string.Empty;
  13424. if (item.FeeName.Contains('-'))
  13425. {
  13426. var feeName = item.FeeName.Split('-');
  13427. thisCountryName = feeName[0];
  13428. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13429. name = feeName[1];
  13430. }
  13431. else name = item.FeeName;
  13432. string thisFeeName = string.Empty;
  13433. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13434. else thisFeeName = $"\r\n{name}:";
  13435. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13436. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13437. rate = rateInfo?.Rate ?? 1.0000M;
  13438. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  13439. label.AppendLine(subLabel);
  13440. }
  13441. if (label.HasValue())
  13442. {
  13443. //以上小计:52440元(美金汇率:7.5 )
  13444. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  13445. label.AppendLine(subLabel);
  13446. }
  13447. designer.SetDataSource("AccomLabel", label.ToString());
  13448. }
  13449. #endregion
  13450. #region 餐饮费
  13451. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  13452. if (mealCosts != null && mealCosts.Infos.Any())
  13453. {
  13454. string currencyName = string.Empty;
  13455. decimal rate = 1.0000M;
  13456. var label = new StringBuilder();
  13457. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  13458. foreach (var item in mealCosts.Infos)
  13459. {
  13460. string name = string.Empty;
  13461. if (item.FeeName.Contains('-'))
  13462. {
  13463. var feeName = item.FeeName.Split('-');
  13464. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  13465. }
  13466. else name = $"\r\n{item.FeeName}:";
  13467. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13468. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13469. rate = rateInfo?.Rate ?? 1.0000M;
  13470. label.Append(name);
  13471. label.Append(item.UnitPrice.TruncDecimals(2));
  13472. label.Append(currencyName);
  13473. label.Append("/天*");
  13474. label.Append(item.Quantity.ToString("#0"));
  13475. label.Append('*');
  13476. label.Append(item.PplNum);
  13477. label.Append("人\r\n");
  13478. }
  13479. if (label.HasValue())
  13480. {
  13481. label.Append("\r\n以上小计:");
  13482. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  13483. label.Append("元\r\n(");
  13484. label.Append("汇率:");
  13485. label.Append(rate.TruncDecimals(4));
  13486. label.Append(')');
  13487. }
  13488. designer.SetDataSource("MealLabel", label.ToString());
  13489. }
  13490. #endregion
  13491. #region 车辆安排
  13492. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  13493. if (vehArranges != null && vehArranges.Infos.Any())
  13494. {
  13495. string currencyName = string.Empty;
  13496. //decimal rate = 1.0000M;
  13497. var label = new StringBuilder();
  13498. foreach (var item in vehArranges.Infos)
  13499. {
  13500. label.AppendLine();
  13501. label.AppendLine();
  13502. label.Append(item.FeeName);
  13503. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  13504. }
  13505. designer.SetDataSource("VehArrangeLabel", label.ToString());
  13506. }
  13507. #endregion
  13508. #region 邀请函发放对象
  13509. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  13510. designer.SetDataSource("InviteToContent", "");
  13511. #endregion
  13512. #region 邀请函费
  13513. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  13514. var is_label = new StringBuilder();
  13515. if (inviteCosts != null && inviteCosts.Infos.Any())
  13516. {
  13517. string currencyName = string.Empty;
  13518. decimal rate = 1.0000M;
  13519. foreach (var item in inviteCosts.Infos)
  13520. {
  13521. //乌兹别克斯坦:2000美金
  13522. currencyName = item.Currency;
  13523. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13524. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  13525. is_label.AppendLine(label);
  13526. }
  13527. if (is_label.HasValue())
  13528. {
  13529. //以上小计:28500元(美金汇率:7.5)
  13530. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  13531. is_label.AppendLine(label);
  13532. }
  13533. }
  13534. designer.SetDataSource("InviteCostContent", is_label.ToString());
  13535. #endregion
  13536. #region 邀请函发放时间
  13537. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  13538. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  13539. #endregion
  13540. #region 公务活动(含翻译)
  13541. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  13542. var oa_label = new StringBuilder();
  13543. if (officialActs != null && officialActs.Infos.Any())
  13544. {
  13545. string currencyName = string.Empty;
  13546. decimal rate = 1.0000M;
  13547. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  13548. foreach (var item in officialActs.Infos)
  13549. {
  13550. //乌兹别克斯坦:1000美金/场
  13551. currencyName = item.Currency;
  13552. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13553. string label_remark = string.Empty;
  13554. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  13555. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  13556. }
  13557. label_content += "*总费用中未含超出公务活动价格";
  13558. //8场公务活动(以上小计:60000元)
  13559. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  13560. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  13561. oa_label.AppendLine(label_title);
  13562. oa_label.AppendLine(label_content);
  13563. }
  13564. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  13565. #endregion
  13566. #region 签证+保险
  13567. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  13568. var vi_label = new StringBuilder();
  13569. if (visaIns != null && visaIns.Infos.Any())
  13570. {
  13571. foreach (var item in visaIns.Infos)
  13572. {
  13573. //签证:500元/人
  13574. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  13575. vi_label.AppendLine(label);
  13576. }
  13577. if (vi_label.HasValue())
  13578. {
  13579. //以上小计:6000元
  13580. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  13581. vi_label.AppendLine(label);
  13582. }
  13583. }
  13584. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  13585. #endregion
  13586. #region 服务费
  13587. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  13588. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13589. #endregion
  13590. #region 公杂费
  13591. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  13592. var pm_label = new StringBuilder();
  13593. if (pubMiscs != null && pubMiscs.Infos.Any())
  13594. {
  13595. string currencyName = string.Empty,
  13596. countryName = string.Empty;
  13597. decimal rate = 1.0000M;
  13598. foreach (var item in pubMiscs.Infos)
  13599. {
  13600. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  13601. string name = string.Empty, thisCountryName = string.Empty;
  13602. if (item.FeeName.Contains('-'))
  13603. {
  13604. var feeName = item.FeeName.Split('-');
  13605. thisCountryName = feeName[0];
  13606. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13607. name = feeName[1];
  13608. }
  13609. else name = item.FeeName;
  13610. string thisFeeName = string.Empty;
  13611. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13612. else thisFeeName = $"\r\n{name}:";
  13613. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13614. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13615. rate = rateInfo?.Rate ?? 1.0000M;
  13616. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  13617. pm_label.AppendLine(label);
  13618. }
  13619. if (pm_label.HasValue())
  13620. {
  13621. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  13622. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  13623. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  13624. pm_label.AppendLine(string.Format("部分发放成员"));
  13625. }
  13626. }
  13627. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  13628. #endregion
  13629. #region 税费
  13630. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  13631. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13632. #endregion
  13633. #region 合计(单位:元)
  13634. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  13635. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  13636. #endregion
  13637. #region 汇率 Remark
  13638. var rate_label = new StringBuilder();
  13639. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  13640. foreach (var item in rateGroups)
  13641. {
  13642. //美元汇率按\r\n1:7.5
  13643. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  13644. rate_label.AppendLine(label);
  13645. }
  13646. designer.SetDataSource("RateLabel", rate_label.ToString());
  13647. #endregion
  13648. designer.Process();
  13649. //文件名
  13650. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  13651. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  13652. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  13653. return Ok(JsonView(true, "成功", url));
  13654. }
  13655. #endregion
  13656. #region 签证费用录入
  13657. /// <summary>
  13658. /// 根据diid查询签证费用列表
  13659. /// </summary>
  13660. /// <param name="dto"></param>
  13661. /// <returns></returns>
  13662. [HttpPost]
  13663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13664. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  13665. {
  13666. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  13667. if (groupData.Code != 0)
  13668. {
  13669. return Ok(JsonView(false, groupData.Msg));
  13670. }
  13671. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13672. }
  13673. /// <summary>
  13674. /// 根据签证费用Id查询单条数据及c表数据
  13675. /// </summary>
  13676. /// <param name="dto"></param>
  13677. /// <returns></returns>
  13678. [HttpPost]
  13679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13680. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  13681. {
  13682. Result groupData = await _visaPriceRep.PostVisaById(dto);
  13683. if (groupData.Code != 0)
  13684. {
  13685. return Ok(JsonView(false, groupData.Msg));
  13686. }
  13687. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13688. }
  13689. /// <summary>
  13690. /// 签证费用删除
  13691. /// </summary>
  13692. /// <param name="dto"></param>
  13693. /// <returns></returns>
  13694. [HttpPost]
  13695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13696. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  13697. {
  13698. _sqlSugar.BeginTran();
  13699. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  13700. if (!res)
  13701. {
  13702. _sqlSugar.RollbackTran();
  13703. return Ok(JsonView(false, "删除失败"));
  13704. }
  13705. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13706. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  13707. .SetColumns(a => new Grp_CreditCardPayment()
  13708. {
  13709. IsDel = 1,
  13710. DeleteUserId = dto.DeleteUserId,
  13711. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13712. })
  13713. .ExecuteCommand();
  13714. if (resSub < 1)
  13715. {
  13716. _sqlSugar.RollbackTran();
  13717. return Ok(JsonView(false, "删除失败"));
  13718. }
  13719. _sqlSugar.CommitTran();
  13720. return Ok(JsonView(true, "删除成功!"));
  13721. }
  13722. /// <summary>
  13723. /// 签证费用录入下拉框初始化
  13724. /// </summary>
  13725. /// <returns></returns>
  13726. [HttpPost]
  13727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13728. public async Task<IActionResult> VisaPriceAddSelect()
  13729. {
  13730. //支付方式
  13731. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  13732. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  13733. //币种
  13734. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  13735. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  13736. //乘客类型
  13737. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  13738. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  13739. //卡类型
  13740. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  13741. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  13742. //代办费类型
  13743. var agencyFeeTypeData = new List<dynamic>() {
  13744. new { id = 0 , Text = "未选择" },
  13745. new { id = 1 , Text = "小公务" },
  13746. new { id = 2 , Text = "大公务" },
  13747. };
  13748. //签证费用标准国家Data
  13749. var visaSql = string.Format(@"select
  13750. id,
  13751. case
  13752. when FeeType = 0 then Country+'(因公)'
  13753. when FeeType = 1 then Country+'(因私)'
  13754. else Country+'(未设置)'
  13755. end as 'country'
  13756. from Res_VisaFeeStandard where isdel = 0");
  13757. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  13758. var data = new
  13759. {
  13760. Payment = _Payment,
  13761. CurrencyList = _CurrencyList,
  13762. PassengerType = _PassengerType,
  13763. BankCard = _BankCard,
  13764. AgencyFeeType = agencyFeeTypeData,
  13765. CountryFeeData = visaCountryFeeData
  13766. };
  13767. return Ok(JsonView(true, "查询成功!", data));
  13768. }
  13769. /// <summary>
  13770. /// 签证费用录入操作(Status:1.新增,2.修改)
  13771. /// </summary>
  13772. /// <param name="dto"></param>
  13773. /// <returns></returns>
  13774. [HttpPost]
  13775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13776. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  13777. {
  13778. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  13779. if (groupData.Code != 0)
  13780. {
  13781. return Ok(JsonView(false, groupData.Msg));
  13782. }
  13783. #region 应用推送
  13784. try
  13785. {
  13786. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13787. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13788. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13789. //2024-10-21 新增LZ UID
  13790. var userIds = new List<int>() { 21 };
  13791. string title = $"系统通知";
  13792. string content = "";
  13793. var diId = dto.DiId;
  13794. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13795. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13796. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13797. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13798. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13799. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  13800. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13801. }
  13802. catch (Exception ex)
  13803. {
  13804. }
  13805. #endregion
  13806. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13807. }
  13808. #endregion
  13809. #region 签证提成录入
  13810. /// <summary>
  13811. /// 签证提成录入
  13812. /// 基础数据
  13813. /// </summary>
  13814. /// <returns></returns>
  13815. [HttpGet]
  13816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13817. public async Task<IActionResult> VisaCommissionInit()
  13818. {
  13819. return Ok(await _visaCommissionRep.Init());
  13820. }
  13821. /// <summary>
  13822. /// 签证提成录入
  13823. /// Item
  13824. /// </summary>
  13825. /// <param name="_dto"></param>
  13826. /// <returns></returns>
  13827. [HttpPost]
  13828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13829. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13830. {
  13831. var validator = new VisaCommissionItemDtoValidator();
  13832. var validatorRes = await validator.ValidateAsync(_dto);
  13833. if (!validatorRes.IsValid)
  13834. {
  13835. var sb = new StringBuilder();
  13836. foreach (var item in validatorRes.Errors)
  13837. {
  13838. sb.AppendLine(item.ErrorMessage);
  13839. }
  13840. return Ok(JsonView(false, sb.ToString()));
  13841. }
  13842. return Ok(await _visaCommissionRep.Item(_dto));
  13843. }
  13844. /// <summary>
  13845. /// 签证提成录入
  13846. /// Save
  13847. /// </summary>
  13848. /// <param name="_dto"></param>
  13849. /// <returns></returns>
  13850. [HttpPost]
  13851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13852. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13853. {
  13854. //参数验证
  13855. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13856. foreach (var item in _dto.Items)
  13857. {
  13858. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13859. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13860. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13861. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13862. }
  13863. return Ok(await _visaCommissionRep.Save(_dto));
  13864. }
  13865. /// <summary>
  13866. /// 签证提成录入
  13867. /// Create
  13868. /// </summary>
  13869. /// <param name="_dto"></param>
  13870. /// <returns></returns>
  13871. [HttpPost]
  13872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13873. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13874. {
  13875. var validator = new VisaCommissionCreateDtoValidator();
  13876. var validatorRes = await validator.ValidateAsync(_dto);
  13877. if (!validatorRes.IsValid)
  13878. {
  13879. var sb = new StringBuilder();
  13880. foreach (var item in validatorRes.Errors)
  13881. {
  13882. sb.AppendLine(item.ErrorMessage);
  13883. }
  13884. return Ok(JsonView(false, sb.ToString()));
  13885. }
  13886. return Ok(await _visaCommissionRep.Create(_dto));
  13887. }
  13888. /// <summary>
  13889. /// 签证提成录入
  13890. /// Put(编辑)
  13891. /// </summary>
  13892. /// <param name="id"></param>
  13893. /// <param name="_dto"></param>
  13894. /// <returns></returns>
  13895. [HttpPut]
  13896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13897. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13898. {
  13899. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13900. var validator = new VisaCommissionCreateDtoValidator();
  13901. var validatorRes = await validator.ValidateAsync(_dto);
  13902. if (!validatorRes.IsValid)
  13903. {
  13904. var sb = new StringBuilder();
  13905. foreach (var item in validatorRes.Errors)
  13906. {
  13907. sb.AppendLine(item.ErrorMessage);
  13908. }
  13909. return Ok(JsonView(false, sb.ToString()));
  13910. }
  13911. return Ok(await _visaCommissionRep.Edit(id, _dto));
  13912. }
  13913. /// <summary>
  13914. /// 签证提成录入
  13915. /// Del
  13916. /// </summary>
  13917. /// <param name="id"></param>
  13918. /// <param name="currUserId"></param>
  13919. /// <returns></returns>
  13920. [HttpPost]
  13921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13922. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13923. {
  13924. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13925. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13926. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13927. }
  13928. #endregion
  13929. #region op费用录入
  13930. /// <summary>
  13931. /// 根据diid查询op费用列表
  13932. /// </summary>
  13933. /// <param name="dto"></param>
  13934. /// <returns></returns>
  13935. [HttpPost]
  13936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13937. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13938. {
  13939. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13940. if (groupData.Code != 0)
  13941. {
  13942. return Ok(JsonView(false, groupData.Msg));
  13943. }
  13944. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13945. }
  13946. /// <summary>
  13947. /// 根据op费用Id查询单条数据及c表数据
  13948. /// </summary>
  13949. /// <param name="dto"></param>
  13950. /// <returns></returns>
  13951. [HttpPost]
  13952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13953. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13954. {
  13955. try
  13956. {
  13957. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13958. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13959. var data = new
  13960. {
  13961. CarTouristGuideGround = _groupData,
  13962. CreditCardPayment = _creditCardPayment
  13963. };
  13964. return Ok(JsonView(true, "查询成功!", data));
  13965. }
  13966. catch (Exception ex)
  13967. {
  13968. return Ok(JsonView(false, "程序错误!"));
  13969. }
  13970. }
  13971. /// <summary>
  13972. /// op费用删除
  13973. /// </summary>
  13974. /// <param name="dto"></param>
  13975. /// <returns></returns>
  13976. [HttpPost]
  13977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13978. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13979. {
  13980. try
  13981. {
  13982. _sqlSugar.BeginTran();
  13983. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13984. if (!res)
  13985. {
  13986. return Ok(JsonView(false, "删除失败"));
  13987. }
  13988. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13989. {
  13990. IsDel = 1,
  13991. DeleteUserId = dto.DeleteUserId,
  13992. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13993. }).ExecuteCommandAsync();
  13994. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13995. {
  13996. IsDel = 1,
  13997. DeleteUserId = dto.DeleteUserId,
  13998. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13999. }).ExecuteCommandAsync();
  14000. #region 删除超支相关数据
  14001. //删除导入的超支数据
  14002. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  14003. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  14004. {
  14005. IsDel = 1,
  14006. DeleteUserId = dto.DeleteUserId,
  14007. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14008. }).ExecuteCommand();
  14009. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  14010. {
  14011. IsDel = 1,
  14012. DeleteUserId = dto.DeleteUserId,
  14013. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14014. }).ExecuteCommand();
  14015. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  14016. {
  14017. IsDel = 1,
  14018. DeleteUserId = dto.DeleteUserId,
  14019. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14020. }).ExecuteCommand();
  14021. #endregion
  14022. _sqlSugar.CommitTran();
  14023. return Ok(JsonView(true, "删除成功!"));
  14024. }
  14025. catch (Exception ex)
  14026. {
  14027. _sqlSugar.RollbackTran();
  14028. return Ok(JsonView(false, "程序错误!" + ex.Message));
  14029. }
  14030. }
  14031. /// <summary>
  14032. /// op费用录入操作(Status:1.新增,2.修改)
  14033. /// </summary>
  14034. /// <param name="dto"></param>
  14035. /// <returns></returns>
  14036. [HttpPost]
  14037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14038. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  14039. {
  14040. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  14041. if (groupData.Code != 0)
  14042. {
  14043. return Ok(JsonView(false, groupData.Msg));
  14044. }
  14045. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14046. }
  14047. /// <summary>
  14048. /// 填写费用详细页面初始化绑定
  14049. /// </summary>
  14050. /// <param name="dto"></param>
  14051. /// <returns></returns>
  14052. [HttpPost]
  14053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14054. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  14055. {
  14056. try
  14057. {
  14058. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  14059. if (groupData.Code != 0)
  14060. {
  14061. return Ok(JsonView(false, groupData.Msg));
  14062. }
  14063. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14064. }
  14065. catch (Exception ex)
  14066. {
  14067. return Ok(JsonView(false, ex.Message));
  14068. }
  14069. }
  14070. /// <summary>
  14071. /// 根据op费用Id查询详细数据
  14072. /// </summary>
  14073. /// <param name="dto"></param>
  14074. /// <returns></returns>
  14075. [HttpPost]
  14076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14077. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  14078. {
  14079. try
  14080. {
  14081. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  14082. if (groupData.Code != 0)
  14083. {
  14084. return Ok(JsonView(false, groupData.Msg));
  14085. }
  14086. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14087. }
  14088. catch (Exception ex)
  14089. {
  14090. return Ok(JsonView(false, ex.Message));
  14091. }
  14092. }
  14093. /// <summary>
  14094. /// OP费用录入填写详情
  14095. /// </summary>
  14096. /// <param name="dto"></param>
  14097. /// <returns></returns>
  14098. [HttpPost]
  14099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14100. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  14101. {
  14102. try
  14103. {
  14104. #region 参数校验
  14105. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  14106. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  14107. if (di == null) return Ok(JsonView(false, "团组错误!"));
  14108. #endregion
  14109. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  14110. if (groupData.Code != 0)
  14111. {
  14112. return Ok(JsonView(false, groupData.Msg));
  14113. }
  14114. //自动审核
  14115. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  14116. #region 尾款自动审核
  14117. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14118. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  14119. if (opinfos.PriceType == 1062)
  14120. {
  14121. var isAuto = false;
  14122. //找对应的首付款
  14123. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14124. .InnerJoin<Grp_CreditCardPayment>((x, a) => a.IsDel == 0 && a.CTable == 79 && a.CId == x.Id && a.DIId == x.DiId && (a.IsAuditGM == 1 || a.IsAuditGM == 3))
  14125. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  14126. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  14127. x.PriceType == 1061 && x.DiId == dto.DiId);
  14128. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  14129. {
  14130. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  14131. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  14132. //合计中排除城市税
  14133. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  14134. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  14135. .Sum(x => x.Price * x.Count);
  14136. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  14137. if (balance >= opinfos.ServiceQuotedPrice)
  14138. {
  14139. isAuto = true;
  14140. }
  14141. }
  14142. if (isAuto)
  14143. {
  14144. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  14145. .SetColumns(a => new Grp_CreditCardPayment
  14146. {
  14147. IsAuditGM = 3, //自动审核通过
  14148. AuditGMOperate = 4,
  14149. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14150. })
  14151. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  14152. .ExecuteCommand();
  14153. }
  14154. }
  14155. #endregion
  14156. #region 应用推送
  14157. try
  14158. {
  14159. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14160. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14161. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14162. //2024-10-21 新增LZ UID
  14163. var userIds = new List<int>() { 21 };
  14164. string title = $"系统通知";
  14165. var diId = dto.DiId;
  14166. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14167. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14168. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  14169. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14170. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  14171. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14172. }
  14173. catch (Exception ex)
  14174. {
  14175. }
  14176. #endregion
  14177. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14178. }
  14179. catch (Exception ex)
  14180. {
  14181. return Ok(JsonView(false, ex.Message));
  14182. }
  14183. }
  14184. /// <summary>
  14185. /// 获取三公详细所有城市
  14186. /// </summary>
  14187. /// <returns></returns>
  14188. [HttpGet]
  14189. public IActionResult OpCarCityResult()
  14190. {
  14191. var jw = JsonView(false);
  14192. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  14193. {
  14194. x.Id,
  14195. x.Country,
  14196. x.City,
  14197. }).ToList();
  14198. if (data.Count > 0)
  14199. {
  14200. jw = JsonView(true, "获取成功!", data);
  14201. }
  14202. else
  14203. {
  14204. jw.Msg = "城市数据为空!";
  14205. jw.Data = Array.Empty<string>();
  14206. }
  14207. return Ok(jw);
  14208. }
  14209. /// <summary>
  14210. /// 导出地接费用明细
  14211. /// </summary>
  14212. /// <param name="dto"></param>
  14213. /// <returns></returns>
  14214. [HttpPost]
  14215. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  14216. {
  14217. var jw = JsonView(false);
  14218. if (dto.Diid < 1)
  14219. {
  14220. jw.Msg = "请输入正确的diid!";
  14221. return Ok(jw);
  14222. }
  14223. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14224. if (group == null)
  14225. {
  14226. jw.Msg = "未找到团组信息!";
  14227. return Ok(jw);
  14228. }
  14229. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14230. if (localGuideArr.Count == 0)
  14231. {
  14232. jw.Msg = "该团组暂无地接信息!";
  14233. return Ok(jw);
  14234. }
  14235. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  14236. var overspendSoure = new Dictionary<int, int>
  14237. {
  14238. { 91, 982 }, //车
  14239. { 92 , 1059} ,//导游
  14240. { 994 , 1073}, //翻译
  14241. { 988 , 1074 }, //早餐
  14242. { 93 , 1075 }, //午餐
  14243. { 989 , 1076 }, //晚餐
  14244. };
  14245. var Zips = new Dictionary<string, Stream>();
  14246. foreach (var groupArr in localGroup)
  14247. {
  14248. var keyValue = groupArr.Key;
  14249. if (int.TryParse(keyValue, out int cityid))
  14250. {
  14251. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  14252. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  14253. }
  14254. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  14255. foreach (var item in groupArr)
  14256. {
  14257. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  14258. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  14259. new Grp_CarTouristGuideGroundReservationsContentExtend
  14260. {
  14261. Count = a.Count,
  14262. CreateTime = a.CreateTime,
  14263. CreateUserId = a.CreateUserId,
  14264. CTGGRId = a.CTGGRId,
  14265. Currency = a.Currency,
  14266. DatePrice = a.DatePrice,
  14267. DeleteTime = a.DeleteTime,
  14268. DeleteUserId = a.DeleteUserId,
  14269. DiId = a.DiId,
  14270. Id = a.Id,
  14271. IsDel = a.IsDel,
  14272. Price = a.Price,
  14273. PriceContent = a.PriceContent,
  14274. Remark = a.Remark,
  14275. SId = a.SId,
  14276. SidName = b.Name,
  14277. Units = a.Units,
  14278. }
  14279. ).ToList();
  14280. if (content.Count > 0)
  14281. {
  14282. contentArr.Add(content);
  14283. }
  14284. }
  14285. //open excel
  14286. //set excel
  14287. //save excel
  14288. try
  14289. {
  14290. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  14291. IWorkbook workbook;
  14292. if (Path.GetExtension(filePath).ToLower() == ".xls")
  14293. {
  14294. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14295. }
  14296. else
  14297. {
  14298. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14299. }
  14300. ISheet sheet = workbook.GetSheetAt(0);
  14301. var rowStartIndex = 2;
  14302. var clounmCount = 10;
  14303. var initStyleRow = sheet.GetRow(2);
  14304. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  14305. //var overspendArrDetail =
  14306. var existsId = new List<CarCompare>();
  14307. var lastElem = arr.Last();
  14308. var thisSid = -1;
  14309. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  14310. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  14311. {
  14312. Name = "未知币种!",
  14313. Remark = "未知币种!",
  14314. };
  14315. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  14316. Action cloneRowFn = () =>
  14317. {
  14318. rowStartIndex++;
  14319. var cloneRow = sheet.CreateRow(rowStartIndex);
  14320. // 复制样式
  14321. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  14322. {
  14323. ICell sourceCell = initStyleRow.GetCell(i);
  14324. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  14325. // 确保单元格存在样式
  14326. if (sourceCell.CellStyle != null)
  14327. {
  14328. targetCell.CellStyle = sourceCell.CellStyle;
  14329. }
  14330. }
  14331. };
  14332. var mergeRow = () =>
  14333. {
  14334. for (int i = 2; i < sheet.LastRowNum; i++)
  14335. {
  14336. var row = sheet.GetRow(i);
  14337. var cellFirst = row.GetCell(0);
  14338. var thisIndex = i + 1;
  14339. while (thisIndex < sheet.LastRowNum)
  14340. {
  14341. var nextRow = sheet.GetRow(thisIndex);
  14342. var nextCellFirst = nextRow.GetCell(0);
  14343. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  14344. {
  14345. thisIndex++;
  14346. }
  14347. else
  14348. {
  14349. break;
  14350. }
  14351. }
  14352. thisIndex--;
  14353. if (thisIndex != i)
  14354. {
  14355. //合并row
  14356. var cellRangeAddress = new CellRangeAddress(
  14357. i, // 起始行索引(0-based)
  14358. thisIndex, // 结束行索引(0-based)
  14359. 0, // 起始列索引(0-based)
  14360. 0 // 结束列索引(0-based)
  14361. );
  14362. sheet.AddMergedRegion(cellRangeAddress);
  14363. i = thisIndex;
  14364. }
  14365. }
  14366. };
  14367. var chaoshiNumber = 0;
  14368. var totalNumber = 0.00M;
  14369. string lastStr = "";
  14370. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  14371. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  14372. {
  14373. b.IsAuditGM,
  14374. x.Id,
  14375. x.Area,
  14376. b.PayPercentage,
  14377. b.PayMoney,
  14378. }).ToList();
  14379. string yesPayment = "", noPayment = "";
  14380. foreach (var item in queryCarArrByCityAndDiid)
  14381. {
  14382. if (item.IsAuditGM == 1)
  14383. {
  14384. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14385. }
  14386. else
  14387. {
  14388. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14389. }
  14390. }
  14391. lastStr = yesPayment + noPayment;
  14392. foreach (var item in arr)
  14393. {
  14394. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  14395. {
  14396. if (thisSid != item.SId)
  14397. {
  14398. if (thisSid == -1)
  14399. {
  14400. thisSid = item.SId;
  14401. }
  14402. else
  14403. {
  14404. //合并小计行
  14405. //创建合并区域的实例
  14406. var cellRangeAddress = new CellRangeAddress(
  14407. rowStartIndex, // 起始行索引(0-based)
  14408. rowStartIndex, // 结束行索引(0-based)
  14409. 0, // 起始列索引(0-based)
  14410. 3 // 结束列索引(0-based)
  14411. );
  14412. sheet.AddMergedRegion(cellRangeAddress);
  14413. var CellStyle = workbook.CreateCellStyle();
  14414. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14415. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14416. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14417. for (int i = 0; i <= clounmCount; i++)
  14418. {
  14419. if (i > 6)
  14420. {
  14421. var CellStyle1 = workbook.CreateCellStyle();
  14422. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14423. IFont Font = workbook.CreateFont(); // 创建字体
  14424. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14425. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14426. CellStyle1.SetFont(Font);
  14427. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14428. }
  14429. else
  14430. {
  14431. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14432. }
  14433. }
  14434. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14435. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14436. //超时合计
  14437. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14438. //超时数
  14439. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14440. //超时合计费用
  14441. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14442. thisSid = item.SId;
  14443. cloneRowFn();
  14444. chaoshiNumber = 0;
  14445. totalNumber = 0;
  14446. }
  14447. }
  14448. IRow row = sheet.GetRow(rowStartIndex);
  14449. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14450. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  14451. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  14452. if (isOpenOverspendSoure)
  14453. {
  14454. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14455. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  14456. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  14457. }
  14458. for (int i = 0; i <= clounmCount; i++)
  14459. {
  14460. var cell = row.GetCell(i);
  14461. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  14462. if (cell == null)
  14463. {
  14464. cell = row.CreateCell(i);
  14465. }
  14466. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  14467. fontRed.CloneStyleFrom(cell.CellStyle);
  14468. IFont Font = workbook.CreateFont(); // 创建字体
  14469. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  14470. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14471. fontRed.SetFont(Font);
  14472. byte[] rgb = new byte[3] { 255, 242, 204 };
  14473. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  14474. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  14475. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  14476. if (workbook is XSSFWorkbook)
  14477. {
  14478. BackgroundColor255_242_204.FillForegroundColor = 0;
  14479. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  14480. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14481. }
  14482. else
  14483. {
  14484. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  14485. }
  14486. if (i == 1 || i > 6)
  14487. {
  14488. if (i > 6)
  14489. {
  14490. fontRed.FillForegroundColor = 0;
  14491. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  14492. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14493. }
  14494. cell.CellStyle = fontRed;
  14495. }
  14496. if (i > 2 && i < 7)
  14497. {
  14498. cell.CellStyle = BackgroundColor255_242_204;
  14499. }
  14500. cell.SetCellValue(setCellValue); //写入单元格
  14501. }
  14502. if (overspendSoure.ContainsKey(thisSid))
  14503. {
  14504. var overspendId = overspendSoure[thisSid];
  14505. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14506. }
  14507. cloneRowFn();
  14508. existsId.Add(new CarCompare
  14509. {
  14510. DataPrice = item.DatePrice.ObjToDate(),
  14511. Sid = item.SId
  14512. });
  14513. }
  14514. if (item.Equals(lastElem))
  14515. {
  14516. //合并小计行
  14517. //创建合并区域的实例
  14518. var cellRangeAddress = new CellRangeAddress(
  14519. rowStartIndex, // 起始行索引(0-based)
  14520. rowStartIndex, // 结束行索引(0-based)
  14521. 0, // 起始列索引(0-based)
  14522. 3 // 结束列索引(0-based)
  14523. );
  14524. sheet.AddMergedRegion(cellRangeAddress);
  14525. var CellStyle = workbook.CreateCellStyle();
  14526. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14527. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14528. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14529. for (int i = 0; i <= clounmCount; i++)
  14530. {
  14531. if (i > 6)
  14532. {
  14533. var CellStyle1 = workbook.CreateCellStyle();
  14534. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14535. IFont Font = workbook.CreateFont(); // 创建字体
  14536. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14537. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14538. CellStyle1.SetFont(Font);
  14539. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14540. }
  14541. else
  14542. {
  14543. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14544. }
  14545. }
  14546. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14547. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14548. //超时合计
  14549. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14550. //超时数
  14551. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14552. //超时合计费用
  14553. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14554. cloneRowFn();
  14555. // 创建合并区域的实例
  14556. cellRangeAddress = new CellRangeAddress(
  14557. rowStartIndex, // 起始行索引(0-based)
  14558. rowStartIndex, // 结束行索引(0-based)
  14559. 0, // 起始列索引(0-based)
  14560. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  14561. );
  14562. // 添加合并区域
  14563. sheet.AddMergedRegion(cellRangeAddress);
  14564. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  14565. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  14566. }
  14567. }
  14568. mergeRow();
  14569. // 保存修改后的Excel文件到新文件
  14570. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  14571. // new FileStream(newFilePath, FileMode.CreateNew)
  14572. using (var stream = new MemoryStream())
  14573. {
  14574. workbook.Write(stream, true);
  14575. stream.Flush();
  14576. stream.Seek(0, SeekOrigin.Begin);
  14577. var memoryStream = new MemoryStream();
  14578. stream.CopyTo(memoryStream);
  14579. memoryStream.Seek(0, SeekOrigin.Begin);
  14580. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  14581. }
  14582. workbook.Close();
  14583. workbook.Dispose();
  14584. }
  14585. catch (Exception ex)
  14586. {
  14587. jw.Msg = "出现异常!" + ex.Message;
  14588. return Ok(jw);
  14589. }
  14590. }
  14591. if (Zips.Count > 0)
  14592. {
  14593. var io = new IOOperatorHelper();
  14594. var byts = io.ConvertZipStream(Zips);
  14595. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  14596. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  14597. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  14598. }
  14599. else
  14600. {
  14601. jw.Msg = "暂无生成文件!";
  14602. }
  14603. return Ok(jw);
  14604. }
  14605. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  14606. {
  14607. string outStr = string.Empty;
  14608. switch (i)
  14609. {
  14610. case 0:
  14611. outStr = arr[0].SidName;
  14612. break;
  14613. case 1:
  14614. outStr = arr[0].DataPriceStr;
  14615. break;
  14616. case 2:
  14617. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  14618. break;
  14619. case 4:
  14620. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  14621. break;
  14622. case 7:
  14623. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14624. {
  14625. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  14626. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  14627. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  14628. }
  14629. break;
  14630. case 8:
  14631. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14632. {
  14633. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  14634. }
  14635. break;
  14636. case 9:
  14637. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14638. {
  14639. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  14640. }
  14641. break;
  14642. case 10:
  14643. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14644. {
  14645. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  14646. }
  14647. break;
  14648. }
  14649. return outStr;
  14650. }
  14651. #region OP行程单
  14652. /// <summary>
  14653. /// OP行程单初始化
  14654. /// </summary>
  14655. /// <param name="dto"></param>
  14656. /// <returns></returns>
  14657. [HttpPost]
  14658. public IActionResult InitOpTravel(InitOpTravelDto dto)
  14659. {
  14660. var jw = JsonView(false);
  14661. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  14662. var group = groupList.First();
  14663. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14664. if (group == null)
  14665. {
  14666. jw.Msg = "暂无团组!";
  14667. return Ok(jw);
  14668. }
  14669. group = groupList.Find(x => x.Id == diid);
  14670. if (group == null)
  14671. {
  14672. jw.Msg = "请输入正确的团组ID!";
  14673. return Ok(jw);
  14674. }
  14675. string city = string.Empty;
  14676. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  14677. if (blackCode.Count > 0)
  14678. {
  14679. var black = blackCode.First();
  14680. black.BlackCode = black.BlackCode ?? "";
  14681. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  14682. if (blackSp.Length > 0)
  14683. {
  14684. try
  14685. {
  14686. var cityArrCode = new List<string>(20);
  14687. foreach (var item in blackSp)
  14688. {
  14689. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  14690. var IndexSelect = itemSp[2];
  14691. var cityArrCodeLength = cityArrCode.Count - 1;
  14692. var startCity = IndexSelect.Substring(0, 3);
  14693. if (cityArrCodeLength > 0)
  14694. {
  14695. var arrEndCity = cityArrCode[cityArrCodeLength];
  14696. if (arrEndCity != startCity)
  14697. {
  14698. cityArrCode.Add(startCity.ToUpper());
  14699. }
  14700. }
  14701. else
  14702. {
  14703. cityArrCode.Add(startCity.ToUpper());
  14704. }
  14705. var endCity = IndexSelect.Substring(3, 3);
  14706. cityArrCode.Add(endCity.ToUpper());
  14707. }
  14708. var cityThree = string.Empty;
  14709. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  14710. cityThree = cityThree.TrimEnd(',');
  14711. if (string.IsNullOrWhiteSpace(cityThree))
  14712. {
  14713. throw new
  14714. Exception("error");
  14715. }
  14716. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  14717. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  14718. foreach (var item in cityArrCode)
  14719. {
  14720. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  14721. if (find != null)
  14722. {
  14723. city += find.City + "/";
  14724. }
  14725. else
  14726. {
  14727. city += item + "三字码未收入/";
  14728. }
  14729. }
  14730. city = city.TrimEnd('/');
  14731. }
  14732. catch (Exception e)
  14733. {
  14734. city = "黑屏代码格式不正确!";
  14735. }
  14736. }
  14737. }
  14738. else
  14739. {
  14740. city = "未录入黑屏代码";
  14741. }
  14742. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  14743. {
  14744. Date = x.Date,
  14745. Days = x.Days,
  14746. Diffgroup = x.Diffgroup,
  14747. Diid = x.Diid,
  14748. Traffic_First = x.Traffic_First,
  14749. Traffic_Second = x.Traffic_Second,
  14750. Trip = x.Trip,
  14751. WeekDay = x.WeekDay,
  14752. Id = x.Id
  14753. }).ToList();
  14754. jw.Data = new
  14755. {
  14756. groupList = groupList.Select(x => new
  14757. {
  14758. x.Id,
  14759. x.TeamName,
  14760. x.TourCode
  14761. }).ToList(),
  14762. groupInfo = new
  14763. {
  14764. group.VisitDays,
  14765. group.TourCode,
  14766. group.VisitPNumber,
  14767. group.TeamName,
  14768. city
  14769. },
  14770. OpTravelList
  14771. };
  14772. jw.Code = 200;
  14773. jw.Msg = "操作成功!";
  14774. return Ok(jw);
  14775. }
  14776. /// <summary>
  14777. /// 删除团组行程单
  14778. /// </summary>
  14779. /// <returns></returns>
  14780. [HttpPost]
  14781. public IActionResult DelTravel(DelOpTravelDto dto)
  14782. {
  14783. var jw = JsonView(false);
  14784. if (dto.UserId <= 0 || dto.Diid <= 0)
  14785. {
  14786. jw.Msg = "请输入正确的参数!";
  14787. return Ok(jw);
  14788. }
  14789. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  14790. .SetColumns(x => new Grp_TravelList
  14791. {
  14792. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  14793. DeleteUserId = dto.UserId,
  14794. IsDel = 1,
  14795. }).ExecuteCommand();
  14796. jw = JsonView(true);
  14797. return Ok(jw);
  14798. }
  14799. /// <summary>
  14800. /// 行程单保存
  14801. /// </summary>
  14802. /// <returns></returns>
  14803. [HttpPost]
  14804. public IActionResult TravelSave(TravelSaveDto dto)
  14805. {
  14806. var jw = JsonView(false);
  14807. if (dto.Arr.Count > 0)
  14808. {
  14809. try
  14810. {
  14811. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14812. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14813. .ToList();
  14814. _sqlSugar.BeginTran();
  14815. foreach (var item in dto.Arr)
  14816. {
  14817. if (item.Id == 0)
  14818. {
  14819. throw new Exception("请传入正确的Id");
  14820. }
  14821. //比较上一次的差异
  14822. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14823. if (findTravel != null)
  14824. {
  14825. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14826. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14827. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14828. }
  14829. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14830. .SetColumns(x => new Grp_TravelList
  14831. {
  14832. Trip = item.Trip
  14833. }).ExecuteCommand();
  14834. }
  14835. _sqlSugar.CommitTran();
  14836. jw = JsonView(true);
  14837. }
  14838. catch (Exception ex)
  14839. {
  14840. _sqlSugar.RollbackTran();
  14841. jw.Msg = "程序异常!" + ex.Message;
  14842. }
  14843. }
  14844. else
  14845. {
  14846. jw.Msg = "请传入正确的参数!";
  14847. }
  14848. return Ok(jw);
  14849. }
  14850. private static string CheckStr(string original, string changed)
  14851. {
  14852. // 创建diff_match_patch对象
  14853. var dmp = new diff_match_patch();
  14854. // 计算差异
  14855. List<Diff> diffs = dmp.diff_main(original, changed);
  14856. // 清理和合并差异
  14857. dmp.diff_cleanupSemantic(diffs);
  14858. // 使用StringBuilder构建最终的字符串
  14859. var finalString = new StringBuilder();
  14860. // 输出差异结果,并构建变动后的字符串
  14861. foreach (Diff diff in diffs)
  14862. {
  14863. switch (diff.operation)
  14864. {
  14865. case Operation.EQUAL:
  14866. // 相等的部分,直接添加到最终字符串
  14867. finalString.Append(diff.text);
  14868. break;
  14869. case Operation.INSERT:
  14870. // 插入的部分,添加标记并添加到最终字符串
  14871. finalString.Append("[++]" + diff.text + "[++]");
  14872. break;
  14873. case Operation.DELETE:
  14874. // 删除的部分,不添加到最终字符串
  14875. //finalString.Append("[++]" + diff.text + "[++]");
  14876. break;
  14877. }
  14878. }
  14879. // 输出变动后的字符串
  14880. return finalString.ToString();
  14881. }
  14882. private class tagContent
  14883. {
  14884. public DateTime Date { get; set; }
  14885. public string StartTag { get; set; }
  14886. public string EndTag { get; set; }
  14887. public string Content { get; set; }
  14888. public static int tagLength { get { return 3; } }
  14889. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14890. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14891. public bool IsFinally { get; set; }
  14892. }
  14893. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14894. {
  14895. var results = new List<string>();
  14896. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14897. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14898. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14899. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14900. string[] strValueArr = new string[1];
  14901. foreach (System.Text.RegularExpressions.Match match in matches)
  14902. {
  14903. var strValue = match.Groups[1].Value;
  14904. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  14905. }
  14906. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  14907. return results;
  14908. }
  14909. /// <summary>
  14910. /// 导出行程单
  14911. /// </summary>
  14912. /// <param name="dto"></param>
  14913. /// <returns></returns>
  14914. [HttpPost]
  14915. public IActionResult ExportTravel(ExportTravelDto dto)
  14916. {
  14917. var jw = JsonView(false);
  14918. jw.Data = "";
  14919. int diid = 0;
  14920. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  14921. if (Find == null)
  14922. {
  14923. jw.Msg = "请选择正确的团组!";
  14924. return Ok(jw);
  14925. }
  14926. else
  14927. {
  14928. diid = Find.Id;
  14929. }
  14930. //数据源
  14931. var _travelList = new List<Grp_TravelList>();
  14932. DataTable dtBlack = null;
  14933. try
  14934. {
  14935. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14936. }
  14937. catch (Exception)
  14938. {
  14939. jw.Msg = "机票黑屏代码有误!";
  14940. return Ok(jw);
  14941. }
  14942. string CityStr = string.Empty;
  14943. if (dtBlack.Rows.Count == 0)
  14944. {
  14945. jw.Msg = "机票黑屏代码有误!";
  14946. return Ok(jw);
  14947. }
  14948. else
  14949. {
  14950. foreach (DataRow row in dtBlack.Rows)
  14951. {
  14952. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14953. {
  14954. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14955. return Ok(jw);
  14956. }
  14957. }
  14958. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14959. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14960. }
  14961. // 指定的文字
  14962. var targetTextDic = new Dictionary<string, List<string>>();
  14963. //创建数据源Table
  14964. var dtSource = new DataTable();
  14965. dtSource.Columns.Add("Days", typeof(string));
  14966. dtSource.Columns.Add("Date", typeof(string));
  14967. dtSource.Columns.Add("Week", typeof(string));
  14968. dtSource.Columns.Add("Traffic", typeof(string));
  14969. dtSource.Columns.Add("Trip", typeof(string));
  14970. //获取数据,放到datatable
  14971. foreach (var item in _travelList)
  14972. {
  14973. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14974. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14975. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14976. .Replace("[++]", string.Empty);
  14977. DataRow dr = dtSource.NewRow();
  14978. dr["Days"] = item.Days;
  14979. dr["Date"] = item.Date;
  14980. dr["Week"] = item.WeekDay;
  14981. dr["Traffic"] = item.Traffic_First
  14982. + "\r\n"
  14983. + item.Traffic_Second;
  14984. dr["Trip"] = item.Trip;
  14985. dtSource.Rows.Add(dr);
  14986. }
  14987. var dic = new Dictionary<string, string>
  14988. {
  14989. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14990. { "City", CityStr },
  14991. { "Days", Find.VisitDays.ToString() },
  14992. { "DeleCode", Find.TourCode },
  14993. { "Pnum", Find.VisitPNumber.ToString() }
  14994. };
  14995. //模板路径
  14996. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14997. //载入模板
  14998. Document doc = null;
  14999. DocumentBuilder builder = null;
  15000. try
  15001. {
  15002. //载入模板
  15003. doc = new Document(tempPath);
  15004. builder = new DocumentBuilder(doc);
  15005. }
  15006. catch (Exception)
  15007. {
  15008. jw.Msg = "模板位置不存在!";
  15009. return Ok(jw);
  15010. }
  15011. foreach (var key in dic.Keys)
  15012. {
  15013. Bookmark bookmark = doc.Range.Bookmarks[key];
  15014. if (bookmark != null)
  15015. {
  15016. builder.MoveToBookmark(key);
  15017. builder.Write(dic[key]);
  15018. }
  15019. }
  15020. //获取word里所有表格
  15021. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15022. //获取所填表格的序数
  15023. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15024. try
  15025. {
  15026. //循环赋值
  15027. for (int i = 0; i < dtSource.Rows.Count; i++)
  15028. {
  15029. builder.MoveToCell(0, i + 1, 0, 0);
  15030. builder.Write(dtSource.Rows[i]["Days"].ToString());
  15031. builder.MoveToCell(0, i + 1, 1, 0);
  15032. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  15033. builder.MoveToCell(0, i + 1, 2, 0);
  15034. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  15035. var trip = dtSource.Rows[i]["Trip"].ToString();
  15036. builder.MoveToCell(0, i + 1, 3, 0);
  15037. builder.Write(trip);
  15038. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  15039. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  15040. // 获取特定索引的段落
  15041. Paragraph paragraph = (Paragraph)paragraphs[0];
  15042. Run run = paragraph.Runs[0];
  15043. Aspose.Words.Font font = run.Font;
  15044. font.Name = "黑体";
  15045. //设置双休红色
  15046. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  15047. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  15048. paragraph = (Paragraph)paragraphs[1];
  15049. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  15050. {
  15051. run = paragraph.Runs[0];
  15052. font = run.Font;
  15053. font.Color = Color.Red;
  15054. }
  15055. }
  15056. }
  15057. catch (Exception ex)
  15058. {
  15059. }
  15060. //删除多余行
  15061. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  15062. {
  15063. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  15064. }
  15065. var targetTextList = new List<string>();
  15066. // 遍历文档中的表格
  15067. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15068. {
  15069. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15070. {
  15071. var cellIndex = 0;
  15072. foreach (Cell cell in row.Cells)
  15073. {
  15074. if (cellIndex == 1 && row.Cells.Count == 4)
  15075. {
  15076. foreach (var target in targetTextDic.Keys)
  15077. {
  15078. if (cell.GetText().Contains(target))
  15079. {
  15080. targetTextList = targetTextDic[target];
  15081. break;
  15082. }
  15083. }
  15084. }
  15085. // 遍历单元格中的所有段落
  15086. foreach (Paragraph paragraph in cell.Paragraphs)
  15087. {
  15088. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  15089. var runs = new List<Run>();
  15090. foreach (Run run in paragraph.Runs)
  15091. {
  15092. runs.Add(run);
  15093. }
  15094. foreach (Run run in runs)
  15095. {
  15096. foreach (var targetText in targetTextList)
  15097. {
  15098. // 检查文字是否包含指定文字
  15099. if (run.Text.Contains(targetText))
  15100. {
  15101. // 将包含的部分设置为红色
  15102. HighlightText(run, targetText, Color.Red);
  15103. }
  15104. }
  15105. }
  15106. }
  15107. cellIndex++;
  15108. }
  15109. }
  15110. }
  15111. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  15112. if (!Directory.Exists(savePath))
  15113. {
  15114. try
  15115. {
  15116. Directory.CreateDirectory(savePath);
  15117. }
  15118. catch
  15119. {
  15120. }
  15121. }
  15122. string path = savePath + Find.TeamName + "出访日程";
  15123. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  15124. try
  15125. {
  15126. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  15127. string postfix = ".docx";
  15128. if (dto.IsPDF == 1)
  15129. {
  15130. saveFormat = Aspose.Words.SaveFormat.Pdf;
  15131. postfix = ".pdf";
  15132. }
  15133. doc.Save(path + postfix, saveFormat);
  15134. jw = JsonView(true, "导出成功", ftpPath + postfix);
  15135. }
  15136. catch (Exception)
  15137. {
  15138. jw = JsonView(false);
  15139. }
  15140. return Ok(jw);
  15141. }
  15142. /// <summary>
  15143. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  15144. /// </summary>
  15145. /// <param name="num"></param>
  15146. /// <returns></returns>
  15147. static string GetNum(string num)
  15148. {
  15149. string str = "";
  15150. switch (num)
  15151. {
  15152. case "1":
  15153. str = "一";
  15154. break;
  15155. case "2":
  15156. str = "二";
  15157. break;
  15158. case "3":
  15159. str = "三";
  15160. break;
  15161. case "4":
  15162. str = "四";
  15163. break;
  15164. case "5":
  15165. str = "五";
  15166. break;
  15167. case "6":
  15168. str = "六";
  15169. break;
  15170. case "7":
  15171. str = "七";
  15172. break;
  15173. case "8":
  15174. str = "八";
  15175. break;
  15176. case "9":
  15177. str = "九";
  15178. break;
  15179. case "10":
  15180. str = "十";
  15181. break;
  15182. case "11":
  15183. str = "十一";
  15184. break;
  15185. case "12":
  15186. str = "十二";
  15187. break;
  15188. case "一":
  15189. str = "1";
  15190. break;
  15191. case "二":
  15192. str = "2";
  15193. break;
  15194. case "三":
  15195. str = "3";
  15196. break;
  15197. case "四":
  15198. str = "4";
  15199. break;
  15200. case "五":
  15201. str = "5";
  15202. break;
  15203. case "六":
  15204. str = "6";
  15205. break;
  15206. case "七":
  15207. str = "7";
  15208. break;
  15209. case "八":
  15210. str = "8";
  15211. break;
  15212. case "九":
  15213. str = "9";
  15214. break;
  15215. case "十":
  15216. str = "10";
  15217. break;
  15218. case "十一":
  15219. str = "11";
  15220. break;
  15221. case "十二":
  15222. str = "12";
  15223. break;
  15224. }
  15225. return str;
  15226. }
  15227. /// <summary>
  15228. /// 高亮包含指定文字的部分
  15229. /// </summary>
  15230. /// <param name="run"></param>
  15231. /// <param name="targetText"></param>
  15232. /// <param name="color"></param>
  15233. static void HighlightText(Run run, string targetText, Color color)
  15234. {
  15235. string text = run.Text;
  15236. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  15237. if (startIndex >= 0)
  15238. {
  15239. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  15240. // 前部分
  15241. if (startIndex > 0)
  15242. {
  15243. Run beforeRun = (Run)run.Clone(true);
  15244. beforeRun.Text = text.Substring(0, startIndex);
  15245. parentParagraph.InsertBefore(beforeRun, run);
  15246. }
  15247. // 匹配部分
  15248. Run matchRun = (Run)run.Clone(true);
  15249. matchRun.Text = text.Substring(startIndex, targetText.Length);
  15250. matchRun.Font.Color = color;
  15251. parentParagraph.InsertBefore(matchRun, run);
  15252. // 后部分
  15253. if (startIndex + targetText.Length < text.Length)
  15254. {
  15255. Run afterRun = (Run)run.Clone(true);
  15256. afterRun.Text = text.Substring(startIndex + targetText.Length);
  15257. parentParagraph.InsertBefore(afterRun, run);
  15258. }
  15259. // 删除原始Run
  15260. run.Remove();
  15261. }
  15262. }
  15263. #endregion
  15264. #endregion
  15265. #region 团组成本
  15266. /// <summary>
  15267. /// 团组成本数据初始化
  15268. /// </summary>
  15269. /// <param name="dto"></param>
  15270. /// <returns></returns>
  15271. [HttpPost]
  15272. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  15273. {
  15274. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15275. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15276. WHEN COUNT(*) >= 0 THEN 'True'
  15277. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15278. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15279. ").ToList(); //团组列表
  15280. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  15281. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  15282. var visaCountryInfoArr = new ArrayList();
  15283. var groupinfoValue = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == diid && x.IsDel == 0);
  15284. if (groupinfoValue != null)
  15285. {
  15286. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  15287. var dicity = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == groupinfoValue.CityId);
  15288. dicity ??= new Sys_Cities()
  15289. {
  15290. ParentId = 122
  15291. };
  15292. var diparent = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == dicity.ParentId);
  15293. var spArr = new string[1] { countryArr };
  15294. if (countryArr.Contains("|"))
  15295. {
  15296. spArr = countryArr.Split("|");
  15297. }
  15298. else if (countryArr.Contains("、"))
  15299. {
  15300. spArr = countryArr.Split("、");
  15301. }
  15302. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  15303. {
  15304. try
  15305. {
  15306. var visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  15307. .Where(x => x.IsDel == 0 && x.Country == item)
  15308. .ToList();
  15309. if (visa.Any())
  15310. {
  15311. var visainfo = _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
  15312. .Where(x => x.IsDel == 0 && visa.Select(x => x.Id).Contains(x.ParentId))
  15313. .ToList();
  15314. var visaMain = visainfo.FirstOrDefault(x => x.ProvinceId == diparent.Id);
  15315. var visayinsiValue = visainfo.FirstOrDefault(x => x.ParentId == visa.FirstOrDefault(x => x.FeeType == 1)?.Id);
  15316. visaCountryInfoArr.Add(new
  15317. {
  15318. country = item,
  15319. yinsi = new
  15320. {
  15321. Id = visayinsiValue.Id,
  15322. value = visayinsiValue.SmallVisaPrice
  15323. },
  15324. visaMain = new
  15325. {
  15326. Id = visaMain.Id,
  15327. IsVisaOnArrival = visaMain.IsVisaOnArrival ? "是" : "否",
  15328. IsElectronicSign = visaMain.IsElectronicSign ? "是" : "否",
  15329. VisaTime = visaMain.VisaTime,
  15330. IsVisaExemptionLarge = visaMain.IsVisaExemptionLarge ? "是" : "否",
  15331. LargeVisaPrice = visaMain.LargeVisaPrice,
  15332. LargeAgencyFee = visaMain.LargeAgencyFee,
  15333. IsVisaExemptionSmall = visaMain.IsVisaExemptionSmall ? "是" : "否",
  15334. SmallVisaPrice = visaMain.SmallVisaPrice,
  15335. SmallAgencyFee = visaMain.SmallAgencyFee,
  15336. NormExtFee = visaMain.NormExtFee,
  15337. UrgExtFee = visaMain.UrgExtFee,
  15338. IsUrgent = visaMain.IsUrgent ? "是" : "否",
  15339. UrgentTime = visaMain.UrgentTime,
  15340. UrgentPrice = visaMain.UrgentPrice,
  15341. UrgentPriceDesc = visaMain.UrgentPriceDesc,
  15342. Remark = visaMain.Remark,
  15343. }
  15344. });
  15345. }
  15346. }
  15347. catch (Exception ex)
  15348. {
  15349. //写入日志
  15350. _logger.LogError(ex, "团组成本解析签证异常!");
  15351. }
  15352. }
  15353. }
  15354. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  15355. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  15356. #region 屏蔽黑屏代码生成
  15357. //var create = _GroupCostRepository.
  15358. // CreateGroupCostByBlackCode(dto.Diid);
  15359. //if (groupCost.Count == 0 && create.Code == 0)
  15360. //{
  15361. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  15362. //}
  15363. #endregion
  15364. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  15365. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  15366. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  15367. groupCostMap = groupCostMap.Select(x =>
  15368. {
  15369. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  15370. {
  15371. x.Date = dataForamt.ToString("yyyy-MM-dd");
  15372. }
  15373. return x;
  15374. }).ToList();
  15375. //GroupCostParameter.Add(new
  15376. // Grp_GroupCostParameter());
  15377. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  15378. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  15379. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  15380. return Ok(JsonView(new
  15381. {
  15382. groupList,
  15383. groupInfo,
  15384. groupChecks,
  15385. groupCost = groupCostMap,
  15386. hotelNumber,
  15387. GroupCostParameter = GroupCostParameterMap,
  15388. visaCountryInfoArr = visaCountryInfoArr,
  15389. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  15390. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  15391. hotelIsTrue,
  15392. groupModuleOperators
  15393. }));
  15394. }
  15395. /// <summary>
  15396. /// 团组成本信息保存
  15397. /// </summary>
  15398. /// <param name="dto"></param>
  15399. /// <returns></returns>
  15400. [HttpPost]
  15401. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  15402. {
  15403. if (dto.Diid <= 0 || dto.Userid <= 0)
  15404. {
  15405. return Ok(JsonView(false));
  15406. }
  15407. JsonView jw = null;
  15408. bool isTrue = false;
  15409. #region 复制团组成本
  15410. //if (dto.Diid == 2581)
  15411. //{
  15412. // dto.Diid = 2599;
  15413. // dto.CheckBoxs.ForEach(x =>
  15414. // {
  15415. // x.Diid = 2599;
  15416. // });
  15417. // dto.GroupCosts.ForEach(x =>
  15418. // {
  15419. // x.Diid = 2599;
  15420. // });
  15421. // dto.CostTypeHotelNumbers.ForEach(x =>
  15422. // {
  15423. // x.Diid = 2599;
  15424. // });
  15425. // dto.GroupCostParameters.ForEach(x =>
  15426. // {
  15427. // x.DiId = 2599;
  15428. // });
  15429. //}
  15430. #endregion
  15431. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15432. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15433. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15434. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15435. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15436. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15437. try
  15438. {
  15439. _sqlSugar.BeginTran();
  15440. isTrue = await _GroupCostRepository.
  15441. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15442. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15443. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15444. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15445. _sqlSugar.CommitTran();
  15446. jw = JsonView(true, "保存成功!", isTrue);
  15447. }
  15448. catch (Exception)
  15449. {
  15450. _sqlSugar.RollbackTran();
  15451. jw = JsonView(false);
  15452. }
  15453. return Ok(jw);
  15454. }
  15455. /// <summary>
  15456. /// 复制团组成本信息
  15457. /// </summary>
  15458. /// <param name="dto"></param>
  15459. /// <returns></returns>
  15460. [HttpPost]
  15461. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  15462. {
  15463. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  15464. {
  15465. return Ok(JsonView(false, "参数有误!"));
  15466. }
  15467. #region 复制团组成本
  15468. dto.Diid = dto.ToGroupId;
  15469. dto.CheckBoxs.ForEach(x =>
  15470. {
  15471. x.Diid = dto.ToGroupId;
  15472. });
  15473. dto.GroupCosts.ForEach(x =>
  15474. {
  15475. x.Diid = dto.ToGroupId;
  15476. });
  15477. dto.CostTypeHotelNumbers.ForEach(x =>
  15478. {
  15479. x.Diid = dto.ToGroupId;
  15480. });
  15481. dto.GroupCostParameters.ForEach(x =>
  15482. {
  15483. x.DiId = dto.ToGroupId;
  15484. });
  15485. #endregion
  15486. JsonView jw = null;
  15487. bool isTrue = false;
  15488. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15489. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15490. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15491. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15492. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15493. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15494. try
  15495. {
  15496. _sqlSugar.BeginTran();
  15497. isTrue = await _GroupCostRepository.
  15498. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15499. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15500. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15501. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15502. _sqlSugar.CommitTran();
  15503. jw = JsonView(true, "保存成功!", isTrue);
  15504. }
  15505. catch (Exception)
  15506. {
  15507. _sqlSugar.RollbackTran();
  15508. jw = JsonView(false);
  15509. }
  15510. return Ok(jw);
  15511. }
  15512. /// <summary>
  15513. /// 司兼导数据
  15514. /// </summary>
  15515. /// <param name="dto"></param>
  15516. /// <returns></returns>
  15517. [HttpPost]
  15518. public IActionResult GetCarGuides(CarGuidesDto dto)
  15519. {
  15520. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  15521. return Ok(JsonView(true, "获取成功!", Data));
  15522. }
  15523. /// <summary>
  15524. /// 导游数据
  15525. /// </summary>
  15526. /// <param name="dto"></param>
  15527. /// <returns></returns>
  15528. [HttpPost]
  15529. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  15530. {
  15531. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  15532. // 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
  15533. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  15534. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  15535. return Ok(JsonView(true, "获取成功!", Data));
  15536. }
  15537. /// <summary>
  15538. /// 成本车数据
  15539. /// </summary>
  15540. /// <param name="dto"></param>
  15541. /// <returns></returns>
  15542. [HttpPost]
  15543. public IActionResult GetCarInfo(CarGuidesDto dto)
  15544. {
  15545. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  15546. return Ok(JsonView(true, "获取成功!", Data));
  15547. }
  15548. /// <summary>
  15549. /// 景点数据
  15550. /// </summary>
  15551. /// <param name="dto"></param>
  15552. /// <returns></returns>
  15553. [HttpPost]
  15554. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  15555. {
  15556. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  15557. return Ok(JsonView(true, "获取成功!", Data));
  15558. }
  15559. /// <summary>
  15560. /// 成本通知
  15561. /// </summary>
  15562. /// <param name="dto"></param>
  15563. /// <returns></returns>
  15564. [HttpPost]
  15565. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  15566. {
  15567. if (dto.Diid < 0)
  15568. {
  15569. return Ok(JsonView(false));
  15570. }
  15571. JsonView jw;
  15572. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  15573. if (GroupCostParameter != null)
  15574. {
  15575. int IsShare = 0;
  15576. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  15577. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  15578. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  15579. string msg = string.Empty;
  15580. if (isTrue)
  15581. {
  15582. if (IsShare == 0)
  15583. {
  15584. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  15585. }
  15586. else
  15587. {
  15588. #region 企微通知对应岗位用户
  15589. try
  15590. {
  15591. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  15592. }
  15593. catch (Exception)
  15594. {
  15595. }
  15596. #endregion
  15597. msg = "通知成功,其他模块操作人员可见此成本信息!";
  15598. }
  15599. jw = JsonView(isTrue, msg, new { IsShare });
  15600. }
  15601. else
  15602. {
  15603. msg = "修改失败!";
  15604. jw = JsonView(isTrue, msg);
  15605. }
  15606. }
  15607. else
  15608. {
  15609. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  15610. }
  15611. return Ok(jw);
  15612. }
  15613. /// <summary>
  15614. /// 导出报价单
  15615. /// </summary>
  15616. /// <param name="dto"></param>
  15617. /// <returns></returns>
  15618. [HttpPost]
  15619. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  15620. {
  15621. if (dto.Diid == 0)
  15622. {
  15623. return Ok(JsonView(false, "请传递团组id"));
  15624. }
  15625. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15626. if (deleInfo.Code != 0)
  15627. {
  15628. return Ok(JsonView(false, "团组信息查询失败!"));
  15629. }
  15630. var di = deleInfo.Data as DelegationInfoWebView;
  15631. if (di != null)
  15632. {
  15633. di.TeamName = di.TeamName.Replace("|", "、");
  15634. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  15635. //文件名
  15636. string strFileName = di.TeamName + "-收款账单.doc";
  15637. //获取模板
  15638. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  15639. //载入模板
  15640. Document doc = new Document(tmppath);
  15641. decimal TotalPrice = 0.00M;
  15642. string itemStr = string.Empty;
  15643. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  15644. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15645. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15646. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  15647. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  15648. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  15649. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  15650. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  15651. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  15652. foreach (var cost in groupCostType)
  15653. {
  15654. var List = cost.ToList();
  15655. if (cost.Key == "A")
  15656. {
  15657. foreach (var ListItem in List)
  15658. {
  15659. if (ListItem.number > 0)
  15660. {
  15661. if (ListItem.code.Contains("TBR"))
  15662. {
  15663. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15664. }
  15665. else
  15666. {
  15667. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15668. }
  15669. TotalPrice += (ListItem.number * ListItem.price);
  15670. }
  15671. }
  15672. }
  15673. else
  15674. {
  15675. itemStr = itemStr.Insert(0, "A段\r\n");
  15676. itemStr += "B段\r\n";
  15677. foreach (var ListItem in List)
  15678. {
  15679. if (ListItem.number > 0)
  15680. {
  15681. if (ListItem.code.Contains("TBR"))
  15682. {
  15683. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15684. }
  15685. else
  15686. {
  15687. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15688. }
  15689. TotalPrice += (ListItem.number * ListItem.price);
  15690. }
  15691. }
  15692. }
  15693. }
  15694. #region 替换Word模板书签内容
  15695. Dictionary<string, string> marks = new Dictionary<string, string>();
  15696. marks.Add("To", di.ClientUnit);//付款方
  15697. marks.Add("ToTel", di.TellPhone);//付款方电话
  15698. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  15699. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  15700. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  15701. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  15702. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  15703. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  15704. marks.Add("PayItemContent", itemStr);//详细信息
  15705. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  15706. #endregion
  15707. ////注
  15708. //if (doc.Range.Bookmarks["Attention"] != null)
  15709. //{
  15710. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  15711. // mark.Text = frList[0].Attention;
  15712. //}
  15713. foreach (var item in marks.Keys)
  15714. {
  15715. if (doc.Range.Bookmarks[item] != null)
  15716. {
  15717. Bookmark mark = doc.Range.Bookmarks[item];
  15718. mark.Text = marks[item];
  15719. }
  15720. }
  15721. byte[] bytes = null;
  15722. using (MemoryStream stream = new MemoryStream())
  15723. {
  15724. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15725. bytes = stream.ToArray();
  15726. }
  15727. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  15728. return Ok(JsonView(true, "", new
  15729. {
  15730. Data = bytes,
  15731. strFileName,
  15732. }));
  15733. }
  15734. else
  15735. {
  15736. return Ok(JsonView(false, "团组信息不存在!"));
  15737. }
  15738. }
  15739. /// <summary>
  15740. /// 导出团组成本
  15741. /// </summary>
  15742. /// <param name="dto"></param>
  15743. /// <returns></returns>
  15744. [HttpPost]
  15745. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  15746. {
  15747. var jw = JsonView(false);
  15748. if (dto.Diid == 0)
  15749. {
  15750. return Ok(JsonView(false, "请传递团组id"));
  15751. }
  15752. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15753. if (deleInfo.Code != 0)
  15754. {
  15755. return Ok(JsonView(false, "团组信息查询失败!"));
  15756. }
  15757. var di = deleInfo.Data as DelegationInfoWebView;
  15758. if (di == null)
  15759. {
  15760. return Ok(JsonView(false, "团组信息查询失败!"));
  15761. }
  15762. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  15763. WorkbookDesigner designer = new WorkbookDesigner();
  15764. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  15765. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  15766. List<int> hideColumnList = new List<int>();
  15767. var ColumnSetting = new[]
  15768. {
  15769. new { tag = "VF", Index = 4, P = "CarCost" },
  15770. new { tag = "VN", Index = 5, P = "CarNumber" },
  15771. new { tag = "VRD", Index = 6, P = "CarTiming" },
  15772. new { tag = "T/G S", Index = 7, P = "TGS" },
  15773. new { tag = "TGWH", Index = 8, P = "TGWH" },
  15774. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  15775. new { tag = "T/G M", Index = 10, P = "TGM" },
  15776. new { tag = "T/G A", Index = 11, P = "TGA" },
  15777. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  15778. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  15779. new { tag = "C/F S", Index = 14, P = "CFS" },
  15780. new { tag = "C/F M", Index = 15, P = "CFM" },
  15781. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  15782. new { tag = "B", Index = 17, P = "B" },
  15783. new { tag = "L", Index = 18, P = "L" },
  15784. new { tag = "D", Index = 19, P = "D" },
  15785. new { tag = "TBR", Index = 20, P = "TBR" },
  15786. new { tag = "SGR", Index = 21, P = "SGR" },
  15787. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  15788. new { tag = "Suite", Index = 23, P = "Suite" },
  15789. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  15790. new { tag = "T/V", Index = 25, P = "TV" },
  15791. new { tag = "1/L", Index = 26, P = "iL" },
  15792. new { tag = "I/F", Index = 27, P = "IF" },
  15793. new { tag = "EF", Index = 28, P = "EF" },
  15794. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  15795. new { tag = "TE", Index = 30, P = "TE" },
  15796. new { tag = "T/G T", Index = 31, P = "TGTips" },
  15797. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  15798. new { tag = "P/C", Index = 33, P = "PC" },
  15799. new { tag = "T/L F", Index = 34, P = "TLF" },
  15800. new { tag = "E/C T", Index = 35, P = "ECT" }
  15801. };
  15802. Func<string, bool> isEmpty = (str) =>
  15803. {
  15804. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  15805. {
  15806. return true;
  15807. }
  15808. if (string.IsNullOrWhiteSpace(str))
  15809. {
  15810. return true;
  15811. }
  15812. return false;
  15813. };
  15814. for (int i = 0; i < List_GC.Count; i++)
  15815. {
  15816. GroupCost_Excel gc = new GroupCost_Excel();
  15817. gc.Id = List_GC[i].Id;
  15818. gc.Diid = List_GC[i].Diid.ToString();
  15819. gc.DAY = List_GC[i].DAY;
  15820. string week = "";
  15821. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  15822. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  15823. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  15824. gc.ITIN = List_GC[i].ITIN;
  15825. gc.CarType = List_GC[i].CarType;
  15826. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  15827. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  15828. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  15829. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  15830. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  15831. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  15832. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  15833. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  15834. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  15835. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  15836. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  15837. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  15838. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  15839. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  15840. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  15841. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  15842. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  15843. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  15844. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  15845. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15846. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15847. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15848. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15849. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15850. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15851. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15852. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15853. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15854. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15855. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15856. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15857. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15858. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15859. gc.EFR = List_GC[i].EFR;
  15860. List_GC1.Add(gc);
  15861. }
  15862. if (List_GC1.Count > 0)
  15863. {
  15864. var p = List_GC1[0];
  15865. var prs = p.GetType().GetProperties();
  15866. foreach (var item in prs)
  15867. {
  15868. var tp = item.PropertyType;
  15869. if (tp == typeof(int))
  15870. {
  15871. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15872. if (val == 0)
  15873. {
  15874. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15875. if (columnSetting != null)
  15876. {
  15877. hideColumnList.Add(columnSetting.Index);
  15878. }
  15879. }
  15880. }
  15881. if (tp == typeof(decimal))
  15882. {
  15883. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15884. if (val == 0)
  15885. {
  15886. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15887. if (columnSetting != null)
  15888. {
  15889. hideColumnList.Add(columnSetting.Index);
  15890. }
  15891. }
  15892. }
  15893. if (tp == typeof(string))
  15894. {
  15895. var val = List_GC1.Sum(x =>
  15896. {
  15897. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15898. if (decimal.TryParse(str, out decimal str_De))
  15899. {
  15900. return str_De;
  15901. }
  15902. else
  15903. {
  15904. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  15905. }
  15906. });
  15907. if (val == 0)
  15908. {
  15909. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15910. if (columnSetting != null)
  15911. {
  15912. hideColumnList.Add(columnSetting.Index);
  15913. }
  15914. }
  15915. }
  15916. }
  15917. }
  15918. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  15919. dt.TableName = "TB";
  15920. //报表标题等不用dt的值
  15921. designer.SetDataSource("TeamName", dto.title.TeamName);
  15922. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  15923. designer.SetDataSource("Tax", dto.title.Tax);
  15924. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  15925. designer.SetDataSource("Currency", dto.title.Currency);
  15926. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  15927. designer.SetDataSource("Rate", dto.title.Rate);
  15928. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  15929. var Aparams = hotels.Find(x => x.Type == "Default");
  15930. if (Aparams == null)
  15931. {
  15932. return Ok(jw);
  15933. }
  15934. //酒店数量
  15935. var txtSGRNumber = Aparams.SGR.ToString();
  15936. var txtTBRNumber = Aparams.TBR.ToString();
  15937. var txtJSESNumber = Aparams.JSES.ToString();
  15938. var txtSUITENumbe = Aparams.SUITE.ToString();
  15939. if (dto.costType == "B")
  15940. {
  15941. Aparams = hotels.Find(x => x.Type == "A");
  15942. var Bparams = hotels.Find(x => x.Type == "B");
  15943. if (Aparams == null || Bparams == null)
  15944. {
  15945. return Ok(jw);
  15946. }
  15947. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  15948. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  15949. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  15950. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  15951. }
  15952. designer.SetDataSource("SGRNumber", txtSGRNumber);
  15953. designer.SetDataSource("TBRNumber", txtTBRNumber);
  15954. designer.SetDataSource("JSESNumber", txtJSESNumber);
  15955. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  15956. var ws = designer.Workbook.Worksheets[1];
  15957. int Row = List_GC.Count;
  15958. int startIndex = 0;
  15959. int HideRows = 0;
  15960. Row = 0;
  15961. List<int> hideRowsList = new List<int>();
  15962. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  15963. #region A段left数据
  15964. var left = dto.leftInfo.Find(x => x.Type == "A");
  15965. if (left == null)
  15966. {
  15967. return Ok(jw);
  15968. }
  15969. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15970. if (leftBindData != null)
  15971. {
  15972. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15973. designer.SetDataSource("VisaRS", leftBindData.rs);
  15974. designer.SetDataSource("VisaXS", leftBindData.xs);
  15975. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15976. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15977. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15978. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15979. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15980. }
  15981. else
  15982. {
  15983. hideRowsList.Add(Row + startIndex + HideRows);
  15984. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15985. }
  15986. HideRows += 2;
  15987. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  15988. if (leftBindData != null)
  15989. {
  15990. designer.SetDataSource("BXDRCB", leftBindData.cb);
  15991. designer.SetDataSource("BXRS", leftBindData.rs);
  15992. designer.SetDataSource("BXXS", leftBindData.xs);
  15993. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15994. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15995. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15996. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15997. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15998. }
  15999. else
  16000. {
  16001. hideRowsList.Add(Row + startIndex + HideRows);
  16002. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16003. }
  16004. HideRows += 2;
  16005. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  16006. if (leftBindData != null)
  16007. {
  16008. designer.SetDataSource("HSDRCB", leftBindData.cb);
  16009. designer.SetDataSource("HSRS", leftBindData.rs);
  16010. designer.SetDataSource("HSXS", leftBindData.xs);
  16011. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16012. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16013. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16014. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16015. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16016. }
  16017. else
  16018. {
  16019. hideRowsList.Add(Row + startIndex + HideRows);
  16020. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16021. }
  16022. HideRows += 2;
  16023. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  16024. if (leftBindData != null)
  16025. {
  16026. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  16027. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  16028. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  16029. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16030. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16031. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16032. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16033. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16034. }
  16035. else
  16036. {
  16037. hideRowsList.Add(Row + startIndex + HideRows);
  16038. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16039. }
  16040. HideRows += 2;
  16041. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  16042. if (leftBindData != null)
  16043. {
  16044. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  16045. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  16046. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  16047. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16048. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16049. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16050. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16051. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16052. }
  16053. else
  16054. {
  16055. hideRowsList.Add(Row + startIndex + HideRows);
  16056. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16057. }
  16058. HideRows += 2;
  16059. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  16060. if (leftBindData != null)
  16061. {
  16062. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  16063. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  16064. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  16065. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16066. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16067. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16068. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16069. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16070. }
  16071. else
  16072. {
  16073. hideRowsList.Add(Row + startIndex + HideRows);
  16074. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16075. }
  16076. HideRows += 2;
  16077. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  16078. if (leftBindData != null)
  16079. {
  16080. ////TBR
  16081. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  16082. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  16083. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  16084. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16085. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16086. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16087. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16088. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16089. }
  16090. else
  16091. {
  16092. hideRowsList.Add(Row + startIndex + HideRows);
  16093. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16094. }
  16095. HideRows += 2;
  16096. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16097. if (leftBindData != null)
  16098. {
  16099. ////SGR
  16100. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  16101. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  16102. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  16103. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16104. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16105. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16106. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16107. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16108. }
  16109. else
  16110. {
  16111. hideRowsList.Add(Row + startIndex + HideRows);
  16112. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16113. }
  16114. HideRows += 2;
  16115. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16116. if (leftBindData != null)
  16117. {
  16118. ////JS/ES
  16119. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  16120. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  16121. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  16122. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16123. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16124. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16125. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16126. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16127. }
  16128. else
  16129. {
  16130. hideRowsList.Add(Row + startIndex + HideRows);
  16131. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16132. }
  16133. HideRows += 2;
  16134. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16135. if (leftBindData != null)
  16136. {
  16137. ////SUITE
  16138. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  16139. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  16140. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  16141. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16142. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16143. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16144. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16145. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16146. }
  16147. else
  16148. {
  16149. hideRowsList.Add(Row + startIndex + HideRows);
  16150. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16151. }
  16152. HideRows += 2;
  16153. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16154. if (leftBindData != null)
  16155. {
  16156. designer.SetDataSource("DJDRCB", leftBindData.cb);
  16157. designer.SetDataSource("DJRS", leftBindData.rs);
  16158. designer.SetDataSource("DJXS", leftBindData.xs);
  16159. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16160. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16161. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16162. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16163. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16164. }
  16165. else
  16166. {
  16167. hideRowsList.Add(Row + startIndex + HideRows);
  16168. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16169. }
  16170. HideRows += 2;
  16171. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16172. if (leftBindData != null)
  16173. {
  16174. designer.SetDataSource("HCPCB", leftBindData.cb);
  16175. designer.SetDataSource("HCPRS", leftBindData.rs);
  16176. designer.SetDataSource("HCPXS", leftBindData.xs);
  16177. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16178. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16179. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16180. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16181. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16182. }
  16183. else
  16184. {
  16185. hideRowsList.Add(Row + startIndex + HideRows);
  16186. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16187. }
  16188. HideRows += 2;
  16189. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16190. if (leftBindData != null)
  16191. {
  16192. designer.SetDataSource("CPCB", leftBindData.cb);
  16193. designer.SetDataSource("CPRS", leftBindData.rs);
  16194. designer.SetDataSource("CPXS", leftBindData.xs);
  16195. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16196. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16197. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16198. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16199. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16200. }
  16201. else
  16202. {
  16203. hideRowsList.Add(Row + startIndex + HideRows);
  16204. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16205. }
  16206. HideRows += 2;
  16207. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16208. if (leftBindData != null)
  16209. {
  16210. designer.SetDataSource("GWDRCD", leftBindData.cb);
  16211. designer.SetDataSource("GWRS", leftBindData.rs);
  16212. designer.SetDataSource("GWXS", leftBindData.xs);
  16213. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16214. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16215. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16216. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16217. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16218. }
  16219. else
  16220. {
  16221. hideRowsList.Add(Row + startIndex + HideRows);
  16222. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16223. }
  16224. HideRows += 2;
  16225. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16226. if (leftBindData != null)
  16227. {
  16228. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  16229. designer.SetDataSource("LYJRS", leftBindData.rs);
  16230. designer.SetDataSource("LYJXS", leftBindData.xs);
  16231. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16232. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16233. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16234. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16235. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16236. }
  16237. else
  16238. {
  16239. hideRowsList.Add(Row + startIndex + HideRows);
  16240. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16241. }
  16242. #endregion
  16243. #region A段Right信息
  16244. var right = dto.rightInfo.Find(x => x.Type == "A");
  16245. if (right == null)
  16246. {
  16247. return Ok(jw);
  16248. }
  16249. HideRows += 4;
  16250. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16251. if (rightBindData != null)
  16252. {
  16253. //经济舱 + 双人间 TBR
  16254. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  16255. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  16256. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16257. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  16258. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16259. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16260. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16261. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16262. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16263. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16264. }
  16265. else
  16266. {
  16267. hideRowsList.Add(Row + startIndex + HideRows);
  16268. }
  16269. HideRows += 2;
  16270. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16271. if (rightBindData != null)
  16272. {
  16273. //经济舱 + 单人间 SGR
  16274. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  16275. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  16276. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16277. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  16278. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16279. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16280. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16281. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16282. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16283. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16284. }
  16285. else
  16286. {
  16287. hideRowsList.Add(Row + startIndex + HideRows);
  16288. }
  16289. HideRows += 2;
  16290. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16291. if (rightBindData != null)
  16292. {
  16293. //公务舱 + 单人间 SGR
  16294. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  16295. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  16296. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16297. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  16298. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16299. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16300. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16301. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16302. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16303. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16304. }
  16305. else
  16306. {
  16307. hideRowsList.Add(Row + startIndex + HideRows);
  16308. }
  16309. HideRows += 2;
  16310. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16311. if (rightBindData != null)
  16312. {
  16313. //公务舱 + 小套房 JSES
  16314. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  16315. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  16316. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16317. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  16318. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16319. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16320. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16321. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16322. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16323. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16324. }
  16325. else
  16326. {
  16327. hideRowsList.Add(Row + startIndex + HideRows);
  16328. }
  16329. HideRows += 2;
  16330. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16331. if (rightBindData != null)
  16332. {
  16333. //公务舱 + 小套房 JSES
  16334. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  16335. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  16336. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16337. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  16338. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16339. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16340. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16341. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16342. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16343. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16344. }
  16345. else
  16346. {
  16347. hideRowsList.Add(Row + startIndex + HideRows);
  16348. }
  16349. HideRows += 2;
  16350. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16351. if (rightBindData != null)
  16352. {
  16353. //经济舱 + 大套房
  16354. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  16355. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  16356. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16357. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  16358. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16359. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16360. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16361. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16362. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16363. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16364. }
  16365. else
  16366. {
  16367. hideRowsList.Add(Row + startIndex + HideRows);
  16368. }
  16369. HideRows += 2;
  16370. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16371. if (rightBindData != null)
  16372. {
  16373. //头等舱 + 小套房 JSES
  16374. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  16375. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  16376. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16377. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  16378. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16379. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16380. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16381. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16382. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16383. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16384. }
  16385. else
  16386. {
  16387. hideRowsList.Add(Row + startIndex + HideRows);
  16388. }
  16389. HideRows += 2;
  16390. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16391. if (rightBindData != null)
  16392. {
  16393. //头等舱 + 大套房
  16394. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  16395. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  16396. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16397. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  16398. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16399. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16400. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16401. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16402. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16403. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16404. }
  16405. else
  16406. {
  16407. hideRowsList.Add(Row + startIndex + HideRows);
  16408. }
  16409. #endregion
  16410. #region B段标题清空
  16411. designer.SetDataSource("CostBDRCB", "");
  16412. designer.SetDataSource("CostBRS", "");
  16413. designer.SetDataSource("CostBXS", "");
  16414. designer.SetDataSource("CostBZCB", "");
  16415. designer.SetDataSource("CostBDRBJ", "");
  16416. designer.SetDataSource("CostBZBJ", "");
  16417. designer.SetDataSource("CostBDRLR", "");
  16418. designer.SetDataSource("CostBZLR", "");
  16419. designer.SetDataSource("CostBDRCBOM", "");
  16420. designer.SetDataSource("CostBRSOM", "");
  16421. designer.SetDataSource("CostBZCBOM", "");
  16422. designer.SetDataSource("CostBDRBJOM", "");
  16423. designer.SetDataSource("CostBZBJOM", "");
  16424. designer.SetDataSource("CostBDRLROM", "");
  16425. designer.SetDataSource("CostBZLROM", "");
  16426. #endregion
  16427. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  16428. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  16429. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  16430. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  16431. designer.SetDataSource("DJName", "地接(CNY)");
  16432. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  16433. designer.SetDataSource("CPName", "地接-船票(CNY)");
  16434. designer.SetDataSource("GWName", "公务(CNY)");
  16435. designer.SetDataSource("YQHName", "邀请函(CNY)");
  16436. designer.SetDataSource("LYJName", "零用金(CNY)");
  16437. designer.SetDataSource("HSName", "核酸检测(CNY)");
  16438. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  16439. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  16440. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  16441. designer.SetDataSource("BXName", "保险(CNY)");
  16442. designer.SetDataSource("VisaName", "签证(CNY)");
  16443. #region B段基本数据
  16444. if (dto.costType == "B")
  16445. {
  16446. left = dto.leftInfo.Find(x => x.Type == "B");
  16447. if (left == null)
  16448. {
  16449. return Ok(jw);
  16450. }
  16451. #region B段left数据
  16452. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  16453. if (leftBindData != null)
  16454. {
  16455. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  16456. designer.SetDataSource("BHSRS", leftBindData.rs);
  16457. designer.SetDataSource("BHSXS", leftBindData.xs);
  16458. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16459. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16460. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16461. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16462. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16463. }
  16464. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  16465. if (leftBindData != null)
  16466. {
  16467. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  16468. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  16469. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  16470. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16471. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16472. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16473. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16474. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16475. }
  16476. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  16477. if (leftBindData != null)
  16478. {
  16479. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  16480. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  16481. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  16482. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16483. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16484. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16485. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16486. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16487. }
  16488. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  16489. if (leftBindData != null)
  16490. {
  16491. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  16492. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  16493. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  16494. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16495. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16496. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16497. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16498. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16499. }
  16500. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16501. if (leftBindData != null)
  16502. {
  16503. designer.SetDataSource("BHCPCB", leftBindData.cb);
  16504. designer.SetDataSource("BHCPRS", leftBindData.rs);
  16505. designer.SetDataSource("BHCPXS", leftBindData.xs);
  16506. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16507. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16508. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16509. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16510. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16511. }
  16512. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16513. if (leftBindData != null)
  16514. {
  16515. designer.SetDataSource("BCPCB", leftBindData.cb);
  16516. designer.SetDataSource("BCPRS", leftBindData.rs);
  16517. designer.SetDataSource("BCPXS", leftBindData.xs);
  16518. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16519. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16520. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16521. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16522. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16523. }
  16524. //TBR
  16525. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  16526. if (leftBindData != null)
  16527. {
  16528. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  16529. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  16530. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  16531. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16532. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16533. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16534. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16535. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16536. }
  16537. //SGR
  16538. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16539. if (leftBindData != null)
  16540. {
  16541. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  16542. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  16543. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  16544. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16545. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16546. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16547. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16548. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16549. }
  16550. //JS/ES
  16551. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16552. if (leftBindData != null)
  16553. {
  16554. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  16555. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  16556. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  16557. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16558. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16559. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16560. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16561. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16562. }
  16563. //SUITE
  16564. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16565. if (leftBindData != null)
  16566. {
  16567. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  16568. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  16569. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  16570. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16571. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16572. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16573. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16574. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16575. }
  16576. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16577. if (leftBindData != null)
  16578. {
  16579. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  16580. designer.SetDataSource("BDJRS", leftBindData.rs);
  16581. designer.SetDataSource("BDJXS", leftBindData.xs);
  16582. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16583. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16584. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16585. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16586. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16587. }
  16588. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16589. if (leftBindData != null)
  16590. {
  16591. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  16592. designer.SetDataSource("BGWRS", leftBindData.rs);
  16593. designer.SetDataSource("BGWXS", leftBindData.xs);
  16594. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16595. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16596. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16597. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16598. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16599. }
  16600. #region 优化方案
  16601. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  16602. //excelBind.Add("零用金", new {
  16603. //cb="",
  16604. //rs="",
  16605. //xs ="",
  16606. //zcb = "",
  16607. //});
  16608. #endregion
  16609. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16610. if (leftBindData != null)
  16611. {
  16612. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  16613. designer.SetDataSource("BLYJRS", leftBindData.rs);
  16614. designer.SetDataSource("BLYJXS", leftBindData.xs);
  16615. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16616. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16617. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16618. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16619. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16620. }
  16621. #endregion
  16622. #region B段Right信息
  16623. right = dto.rightInfo.Find(x => x.Type == "B");
  16624. if (right == null)
  16625. {
  16626. return Ok(jw);
  16627. }
  16628. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16629. if (rightBindData != null)
  16630. {
  16631. //经济舱 + 双人间 TBR
  16632. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  16633. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  16634. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16635. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  16636. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16637. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16638. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16639. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16640. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16641. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16642. }
  16643. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16644. if (rightBindData != null)
  16645. {
  16646. //经济舱 + 单人间 SGR
  16647. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  16648. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  16649. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16650. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  16651. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16652. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16653. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16654. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16655. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16656. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16657. }
  16658. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16659. if (rightBindData != null)
  16660. {
  16661. //公务舱 + 单人间 SGR
  16662. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  16663. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  16664. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16665. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  16666. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16667. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16668. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16669. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16670. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16671. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16672. }
  16673. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16674. if (rightBindData != null)
  16675. {
  16676. //公务舱 + 小套房 JSES
  16677. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  16678. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  16679. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16680. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  16681. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16682. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16683. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16684. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16685. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16686. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16687. }
  16688. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16689. if (rightBindData != null)
  16690. {
  16691. //公务舱 + 小套房 JSES
  16692. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  16693. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  16694. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16695. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  16696. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16697. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16698. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16699. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16700. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16701. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16702. }
  16703. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16704. if (rightBindData != null)
  16705. {
  16706. //经济舱 + 大套房
  16707. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  16708. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  16709. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16710. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  16711. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16712. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16713. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16714. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16715. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16716. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16717. }
  16718. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16719. if (rightBindData != null)
  16720. {
  16721. //头等舱 + 小套房 JSES
  16722. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  16723. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  16724. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16725. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  16726. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16727. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16728. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16729. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16730. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16731. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16732. }
  16733. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16734. if (rightBindData != null)
  16735. {
  16736. //头等舱 + 大套房
  16737. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  16738. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  16739. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16740. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  16741. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16742. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16743. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16744. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16745. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16746. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16747. }
  16748. #endregion
  16749. #region 标题
  16750. designer.SetDataSource("CostBDRCB", "单人成本");
  16751. designer.SetDataSource("CostBRS", "人数");
  16752. designer.SetDataSource("CostBXS", "系数");
  16753. designer.SetDataSource("CostBZCB", "总成本");
  16754. designer.SetDataSource("CostBDRBJ", "单人报价");
  16755. designer.SetDataSource("CostBZBJ", "总报价");
  16756. designer.SetDataSource("CostBDRLR", "单人利润");
  16757. designer.SetDataSource("CostBZLR", "总利润");
  16758. designer.SetDataSource("CostBDRCBOM", "单人成本");
  16759. designer.SetDataSource("CostBRSOM", "人数");
  16760. designer.SetDataSource("CostBZCBOM", "总成本");
  16761. designer.SetDataSource("CostBDRBJOM", "单人报价");
  16762. designer.SetDataSource("CostBZBJOM", "总报价");
  16763. designer.SetDataSource("CostBDRLROM", "单人利润");
  16764. designer.SetDataSource("CostBZLROM", "总利润");
  16765. #endregion
  16766. }
  16767. #endregion
  16768. designer.SetDataSource("TzZCB2", TzZCB2);
  16769. designer.SetDataSource("TzZBJ2", TzZBJ2);
  16770. designer.SetDataSource("TzZLR2", TzZLR2);
  16771. string[] dataSourceKeys = new string[]
  16772. {
  16773. "VF",
  16774. "TGS",
  16775. "TGOF",
  16776. "TGM",
  16777. "TGA",
  16778. "TGTF",
  16779. "TGEF",
  16780. "CFM",
  16781. "CFOF",
  16782. "B",
  16783. "L",
  16784. "D",
  16785. "TBR",
  16786. "SGR",
  16787. "JSES",
  16788. "Suite",
  16789. "TV",
  16790. "1L",
  16791. "IF",
  16792. "EF",
  16793. "BRF",
  16794. "TE",
  16795. "TGT",
  16796. "DRVT",
  16797. "PC",
  16798. "TLF",
  16799. "ECT"
  16800. };
  16801. foreach (var item in dataSourceKeys)
  16802. {
  16803. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  16804. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  16805. var find = dto.titleModel.FirstOrDefault(expr);
  16806. if (find != null)
  16807. {
  16808. designer.SetDataSource(item, find.text);
  16809. }
  16810. else
  16811. {
  16812. designer.SetDataSource(item, 0);
  16813. }
  16814. }
  16815. designer.SetDataSource(dt);
  16816. //根据数据源处理生成报表内容
  16817. designer.Process();
  16818. designer.Workbook.Worksheets[0].Name = "费用明细";
  16819. designer.Workbook.Worksheets[1].Name = "费用总核算";
  16820. Worksheet sheet = designer.Workbook.Worksheets[0];
  16821. #region 隐藏舱位
  16822. var settingAir = new[]
  16823. {
  16824. new { key = "经济舱", index = 7 },
  16825. new { key = "公务舱", index = 19 },
  16826. new { key = "头等舱", index = 11 }
  16827. };
  16828. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  16829. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  16830. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  16831. .Select((c, s) => s.Name)
  16832. .ToList()
  16833. .GroupBy(x => x)
  16834. .Select(x => x.Key);
  16835. foreach (var item in settingAir)
  16836. {
  16837. if (!airType.Contains(item.key))
  16838. {
  16839. hideRowsList.Add(item.index);
  16840. }
  16841. }
  16842. #endregion
  16843. foreach (var Rowindex in hideRowsList)
  16844. {
  16845. ws.Cells.HideRows(Rowindex, 2);
  16846. }
  16847. ws = designer.Workbook.Worksheets[0];
  16848. foreach (var Column in hideColumnList)
  16849. {
  16850. ws.Cells.HideColumns(Column, 1);
  16851. }
  16852. byte[] bytes = null;
  16853. string strFileName = di.TeamName + "-团组-成本.xls";
  16854. using (MemoryStream stream = new MemoryStream())
  16855. {
  16856. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16857. bytes = stream.ToArray();
  16858. }
  16859. return Ok(JsonView(true, "", new
  16860. {
  16861. Data = bytes,
  16862. strFileName,
  16863. }));
  16864. }
  16865. /// <summary>
  16866. /// 导出客户报表
  16867. /// </summary>
  16868. /// <returns></returns>
  16869. [HttpPost]
  16870. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16871. {
  16872. var jw = JsonView(false);
  16873. if (dto.Diid == 0)
  16874. {
  16875. return Ok(JsonView(false, "请传递团组id"));
  16876. }
  16877. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16878. if (deleInfo.Code != 0)
  16879. {
  16880. return Ok(JsonView(false, "团组信息查询失败!"));
  16881. }
  16882. var di = deleInfo.Data as DelegationInfoWebView;
  16883. if (di == null)
  16884. {
  16885. return Ok(JsonView(false, "团组信息查询失败!"));
  16886. }
  16887. //文件名
  16888. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16889. //获取模板
  16890. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16891. //载入模板
  16892. Document doc = new Document(tmppath);
  16893. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16894. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16895. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16896. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16897. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16898. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16899. if (AParameter == null)
  16900. {
  16901. return Ok(JsonView(false, "系数不存在!"));
  16902. }
  16903. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  16904. , TzAirDesc, TzZCost;
  16905. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  16906. = TzAirDesc = TzZCost = string.Empty;
  16907. TzNumber = AParameter.CostTypenumber.ToString();
  16908. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  16909. CarGuides1 = dto.CarGuides1;
  16910. Meal = dto.Meal;
  16911. SubsidizedMeals = dto.SubsidizedMeals;
  16912. NightRepair = dto.NightRepair;
  16913. AttractionsTickets = dto.AttractionsTickets;
  16914. MiscellaneousFees = dto.MiscellaneousFees;
  16915. ATip = dto.ATip;
  16916. TzHotelDesc = "";
  16917. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  16918. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  16919. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  16920. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  16921. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  16922. TzAirDesc = "";
  16923. TzZCost = dto.TzZCost;
  16924. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  16925. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  16926. var index = 1;
  16927. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  16928. foreach (var item in TzHotelDescArr)
  16929. {
  16930. if (AinfoArr != null)
  16931. {
  16932. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16933. if (Ainfo != null)
  16934. {
  16935. if (int.Parse(Ainfo.rs) <= 0)
  16936. {
  16937. continue;
  16938. }
  16939. var hotelText = string.Empty;
  16940. switch (item)
  16941. {
  16942. case "SGR":
  16943. hotelText = "单人间";
  16944. break;
  16945. case "JSES":
  16946. hotelText = "小套房";
  16947. break;
  16948. case "SUITE":
  16949. hotelText = "套房";
  16950. break;
  16951. case "TBR":
  16952. hotelText = "双人间";
  16953. break;
  16954. }
  16955. if (item != "TBR")
  16956. {
  16957. 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";
  16958. }
  16959. else
  16960. {
  16961. 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";
  16962. }
  16963. index++;
  16964. }
  16965. }
  16966. }
  16967. index = 1;
  16968. foreach (var item in TzAirDescArr)
  16969. {
  16970. if (AinfoArr != null)
  16971. {
  16972. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16973. if (Ainfo != null)
  16974. {
  16975. if (int.Parse(Ainfo.rs) <= 0)
  16976. {
  16977. continue;
  16978. }
  16979. 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";
  16980. index++;
  16981. }
  16982. }
  16983. }
  16984. if (dto.costType == "B")
  16985. {
  16986. if (BParameter == null)
  16987. {
  16988. return Ok(JsonView(false, "B段系数不存在!"));
  16989. }
  16990. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16991. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16992. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16993. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16994. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16995. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16996. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16997. foreach (var item in TzHotelDescArr)
  16998. {
  16999. if (AinfoArr != null)
  17000. {
  17001. TzHotelDesc += "B段信息 \r\n";
  17002. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  17003. if (Ainfo != null)
  17004. {
  17005. if (int.Parse(Ainfo.rs) <= 0)
  17006. {
  17007. continue;
  17008. }
  17009. var hotelText = string.Empty;
  17010. switch (item)
  17011. {
  17012. case "SGR":
  17013. hotelText = "单人间";
  17014. break;
  17015. case "JSES":
  17016. hotelText = "小套房";
  17017. break;
  17018. case "SUITE":
  17019. hotelText = "套房";
  17020. break;
  17021. case "TBR":
  17022. hotelText = "双人间";
  17023. break;
  17024. }
  17025. if (item != "TBR")
  17026. {
  17027. 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";
  17028. }
  17029. else
  17030. {
  17031. 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";
  17032. }
  17033. index++;
  17034. }
  17035. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  17036. }
  17037. }
  17038. index = 1;
  17039. foreach (var item in TzAirDescArr)
  17040. {
  17041. if (AinfoArr != null)
  17042. {
  17043. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  17044. if (Ainfo != null)
  17045. {
  17046. if (int.Parse(Ainfo.rs) <= 0)
  17047. {
  17048. continue;
  17049. }
  17050. 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";
  17051. index++;
  17052. }
  17053. }
  17054. }
  17055. }
  17056. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  17057. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  17058. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  17059. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  17060. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  17061. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  17062. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  17063. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  17064. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  17065. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  17066. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  17067. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  17068. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  17069. DickeyValue.Add("Visa", Visa); // 签证单人报价
  17070. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  17071. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  17072. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  17073. DickeyValue.Add("TzZCost", TzZCost);
  17074. foreach (var key in DickeyValue.Keys)
  17075. {
  17076. if (doc.Range.Bookmarks[key] != null)
  17077. {
  17078. Bookmark mark = doc.Range.Bookmarks[key];
  17079. mark.Text = DickeyValue[key];
  17080. }
  17081. }
  17082. byte[] bytes = null;
  17083. string strFileName = di.TeamName + "-客户报价.doc";
  17084. using (MemoryStream stream = new MemoryStream())
  17085. {
  17086. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  17087. bytes = stream.ToArray();
  17088. }
  17089. return Ok(JsonView(true, "", new
  17090. {
  17091. Data = bytes,
  17092. strFileName,
  17093. }));
  17094. }
  17095. /// <summary>
  17096. /// 团组成本 各模块(酒店,地接,机票)成本提示
  17097. /// </summary>
  17098. /// <param name="dto"></param>
  17099. /// <returns></returns>
  17100. [HttpPost]
  17101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17102. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  17103. {
  17104. try
  17105. {
  17106. #region 参数验证
  17107. if (dto.DiId < 0)
  17108. {
  17109. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  17110. }
  17111. List<int> cTableIds = new List<int>() {
  17112. 76 ,//酒店预订
  17113. 77 ,//行程
  17114. 79 ,//车/导游地接
  17115. 80 ,//签证
  17116. 81 ,//邀请/公务活
  17117. 82 ,//团组客户保险
  17118. 85 ,//机票预订
  17119. 98 ,//其他款项
  17120. 285 ,//收款退还
  17121. 751 ,//酒店早餐
  17122. 1015 // 超支费用
  17123. };
  17124. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  17125. {
  17126. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  17127. }
  17128. #endregion
  17129. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  17130. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  17131. if (_GroupCostParameters.Count <= 0)
  17132. {
  17133. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  17134. }
  17135. if (_GroupCostParameters[0].IsShare == 0)
  17136. {
  17137. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  17138. }
  17139. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17140. //处理date为空问题
  17141. if (_GroupCosts.Count > 0)
  17142. {
  17143. for (int i = 0; i < _GroupCosts.Count; i++)
  17144. {
  17145. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  17146. {
  17147. if (i > 0)
  17148. {
  17149. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  17150. }
  17151. }
  17152. }
  17153. }
  17154. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  17155. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  17156. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  17157. string currCode = "";
  17158. #region currCode 验证
  17159. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  17160. if (isInt)
  17161. {
  17162. var currData = currDatas.Find(it => it.Id == intCurrency);
  17163. if (currData != null)
  17164. {
  17165. currCode = currData.Name;
  17166. }
  17167. }
  17168. else
  17169. {
  17170. currCode = _GroupCostParameters[0].Currency.Trim();
  17171. }
  17172. #endregion
  17173. //op,酒店单段模式存储
  17174. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  17175. {
  17176. CurrencyCode = currCode,
  17177. Rate = _GroupCostParameters[0].Rate,
  17178. CostType = _GroupCostParameters[0].CostType,
  17179. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  17180. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  17181. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  17182. };
  17183. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  17184. if (_GroupCostParameters.Count == 2)
  17185. {
  17186. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  17187. }
  17188. foreach (var item in _GroupCostParameters)
  17189. {
  17190. decimal _rate = 1;
  17191. decimal _rate1 = item.Rate;
  17192. decimal _scale = 1;
  17193. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  17194. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  17195. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  17196. //if (userInfo != null)
  17197. //{
  17198. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  17199. // {
  17200. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  17201. // {
  17202. // _scale = 1.00M;
  17203. // }
  17204. // }
  17205. //}
  17206. #endregion
  17207. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  17208. {
  17209. CurrencyCode = currCode,
  17210. Rate = _rate1,
  17211. CostType = item.CostType,
  17212. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  17213. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  17214. CostTypeNumber = item.CostTypenumber
  17215. };
  17216. if (_GroupCostParameters.Count > 1)
  17217. {
  17218. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  17219. }
  17220. else
  17221. {
  17222. modulePromptInfo.CostTypeNumber = item.LYJRS;
  17223. }
  17224. if (dto.CTable == 79)//
  17225. {
  17226. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  17227. modulePromptInfo.TotalCost = item.DJCB;
  17228. }
  17229. List<string> costTypes = new List<string>() { "A", "B" };
  17230. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  17231. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  17232. if (_GroupCostsDuplicates.Count() == 1)
  17233. {
  17234. _GroupCostsTypeData = _GroupCosts;
  17235. }
  17236. else
  17237. {
  17238. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  17239. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  17240. }
  17241. /*
  17242. * 76 酒店预订
  17243. * 77 行程
  17244. * 79 车/导游地接
  17245. * 80 签证
  17246. * 81 邀请/公务活动
  17247. * 82 团组客户保险
  17248. * 85 机票预订
  17249. * 98 其他款项
  17250. * 285 收款退还
  17251. * 751 酒店早餐
  17252. * 1015 超支费用
  17253. */
  17254. switch (dto.CTable)
  17255. {
  17256. case 76: // 酒店预订
  17257. _ModuleSubPromptInfo.AddRange(
  17258. _GroupCostsTypeData.Select(it => new
  17259. {
  17260. it.DAY,
  17261. it.Date,
  17262. it.ACCON,
  17263. it.ITIN,
  17264. it.SGR,
  17265. it.TBR,
  17266. it.JS_ES,
  17267. it.Suite
  17268. })
  17269. );
  17270. break;
  17271. case 79: // 车/导游地接
  17272. _ModuleSubPromptInfo.AddRange(
  17273. _GroupCostsTypeData.Select(it => new
  17274. {
  17275. Date = it.Date, //日期
  17276. CarFee = it.CarCost * _rate * _scale, //车费用
  17277. CarType = it.CarType, //车型
  17278. DriverFee = it.CFS * _rate * _scale, //司机工资
  17279. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  17280. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  17281. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  17282. GuideFee = it.TGS * _rate * _scale, //导游费用
  17283. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  17284. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  17285. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  17286. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  17287. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  17288. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  17289. Breakfast = it.B * _rate * _scale, //早餐费
  17290. Lunch = it.L * _rate * _scale, //午餐费
  17291. Dinner = it.D * _rate * _scale, //晚餐费
  17292. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  17293. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  17294. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  17295. TicketFee = it.EF * _rate * _scale, //门票费
  17296. TicketRemark = it.EFR, //门票费描述
  17297. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  17298. TravelSupplies = it.TE * _rate * _scale, //出行物资
  17299. SpentCash = it.PC * _rate * _scale, //零用金
  17300. LeadersFee = it.TLF * _rate * _scale, //领队费
  17301. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  17302. })
  17303. );
  17304. break;
  17305. case 85: // 机票
  17306. List<dynamic> datas = new List<dynamic>();
  17307. datas.Add(
  17308. new
  17309. {
  17310. AirType = "经济舱",
  17311. AirNum = item.JJCRS,
  17312. AirDRCB = item.JJCCB,
  17313. AirZCB = (item.JJCRS * item.JJCCB)
  17314. }
  17315. );
  17316. datas.Add(
  17317. new
  17318. {
  17319. AirType = "公务舱",
  17320. AirNum = item.GWCRS,
  17321. AirDRCB = item.GWCCB,
  17322. AirZCB = (item.GWCRS * item.GWCCB)
  17323. }
  17324. );
  17325. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17326. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  17327. modulePromptInfo.Data = new
  17328. {
  17329. airFeeData = datas,
  17330. airInitData = initDatas
  17331. };
  17332. _ModulePromptInfos.Add(modulePromptInfo);
  17333. break;
  17334. default:
  17335. break;
  17336. }
  17337. }
  17338. if (dto.CTable != 85)
  17339. {
  17340. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  17341. _ModulePromptInfos.Add(_ModulePromptInfo);
  17342. }
  17343. _view.ModulePromptInfos = _ModulePromptInfos;
  17344. return Ok(JsonView(true, "操作成功!", _view));
  17345. }
  17346. catch (Exception ex)
  17347. {
  17348. return Ok(JsonView(false, ex.Message));
  17349. }
  17350. }
  17351. /// <summary>
  17352. /// 根据黑屏代码重新生成行程
  17353. /// </summary>
  17354. /// <param name="dto"></param>
  17355. /// <returns></returns>
  17356. [HttpPost]
  17357. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  17358. {
  17359. var jw = JsonView(false, "Error");
  17360. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  17361. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  17362. .Select(x => new
  17363. {
  17364. x.Id,
  17365. x.Title
  17366. })
  17367. .ToList();
  17368. if (Create.Any())
  17369. {
  17370. jw.Msg = "获取成功!";
  17371. jw.Code = 200;
  17372. jw.Data = new
  17373. {
  17374. BlackCodeListSelect = Create,
  17375. blackCodeIsTrue = true
  17376. };
  17377. }
  17378. else
  17379. {
  17380. jw.Code = 400;
  17381. jw.Data = new
  17382. {
  17383. BlackCodeListSelect = Create,
  17384. blackCodeIsTrue = false,
  17385. };
  17386. }
  17387. return Ok(jw);
  17388. }
  17389. /// <summary>
  17390. /// 根据黑屏代码Id重新生成行程
  17391. /// </summary>
  17392. /// <param name="dto"></param>
  17393. /// <returns></returns>
  17394. [HttpPost]
  17395. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  17396. {
  17397. var jw = JsonView(false, "Error");
  17398. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  17399. if (result.Code == 0)
  17400. {
  17401. jw.Msg = "获取成功!";
  17402. jw.Code = 200;
  17403. jw.Data = new
  17404. {
  17405. groupCost = result.Data,
  17406. blackCodeIsTrue = true
  17407. };
  17408. }
  17409. else
  17410. {
  17411. jw.Code = 400;
  17412. jw.Data = new
  17413. {
  17414. groupCost = result.Data,
  17415. blackCodeIsTrue = false,
  17416. };
  17417. }
  17418. return Ok(jw);
  17419. }
  17420. /// <summary>
  17421. /// 成本获取OP历史车费用
  17422. /// </summary>
  17423. /// <param name="dto"></param>
  17424. /// <returns></returns>
  17425. [HttpPost]
  17426. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  17427. {
  17428. var jw = JsonView(false);
  17429. try
  17430. {
  17431. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  17432. //获取现有所有车的数据
  17433. if (!dto.Param.IsNullOrWhiteSpace())
  17434. {
  17435. string sql = $@"
  17436. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  17437. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  17438. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  17439. 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
  17440. AND gctggr.ServiceEndTime is not NULL
  17441. ORDER by gctggrc.id DESC
  17442. ";
  17443. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  17444. var numeberResult = await Task.Run(() =>
  17445. {
  17446. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  17447. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  17448. return numberArr;
  17449. });
  17450. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  17451. foreach (var item in numeberResult)
  17452. {
  17453. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  17454. {
  17455. Country = "数据异常!",
  17456. City = string.Empty,
  17457. };
  17458. item.Area = find.Country + " " + find.City;
  17459. }
  17460. dbResult.AddRange(numeberResult);
  17461. if (dto.Param.Contains("、"))
  17462. {
  17463. var sp = dto.Param.Split("、");
  17464. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17465. .Where(x =>
  17466. {
  17467. return System.Array.Exists(sp, e =>
  17468. {
  17469. bool where = false;
  17470. if (x.Area != null)
  17471. {
  17472. where = x.Area.Contains(e);
  17473. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17474. {
  17475. return false;
  17476. }
  17477. }
  17478. if (x.PriceName != null && !where)
  17479. {
  17480. where = x.PriceName.Contains(e);
  17481. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17482. {
  17483. return false;
  17484. }
  17485. }
  17486. return where;
  17487. });
  17488. }).ToList();
  17489. }
  17490. else
  17491. {
  17492. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17493. .Where(x =>
  17494. {
  17495. bool where = false;
  17496. if (x.Area != null)
  17497. {
  17498. where = x.Area.Contains(dto.Param);
  17499. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17500. {
  17501. return false;
  17502. }
  17503. }
  17504. if (x.PriceName != null && !where)
  17505. {
  17506. where = x.PriceName.Contains(dto.Param);
  17507. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17508. {
  17509. return false;
  17510. }
  17511. }
  17512. return where;
  17513. }
  17514. )
  17515. .ToList();
  17516. }
  17517. }
  17518. var view = dbResult.Select(x =>
  17519. {
  17520. decimal dp = 0.00M;
  17521. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  17522. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  17523. if (string.IsNullOrWhiteSpace(x.DatePrice))
  17524. {
  17525. if (startB && endB)
  17526. {
  17527. var timesp = endD.Subtract(startD);
  17528. if ((timesp.Days + 1) != 0)
  17529. {
  17530. dp = x.Price / (timesp.Days + 1);
  17531. }
  17532. }
  17533. }
  17534. else
  17535. {
  17536. dp = x.Price;
  17537. }
  17538. return new
  17539. {
  17540. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  17541. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  17542. x.Area,
  17543. x.id,
  17544. price = x.Price.ToString("F2"),
  17545. x.PriceName,
  17546. x.PriceContent,
  17547. x.TeamName,
  17548. x.DatePrice,
  17549. dayPrice = dp.ToString("F2"),
  17550. };
  17551. }).OrderByDescending(x => x.id).ToList();
  17552. jw = JsonView(true, "获取成功!", view);
  17553. }
  17554. catch (Exception e)
  17555. {
  17556. jw = JsonView(false, e.Message);
  17557. }
  17558. return Ok(jw);
  17559. }
  17560. [HttpPost]
  17561. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  17562. {
  17563. var jw = JsonView(true);
  17564. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  17565. #region SQL语句
  17566. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  17567. //{
  17568. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17569. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17570. // WHEN COUNT(*) >= 0 THEN 'True'
  17571. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17572. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  17573. // ")
  17574. // .ToList();
  17575. //}
  17576. //else
  17577. //{
  17578. // string likeKey = string.Empty;
  17579. // foreach (var item in dto.Keyword)
  17580. // {
  17581. // likeKey += "%" + item;
  17582. // }
  17583. // likeKey += "%";
  17584. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17585. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17586. // WHEN COUNT(*) >= 0 THEN 'True'
  17587. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17588. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  17589. // ")
  17590. // .ToList();
  17591. //}
  17592. #endregion
  17593. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  17594. {
  17595. @KeyWord = dto.Keyword
  17596. });
  17597. if (table != null && table.Rows.Count > 0)
  17598. {
  17599. foreach (DataRow row in table.Rows)
  17600. {
  17601. matches.Add(new DelegationInfoAndIsTrueView
  17602. {
  17603. Id = row.Field<int>("Id"),
  17604. GroupName = row.Field<string>("GroupName"),
  17605. isTrue = row.Field<string>("isTrue")
  17606. });
  17607. }
  17608. }
  17609. if (matches.Any())
  17610. {
  17611. jw.Data = matches;
  17612. }
  17613. else
  17614. {
  17615. jw.Code = 201;
  17616. jw.Msg = "empty list";
  17617. jw.Data = new List<string>(1);
  17618. }
  17619. return Ok(jw);
  17620. }
  17621. /// <summary>
  17622. /// 报价Word下载
  17623. /// </summary>
  17624. /// <param name="dto"></param>
  17625. /// <returns></returns>
  17626. [HttpPost]
  17627. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  17628. {
  17629. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17630. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17631. if (di == null)
  17632. {
  17633. return Ok(JsonView(false, "团组不存在!"));
  17634. }
  17635. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17636. if (mainPrice == null || mainPrice.IsShare == 0)
  17637. {
  17638. return Ok(JsonView(false, "团组成本不存在!"));
  17639. }
  17640. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17641. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17642. if (costTypeHotelNumbers == null)
  17643. {
  17644. return Ok(JsonView(false, "团组成本不存在!"));
  17645. }
  17646. //文件名
  17647. string strFileName = di.TeamName + "-收款账单.doc";
  17648. //获取模板
  17649. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  17650. //载入模板
  17651. Document doc = new Document(tmppath);
  17652. decimal allPrice = 0.00M;
  17653. string itemStr = string.Empty;
  17654. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  17655. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  17656. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  17657. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  17658. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  17659. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  17660. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  17661. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  17662. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  17663. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  17664. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17665. {
  17666. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17667. ("BXRS", "BXCB", "BXXS", "bx"),
  17668. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17669. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17670. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  17671. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  17672. ("CPRS", "CPCB", "CPXS", "cp"),
  17673. ("HSRS", "HSCB", "HSXS", "hsjc"),
  17674. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  17675. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  17676. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  17677. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  17678. ("DJRS", "DJCB", "DJXS", "dj"),
  17679. ("GWRS", "GWCB", "GWXS", "gw"),
  17680. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  17681. };
  17682. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17683. var rightSum = 0.00M;
  17684. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17685. {
  17686. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17687. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17688. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17689. if (prefix == "tbr")
  17690. {
  17691. rsValue *= 2;
  17692. cbValue /= 2;
  17693. }
  17694. if (OtherCostPropertyBJ.Contains(prefix))
  17695. {
  17696. rightSum += cbValue * xsValue;
  17697. }
  17698. }
  17699. var hotelRooms = new Dictionary<string, int>
  17700. {
  17701. { "SGR", costTypeHotelNumbers.SGR },
  17702. { "TBR", costTypeHotelNumbers.TBR },
  17703. { "JSES", costTypeHotelNumbers.JSES },
  17704. { "SUITE", costTypeHotelNumbers.SUITE }
  17705. };
  17706. var flights = new Dictionary<string, int>
  17707. {
  17708. { "经济舱", mainPrice.JJCRS },
  17709. { "公务舱", mainPrice.GWCRS },
  17710. { "头等舱", mainPrice.TDCRS }
  17711. };
  17712. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17713. {
  17714. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17715. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17716. { "头等舱", new[] { "SUITE", "JSES" } }
  17717. };
  17718. var result = new Dictionary<string, int>();
  17719. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  17720. foreach (var flight in flights.Keys)
  17721. {
  17722. // 获取当前舱位的匹配规则
  17723. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17724. {
  17725. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17726. }
  17727. }
  17728. #region right计算
  17729. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17730. {
  17731. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17732. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17733. airHotelPriceList.Add(new
  17734. AirHotelPrice
  17735. {
  17736. Name = "经济舱TBR",
  17737. Price = rightSum + air + hotel,
  17738. Count = result["经济舱TBR"] * 2
  17739. });
  17740. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17741. }
  17742. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17743. {
  17744. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17745. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17746. airHotelPriceList.Add(new
  17747. AirHotelPrice
  17748. {
  17749. Name = "经济舱SGR",
  17750. Price = rightSum + air + hotel,
  17751. Count = result["经济舱SGR"]
  17752. });
  17753. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17754. }
  17755. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17756. {
  17757. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17758. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17759. airHotelPriceList.Add(new
  17760. AirHotelPrice
  17761. {
  17762. Name = "公务舱SGR",
  17763. Price = rightSum + air + hotel,
  17764. Count = result["公务舱SGR"]
  17765. });
  17766. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17767. }
  17768. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17769. {
  17770. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17771. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17772. airHotelPriceList.Add(new
  17773. AirHotelPrice
  17774. {
  17775. Name = "公务舱JSES",
  17776. Price = rightSum + air + hotel,
  17777. Count = result["公务舱JSES"]
  17778. });
  17779. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17780. }
  17781. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17782. {
  17783. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17784. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17785. airHotelPriceList.Add(new
  17786. AirHotelPrice
  17787. {
  17788. Name = "公务舱SUITE",
  17789. Price = rightSum + air + hotel,
  17790. Count = result["公务舱SUITE"]
  17791. });
  17792. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17793. }
  17794. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17795. {
  17796. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17797. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17798. airHotelPriceList.Add(new
  17799. AirHotelPrice
  17800. {
  17801. Name = "经济舱SUITE",
  17802. Price = rightSum + air + hotel,
  17803. Count = result["经济舱SUITE"]
  17804. });
  17805. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17806. }
  17807. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17808. {
  17809. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17810. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17811. airHotelPriceList.Add(new
  17812. AirHotelPrice
  17813. {
  17814. Name = "头等舱JSES",
  17815. Price = rightSum + air + hotel,
  17816. Count = result["头等舱JSES"]
  17817. });
  17818. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17819. }
  17820. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17821. {
  17822. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17823. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17824. airHotelPriceList.Add(new
  17825. AirHotelPrice
  17826. {
  17827. Name = "头等舱SUITE",
  17828. Price = rightSum + air + hotel,
  17829. Count = result["头等舱SUITE"]
  17830. });
  17831. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17832. }
  17833. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17834. {
  17835. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17836. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17837. airHotelPriceList.Add(new
  17838. AirHotelPrice
  17839. {
  17840. Name = "经济舱JSES",
  17841. Price = rightSum + air + hotel,
  17842. Count = result["经济舱JSES"]
  17843. });
  17844. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17845. }
  17846. #endregion
  17847. foreach (var item in airSouer.Keys)
  17848. {
  17849. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17850. if (find != null && find.Count > 0)
  17851. {
  17852. if (item.Contains("TBR"))
  17853. {
  17854. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17855. }
  17856. else
  17857. {
  17858. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17859. }
  17860. }
  17861. }
  17862. #region 替换Word模板书签内容
  17863. Dictionary<string, string> marks = new Dictionary<string, string>();
  17864. marks.Add("To", di.ClientUnit);//付款方
  17865. marks.Add("ToTel", di.TellPhone);//付款方电话
  17866. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17867. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17868. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17869. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17870. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17871. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17872. marks.Add("PayItemContent", itemStr);//详细信息
  17873. marks.Add("Total", allPrice.ToString("F2"));//合计
  17874. #endregion
  17875. foreach (var item in marks.Keys)
  17876. {
  17877. if (doc.Range.Bookmarks[item] != null)
  17878. {
  17879. Bookmark mark = doc.Range.Bookmarks[item];
  17880. mark.Text = marks[item];
  17881. }
  17882. }
  17883. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17884. doc.Save(savePaht);
  17885. var jw = new JsonView();
  17886. jw.Msg = "生成成功!";
  17887. jw.Code = 200;
  17888. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17889. return Ok(jw);
  17890. }
  17891. /// <summary>
  17892. /// 详细报价费用Excel下载
  17893. /// </summary>
  17894. /// <param name="dto"></param>
  17895. /// <returns></returns>
  17896. [HttpPost]
  17897. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17898. {
  17899. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17900. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17901. if (di == null)
  17902. {
  17903. return Ok(JsonView(false, "团组不存在!"));
  17904. }
  17905. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17906. if (mainPrice == null || mainPrice.IsShare == 0)
  17907. {
  17908. return Ok(JsonView(false, "团组成本不存在!"));
  17909. }
  17910. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17911. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17912. if (costTypeHotelNumbers == null)
  17913. {
  17914. return Ok(JsonView(false, "团组成本不存在!"));
  17915. }
  17916. WorkbookDesigner designer = new WorkbookDesigner();
  17917. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  17918. List<int> hideRowsList = new List<int>();
  17919. int conterStartIndex = 3;
  17920. int rowIndex = conterStartIndex;
  17921. designer.SetDataSource("GroupName", di.TeamName);
  17922. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17923. {
  17924. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17925. ("BXRS", "BXCB", "BXXS", "bx"),
  17926. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17927. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17928. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  17929. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  17930. ("CPRS", "CPCB", "CPXS", "cp") ,
  17931. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  17932. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  17933. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  17934. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  17935. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  17936. ("DJRS", "DJCB", "DJXS", "dj") ,
  17937. ("GWRS", "GWCB", "GWXS", "gw") ,
  17938. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  17939. };
  17940. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17941. var rightSum = 0.00M;
  17942. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17943. {
  17944. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17945. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17946. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17947. if (prefix == "tbr")
  17948. {
  17949. rsValue *= 2;
  17950. cbValue /= 2;
  17951. }
  17952. if (OtherCostPropertyBJ.Contains(prefix))
  17953. {
  17954. rightSum += cbValue * xsValue;
  17955. }
  17956. if (rsValue == 0)
  17957. {
  17958. hideRowsList.Add(rowIndex);
  17959. }
  17960. else
  17961. {
  17962. designer.SetDataSource($"{prefix}rs", rsValue);
  17963. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  17964. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17965. }
  17966. rowIndex += 2;
  17967. }
  17968. var hotelRooms = new Dictionary<string, int>
  17969. {
  17970. { "SGR", costTypeHotelNumbers.SGR },
  17971. { "TBR", costTypeHotelNumbers.TBR },
  17972. { "JSES", costTypeHotelNumbers.JSES },
  17973. { "SUITE", costTypeHotelNumbers.SUITE }
  17974. };
  17975. var flights = new Dictionary<string, int>
  17976. {
  17977. { "经济舱", mainPrice.JJCRS },
  17978. { "公务舱", mainPrice.GWCRS },
  17979. { "头等舱", mainPrice.TDCRS }
  17980. };
  17981. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17982. {
  17983. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17984. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17985. { "头等舱", new[] { "SUITE", "JSES" } }
  17986. };
  17987. var result = new Dictionary<string, int>();
  17988. foreach (var flight in flights.Keys)
  17989. {
  17990. // 获取当前舱位的匹配规则
  17991. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17992. {
  17993. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17994. }
  17995. }
  17996. var allPrice = 0.00M;
  17997. #region right计算
  17998. int airRowIndex = 35;
  17999. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  18000. {
  18001. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18002. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  18003. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  18004. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  18005. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  18006. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  18007. }
  18008. else
  18009. {
  18010. hideRowsList.Add(airRowIndex);
  18011. }
  18012. airRowIndex += 2;
  18013. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  18014. {
  18015. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18016. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  18017. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  18018. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  18019. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  18020. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  18021. }
  18022. else
  18023. {
  18024. hideRowsList.Add(airRowIndex);
  18025. }
  18026. airRowIndex += 2;
  18027. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  18028. {
  18029. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18030. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  18031. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  18032. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  18033. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  18034. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  18035. }
  18036. else
  18037. {
  18038. hideRowsList.Add(airRowIndex);
  18039. }
  18040. airRowIndex += 2;
  18041. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  18042. {
  18043. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18044. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18045. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  18046. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  18047. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  18048. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  18049. }
  18050. else
  18051. {
  18052. hideRowsList.Add(airRowIndex);
  18053. }
  18054. airRowIndex += 2;
  18055. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  18056. {
  18057. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18058. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18059. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  18060. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  18061. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  18062. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  18063. }
  18064. else
  18065. {
  18066. hideRowsList.Add(airRowIndex);
  18067. }
  18068. airRowIndex += 2;
  18069. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  18070. {
  18071. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18072. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18073. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  18074. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  18075. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  18076. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  18077. }
  18078. else
  18079. {
  18080. hideRowsList.Add(airRowIndex);
  18081. }
  18082. airRowIndex += 2;
  18083. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  18084. {
  18085. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18086. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18087. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  18088. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  18089. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  18090. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  18091. }
  18092. else
  18093. {
  18094. hideRowsList.Add(airRowIndex);
  18095. }
  18096. airRowIndex += 2;
  18097. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  18098. {
  18099. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18100. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18101. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  18102. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  18103. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  18104. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  18105. }
  18106. else
  18107. {
  18108. hideRowsList.Add(airRowIndex);
  18109. }
  18110. airRowIndex += 2;
  18111. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  18112. {
  18113. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18114. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18115. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  18116. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  18117. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  18118. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  18119. }
  18120. else
  18121. {
  18122. hideRowsList.Add(airRowIndex);
  18123. }
  18124. #endregion
  18125. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  18126. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  18127. var ws = designer.Workbook.Worksheets[0];
  18128. foreach (var Rowindex in hideRowsList)
  18129. {
  18130. ws.Cells.HideRows(Rowindex, 2);
  18131. }
  18132. designer.Process();
  18133. designer.Workbook.Save(savePaht);
  18134. return Ok(JsonView(true, "生成成功!", new
  18135. {
  18136. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  18137. }));
  18138. }
  18139. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  18140. {
  18141. foreach (var roomType in roomTypes)
  18142. {
  18143. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  18144. {
  18145. hotelRooms[roomType]--;
  18146. flights[flightType]--;
  18147. if (roomType == "TBR")
  18148. {
  18149. flights[flightType]--; // 双人间在减少1
  18150. }
  18151. string key = flightType + roomType;
  18152. if (result.Keys.Contains(key))
  18153. {
  18154. result[key]++;
  18155. }
  18156. else
  18157. {
  18158. result.Add(key, 1);
  18159. }
  18160. }
  18161. }
  18162. }
  18163. private class AirHotelPrice
  18164. {
  18165. public string Name { get; set; }
  18166. public decimal Price { get; set; }
  18167. public int Count { get; set; }
  18168. }
  18169. /// <summary>
  18170. /// 团组系数设置
  18171. /// </summary>
  18172. /// <param name="dto"></param>
  18173. /// <returns></returns>
  18174. [HttpPost]
  18175. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  18176. {
  18177. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  18178. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  18179. if (di == null)
  18180. {
  18181. return Ok(JsonView(false, "团组不存在!"));
  18182. }
  18183. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  18184. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  18185. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  18186. // FirstAsync(firstExpression.ToExpression());
  18187. #region JSON
  18188. string hcpJson = @"
  18189. [
  18190. {
  18191. ""min"": 1,
  18192. ""max"": 500,
  18193. ""value"": 1.50
  18194. },
  18195. {
  18196. ""min"": 501,
  18197. ""max"": 1000,
  18198. ""value"": 1.40
  18199. },
  18200. {
  18201. ""min"": 1001,
  18202. ""max"": 2000,
  18203. ""value"": 1.35
  18204. }
  18205. ]";
  18206. #endregion
  18207. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  18208. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  18209. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  18210. .ToList();
  18211. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  18212. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  18213. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  18214. // new List<(Predicate<decimal>, decimal)>()
  18215. // {
  18216. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  18217. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  18218. // }
  18219. // ));
  18220. #region 签证系数
  18221. var visaXS = 0.00M;
  18222. switch (dto.VisaCB)
  18223. {
  18224. case decimal n when (n > 1 && n < 500):
  18225. switch (dto.VisaRS)
  18226. {
  18227. case 2 or 3:
  18228. visaXS = 1.35M;
  18229. break;
  18230. case 4 or 5:
  18231. visaXS = 1.30M;
  18232. break;
  18233. case 6 or 7:
  18234. visaXS = 1.25M;
  18235. break;
  18236. case 8 or 9 or 10:
  18237. visaXS = 1.20M;
  18238. break;
  18239. case > 10:
  18240. visaXS = 1.15M;
  18241. break;
  18242. default:
  18243. visaXS = 0.00M;
  18244. break;
  18245. }
  18246. break;
  18247. case decimal n when (n >= 500 && n < 1000):
  18248. switch (dto.VisaRS)
  18249. {
  18250. case 2 or 3 or 4:
  18251. visaXS = 1.30M;
  18252. break;
  18253. case 5 or 6 or 7 or 8:
  18254. visaXS = 1.25M;
  18255. break;
  18256. case 9 or 10:
  18257. visaXS = 1.20M;
  18258. break;
  18259. case > 10:
  18260. visaXS = 1.15M;
  18261. break;
  18262. default:
  18263. visaXS = 0.00M;
  18264. break;
  18265. }
  18266. break;
  18267. default:
  18268. switch (dto.VisaRS)
  18269. {
  18270. case 2 or 3 or 4:
  18271. visaXS = 1.30M;
  18272. break;
  18273. case 5 or 6 or 7 or 8:
  18274. visaXS = 1.25M;
  18275. break;
  18276. case 9 or 10:
  18277. visaXS = 1.20M;
  18278. break;
  18279. case > 10:
  18280. visaXS = 1.15M;
  18281. break;
  18282. default:
  18283. visaXS = 0.00M;
  18284. break;
  18285. }
  18286. break;
  18287. }
  18288. #endregion
  18289. #region 火车系数
  18290. var hcpXS = 0.00M;
  18291. foreach (var (condition, result) in hcpSwitchDictionary)
  18292. {
  18293. if (condition(dto.HCPCB))
  18294. {
  18295. hcpXS = result;
  18296. break;
  18297. }
  18298. }
  18299. #endregion
  18300. #region 机票系数
  18301. #region 经济舱系数
  18302. var jjcXS = 0.00M;
  18303. switch (dto.JJCCB)
  18304. {
  18305. case decimal x when (x >= 1000 && x <= 3000):
  18306. jjcXS = 2.6M;
  18307. break;
  18308. case decimal x when (x >= 3001 && x <= 8000):
  18309. jjcXS = 2.3M;
  18310. break;
  18311. case decimal x when (x >= 8001 && x <= 15000):
  18312. jjcXS = 2.1M;
  18313. break;
  18314. case decimal x when (x >= 15001 && x <= 30000):
  18315. jjcXS = 1.95M;
  18316. break;
  18317. case > 30000:
  18318. jjcXS = 1.8M;
  18319. break;
  18320. default:
  18321. break;
  18322. }
  18323. #endregion
  18324. #region 公务舱系数
  18325. var gwcXS = 0.00M;
  18326. switch (dto.GWCCB)
  18327. {
  18328. case decimal x when (x >= 1000 && x <= 3000):
  18329. gwcXS = 2.5M;
  18330. break;
  18331. case decimal x when (x >= 3001 && x <= 8000):
  18332. gwcXS = 2.2M;
  18333. break;
  18334. case decimal x when (x >= 8001 && x <= 15000):
  18335. gwcXS = 2.0M;
  18336. break;
  18337. case decimal x when (x >= 15001 && x <= 30000):
  18338. gwcXS = 1.85M;
  18339. break;
  18340. case > 30000:
  18341. gwcXS = 1.7M;
  18342. break;
  18343. default:
  18344. break;
  18345. }
  18346. #endregion
  18347. #region 头等舱系数
  18348. var tdcXS = 0.00M;
  18349. switch (dto.TDCCB)
  18350. {
  18351. case > 70000:
  18352. tdcXS = 1.5M;
  18353. break;
  18354. default:
  18355. tdcXS = 1.9M;
  18356. break;
  18357. }
  18358. #endregion
  18359. #endregion
  18360. #region 酒店系数
  18361. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  18362. {
  18363. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  18364. {1.5M, new List<string>(){"越南社会主义共和国",
  18365. "老挝",
  18366. "柬埔寨",
  18367. "泰国",
  18368. "缅甸",
  18369. "马来西亚",
  18370. //"新加坡",
  18371. "文莱达鲁萨兰",
  18372. "印度尼西亚",
  18373. "东帝汶"}},
  18374. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  18375. };
  18376. #region SGR
  18377. var sgrXS = 1.25M;
  18378. #endregion
  18379. #region TBR
  18380. var tbrXS = 1.25M;
  18381. #endregion
  18382. #region JSES
  18383. var jsesXS = 1.25M;
  18384. #endregion
  18385. #region SUITE
  18386. var suiteXS = 1.25M;
  18387. #endregion
  18388. var countryArr = di.VisitCountry.Split("|");
  18389. foreach (var item in dic)
  18390. {
  18391. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  18392. .Count();
  18393. if (extsisCount > 0)
  18394. {
  18395. jsesXS = item.Key;
  18396. sgrXS = item.Key;
  18397. tbrXS = item.Key;
  18398. suiteXS = item.Key;
  18399. }
  18400. }
  18401. #endregion
  18402. #region 地接系数
  18403. var djXS = 0.00M;
  18404. switch (dto.DJRS)
  18405. {
  18406. case 2 or 3:
  18407. djXS = 2.65M;
  18408. break;
  18409. case 4:
  18410. djXS = 2.6M;
  18411. break;
  18412. case 5 or 6:
  18413. djXS = 2.5M;
  18414. break;
  18415. case 7 or 8:
  18416. djXS = 2.4M;
  18417. break;
  18418. case 9 or 10:
  18419. djXS = 2.3M;
  18420. break;
  18421. case 11:
  18422. djXS = 2.2M;
  18423. break;
  18424. case 12:
  18425. djXS = 2.1M;
  18426. break;
  18427. case 13 or 14:
  18428. djXS = 2M;
  18429. break;
  18430. case 15:
  18431. djXS = 1.9M;
  18432. break;
  18433. case 16 or 17 or 18:
  18434. djXS = 1.8M;
  18435. break;
  18436. case 19 or 20:
  18437. djXS = 1.7M;
  18438. break;
  18439. }
  18440. #endregion
  18441. #region 零用金系数
  18442. var lyjXS = 0.00M;
  18443. switch (dto.LYJRS)
  18444. {
  18445. case 2:
  18446. lyjXS = 1.25M;
  18447. break;
  18448. case 3 or 4 or 5:
  18449. lyjXS = 1.2M;
  18450. break;
  18451. case int number when (number > 5 && number < 10):
  18452. lyjXS = 1.15M;
  18453. break;
  18454. case > 10:
  18455. lyjXS = 1.1M;
  18456. break;
  18457. default:
  18458. break;
  18459. }
  18460. #endregion
  18461. return Ok(JsonView(true, "查询成功", new ArrayList()
  18462. {
  18463. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  18464. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  18465. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  18466. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  18467. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  18468. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  18469. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  18470. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  18471. new { label = "地接系数", value = djXS, key = "djXS" },
  18472. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  18473. new { label = "公务系数", value = 2M, key = "gwXS" }
  18474. }));
  18475. }
  18476. #endregion
  18477. #region 酒店预订 New 2023-12-28 17:45
  18478. /// <summary>
  18479. /// 酒店预订
  18480. /// 酒店费用列表 根据团组Id查询
  18481. /// </summary>
  18482. /// <param name="_dto"></param>
  18483. /// <returns></returns>
  18484. [HttpPost]
  18485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18486. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  18487. {
  18488. #region 参数验证
  18489. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18490. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18491. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18492. #region 团组操作权限验证 76 酒店预定模块
  18493. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18494. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18495. #endregion
  18496. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18497. #region 页面操作权限验证
  18498. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18499. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18500. #endregion
  18501. #endregion
  18502. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  18503. }
  18504. /// <summary>
  18505. /// 酒店预订
  18506. /// 基础数据
  18507. /// </summary>
  18508. /// <param name="_dto"></param>
  18509. /// <returns></returns>
  18510. [HttpPost]
  18511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18512. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  18513. {
  18514. #region 参数验证
  18515. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18516. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18517. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18518. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18519. #region 页面操作权限验证
  18520. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18521. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18522. #endregion
  18523. #region 团组操作权限验证 76 酒店预定模块
  18524. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18525. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18526. #endregion
  18527. #endregion
  18528. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  18529. }
  18530. /// <summary>
  18531. /// 酒店预订
  18532. /// 创建 入住卷号码
  18533. /// </summary>
  18534. /// <param name="_dto"></param>
  18535. /// <returns></returns>
  18536. [HttpPost]
  18537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18538. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  18539. {
  18540. #region 参数验证
  18541. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18542. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18543. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18544. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18545. #region 页面操作权限验证
  18546. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18547. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18548. #endregion
  18549. #region 团组操作权限验证 76 酒店预定模块
  18550. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18551. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18552. #endregion
  18553. #endregion
  18554. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  18555. if (data.Code != 0)
  18556. {
  18557. return Ok(JsonView(false, data.Msg));
  18558. }
  18559. return Ok(JsonView(true, data.Msg, data.Data));
  18560. }
  18561. /// <summary>
  18562. /// 酒店预订
  18563. /// 详情
  18564. /// </summary>
  18565. /// <param name="_dto"></param>
  18566. /// <returns></returns>
  18567. [HttpPost]
  18568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18569. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  18570. {
  18571. #region 参数验证
  18572. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  18573. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18574. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  18575. #region 团组操作权限验证 76 酒店预定模块
  18576. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18577. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18578. #endregion
  18579. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18580. #region 页面操作权限验证
  18581. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18582. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18583. #endregion
  18584. #endregion
  18585. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  18586. }
  18587. /// <summary>
  18588. /// 酒店预订
  18589. /// Add Or Edit
  18590. /// </summary>
  18591. /// <param name="_dto"></param>
  18592. /// <returns></returns>
  18593. [HttpPost]
  18594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18595. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  18596. {
  18597. #region 参数验证
  18598. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18599. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18600. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18601. #region 团组操作权限验证 76 酒店预定模块
  18602. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18603. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18604. #endregion
  18605. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18606. #region 页面操作权限验证
  18607. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18608. if (_dto.Id == 0) // Add
  18609. {
  18610. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18611. }
  18612. else if (_dto.Id > 1) // Edit
  18613. {
  18614. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18615. }
  18616. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  18617. #endregion
  18618. #endregion
  18619. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  18620. if (_view.Code != 200)
  18621. {
  18622. return Ok(_view);
  18623. }
  18624. #region 成本无酒店价格数据进入超支
  18625. _sqlSugar.BeginTran();
  18626. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  18627. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  18628. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  18629. for (int i = 0; i < groupCost.Count; i++)
  18630. {
  18631. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  18632. {
  18633. groupCost[i].Date = groupCost[i - 1].Date;
  18634. }
  18635. }
  18636. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  18637. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  18638. List<Fin_GroupExtraCostDto_OP>();
  18639. if (start_Bool && end_Bool)
  18640. {
  18641. while (start_Time < end_Time)
  18642. {
  18643. foreach (var item in groupCost_Grp)
  18644. {
  18645. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  18646. {
  18647. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  18648. {
  18649. extraCostList.Add(new
  18650. Fin_GroupExtraCostDto_OP
  18651. {
  18652. Area = _dto.AreaId,
  18653. coefficient = 1.5M,
  18654. createUser = _dto.UserId,
  18655. currency = _dto.CardPriceCurrency,
  18656. diId = _dto.DiId,
  18657. ManagerConfirm = 0,
  18658. SupervisorConfirm = 0,
  18659. SYsupervisorConfirm = 0,
  18660. editType = 1,
  18661. PortType = 1,
  18662. price = _dto.CardPrice,
  18663. PriceCount = 1,
  18664. priceType = 1027,
  18665. priceDetailType = 1044,
  18666. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  18667. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  18668. });
  18669. }
  18670. }
  18671. }
  18672. start_Time = start_Time.AddDays(1);
  18673. }
  18674. }
  18675. if (extraCostList.Any())
  18676. {
  18677. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  18678. }
  18679. _sqlSugar.CommitTran();
  18680. #endregion
  18681. #region 应用推送
  18682. try
  18683. {
  18684. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18685. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18686. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18687. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18688. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18689. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18690. var diId = _dto.DiId;
  18691. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18692. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18693. #region 操作记录
  18694. var opInfo = new Crm_TableOperationRecord()
  18695. {
  18696. TableName = "Grp_HotelReservations",
  18697. PortType = _dto.PortType,
  18698. DataId = hotelId,
  18699. CreateUserId = _dto.UserId
  18700. };
  18701. //var opStatus = OperationEnum.NoOperation;
  18702. if (_dto.Id < 1) //添加操作
  18703. {
  18704. opInfo.OperationItem = OperationEnum.Add;
  18705. }
  18706. else if (_dto.Id > 0)
  18707. {
  18708. opInfo.OperationItem = OperationEnum.Edit;
  18709. }
  18710. string opRemark = string.Empty;
  18711. if (ccpInfo != null)
  18712. {
  18713. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  18714. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  18715. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  18716. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  18717. }
  18718. opInfo.Remark = opRemark;
  18719. await _tableorRep.AddAsync(opInfo);
  18720. #endregion
  18721. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  18722. //2024-10-21 新增LZ UID
  18723. var userIds = new List<int>() { 21 };
  18724. string title = $"费用审核";
  18725. string content = "";
  18726. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18727. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18728. try
  18729. {
  18730. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  18731. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  18732. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  18733. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  18734. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  18735. }
  18736. catch (Exception ex)
  18737. {
  18738. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  18739. }
  18740. }
  18741. catch (Exception ex)
  18742. {
  18743. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  18744. }
  18745. try
  18746. {
  18747. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18748. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18749. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18750. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18751. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18752. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18753. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18754. //自动审核
  18755. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  18756. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  18757. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  18758. //2024-10-21 新增LZ UID
  18759. var userIds = new List<int>() { 21 };
  18760. string title = $"系统通知";
  18761. var diId = _dto.DiId;
  18762. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18763. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18764. string content = "";
  18765. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18766. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18767. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18768. }
  18769. catch (Exception ex)
  18770. {
  18771. }
  18772. #endregion
  18773. return Ok(_view);
  18774. }
  18775. /// <summary>
  18776. /// 酒店自动审核测试
  18777. /// Add Or Edit
  18778. /// </summary>
  18779. /// <param name="diid"></param>
  18780. /// <param name="dataId"></param>
  18781. /// <returns></returns>
  18782. [HttpPost]
  18783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18784. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  18785. {
  18786. #region 应用推送
  18787. try
  18788. {
  18789. //自动审核
  18790. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  18791. }
  18792. catch (Exception ex)
  18793. {
  18794. return Ok(JsonView(false, ex.Message));
  18795. }
  18796. #endregion
  18797. return Ok(JsonView(false, "操作成功"));
  18798. }
  18799. /// <summary>
  18800. /// 酒店预订
  18801. /// Del
  18802. /// </summary>
  18803. /// <param name="_dto"></param>
  18804. /// <returns></returns>
  18805. [HttpPost]
  18806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18807. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  18808. {
  18809. #region 参数验证
  18810. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18811. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18812. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18813. #region 团组操作权限验证 76 酒店预定模块
  18814. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18815. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18816. #endregion
  18817. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18818. #region 页面操作权限验证
  18819. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18820. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18821. #endregion
  18822. #endregion
  18823. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  18824. #region 操作记录
  18825. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  18826. {
  18827. TableName = "Grp_HotelReservations",
  18828. PortType = _dto.PortType,
  18829. OperationItem = OperationEnum.Del,
  18830. DataId = _dto.Id,
  18831. CreateUserId = _dto.UserId
  18832. });
  18833. #endregion
  18834. return Ok(data);
  18835. }
  18836. /// <summary>
  18837. /// 酒店预订
  18838. /// 生成VOUCHER
  18839. /// 2024.05.06 之前版本
  18840. /// </summary>
  18841. /// <param name="_dto"></param>
  18842. /// <returns></returns>
  18843. [HttpPost]
  18844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18845. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18846. {
  18847. try
  18848. {
  18849. #region 参数验证
  18850. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18851. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18852. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18853. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18854. #region 团组操作权限验证 76 酒店预定模块
  18855. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18856. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18857. #endregion
  18858. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18859. #region 页面操作权限验证
  18860. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18861. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18862. #endregion
  18863. #endregion
  18864. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18865. //判断数据是否完整
  18866. if (hr != null)
  18867. {
  18868. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18869. {
  18870. string strFileName = "HotelStatement/";
  18871. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18872. if (dele != null)
  18873. strFileName += dele.TourCode;
  18874. //载入模板
  18875. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18876. Document doc = new Document(sss);
  18877. DocumentBuilder builder = new DocumentBuilder(doc);
  18878. #region 替换Word模板书签内容
  18879. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18880. //入住卷预定号码
  18881. if (doc.Range.Bookmarks["VNO"] != null)
  18882. {
  18883. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18884. mark.Text = hr.CheckNumber;
  18885. }
  18886. //酒店时间
  18887. if (doc.Range.Bookmarks["Date"] != null)
  18888. {
  18889. Bookmark mark = doc.Range.Bookmarks["Date"];
  18890. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18891. }
  18892. //团号
  18893. if (doc.Range.Bookmarks["TNo"] != null)
  18894. {
  18895. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18896. mark.Text = dele.TourCode;
  18897. }
  18898. //预定号码
  18899. if (doc.Range.Bookmarks["BookingId"] != null)
  18900. {
  18901. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  18902. mark.Text = hr.ReservationsNo;
  18903. }
  18904. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  18905. {
  18906. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  18907. mark.Text = hr.DetermineNo;
  18908. }
  18909. //酒店城市
  18910. if (doc.Range.Bookmarks["City"] != null)
  18911. {
  18912. Bookmark mark = doc.Range.Bookmarks["City"];
  18913. mark.Text = hr.City;
  18914. }
  18915. //酒店名称
  18916. if (doc.Range.Bookmarks["HName"] != null)
  18917. {
  18918. Bookmark mark = doc.Range.Bookmarks["HName"];
  18919. mark.Text = hr.HotelName;
  18920. }
  18921. //酒店地址
  18922. if (doc.Range.Bookmarks["Address"] != null)
  18923. {
  18924. Bookmark mark = doc.Range.Bookmarks["Address"];
  18925. mark.Text = hr.HotelAddress;
  18926. }
  18927. //酒店电话
  18928. if (doc.Range.Bookmarks["Tel"] != null)
  18929. {
  18930. Bookmark mark = doc.Range.Bookmarks["Tel"];
  18931. mark.Text = hr.HotelTel;
  18932. }
  18933. //酒店传真
  18934. if (doc.Range.Bookmarks["Fax"] != null)
  18935. {
  18936. Bookmark mark = doc.Range.Bookmarks["Fax"];
  18937. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  18938. {
  18939. mark.Text = hr.HotelFax;
  18940. }
  18941. }
  18942. //入住时间
  18943. if (doc.Range.Bookmarks["CIn"] != null)
  18944. {
  18945. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18946. Bookmark mark = doc.Range.Bookmarks["CIn"];
  18947. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  18948. }
  18949. //退房时间
  18950. if (doc.Range.Bookmarks["COut"] != null)
  18951. {
  18952. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18953. Bookmark mark = doc.Range.Bookmarks["COut"];
  18954. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18955. }
  18956. //客户名称
  18957. if (doc.Range.Bookmarks["GName"] != null)
  18958. {
  18959. string guestName = "";
  18960. string[] clients = Array.Empty<string>();
  18961. if (hr.GuestName.Contains(","))
  18962. {
  18963. clients = hr.GuestName.Split(",");
  18964. }
  18965. else
  18966. {
  18967. clients = new string[] { hr.GuestName };
  18968. }
  18969. List<int> clientIds_int = new List<int>();
  18970. if (clients.Length > 0)
  18971. {
  18972. foreach (var item in clients)
  18973. {
  18974. if (item.IsNumeric())
  18975. {
  18976. clientIds_int.Add(int.Parse(item));
  18977. }
  18978. }
  18979. }
  18980. if (clientIds_int.Count > 0)
  18981. {
  18982. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18983. foreach (var client in _clientDatas)
  18984. {
  18985. //男
  18986. if (client.Sex == 0) guestName += $"Mr.";
  18987. //女
  18988. else if (client.Sex == 1) guestName += $"Ms.";
  18989. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18990. {
  18991. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18992. }
  18993. //guestName += $"{client.Pinyin},";
  18994. }
  18995. if (guestName.Length > 0)
  18996. {
  18997. guestName = guestName.Substring(0, guestName.Length - 1);
  18998. }
  18999. }
  19000. else
  19001. {
  19002. guestName = hr.GuestName;
  19003. }
  19004. Bookmark mark = doc.Range.Bookmarks["GName"];
  19005. mark.Text = guestName;
  19006. }
  19007. //房间介绍
  19008. if (doc.Range.Bookmarks["ROOM"] != null)
  19009. {
  19010. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  19011. mark.Text = hr.RoomExplanation;
  19012. }
  19013. //报价描述
  19014. if (doc.Range.Bookmarks["NOTE"] != null)
  19015. {
  19016. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  19017. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  19018. if (ss != null)
  19019. mark.Text = ss.Name;
  19020. }
  19021. //入住时间
  19022. if (doc.Range.Bookmarks["CheckIn"] != null)
  19023. {
  19024. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  19025. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  19026. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  19027. }
  19028. //退房时间
  19029. if (doc.Range.Bookmarks["CheckOut"] != null)
  19030. {
  19031. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  19032. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  19033. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  19034. }
  19035. //日期
  19036. if (doc.Range.Bookmarks["DT"] != null)
  19037. {
  19038. Bookmark mark = doc.Range.Bookmarks["DT"];
  19039. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  19040. }
  19041. //名称
  19042. if (doc.Range.Bookmarks["VName"] != null)
  19043. {
  19044. Bookmark mark = doc.Range.Bookmarks["VName"];
  19045. mark.Text = hr.HotelName;
  19046. }
  19047. //号码
  19048. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  19049. {
  19050. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  19051. mark.Text = hr.CheckNumber;
  19052. }
  19053. #endregion
  19054. strFileName += "VOUCHER.doc";
  19055. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19056. doc.Save(fileDir);
  19057. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19058. return Ok(JsonView(true, "操作成功!", Url));
  19059. }
  19060. else
  19061. {
  19062. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  19063. }
  19064. }
  19065. else
  19066. {
  19067. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  19068. }
  19069. }
  19070. catch (Exception ex)
  19071. {
  19072. return Ok(JsonView(false, ex.Message));
  19073. }
  19074. }
  19075. /// <summary>
  19076. /// 酒店预订
  19077. /// 生成VOUCHER
  19078. /// 2024.05.06 之后版本
  19079. /// </summary>
  19080. /// <param name="_dto"></param>
  19081. /// <returns></returns>
  19082. [HttpPost]
  19083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19084. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  19085. {
  19086. #region 参数验证
  19087. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19088. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19089. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19090. #region 团组操作权限验证 76 酒店预定模块
  19091. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19092. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19093. #endregion
  19094. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19095. #region 页面操作权限验证
  19096. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19097. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19098. #endregion
  19099. #endregion
  19100. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  19101. //判断数据是否完整
  19102. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19103. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19104. string strFileName = "HotelStatement/";
  19105. string guestNames = ""; //格式Mr.xxx Ms.xxx
  19106. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  19107. #region 数据处理
  19108. List<int> guestIds = new List<int>();
  19109. //int index = 0;
  19110. foreach (var item in hrDtas)
  19111. {
  19112. if (item.GuestName.Contains(","))
  19113. {
  19114. string[] guestIdArr = item.GuestName.Split(',');
  19115. foreach (var guestIdStr in guestIdArr)
  19116. {
  19117. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  19118. if (guestBool)
  19119. {
  19120. guestIds.Add(guestId);
  19121. }
  19122. }
  19123. }
  19124. else guestNames += item.GuestName;
  19125. var voucherInfo = new HotelVoucherInfoView()
  19126. {
  19127. HotelName = item.HotelName,
  19128. CheckInDate = item.CheckInDate,
  19129. CheckOutDate = item.CheckOutDate,
  19130. ConfirmationNumber = item.DetermineNo.Trim(),
  19131. RoomType = item.RoomExplanation
  19132. };
  19133. vouchers.Add(voucherInfo);
  19134. }
  19135. if (guestIds.Count > 0)
  19136. {
  19137. guestIds = guestIds.Distinct().ToList();
  19138. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  19139. if (guestDatas.Count > 0)
  19140. {
  19141. guestNames = "";
  19142. foreach (var guest in guestDatas)
  19143. {
  19144. string guestName = "";
  19145. if (guest.Sex == 0) guestName += @"MR.";
  19146. else if (guest.Sex == 1) guestName += @"MS.";
  19147. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19148. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19149. guestNames += @$"{guestName.Trim()}、";
  19150. }
  19151. if (guestNames.Length > 0)
  19152. {
  19153. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19154. }
  19155. }
  19156. }
  19157. #endregion
  19158. //载入模板
  19159. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  19160. Document doc = new Document(sss);
  19161. DocumentBuilder builder = new DocumentBuilder(doc);
  19162. if (doc.Range.Bookmarks["GuestName"] != null)
  19163. {
  19164. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  19165. mark.Text = guestNames;
  19166. }
  19167. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19168. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  19169. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  19170. for (int i = 1; i <= vouchers.Count; i++)
  19171. {
  19172. HotelVoucherInfoView hviv = vouchers[i - 1];
  19173. builder.MoveToCell(0, i, 0, 0);
  19174. builder.Write(hviv.HotelName);
  19175. builder.MoveToCell(0, i, 1, 0);
  19176. builder.Write(hviv.CheckInDate);
  19177. builder.MoveToCell(0, i, 2, 0);
  19178. builder.Write(hviv.CheckOutDate);
  19179. builder.MoveToCell(0, i, 3, 0);
  19180. builder.Write(hviv.RoomType);
  19181. builder.MoveToCell(0, i, 4, 0);
  19182. builder.Write(hviv.ConfirmationNumber);
  19183. }
  19184. //删除多余行
  19185. int currRowIndex = vouchers.Count + 1;
  19186. int delRows = 21 - currRowIndex;
  19187. if (delRows > 0)
  19188. {
  19189. for (int i = 0; i < delRows; i++)
  19190. {
  19191. table.Rows.RemoveAt(currRowIndex);
  19192. //cultivateRowIndex++;
  19193. }
  19194. }
  19195. strFileName += "VOUCHER.docx";
  19196. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19197. doc.Save(fileDir);
  19198. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19199. return Ok(JsonView(true, "操作成功!", Url));
  19200. }
  19201. /// <summary>
  19202. /// 酒店预订
  19203. /// 生成VOUCHER 批量生成
  19204. /// New
  19205. /// </summary>
  19206. /// <param name="_dto"></param>
  19207. /// <returns></returns>
  19208. [HttpPost]
  19209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19210. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  19211. {
  19212. #region 参数验证
  19213. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19214. if (_dto.PageId < 1) _dto.PageId = 28;
  19215. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19216. #region 团组操作权限验证 76 酒店预定模块
  19217. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19218. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19219. #endregion
  19220. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19221. #region 页面操作权限验证
  19222. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19223. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19224. #endregion
  19225. #endregion
  19226. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  19227. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  19228. .OrderBy(x => x.CheckInDate)
  19229. .ToListAsync();
  19230. //判断数据是否完整
  19231. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19232. string strFileName = "HotelStatement/";
  19233. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  19234. if (dele != null)
  19235. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  19236. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  19237. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  19238. .Where(it => it.IsDel == 0)
  19239. .ToListAsync();
  19240. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  19241. for (int i = 0; i < hrDtas.Count; i++)
  19242. {
  19243. string guestNames = string.Empty;
  19244. List<int> guestIds = new List<int>();
  19245. var item = hrDtas[i];
  19246. //处理客户姓名
  19247. if (item.GuestName.Contains(","))
  19248. {
  19249. string[] guestIdArr = item.GuestName.Split(',');
  19250. foreach (var guestIdStr in guestIdArr)
  19251. if (int.TryParse(guestIdStr, out int guestId))
  19252. guestIds.Add(guestId);
  19253. }
  19254. else
  19255. {
  19256. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  19257. if (guestIdBool)
  19258. {
  19259. guestIds.Add(guestId);
  19260. }
  19261. //NaN
  19262. if (item.GuestName.Contains("NaN"))
  19263. {
  19264. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  19265. }
  19266. }
  19267. if (guestIds.Count > 0)
  19268. {
  19269. guestIds = guestIds.Distinct().ToList();
  19270. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  19271. if (guestDatas1.Count > 0)
  19272. {
  19273. guestNames = "";
  19274. foreach (var guest in guestDatas1)
  19275. {
  19276. string guestName = "";
  19277. if (guest.Sex == 0) guestName += @"MR.";
  19278. else if (guest.Sex == 1) guestName += @"MS.";
  19279. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19280. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19281. guestNames += @$"{guestName.Trim()}、";
  19282. }
  19283. if (guestNames.Length > 0)
  19284. {
  19285. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19286. }
  19287. }
  19288. }
  19289. //if (!string.IsNullOrEmpty(guestNames))
  19290. //{
  19291. hrDtas[i].GuestName = guestNames;
  19292. //}
  19293. }
  19294. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  19295. Document doc = new Document();
  19296. DocumentBuilder builder = new DocumentBuilder(doc);
  19297. try
  19298. {
  19299. builder.MoveToDocumentStart();
  19300. foreach (var item in hrDtas)
  19301. {
  19302. //标题
  19303. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19304. builder.ParagraphFormat.LineSpacing = 1;
  19305. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19306. builder.ParagraphFormat.Style.Font.Size = 9;
  19307. builder.ParagraphFormat.Style.Font.Bold = true;
  19308. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19309. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  19310. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19311. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19312. builder.ParagraphFormat.LineSpacing = 1;
  19313. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19314. builder.ParagraphFormat.Style.Font.Size = 9;
  19315. builder.ParagraphFormat.Style.Font.Bold = true;
  19316. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  19317. builder.StartTable();
  19318. // 设置边框颜色
  19319. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  19320. //设置边框样式
  19321. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  19322. //表格
  19323. #region 第一行
  19324. builder.InsertCell();
  19325. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19326. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19327. //builder.CellFormat.AllowAutoFit = false;
  19328. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19329. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19330. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19331. builder.CellFormat.WrapText = true; //自动换行
  19332. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19333. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  19334. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19335. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19336. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19337. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19338. builder.Write("TOUR NO:");
  19339. builder.InsertCell();
  19340. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19341. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19342. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19343. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19344. builder.ParagraphFormat.Style.Font.Bold = false;
  19345. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19346. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19347. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19348. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19349. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19350. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19351. builder.Write($"{dele?.TourCode ?? "-"}");
  19352. builder.InsertCell();
  19353. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19354. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19355. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19356. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19357. builder.ParagraphFormat.Style.Font.Bold = false;
  19358. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19359. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19360. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19361. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19362. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19363. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19364. builder.Write($"CITY:");
  19365. builder.InsertCell();
  19366. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19367. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19368. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19369. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19370. builder.ParagraphFormat.Style.Font.Bold = false;
  19371. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19372. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19373. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19374. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19375. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19376. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19377. builder.Write($"{item.City}");
  19378. builder.EndRow();
  19379. #endregion
  19380. #region 第二行
  19381. builder.InsertCell();
  19382. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19383. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19384. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19385. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19386. builder.ParagraphFormat.Style.Font.Bold = false;
  19387. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19388. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19389. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19390. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19391. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19392. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19393. builder.Write("CONFIRMATION NO:");
  19394. builder.InsertCell();
  19395. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19396. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19397. builder.ParagraphFormat.Style.Font.Size = 8;
  19398. builder.ParagraphFormat.Style.Font.Bold = false;
  19399. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19400. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19401. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19402. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19403. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19404. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19405. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19406. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19407. builder.Write($"{item.DetermineNo}");
  19408. builder.InsertCell();
  19409. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19410. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19411. builder.InsertCell();
  19412. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19413. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19414. builder.EndRow();
  19415. #endregion
  19416. #region 第三行
  19417. builder.InsertCell();
  19418. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19419. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19420. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19421. builder.ParagraphFormat.Style.Font.Bold = false;
  19422. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19423. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19424. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19425. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19426. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19427. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19428. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19429. builder.Write($"HOTEL NAME:");
  19430. builder.InsertCell();
  19431. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19432. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19433. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19434. builder.ParagraphFormat.Style.Font.Bold = false;
  19435. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19436. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19437. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19438. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19439. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19440. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19441. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19442. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19443. builder.Write($"{item.HotelName}");
  19444. builder.InsertCell();
  19445. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19446. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19447. builder.InsertCell();
  19448. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19449. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19450. builder.EndRow();
  19451. #endregion
  19452. #region 第四行
  19453. builder.InsertCell();
  19454. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19455. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19456. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19457. builder.ParagraphFormat.Style.Font.Bold = false;
  19458. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19459. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19460. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19461. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19462. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19463. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19464. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19465. builder.Write($"HOTEL ADDRESS:");
  19466. builder.InsertCell();
  19467. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19468. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19469. builder.ParagraphFormat.Style.Font.Size = 8;
  19470. builder.ParagraphFormat.Style.Font.Bold = false;
  19471. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19472. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19473. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19474. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19475. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19476. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19477. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19478. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19479. builder.Write($"{item.HotelAddress}");
  19480. builder.InsertCell();
  19481. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19482. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19483. builder.InsertCell();
  19484. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19485. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19486. builder.EndRow();
  19487. #endregion
  19488. #region 第五行
  19489. builder.InsertCell();
  19490. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19491. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19492. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19493. builder.ParagraphFormat.Style.Font.Bold = false;
  19494. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19495. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19496. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19497. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19498. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19499. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19500. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19501. builder.Write("TEL:");
  19502. builder.InsertCell();
  19503. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19504. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19505. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19506. builder.ParagraphFormat.Style.Font.Bold = false;
  19507. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19508. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19509. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19510. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19511. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19512. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19513. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19514. builder.Write($"{item.HotelTel}");
  19515. builder.InsertCell();
  19516. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19517. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19518. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19519. builder.ParagraphFormat.Style.Font.Bold = false;
  19520. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19521. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19522. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19523. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19524. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19525. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19526. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19527. builder.Write($"FAX:");
  19528. builder.InsertCell();
  19529. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19530. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19531. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19532. builder.ParagraphFormat.Style.Font.Bold = false;
  19533. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19534. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19535. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19536. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19537. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19538. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19539. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19540. builder.Write($"{item.HotelFax}");
  19541. builder.EndRow();
  19542. #endregion
  19543. #region 第六行
  19544. builder.InsertCell();
  19545. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19546. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19547. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19548. builder.ParagraphFormat.Style.Font.Bold = false;
  19549. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19550. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19551. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19552. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19553. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19554. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19555. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19556. builder.Write("CHECK IN:");
  19557. builder.InsertCell();
  19558. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19559. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19560. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19561. builder.ParagraphFormat.Style.Font.Bold = false;
  19562. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19563. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19564. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19565. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19566. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19567. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19568. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19569. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  19570. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  19571. builder.Write($"{checkInStr}");
  19572. builder.InsertCell();
  19573. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19574. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19575. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19576. builder.ParagraphFormat.Style.Font.Bold = false;
  19577. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19578. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19579. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19580. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19581. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19582. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19583. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19584. builder.Write($"CHECK OUT:");
  19585. builder.InsertCell();
  19586. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19587. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19588. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19589. builder.ParagraphFormat.Style.Font.Bold = false;
  19590. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19591. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19592. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19593. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19594. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19595. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19596. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19597. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  19598. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  19599. builder.Write($"{checkOutStr}");
  19600. builder.EndRow();
  19601. #endregion
  19602. #region 第七行
  19603. builder.InsertCell();
  19604. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19605. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19606. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19607. builder.ParagraphFormat.Style.Font.Bold = false;
  19608. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19609. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19610. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19611. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19612. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19613. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19614. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19615. builder.Write($"GUEST NAME:");
  19616. builder.InsertCell();
  19617. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19618. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19619. builder.ParagraphFormat.Style.Font.Size = 8;
  19620. builder.ParagraphFormat.Style.Font.Bold = false;
  19621. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19622. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19623. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19624. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19625. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19626. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19627. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19628. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19629. builder.Write($"{item.GuestName.Trim()}");
  19630. builder.InsertCell();
  19631. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19632. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19633. builder.InsertCell();
  19634. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19635. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19636. builder.EndRow();
  19637. #endregion
  19638. #region 第八行
  19639. builder.InsertCell();
  19640. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19641. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19642. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19643. builder.ParagraphFormat.Style.Font.Bold = false;
  19644. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19645. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19646. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19647. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19648. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19649. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19650. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19651. builder.Write($"ROOM TYPE:");
  19652. builder.InsertCell();
  19653. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19654. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19655. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19656. builder.ParagraphFormat.Style.Font.Bold = false;
  19657. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19658. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19659. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19660. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19661. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19662. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19663. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19664. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19665. builder.Write($"{item.RoomExplanation}");
  19666. builder.InsertCell();
  19667. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19668. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19669. builder.InsertCell();
  19670. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19671. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19672. builder.EndRow();
  19673. #endregion
  19674. #region 第九行
  19675. builder.InsertCell();
  19676. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19677. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19678. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19679. builder.ParagraphFormat.Style.Font.Bold = false;
  19680. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19681. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19682. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19683. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19684. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19685. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19686. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19687. builder.Write($"NOTE:");
  19688. builder.InsertCell();
  19689. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19690. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19691. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19692. builder.ParagraphFormat.Style.Font.Bold = false;
  19693. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19694. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19695. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19696. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19697. 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.");
  19698. builder.InsertCell();
  19699. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19700. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19701. builder.InsertCell();
  19702. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19703. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19704. builder.EndRow();
  19705. #endregion
  19706. builder.EndTable();
  19707. //换行
  19708. builder.Writeln("");
  19709. builder.Writeln("");
  19710. }
  19711. #region 获取文档中的所有表格 设置文字自适应
  19712. // 获取文档中的所有表格。
  19713. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  19714. {
  19715. // 遍历表格中的所有行。
  19716. foreach (Aspose.Words.Tables.Row row in table.Rows)
  19717. {
  19718. foreach (Cell cell in row.Cells)
  19719. {
  19720. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  19721. cellFormat.Width = 0;
  19722. }
  19723. }
  19724. }
  19725. #endregion
  19726. #region 设置页眉
  19727. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  19728. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  19729. if (System.IO.File.Exists(voucherHeaderPath))
  19730. {
  19731. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  19732. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  19733. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  19734. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  19735. // 调整图片位置
  19736. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  19737. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  19738. shape.Top = 50; // 将图片距离页眉上边缘的距离
  19739. shape.Left = 0; // 将图片距离页面左边缘的距离
  19740. shape.Width = 81; // 设置图片宽度
  19741. shape.Height = 36; // 设置图片高度
  19742. }
  19743. //靠右
  19744. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19745. //// 设置页脚上下边距
  19746. //builder.PageSetup.HeaderDistance = 42;
  19747. // 添加页眉线
  19748. Aspose.Words.Border borderHeader = null;
  19749. try
  19750. {
  19751. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  19752. }
  19753. catch (Exception e)
  19754. {
  19755. // TODO Auto-generated catch block
  19756. //e.printStackTrace();
  19757. }
  19758. borderHeader.Shadow = true;
  19759. borderHeader.DistanceFromText = 2;
  19760. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  19761. #endregion
  19762. }
  19763. catch (Exception ex)
  19764. {
  19765. }
  19766. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19767. doc.Save(fileDir);
  19768. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19769. return Ok(JsonView(true, "操作成功!", Url));
  19770. }
  19771. /// <summary>
  19772. /// 酒店预订
  19773. /// 生成 预定成本 Excel
  19774. /// </summary>
  19775. /// <param name="_dto"></param>
  19776. /// <returns></returns>
  19777. [HttpPost]
  19778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19779. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  19780. {
  19781. #region 参数验证
  19782. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  19783. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  19784. if (!vadalitorRes.IsValid)
  19785. {
  19786. var errors = new StringBuilder();
  19787. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  19788. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  19789. }
  19790. #region 团组操作权限验证 76 酒店预定模块
  19791. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19792. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19793. #endregion
  19794. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19795. #region 页面操作权限验证
  19796. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19797. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19798. #endregion
  19799. #endregion
  19800. decimal _rate = 1.00M;
  19801. string _currency = string.Empty;
  19802. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  19803. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19804. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  19805. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19806. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  19807. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  19808. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  19809. if (_GroupCostParameter == null)
  19810. {
  19811. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  19812. bool isIntType = int.TryParse(_currency, out int currId);
  19813. if (isIntType)
  19814. {
  19815. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19816. }
  19817. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19818. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19819. if (currInfo == null)
  19820. {
  19821. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19822. }
  19823. else _rate = currInfo.Rate;
  19824. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  19825. {
  19826. _rate = _GroupCostParameter.Rate;
  19827. }
  19828. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19829. //string strFileName = "HotelStatement/";
  19830. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19831. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19832. var rateDatas = new List<dynamic>();
  19833. #region 数据处理
  19834. foreach (var item in hrDtas)
  19835. {
  19836. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19837. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19838. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19839. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19840. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19841. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  19842. {
  19843. continue;
  19844. }
  19845. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19846. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19847. string singleRoomFeeStr = string.Empty,
  19848. doubleRoomFeeStr = string.Empty,
  19849. suiteRoomFeeStr = string.Empty,
  19850. otherRoomFeeStr = string.Empty,
  19851. payMoneyStr = string.Empty,
  19852. cardPriceStr = string.Empty;
  19853. if (roomCurr.Equals("CNY"))
  19854. {
  19855. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19856. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19857. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19858. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19859. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19860. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19861. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19862. }
  19863. else
  19864. {
  19865. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19866. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19867. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19868. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19869. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19870. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19871. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19872. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19873. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19874. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19875. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19876. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19877. if (ccpPaymentCurrency.Equals("CNY"))
  19878. {
  19879. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19880. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19881. }
  19882. else
  19883. {
  19884. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19885. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19886. }
  19887. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19888. if (hotelcardPriceCurrency.Equals("CNY"))
  19889. {
  19890. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19891. }
  19892. else
  19893. {
  19894. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19895. }
  19896. }
  19897. string breakfastPriceStr = string.Empty,
  19898. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19899. governmentRentStr = string.Empty,
  19900. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19901. cityTaxStr = string.Empty,
  19902. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19903. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  19904. if (!string.IsNullOrEmpty(breakfastCurrency1))
  19905. {
  19906. if (breakfastCurrency1.Equals("CNY"))
  19907. {
  19908. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19909. }
  19910. else
  19911. {
  19912. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  19913. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  19914. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  19915. }
  19916. }
  19917. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19918. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  19919. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  19920. {
  19921. if (governmentRentCurrency.Equals("CNY"))
  19922. {
  19923. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19924. }
  19925. else
  19926. {
  19927. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  19928. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  19929. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  19930. }
  19931. }
  19932. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19933. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  19934. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  19935. {
  19936. if (cityTaxStrCurrency1.Equals("CNY"))
  19937. {
  19938. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19939. }
  19940. else
  19941. {
  19942. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  19943. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  19944. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  19945. }
  19946. }
  19947. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19948. int payDId = roomInfo?.PayDId ?? 0;
  19949. pcfds.Add(new HotelReservations_PCFD_View()
  19950. {
  19951. City = item.City,
  19952. HotelName = item.HotelName,
  19953. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19954. // SingleRoomCount = item.SingleRoomCount,
  19955. SingleRoomPrice = singleRoomFeeStr,
  19956. // DoubleRoomCount = item.DoubleRoomCount,
  19957. DoubleRoomPrice = doubleRoomFeeStr,
  19958. //SuiteRoomCount = item.SuiteRoomCount,
  19959. SuiteRoomPrice = suiteRoomFeeStr,
  19960. OtherRoomPrice = otherRoomFeeStr,
  19961. //OtherRoomCount = item.OtherRoomCount,
  19962. BreakfastPrice = breakfastPriceStr,
  19963. GovernmentRent = governmentRentStr,
  19964. CityTax = cityTaxStr,
  19965. RoomExplanation = item.RoomExplanation,
  19966. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19967. PayTime = roomInfo?.ConsumptionDate,
  19968. BankNo = roomInfo?.BankNo,
  19969. PayMoney = payMoneyStr,
  19970. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19971. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19972. CardPrice = cardPriceStr,
  19973. Remark = ccpInfo.Remark
  19974. });
  19975. }
  19976. #endregion
  19977. //载入模板
  19978. WorkbookDesigner designer = new WorkbookDesigner();
  19979. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19980. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19981. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19982. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19983. var rateDatas1 = rateDatas.Distinct();
  19984. var rateStr = string.Empty;
  19985. foreach (var item in rateDatas1)
  19986. {
  19987. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19988. }
  19989. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19990. designer.SetDataSource("Opertor", userInfo.CnName);
  19991. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19992. dt.TableName = "ViewMyHotelReservations";
  19993. designer.SetDataSource(dt);
  19994. designer.Process();
  19995. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19996. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19997. designer.Workbook.Save(serverPath);
  19998. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19999. #region 删除指定行
  20000. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  20001. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  20002. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  20003. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  20004. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  20005. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  20006. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  20007. cssIndex = dt.Columns["CityTax"].Ordinal,
  20008. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  20009. remarkIndex = dt.Columns["Remark"].Ordinal;
  20010. //删除指定列
  20011. foreach (DataRow item in dt.Rows)
  20012. {
  20013. string singleStr = item["SingleRoomPrice"].ToString();
  20014. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  20015. if (containsDigitButNotZero1) singleDel = false;
  20016. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  20017. string doubleStr = item["DoubleRoomPrice"].ToString();
  20018. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20019. if (containsDigitButNotZero2) doubleDel = false;
  20020. string suiteStr = item["SuiteRoomPrice"].ToString();
  20021. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20022. if (containsDigitButNotZero3) suiteDel = false;
  20023. string otherStr = item["OtherRoomPrice"].ToString();
  20024. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  20025. if (containsDigitButNotZero4) otherDel = false;
  20026. string zcStr = item["BreakfastPrice"].ToString();
  20027. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  20028. if (containsDigitButNotZero5) zcDel = false;
  20029. string dsStr = item["GovernmentRent"].ToString();
  20030. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  20031. if (containsDigitButNotZero6) dsDel = false;
  20032. string cssStr = item["CityTax"].ToString();
  20033. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  20034. if (containsDigitButNotZero7) cssDel = false;
  20035. string cpStr = item["ConsumptionPatterns"].ToString();
  20036. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  20037. string remarkStr = item["Remark"].ToString();
  20038. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  20039. }
  20040. DeleteColumn(serverPath, remarkIndex, remarkDel);
  20041. DeleteColumn(serverPath, cpIndex, cpDel);
  20042. DeleteColumn(serverPath, dsIndex, dsDel);
  20043. DeleteColumn(serverPath, cssIndex, cssDel);
  20044. DeleteColumn(serverPath, zcIndex, zcDel);
  20045. DeleteColumn(serverPath, otherIndex, otherDel);
  20046. DeleteColumn(serverPath, suiteIndex, suiteDel);
  20047. DeleteColumn(serverPath, doubleIndex, doubleDel);
  20048. DeleteColumn(serverPath, singleIndex, singleDel);
  20049. #endregion
  20050. //只保留第一个表格
  20051. DeleteSheet(serverPath);
  20052. return Ok(JsonView(true, "操作成功", url = rst));
  20053. }
  20054. else
  20055. {
  20056. _currency = _GroupCostParameter.Currency;
  20057. bool isIntType = int.TryParse(_currency, out int currId);
  20058. if (isIntType)
  20059. {
  20060. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  20061. }
  20062. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  20063. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  20064. if (currInfo == null)
  20065. {
  20066. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  20067. }
  20068. if (!_currency.ToUpper().Equals("CNY"))
  20069. {
  20070. _rate = _GroupCostParameter.Rate;
  20071. }
  20072. _rate = currInfo.Rate;
  20073. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  20074. //string strFileName = "HotelStatement/";
  20075. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  20076. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  20077. #region 数据处理
  20078. foreach (var item in hrDtas)
  20079. {
  20080. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  20081. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  20082. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  20083. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  20084. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  20085. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  20086. string singleRoomFeeStr = string.Empty,
  20087. doubleRoomFeeStr = string.Empty,
  20088. suiteRoomFeeStr = string.Empty,
  20089. otherRoomFeeStr = string.Empty,
  20090. payMoneyStr = string.Empty,
  20091. cardPriceStr = string.Empty;
  20092. if (roomCurr.Equals(_currency))
  20093. {
  20094. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  20095. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  20096. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  20097. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  20098. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  20099. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  20100. }
  20101. else
  20102. {
  20103. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  20104. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  20105. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  20106. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  20107. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  20108. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  20109. }
  20110. string breakfastPriceStr = string.Empty,
  20111. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  20112. governmentRentStr = string.Empty,
  20113. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  20114. cityTaxStrStr = string.Empty,
  20115. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  20116. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  20117. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  20118. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  20119. int payDId = roomInfo?.PayDId ?? 0;
  20120. pcfds.Add(new HotelReservations_PCFD_View()
  20121. {
  20122. City = item.City,
  20123. HotelName = item.HotelName,
  20124. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  20125. // SingleRoomCount = item.SingleRoomCount,
  20126. SingleRoomPrice = singleRoomFeeStr,
  20127. // DoubleRoomCount = item.DoubleRoomCount,
  20128. DoubleRoomPrice = doubleRoomFeeStr,
  20129. //SuiteRoomCount = item.SuiteRoomCount,
  20130. SuiteRoomPrice = suiteRoomFeeStr,
  20131. OtherRoomPrice = otherRoomFeeStr,
  20132. //OtherRoomCount = item.OtherRoomCount,
  20133. BreakfastPrice = breakfastPriceStr,
  20134. GovernmentRent = governmentRentStr,
  20135. CityTax = cityTaxStrStr,
  20136. RoomExplanation = item.RoomExplanation,
  20137. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  20138. PayTime = roomInfo?.ConsumptionDate,
  20139. BankNo = roomInfo?.BankNo,
  20140. PayMoney = payMoneyStr,
  20141. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  20142. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  20143. CardPrice = cardPriceStr,
  20144. Remark = ccpInfo.Remark
  20145. });
  20146. }
  20147. #endregion
  20148. //载入模板
  20149. WorkbookDesigner designer = new WorkbookDesigner();
  20150. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  20151. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  20152. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  20153. designer.SetDataSource("TourNo", groupInfo.TourCode);
  20154. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  20155. designer.SetDataSource("Opertor", userInfo.CnName);
  20156. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  20157. dt.TableName = "ViewMyHotelReservations";
  20158. designer.SetDataSource(dt);
  20159. designer.Process();
  20160. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  20161. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  20162. designer.Workbook.Save(serverPath);
  20163. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  20164. #region 删除指定行
  20165. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  20166. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  20167. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  20168. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  20169. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  20170. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  20171. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  20172. cssIndex = dt.Columns["CityTax"].Ordinal,
  20173. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  20174. remarkIndex = dt.Columns["Remark"].Ordinal;
  20175. //删除指定列
  20176. foreach (DataRow item in dt.Rows)
  20177. {
  20178. string singleStr = item["SingleRoomPrice"].ToString();
  20179. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  20180. if (containsDigitButNotZero1) singleDel = false;
  20181. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  20182. string doubleStr = item["DoubleRoomPrice"].ToString();
  20183. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20184. if (containsDigitButNotZero2) doubleDel = false;
  20185. string suiteStr = item["SuiteRoomPrice"].ToString();
  20186. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20187. if (containsDigitButNotZero3) suiteDel = false;
  20188. string otherStr = item["OtherRoomPrice"].ToString();
  20189. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  20190. if (containsDigitButNotZero4) otherDel = false;
  20191. string zcStr = item["BreakfastPrice"].ToString();
  20192. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  20193. if (containsDigitButNotZero5) zcDel = false;
  20194. string dsStr = item["GovernmentRent"].ToString();
  20195. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  20196. if (containsDigitButNotZero6) dsDel = false;
  20197. string cssStr = item["CityTax"].ToString();
  20198. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  20199. if (containsDigitButNotZero7) cssDel = false;
  20200. string cpStr = item["ConsumptionPatterns"].ToString();
  20201. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  20202. string remarkStr = item["Remark"].ToString();
  20203. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  20204. }
  20205. DeleteColumn(serverPath, remarkIndex, remarkDel);
  20206. DeleteColumn(serverPath, cpIndex, cpDel);
  20207. DeleteColumn(serverPath, dsIndex, dsDel);
  20208. DeleteColumn(serverPath, cssIndex, cssDel);
  20209. DeleteColumn(serverPath, zcIndex, zcDel);
  20210. DeleteColumn(serverPath, otherIndex, otherDel);
  20211. DeleteColumn(serverPath, suiteIndex, suiteDel);
  20212. DeleteColumn(serverPath, doubleIndex, doubleDel);
  20213. DeleteColumn(serverPath, singleIndex, singleDel);
  20214. #endregion
  20215. //只保留第一个表格
  20216. DeleteSheet(serverPath);
  20217. return Ok(JsonView(true, "操作成功", url = rst));
  20218. }
  20219. //return Ok(JsonView(false));
  20220. }
  20221. /// <summary>
  20222. /// 删除指定列
  20223. /// </summary>
  20224. /// <param name="file"></param>
  20225. /// <param name="columnIndex"></param>
  20226. /// <param name="isDel"></param>
  20227. private void DeleteColumn(string file, int columnIndex, bool isDel)
  20228. {
  20229. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20230. //wb.Save(file);
  20231. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  20232. if (sheet1 != null)
  20233. {
  20234. if (isDel)
  20235. {
  20236. Cells cells = sheet1.Cells;
  20237. cells.DeleteColumn(columnIndex);
  20238. }
  20239. }
  20240. wb.Save(file);
  20241. }
  20242. /// <summary>
  20243. /// 删除sheet
  20244. /// </summary>
  20245. /// <param name="file"></param>
  20246. private void DeleteSheet(string file)
  20247. {
  20248. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20249. //wb.Save(file);
  20250. List<string> sheets = new List<string>();
  20251. foreach (var item in wb.Worksheets)
  20252. {
  20253. sheets.Add(item.Name);
  20254. }
  20255. if (sheets.Count > 0)
  20256. {
  20257. sheets.RemoveAt(0);//不删除第一个sheet
  20258. foreach (var item in sheets)
  20259. {
  20260. wb.Worksheets.RemoveAt(item);
  20261. }
  20262. }
  20263. wb.Save(file);
  20264. }
  20265. /// <summary>
  20266. /// 酒店预订
  20267. /// 确认单
  20268. /// </summary>
  20269. /// <param name="_dto"></param>
  20270. /// <returns></returns>
  20271. [HttpPost]
  20272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20273. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  20274. {
  20275. try
  20276. {
  20277. #region 参数验证
  20278. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  20279. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20280. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  20281. #region 团组操作权限验证 76 酒店预定模块
  20282. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20283. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  20284. #endregion
  20285. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20286. #region 页面操作权限验证
  20287. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20288. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20289. #endregion
  20290. #endregion
  20291. //团组信息
  20292. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  20293. //酒店数据
  20294. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  20295. if (listhoteldata.Count < 0)
  20296. {
  20297. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  20298. }
  20299. //利datatable存储
  20300. DataTable dt = new DataTable();
  20301. dt.Columns.Add("CheckInDate", typeof(string));
  20302. dt.Columns.Add("City", typeof(string));
  20303. dt.Columns.Add("Hotel", typeof(string));
  20304. dt.Columns.Add("Room", typeof(string));
  20305. for (int i = 0; i < listhoteldata.Count; i++)
  20306. {
  20307. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  20308. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  20309. while (dayStart < dayEnd)
  20310. {
  20311. string temp = "";
  20312. DataRow row = dt.NewRow();
  20313. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  20314. row["City"] = listhoteldata[i].City;
  20315. row["Hotel"] = listhoteldata[i].HotelName;
  20316. if (listhoteldata[i].SingleRoomCount > 0)
  20317. {
  20318. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  20319. }
  20320. if (listhoteldata[i].DoubleRoomCount > 0)
  20321. {
  20322. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  20323. }
  20324. if (listhoteldata[i].SuiteRoomCount > 0)
  20325. {
  20326. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  20327. }
  20328. if (listhoteldata[i].OtherRoomCount > 0)
  20329. {
  20330. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  20331. }
  20332. row["Room"] = temp;
  20333. dt.Rows.Add(row);
  20334. dayStart = dayStart.AddDays(1);
  20335. }
  20336. }
  20337. Dictionary<string, string> dic = new Dictionary<string, string>();
  20338. dic.Add("Dele", di.TeamName);
  20339. dic.Add("City", di.VisitCountry);
  20340. //模板路径
  20341. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  20342. //载入模板
  20343. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  20344. DocumentBuilder builder = new DocumentBuilder(doc);
  20345. foreach (var key in dic.Keys)
  20346. {
  20347. builder.MoveToBookmark(key);
  20348. builder.Write(dic[key]);
  20349. }
  20350. //获取word里所有表格
  20351. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20352. //获取所填表格的序数
  20353. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20354. var rowStart = tableOne.Rows[0]; //获取第1行
  20355. //循环赋值
  20356. for (int i = 0; i < dt.Rows.Count; i++)
  20357. {
  20358. builder.MoveToCell(0, i + 1, 0, 0);
  20359. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  20360. builder.MoveToCell(0, i + 1, 1, 0);
  20361. builder.Write(dt.Rows[i]["City"].ToString());
  20362. builder.MoveToCell(0, i + 1, 2, 0);
  20363. builder.Write(dt.Rows[i]["Hotel"].ToString());
  20364. builder.MoveToCell(0, i + 1, 3, 0);
  20365. builder.Write(dt.Rows[i]["Room"].ToString());
  20366. }
  20367. //删除多余行
  20368. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  20369. {
  20370. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  20371. }
  20372. string strFileName = di.TeamName + "酒店确认单.doc";
  20373. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  20374. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  20375. return Ok(JsonView(true, "成功", url));
  20376. }
  20377. catch (Exception ex)
  20378. {
  20379. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  20380. }
  20381. }
  20382. #endregion
  20383. #region 团组状态
  20384. /// <summary>
  20385. /// 团组状态列表 Page
  20386. /// </summary>
  20387. /// <param name="dto">团组列表请求dto</param>
  20388. /// <returns></returns>
  20389. [HttpPost]
  20390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20391. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  20392. {
  20393. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20394. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  20395. {
  20396. string sqlWhere = string.Empty;
  20397. if (dto.IsSure == 0) //未完成
  20398. {
  20399. sqlWhere += string.Format(@" And IsSure = 0");
  20400. }
  20401. else if (dto.IsSure == 1) //已完成
  20402. {
  20403. sqlWhere += string.Format(@" And IsSure = 1");
  20404. }
  20405. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  20406. {
  20407. string tj = dto.SearchCriteria;
  20408. 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}%')",
  20409. tj, tj, tj, tj, tj);
  20410. }
  20411. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  20412. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  20413. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  20414. From (
  20415. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  20416. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  20417. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  20418. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  20419. From Grp_DelegationInfo gdi
  20420. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  20421. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  20422. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  20423. Where gdi.IsDel = 0 {0}
  20424. ) temp ", sqlWhere);
  20425. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  20426. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  20427. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  20428. }
  20429. else
  20430. {
  20431. return Ok(JsonView(false, "查询失败"));
  20432. }
  20433. }
  20434. /// <summary>
  20435. /// 团组状态
  20436. /// 设置操作完成
  20437. /// </summary>
  20438. /// <param name="dto">团组列表请求dto</param>
  20439. /// <returns></returns>
  20440. [HttpPost]
  20441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20442. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  20443. {
  20444. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20445. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  20446. {
  20447. Id = dto.Id,
  20448. IsSure = 1
  20449. };
  20450. var result = await _sqlSugar.Updateable(_DelegationInfo)
  20451. .UpdateColumns(it => new { it.IsSure })
  20452. .WhereColumns(it => new { it.Id })
  20453. .ExecuteCommandAsync();
  20454. if (result > 0)
  20455. {
  20456. return Ok(JsonView(true, "操作完成!"));
  20457. }
  20458. return Ok(JsonView(false, "操作失败!"));
  20459. }
  20460. #endregion
  20461. #region 保险费用录入
  20462. /// <summary>
  20463. /// 根据团组Id查询保险费用列表
  20464. /// </summary>
  20465. /// <param name="dto"></param>
  20466. /// <returns></returns>
  20467. [HttpPost]
  20468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20469. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  20470. {
  20471. Result groupData = await _customersRep.CustomersByDiId(dto);
  20472. if (groupData.Code != 0)
  20473. {
  20474. return Ok(JsonView(false, groupData.Msg));
  20475. }
  20476. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20477. }
  20478. /// <summary>
  20479. /// 根据保险费用Id查询保险费用详细
  20480. /// </summary>
  20481. /// <param name="dto"></param>
  20482. /// <returns></returns>
  20483. [HttpPost]
  20484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20485. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  20486. {
  20487. try
  20488. {
  20489. Result groupData = await _customersRep.CustomersById(dto);
  20490. if (groupData.Code != 0)
  20491. {
  20492. return Ok(JsonView(false, groupData.Msg));
  20493. }
  20494. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20495. }
  20496. catch (Exception ex)
  20497. {
  20498. return Ok(JsonView(false, ex.Message));
  20499. }
  20500. }
  20501. /// <summary>
  20502. /// 保险费用录入页面初始化绑定
  20503. /// </summary>
  20504. /// <param name="dto"></param>
  20505. /// <returns></returns>
  20506. [HttpPost]
  20507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20508. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  20509. {
  20510. try
  20511. {
  20512. Result groupData = await _customersRep.CustomersInitialize(dto);
  20513. if (groupData.Code != 0)
  20514. {
  20515. return Ok(JsonView(false, groupData.Msg));
  20516. }
  20517. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20518. }
  20519. catch (Exception ex)
  20520. {
  20521. return Ok(JsonView(false, ex.Message));
  20522. }
  20523. }
  20524. /// <summary>
  20525. /// 保险费用操作(Status:1.新增,2.修改)
  20526. /// </summary>
  20527. /// <param name="dto"></param>
  20528. /// <returns></returns>
  20529. [HttpPost]
  20530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20531. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  20532. {
  20533. Result groupData = await _customersRep.OpCustomers(dto);
  20534. if (groupData.Code != 0)
  20535. {
  20536. return Ok(JsonView(false, groupData.Msg));
  20537. }
  20538. #region 应用推送
  20539. try
  20540. {
  20541. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  20542. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  20543. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  20544. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  20545. //自动审核
  20546. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  20547. //2024-10-21 新增LZ UID
  20548. var userIds = new List<int>() { 21 };
  20549. string title = $"系统通知";
  20550. var diId = dto.DiId;
  20551. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20552. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20553. string content = "";
  20554. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20555. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20556. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  20557. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  20558. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  20559. }
  20560. catch (Exception ex)
  20561. {
  20562. }
  20563. #endregion
  20564. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20565. }
  20566. /// <summary>
  20567. /// 保险文件上传
  20568. /// </summary>
  20569. /// <param name="file"></param>
  20570. /// <returns></returns>
  20571. [HttpPost]
  20572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20573. public async Task<IActionResult> UploadCus(IFormFile file)
  20574. {
  20575. try
  20576. {
  20577. if (file != null)
  20578. {
  20579. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20580. //文件名称
  20581. string projectFileName = file.FileName;
  20582. //上传的文件的路径
  20583. string filePath = "";
  20584. if (!Directory.Exists(fileDir))
  20585. {
  20586. Directory.CreateDirectory(fileDir);
  20587. }
  20588. //上传的文件的路径
  20589. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  20590. using (FileStream fs = System.IO.File.Create(filePath))
  20591. {
  20592. file.CopyTo(fs);
  20593. fs.Flush();
  20594. }
  20595. return Ok(JsonView(true, "上传成功!", projectFileName));
  20596. }
  20597. else
  20598. {
  20599. return Ok(JsonView(false, "上传失败!"));
  20600. }
  20601. }
  20602. catch (Exception ex)
  20603. {
  20604. return Ok(JsonView(false, ex.Message));
  20605. }
  20606. }
  20607. /// <summary>
  20608. /// 保险删除指定文件
  20609. /// </summary>
  20610. /// <param name="dto"></param>
  20611. /// <returns></returns>
  20612. [HttpPost]
  20613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20614. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  20615. {
  20616. try
  20617. {
  20618. string filePath = "";
  20619. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20620. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  20621. //int id = 0;
  20622. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  20623. // 删除该文件
  20624. try
  20625. {
  20626. System.IO.File.Delete(filePath);
  20627. 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()
  20628. {
  20629. Attachment = "",
  20630. }).ExecuteCommandAsync();
  20631. if (result != 0)
  20632. {
  20633. return Ok(JsonView(true, "成功!"));
  20634. }
  20635. else
  20636. {
  20637. return Ok(JsonView(false, "失败!"));
  20638. }
  20639. }
  20640. catch (Exception)
  20641. {
  20642. 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()
  20643. {
  20644. Attachment = "",
  20645. }).ExecuteCommandAsync();
  20646. if (result != 0)
  20647. {
  20648. return Ok(JsonView(true, "成功!"));
  20649. }
  20650. else
  20651. {
  20652. return Ok(JsonView(false, "失败!"));
  20653. }
  20654. }
  20655. }
  20656. catch (Exception ex)
  20657. {
  20658. return Ok(JsonView(false, "程序错误!"));
  20659. throw;
  20660. }
  20661. }
  20662. /// <summary>
  20663. /// 保险费用操作(删除)
  20664. /// </summary>
  20665. /// <param name="dto"></param>
  20666. /// <returns></returns>
  20667. [HttpPost]
  20668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20669. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  20670. {
  20671. try
  20672. {
  20673. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  20674. if (!res)
  20675. {
  20676. return Ok(JsonView(false, "删除失败"));
  20677. }
  20678. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  20679. {
  20680. IsDel = 1,
  20681. DeleteUserId = dto.DeleteUserId,
  20682. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  20683. }).ExecuteCommandAsync();
  20684. return Ok(JsonView(true, "删除成功!"));
  20685. }
  20686. catch (Exception ex)
  20687. {
  20688. return Ok(JsonView(false, "程序错误!"));
  20689. throw;
  20690. }
  20691. }
  20692. #endregion
  20693. #region 接团客户名单 PageId 104
  20694. /// <summary>
  20695. /// 接团客户名单
  20696. /// 迁移数据(慎用!)
  20697. /// </summary>
  20698. /// <returns></returns>
  20699. [HttpPost]
  20700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20701. public async Task<IActionResult> PostTourClientListChange()
  20702. {
  20703. try
  20704. {
  20705. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  20706. //var groupClinetData1
  20707. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  20708. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  20709. int updateCount = 0;
  20710. if (oldOAClientList.Count > 0)
  20711. {
  20712. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  20713. _sqlSugar.BeginTran();
  20714. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  20715. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  20716. foreach (var item in oldOAClientList)
  20717. {
  20718. int comId = 0;
  20719. string format = "yyyy-MM-dd HH:mm:ss";
  20720. string data11 = "1990-01-01 00:00";
  20721. var data1 = IsValidDate(item.OPdate, format);
  20722. if (data1) data11 = item.OPdate;
  20723. //客户公司验证
  20724. if (!string.IsNullOrEmpty(item.Company))
  20725. {
  20726. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  20727. if (clientComInfo == null) // add
  20728. {
  20729. var addInfo = new Crm_CustomerCompany()
  20730. {
  20731. CompanyAbbreviation = "",
  20732. CompanyFullName = item.Company,
  20733. Address = "",
  20734. PostCodes = "",
  20735. LastedOpUserId = item.OPer,
  20736. LastedOpDt = Convert.ToDateTime(data11),
  20737. CreateUserId = item.OPer,
  20738. CreateTime = Convert.ToDateTime(data11),
  20739. IsDel = 0
  20740. };
  20741. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  20742. if (comId1 > 0) comId = comId1;
  20743. }
  20744. else comId = clientComInfo.Id;
  20745. }
  20746. //客户人员验证
  20747. int clientId = 0;
  20748. string name = item.LastName + item.Name;
  20749. if (!string.IsNullOrEmpty(name))
  20750. {
  20751. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  20752. if (clientInfo == null)
  20753. {
  20754. DateTime? dateTime = null;
  20755. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  20756. if (isDt) dateTime = birthDayDt;
  20757. var addInfo1 = new Crm_DeleClient()
  20758. {
  20759. CrmCompanyId = comId,
  20760. DiId = -1,
  20761. LastName = item.LastName,
  20762. FirstName = item.Name,
  20763. OldName = "",
  20764. Pinyin = item.Pinyin,
  20765. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  20766. Marriage = 0,
  20767. Phone = item.Phone,
  20768. Job = item.Job,
  20769. BirthDay = dateTime
  20770. };
  20771. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  20772. if (clientId1 > 0) clientId = clientId1;
  20773. }
  20774. else clientId = clientInfo.Id;
  20775. }
  20776. if (clientId < 1)
  20777. {
  20778. continue;
  20779. }
  20780. int airType = 0;
  20781. if (item.AirType == "超经舱") airType = 459;
  20782. else if (item.AirType == "公务舱") airType = 458;
  20783. else if (item.AirType == "经济舱") airType = 460;
  20784. else if (item.AirType == "其他") airType = 565;
  20785. else if (item.AirType == "头等舱") airType = 457;
  20786. var _TourClientListEntity = new Grp_TourClientList()
  20787. {
  20788. DiId = item.Diid,
  20789. ClientId = clientId,
  20790. CreateUserId = item.OPer,
  20791. CreateTime = Convert.ToDateTime(data11),
  20792. Remark = item.Remark,
  20793. IsDel = item.Isdel,
  20794. ShippingSpaceTypeId = airType,
  20795. ShippingSpaceSpecialNeeds = item.AirRemark,
  20796. HotelSpecialNeeds = item.RoomType
  20797. };
  20798. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  20799. if (_TourClientList > 0)
  20800. {
  20801. updateCount++;
  20802. }
  20803. }
  20804. _sqlSugar.CommitTran();
  20805. }
  20806. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  20807. }
  20808. catch (Exception ex)
  20809. {
  20810. _sqlSugar.RollbackTran();
  20811. return Ok(JsonView(false, ex.Message));
  20812. }
  20813. //return Ok(JsonView(true));
  20814. }
  20815. private bool IsValidDate(string dateString, string format)
  20816. {
  20817. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  20818. }
  20819. /// <summary>
  20820. /// 接团客户名单
  20821. /// 根据团组Id查询List
  20822. /// </summary>
  20823. /// <param name="_dto"></param>
  20824. /// <returns></returns>
  20825. [HttpPost]
  20826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20827. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  20828. {
  20829. #region 参数验证
  20830. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  20831. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  20832. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  20833. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20834. #region 页面操作权限验证
  20835. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20836. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20837. #endregion
  20838. #endregion
  20839. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  20840. if (viewData.Code != 0)
  20841. {
  20842. return Ok(JsonView(false, viewData.Msg));
  20843. }
  20844. return Ok(JsonView(viewData.Data));
  20845. }
  20846. /// <summary>
  20847. /// 接团客户名单
  20848. /// 基础数据 Init
  20849. /// </summary>
  20850. /// <param name="_dto"></param>
  20851. /// <returns></returns>
  20852. [HttpPost]
  20853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20854. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20855. {
  20856. #region 参数验证
  20857. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20858. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20859. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20860. #region 页面操作权限验证
  20861. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20862. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20863. #endregion
  20864. #endregion
  20865. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20866. }
  20867. /// <summary>
  20868. /// 接团客户名单
  20869. /// 根据 Id查询 Details
  20870. /// </summary>
  20871. /// <param name="_dto"></param>
  20872. /// <returns></returns>
  20873. [HttpPost]
  20874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20875. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20876. {
  20877. #region 参数验证
  20878. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20879. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20880. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20881. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20882. #region 页面操作权限验证
  20883. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20884. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20885. #endregion
  20886. #endregion
  20887. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20888. if (viewData.Code != 0)
  20889. {
  20890. return Ok(JsonView(false, viewData.Msg));
  20891. }
  20892. return Ok(JsonView(viewData.Data));
  20893. }
  20894. /// <summary>
  20895. /// 接团客户名单
  20896. /// Add Or Edit
  20897. /// </summary>
  20898. /// <param name="_dto"></param>
  20899. /// <returns></returns>
  20900. [HttpPost]
  20901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20902. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  20903. {
  20904. #region 参数验证
  20905. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20906. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20907. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20908. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20909. #region 页面操作权限验证
  20910. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20911. if (_dto.Id == 0) //添加
  20912. {
  20913. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20914. }
  20915. else if (_dto.Id >= 0) //修改
  20916. {
  20917. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20918. }
  20919. #endregion
  20920. #endregion
  20921. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  20922. if (viewData.Code != 0)
  20923. {
  20924. return Ok(JsonView(false, viewData.Msg));
  20925. }
  20926. return Ok(JsonView(true));
  20927. }
  20928. /// <summary>
  20929. /// 接团客户名单
  20930. /// json字符串 AddMultiple(添加多个)
  20931. /// </summary>
  20932. /// <param name="_dto"></param>
  20933. /// <returns></returns>
  20934. [HttpPost]
  20935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20936. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  20937. {
  20938. #region 参数验证
  20939. string jsonLabel = _dto.JsonLabel;
  20940. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20941. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20942. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20943. #region 页面操作权限验证
  20944. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20945. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20946. #endregion
  20947. #endregion
  20948. var request = new TourClientListAddMultipleDto();
  20949. request.DiId = _dto.DiId;
  20950. request.UserId = _dto.UserId;
  20951. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  20952. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  20953. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  20954. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  20955. var infos = new List<TourClientListInfo>();
  20956. foreach (var data in datas)
  20957. {
  20958. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  20959. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  20960. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  20961. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  20962. {
  20963. continue;
  20964. }
  20965. infos.Add(new TourClientListInfo()
  20966. {
  20967. IsAccompany = 1,
  20968. LastName = lastName,
  20969. FirstName = firstName,
  20970. Pinyin = lastNameEn + @"/" + firstNameEn,
  20971. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20972. CompanyFullName = data.CompanyFullName,
  20973. Job = data.Job
  20974. });
  20975. }
  20976. if (infos.Any())
  20977. {
  20978. var viewData = await _tourClientListRep._AddMultiple(request);
  20979. if (viewData.Code != 0)
  20980. {
  20981. return Ok(JsonView(false, viewData.Msg));
  20982. }
  20983. return Ok(JsonView(true));
  20984. }
  20985. return Ok(JsonView(false));
  20986. }
  20987. /// <summary>
  20988. /// 接团客户名单
  20989. /// AddMultiple(添加多个)
  20990. /// </summary>
  20991. /// <param name="_dto"></param>
  20992. /// <returns></returns>
  20993. [HttpPost]
  20994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20995. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20996. {
  20997. #region 参数验证
  20998. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20999. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21000. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21001. #region 页面操作权限验证
  21002. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21003. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  21004. #endregion
  21005. #endregion
  21006. var viewData = await _tourClientListRep._AddMultiple(_dto);
  21007. if (viewData.Code != 0)
  21008. {
  21009. return Ok(JsonView(false, viewData.Msg));
  21010. }
  21011. return Ok(JsonView(true));
  21012. }
  21013. /// <summary>
  21014. /// 接团客户名单
  21015. /// Del
  21016. /// </summary>
  21017. /// <param name="_dto"></param>
  21018. /// <returns></returns>
  21019. [HttpPost]
  21020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21021. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  21022. {
  21023. #region 参数验证
  21024. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21025. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21026. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21027. #region 页面操作权限验证
  21028. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21029. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  21030. #endregion
  21031. #endregion
  21032. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  21033. if (viewData.Code != 0)
  21034. {
  21035. return Ok(JsonView(false, viewData.Msg));
  21036. }
  21037. return Ok(JsonView(true));
  21038. }
  21039. /// <summary>
  21040. /// 接团客户名单
  21041. /// 文件下载 客户名单
  21042. /// </summary>
  21043. /// <param name="_dto"></param>
  21044. /// <returns></returns>
  21045. [HttpPost]
  21046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21047. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  21048. {
  21049. #region 参数验证
  21050. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21051. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21052. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  21053. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21054. #region 页面操作权限验证
  21055. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21056. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21057. #endregion
  21058. #endregion
  21059. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  21060. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  21061. From Grp_TourClientList tcl
  21062. Left Join
  21063. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  21064. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  21065. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  21066. From Crm_DeleClient dc
  21067. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  21068. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  21069. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  21070. Where dc.IsDel = 0) temp
  21071. On temp.DcId =tcl.ClientId
  21072. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  21073. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  21074. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  21075. //载入模板
  21076. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  21077. if (_dto.Language == 1)
  21078. {
  21079. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  21080. }
  21081. //载入模板
  21082. var doc = new Document(tempPath);
  21083. DocumentBuilder builder = new DocumentBuilder(doc);
  21084. //获取word里所有表格
  21085. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21086. //获取所填表格的序数
  21087. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21088. var rowStart = tableOne.Rows[0]; //获取第1行
  21089. if (_dto.Language == 0)
  21090. {
  21091. //循环赋值
  21092. for (int i = 0; i < DcList.Count; i++)
  21093. {
  21094. EncryptionProcessor.DecryptProperties(DcList[i]);
  21095. builder.MoveToCell(0, i + 1, 0, 0);
  21096. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  21097. builder.MoveToCell(0, i + 1, 1, 0);
  21098. int sex = DcList[i].Sex;
  21099. string sexStr = string.Empty;
  21100. if (sex == 0) sexStr = "男";
  21101. else if (sex == 1) sexStr = "女";
  21102. else sexStr = "未设置";
  21103. builder.Write(sexStr);
  21104. builder.MoveToCell(0, i + 1, 2, 0);
  21105. string birthDay = DcList[i].BirthDay;
  21106. string birthDayStr = string.Empty;
  21107. if (!string.IsNullOrEmpty(birthDay))
  21108. {
  21109. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  21110. }
  21111. builder.Write(birthDayStr);
  21112. builder.MoveToCell(0, i + 1, 3, 0);
  21113. string company = "";
  21114. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21115. {
  21116. company = DcList[i].CompanyFullName.ToString();
  21117. }
  21118. builder.Write(company);
  21119. builder.MoveToCell(0, i + 1, 4, 0);
  21120. builder.Write(DcList[i].Job);
  21121. }
  21122. }
  21123. else if (_dto.Language == 1)
  21124. {
  21125. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  21126. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  21127. List<string> transArrayStr = new List<string>();
  21128. string transStrRes1 = "";
  21129. var clientEnglishs = new List<ClientEnglishView>();
  21130. for (int i = 0; i < DcList.Count; i++)
  21131. {
  21132. var dc = DcList[i];
  21133. EncryptionProcessor.DecryptProperties(dc);
  21134. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  21135. if (dc.Job.Equals("暂无")) dc.Job = "-";
  21136. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  21137. if (DcList.Count - 1 == i) transStrRes1 += str1;
  21138. else transStrRes1 += $"{str1}|";
  21139. clientEnglishs.Add(new()
  21140. {
  21141. Id = dc.Id,
  21142. LastName = dc.LastName,
  21143. FirstName = dc.FirstName,
  21144. Pinyin = dc.Pinyin,
  21145. Sex = dc.Sex,
  21146. CompanyFullName = dc.CompanyFullName,
  21147. Job = dc.Job,
  21148. IDCardNo = dc.IDCardNo,
  21149. BirthDay = dc.BirthDay,
  21150. });
  21151. }
  21152. #region AI转英文
  21153. string jsonValue = JsonConvert.SerializeObject(clientEnglishs);
  21154. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  21155. List<SeedMessages> messages = new List<SeedMessages>()
  21156. {
  21157. new SeedMessages
  21158. {
  21159. Role = KimiRole.user,
  21160. Content = jsonValue + text
  21161. }
  21162. };
  21163. KiMiApiClient client = new KiMiApiClient();
  21164. var kimiApiResult = await client.SeedMessage(messages);
  21165. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21166. string clients = kimiApiResult_JObject["content"].ToString();
  21167. string startStr = "```json", endStr = "```";
  21168. // 判断并清除开头部分
  21169. if (clients.StartsWith(startStr))
  21170. {
  21171. clients = clients.Remove(0, startStr.Length);
  21172. }
  21173. // 判断并清除结尾部分
  21174. if (clients.EndsWith(endStr))
  21175. {
  21176. clients = clients.Remove(clients.Length - endStr.Length);
  21177. }
  21178. var en_Json = JsonConvert.DeserializeObject<List<ClientEnglishView>>(clients);
  21179. //循环赋值
  21180. for (int i = 0; i < en_Json.Count; i++)
  21181. {
  21182. var dc = en_Json[i];
  21183. var dc1 = DcList.Find(x => x.Id == dc.Id);
  21184. string PYName = dc.FirstName + " " + dc.LastName;
  21185. builder.MoveToCell(0, i + 1, 0, 0);
  21186. builder.Write(PYName);
  21187. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  21188. builder.MoveToCell(0, i + 1, 1, 0);
  21189. builder.Write(sex);
  21190. DateTime birthDt;
  21191. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  21192. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21193. builder.MoveToCell(0, i + 1, 2, 0);
  21194. builder.Write(birthday);
  21195. string company = string.Empty, job = string.Empty;
  21196. company = dc.CompanyFullName;
  21197. job = dc.Job;
  21198. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  21199. {
  21200. //查询对照表
  21201. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  21202. if (tempCec != null)
  21203. {
  21204. company = tempCec.enName;
  21205. }
  21206. }
  21207. builder.MoveToCell(0, i + 1, 3, 0);
  21208. builder.Write(company);
  21209. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  21210. {
  21211. //查询对照表
  21212. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  21213. if (tempPec != null)
  21214. {
  21215. job = tempPec.enName;
  21216. }
  21217. }
  21218. builder.MoveToCell(0, i + 1, 4, 0);
  21219. builder.Write(job);
  21220. }
  21221. #endregion
  21222. #region 旧翻译英文处理
  21223. ////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";
  21224. //string transStrRes = "";
  21225. //if (transStrRes1.Length > 0)
  21226. //{
  21227. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  21228. //}
  21229. ////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
  21230. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  21231. ////List<string> transArray = new List<string> { };
  21232. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  21233. //if (transStrRes.Contains("|"))
  21234. //{
  21235. // string[] transArray1 = transStrRes.Split('|');
  21236. // if (transArray1.Length > 0)
  21237. // {
  21238. // foreach (var item in transArray1)
  21239. // {
  21240. // if (item.Contains("&"))
  21241. // {
  21242. // string[] transArray2 = item.Split('&');
  21243. // int index = 0;
  21244. // string companyName = "", job = "";
  21245. // if (transArray2.Length > 0)
  21246. // {
  21247. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  21248. // if (1 < transArray2.Length) companyName = transArray2[1];
  21249. // if (2 < transArray2.Length) job = transArray2[2];
  21250. // }
  21251. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  21252. // }
  21253. // }
  21254. // }
  21255. //}
  21256. ////循环赋值
  21257. //for (int i = 0; i < DcList.Count; i++)
  21258. //{
  21259. // string PYName = "";
  21260. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  21261. // {
  21262. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  21263. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  21264. // PYName = PY_First + " " + PY_Last;
  21265. // }
  21266. // else
  21267. // {
  21268. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  21269. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  21270. // PYName = PY_First + " " + PY_Last;
  21271. // }
  21272. // builder.MoveToCell(0, i + 1, 0, 0);
  21273. // builder.Write(PYName);
  21274. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  21275. // builder.MoveToCell(0, i + 1, 1, 0);
  21276. // builder.Write(sex);
  21277. // DateTime birthDt;
  21278. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  21279. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21280. // builder.MoveToCell(0, i + 1, 2, 0);
  21281. // builder.Write(birthday);
  21282. // string company = string.Empty, job = string.Empty;
  21283. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  21284. // if (dcTransInfo != null)
  21285. // {
  21286. // company = dcTransInfo.CompanyName;
  21287. // job = dcTransInfo.Job;
  21288. // }
  21289. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21290. // {
  21291. // //查询对照表
  21292. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  21293. // if (tempCec != null)
  21294. // {
  21295. // company = tempCec.enName;
  21296. // }
  21297. // //翻译
  21298. // else
  21299. // {
  21300. // }
  21301. // }
  21302. // builder.MoveToCell(0, i + 1, 3, 0);
  21303. // builder.Write(company);
  21304. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  21305. // {
  21306. // //查询对照表
  21307. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  21308. // if (tempPec != null)
  21309. // {
  21310. // job = tempPec.enName;
  21311. // }
  21312. // //翻译
  21313. // else
  21314. // {
  21315. // }
  21316. // }
  21317. // builder.MoveToCell(0, i + 1, 4, 0);
  21318. // builder.Write(job);
  21319. //}
  21320. #endregion
  21321. }
  21322. //删除多余行
  21323. while (tableOne.Rows.Count > DcList.Count + 1)
  21324. {
  21325. tableOne.Rows.RemoveAt(DcList.Count + 1);
  21326. }
  21327. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  21328. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  21329. doc.Save(fileDir);
  21330. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  21331. return Ok(JsonView(true, "操作成功!", Url));
  21332. }
  21333. private class TranslateInfo
  21334. {
  21335. public int Index { get; set; }
  21336. public string CompanyName { get; set; }
  21337. public string Job { get; set; }
  21338. }
  21339. [HttpPost]
  21340. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  21341. {
  21342. if (files.Count == 0)
  21343. {
  21344. return Ok(JsonView(false, "文件为空"));
  21345. }
  21346. KiMiApiClient KiMiApi = new KiMiApiClient();
  21347. var seedConter = await KiMiApi.UploadFilesAsync(files);
  21348. if (seedConter.Count == 0)
  21349. {
  21350. return Ok(JsonView(false, "上传结果为空!"));
  21351. }
  21352. var messages = new List<SeedMessages>
  21353. {
  21354. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  21355. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  21356. };
  21357. messages.InsertRange(1, seedConter);
  21358. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  21359. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21360. string clients = kimiApiResult_JObject["content"].ToString();
  21361. string startStr = "```json", endStr = "```";
  21362. // 判断并清除开头部分
  21363. if (clients.StartsWith(startStr))
  21364. {
  21365. clients = clients.Remove(0, startStr.Length);
  21366. }
  21367. // 判断并清除结尾部分
  21368. if (clients.EndsWith(endStr))
  21369. {
  21370. clients = clients.Remove(clients.Length - endStr.Length);
  21371. }
  21372. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  21373. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  21374. {
  21375. {"姓", "LastName" },
  21376. {"名", "FirstName" },
  21377. {"姓名拼音", "Pinyin" },
  21378. {"性别", "Sex" },
  21379. {"单位", "CompanyFullName" },
  21380. {"职务", "Job" },
  21381. {"出生日期", "Birthday" },
  21382. };
  21383. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  21384. foreach (var item in clients_JObject)
  21385. {
  21386. BaiduClientOCRView cdc = new BaiduClientOCRView();
  21387. foreach (var field in clientFieldMap.Keys)
  21388. {
  21389. if (item.TryGetValue(field, out JToken value))
  21390. {
  21391. var getValue = value.ToString();
  21392. System.Type type = cdc.GetType();
  21393. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  21394. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  21395. propertyInfo.SetValue(cdc, propertyValue);
  21396. }
  21397. }
  21398. crmClients.Add(cdc);
  21399. }
  21400. return Ok(JsonView(new
  21401. {
  21402. fileCount = files.Count,
  21403. UploadCount = seedConter.Count,
  21404. ApiResult = clients,
  21405. CrmClients = crmClients
  21406. }));
  21407. }
  21408. #endregion
  21409. #region 团组倒推表
  21410. /// <summary>
  21411. /// 倒推表基础数据
  21412. /// Init
  21413. /// </summary>
  21414. /// <returns></returns>
  21415. [HttpPost]
  21416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21417. public async Task<IActionResult> PostInvertedListInit()
  21418. {
  21419. var viewData = await _invertedListRep._Init();
  21420. if (viewData.Code != 0)
  21421. {
  21422. return Ok(JsonView(false, viewData.Msg));
  21423. }
  21424. return Ok(JsonView(viewData.Data));
  21425. }
  21426. /// <summary>
  21427. /// 倒推表
  21428. /// Info
  21429. /// </summary>
  21430. /// <param name="dto"></param>
  21431. /// <returns></returns>
  21432. [HttpPost]
  21433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21434. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  21435. {
  21436. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  21437. if (viewData.Code != 0)
  21438. {
  21439. return Ok(JsonView(false, viewData.Msg));
  21440. }
  21441. return Ok(JsonView(viewData.Data));
  21442. }
  21443. /// <summary>
  21444. /// 倒推表
  21445. /// Create
  21446. /// </summary>
  21447. /// <param name="dto"></param>
  21448. /// <returns></returns>
  21449. [HttpPost]
  21450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21451. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  21452. {
  21453. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  21454. if (viewData.Code != 0)
  21455. {
  21456. return Ok(JsonView(false, viewData.Msg));
  21457. }
  21458. return Ok(JsonView(viewData.Data));
  21459. }
  21460. /// <summary>
  21461. /// 倒推表
  21462. /// Update
  21463. /// </summary>
  21464. /// <param name="dto"></param>
  21465. /// <returns></returns>
  21466. [HttpPost]
  21467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21468. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  21469. {
  21470. var viewData = await _invertedListRep._Update(dto);
  21471. if (viewData.Code != 0)
  21472. {
  21473. return Ok(JsonView(false, viewData.Msg));
  21474. }
  21475. return Ok(JsonView(viewData.Data));
  21476. }
  21477. /// <summary>
  21478. /// 倒推表
  21479. /// File Download
  21480. /// </summary>
  21481. /// <param name="dto"></param>
  21482. /// <returns></returns>
  21483. [HttpPost]
  21484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21485. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  21486. {
  21487. var info2 = await _invertedListRep._Info(1, dto.DiId);
  21488. if (info2.Code != 0)
  21489. {
  21490. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  21491. }
  21492. var info1 = info2.Data as InvertedListInfoView;
  21493. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  21494. string teamName = "";
  21495. if (info != null) teamName = info.TeamName;
  21496. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  21497. var doc = new Document();
  21498. var builder = new DocumentBuilder(doc);
  21499. #region old insert
  21500. ////载入模板
  21501. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  21502. //Document doc = new Document(tempPath);
  21503. //DocumentBuilder builder = new DocumentBuilder(doc);
  21504. //利用键值对存放数据
  21505. //Dictionary<string, string> dic = new Dictionary<string, string>();
  21506. //dic.Add("TeamName", teamName);
  21507. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  21508. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  21509. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  21510. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  21511. //dic.Add("SQRemark", info1.ApprovalRemark);
  21512. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  21513. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  21514. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  21515. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  21516. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  21517. //dic.Add("QZRemark", info1.VisaInformationRemark);
  21518. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  21519. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  21520. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  21521. //dic.Add("CQRemark", info1.IssueVisaRemark);
  21522. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  21523. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  21524. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  21525. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  21526. //#region 填充word模板书签内容
  21527. //foreach (var key in dic.Keys)
  21528. //{
  21529. // builder.MoveToBookmark(key);
  21530. // builder.Write(dic[key]);
  21531. //}
  21532. //#endregion
  21533. #endregion
  21534. #region New Insert
  21535. string titleFont = $"仿宋",
  21536. contentFont = $"仿宋";
  21537. var fontColor = Color.FromArgb(64, 64, 64);
  21538. //设置标题 团组名称
  21539. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21540. builder.Font.Name = titleFont;
  21541. builder.Font.Color = fontColor;
  21542. builder.Font.Size = 12;
  21543. builder.Font.Bold = true;
  21544. builder.Writeln(teamName);
  21545. //设置副标题 团组出访时间
  21546. builder.Font.Size = 12;
  21547. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  21548. builder.Writeln();
  21549. var backgroundColor = Color.FromArgb(199, 199, 199);
  21550. var table = builder.StartTable();
  21551. builder.InsertCell();
  21552. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  21553. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  21554. builder.CellFormat.Borders.LineWidth = 1;
  21555. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  21556. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  21557. builder.RowFormat.Height = 40;
  21558. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21559. builder.Font.Name = contentFont;
  21560. builder.Font.Size = 12;
  21561. builder.Font.Bold = true;
  21562. builder.Font.Color = fontColor;
  21563. builder.Write("时间");
  21564. builder.InsertCell();
  21565. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  21566. builder.Write("流程");
  21567. builder.InsertCell();
  21568. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  21569. builder.Write("说明");
  21570. builder.EndRow();
  21571. //报批资料准备
  21572. if (info1.IsSelectedAirportd)
  21573. {
  21574. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  21575. }
  21576. //报批/提供送签资料
  21577. if (info1.IsSelectedApprovalData)
  21578. {
  21579. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  21580. }
  21581. //出批件护照办理
  21582. if (info1.IsSelectedIssueApproval)
  21583. {
  21584. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  21585. }
  21586. //签证资料准备
  21587. if (info1.IsSelectedVisaInfo)
  21588. {
  21589. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  21590. }
  21591. //送签
  21592. if (info1.IsSelectedSendVisa)
  21593. {
  21594. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  21595. }
  21596. //出签
  21597. if (info1.IsSelectedIssueVisa)
  21598. {
  21599. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  21600. }
  21601. //机票
  21602. if (info1.IsSelectedAirTicket)
  21603. {
  21604. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  21605. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  21606. }
  21607. //酒店
  21608. if (info1.IsSelectedHotel)
  21609. {
  21610. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  21611. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  21612. }
  21613. //开行前会
  21614. if (info1.IsSelectedPreTripMeeting)
  21615. {
  21616. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  21617. }
  21618. //送机
  21619. if (info1.IsSelectedAirportdDropOff)
  21620. {
  21621. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  21622. }
  21623. builder.EndTable();
  21624. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  21625. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  21626. for (int i = 0; i < table.Rows.Count; i++)
  21627. {
  21628. var row = table.Rows[i];
  21629. //设置宽度
  21630. row.Cells[0].CellFormat.Width = 20.00;
  21631. row.Cells[1].CellFormat.Width = 30.00;
  21632. row.Cells[2].CellFormat.Width = 50.00;
  21633. if (i != 0)
  21634. {
  21635. //边框设置
  21636. InvertedListFileDownloadSetBorders(row.Cells, 0);
  21637. InvertedListFileDownloadSetBorders(row.Cells, 1);
  21638. InvertedListFileDownloadSetBorders(row.Cells, 2);
  21639. }
  21640. }
  21641. #region 页脚插入图片
  21642. // 创建页脚
  21643. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  21644. doc.FirstSection.HeadersFooters.Add(footer);
  21645. Paragraph para = new Paragraph(doc);
  21646. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  21647. footer.AppendChild(para);
  21648. builder.MoveTo(para);
  21649. string imagePath = "./Images/FMGJ_Log.png";
  21650. builder.InsertImage(imagePath);
  21651. #endregion
  21652. #endregion
  21653. var fileDir = AppSettingsHelper.Get("WordBasePath");
  21654. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  21655. string filePath = fileDir + $@"InvertedList/{fileName}";
  21656. doc.Save(filePath);
  21657. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  21658. return Ok(JsonView(true, "操作成功!", Url));
  21659. }
  21660. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  21661. {
  21662. var fontColor = Color.FromArgb(64, 64, 64);
  21663. builder.InsertCell();
  21664. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  21665. builder.RowFormat.Height = 40;
  21666. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21667. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21668. builder.Font.Name = fontName;
  21669. builder.Font.Size = 8;
  21670. builder.Font.Bold = true;
  21671. builder.Font.Color = fontColor;
  21672. builder.Write(dateTime);
  21673. builder.InsertCell();
  21674. builder.Font.Size = 9;
  21675. builder.Font.Bold = true;
  21676. builder.Font.Color = fontColor;
  21677. builder.Write(content);
  21678. builder.InsertCell();
  21679. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21680. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  21681. builder.Font.Size = 9;
  21682. builder.Font.Bold = false;
  21683. builder.Font.Color = fontColor;
  21684. builder.Write(reamrk);
  21685. builder.EndRow();
  21686. }
  21687. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  21688. {
  21689. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  21690. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  21691. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  21692. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  21693. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  21694. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  21695. }
  21696. #endregion
  21697. #region 会务倒推表
  21698. /// <summary>
  21699. /// 会务倒推表
  21700. /// Init
  21701. /// </summary>
  21702. /// <returns></returns>
  21703. [HttpPost]
  21704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21705. public async Task<IActionResult> InforRetrogressTableInit()
  21706. {
  21707. var groupData = await _groupRepository.PostShareGroupInfos(1);
  21708. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  21709. return Ok(JsonView(false, groupData.Msg));
  21710. }
  21711. /// <summary>
  21712. /// 会务倒推表
  21713. /// ExcelDownload
  21714. /// </summary>
  21715. /// <param name="dto"></param>
  21716. /// <returns></returns>
  21717. [HttpPost]
  21718. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  21719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21720. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  21721. {
  21722. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  21723. var validatorRes = await validator.ValidateAsync(dto);
  21724. if (!validatorRes.IsValid)
  21725. {
  21726. StringBuilder sb = new StringBuilder();
  21727. foreach (var item in validatorRes.Errors)
  21728. {
  21729. sb.AppendLine(item.ErrorMessage);
  21730. }
  21731. return Ok(JsonView(false, sb.ToString()));
  21732. }
  21733. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  21734. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  21735. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  21736. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  21737. #region Excel
  21738. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  21739. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  21740. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  21741. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  21742. var fileNamePrefix = string.Empty;
  21743. if (days >= 30)
  21744. {
  21745. tempPath += $"会务工作倒推进度表(30天).xlsx";
  21746. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  21747. }
  21748. else if (days < 30 && days > 7)
  21749. {
  21750. tempPath += $"会务工作倒推进度表(15天).xlsx";
  21751. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  21752. }
  21753. else if (days <= 7)
  21754. {
  21755. tempPath += $"会务工作倒推进度表(7天).xlsx";
  21756. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  21757. }
  21758. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  21759. fileName = CommonFun.ValidFileName(fileName);
  21760. //载入模板
  21761. WorkbookDesigner designer = new WorkbookDesigner();
  21762. designer.Workbook = new Workbook(tempPath);
  21763. designer.Process();
  21764. if (!Directory.Exists(savePath))
  21765. {
  21766. Directory.CreateDirectory(savePath);
  21767. }
  21768. string serverPath = $"{savePath}{fileName}";
  21769. designer.Workbook.Save(serverPath);
  21770. string rst = $"{servicePath}{ftpPath}{fileName}";
  21771. #endregion
  21772. return Ok(JsonView(new { url = rst }));
  21773. }
  21774. #endregion
  21775. #region 三公签证费用(签证费、代办费)
  21776. /// <summary>
  21777. /// 三公签证费用(签证费、代办费)
  21778. /// List
  21779. /// </summary>
  21780. /// <returns></returns>
  21781. [HttpPost]
  21782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21783. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  21784. {
  21785. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  21786. }
  21787. /// <summary>
  21788. /// 三公签证费用(签证费、代办费)
  21789. /// Add Or Update
  21790. /// </summary>
  21791. /// <returns></returns>
  21792. [HttpPost]
  21793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21794. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  21795. {
  21796. var _view = await _visaFeeInfoRep.Update(_dto);
  21797. if (_view.Code != 0)
  21798. {
  21799. return Ok(JsonView(false, _view.Msg));
  21800. }
  21801. return Ok(JsonView(true, _view.Msg));
  21802. }
  21803. #endregion
  21804. #region 酒店询价
  21805. /// <summary>
  21806. /// 酒店询价
  21807. /// Init
  21808. /// </summary>
  21809. /// <returns></returns>
  21810. [HttpPost]
  21811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21812. public async Task<IActionResult> PostHotelInquiryInit()
  21813. {
  21814. var res = await _hotelInquiryRep._Init();
  21815. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21816. return Ok(JsonView(true, res.Msg, res.Data));
  21817. }
  21818. /// <summary>
  21819. /// 酒店询价
  21820. /// page Item
  21821. /// </summary>
  21822. /// <param name="_dto"></param>
  21823. /// <returns></returns>
  21824. [HttpPost]
  21825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21826. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  21827. {
  21828. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  21829. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21830. var view = res.Data as PageDataViewBase;
  21831. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  21832. }
  21833. /// <summary>
  21834. /// 酒店询价
  21835. /// info
  21836. /// </summary>
  21837. /// <param name="_dto"></param>
  21838. /// <returns></returns>
  21839. [HttpPost]
  21840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21841. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  21842. {
  21843. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  21844. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21845. return Ok(JsonView(true, res.Msg, res.Data));
  21846. }
  21847. /// <summary>
  21848. /// 酒店询价
  21849. /// Add Or Edit
  21850. /// </summary>
  21851. /// <param name="_dto"></param>
  21852. /// <returns></returns>
  21853. [HttpPost]
  21854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21855. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  21856. {
  21857. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  21858. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21859. return Ok(JsonView(true, res.Msg, res.Data));
  21860. }
  21861. /// <summary>
  21862. /// 酒店询价
  21863. /// Del
  21864. /// </summary>
  21865. /// <param name="_dto"></param>
  21866. /// <returns></returns>
  21867. [HttpPost]
  21868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21869. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21870. {
  21871. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21872. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21873. return Ok(JsonView(true, res.Msg, res.Data));
  21874. }
  21875. #endregion
  21876. #region 下载匹配op行程单
  21877. /// <summary>
  21878. /// 匹配op行程单
  21879. /// Init
  21880. /// </summary>
  21881. /// <param name="dto">团组列表请求dto</param>
  21882. /// <returns></returns>
  21883. [HttpPost]
  21884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21885. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21886. {
  21887. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21888. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21889. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21890. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21891. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21892. .Where(it => it.IsDel == 0)
  21893. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21894. .OrderByDescending(it => it.VisitStartDate)
  21895. .ToList();
  21896. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21897. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21898. var diids = groupInfos.Select(it => it.Id).ToList();
  21899. List<string> countrys = new List<string>();
  21900. foreach (var item in country)
  21901. {
  21902. var data = _groupRepository.FormartTeamName(item);
  21903. var dataArray = _groupRepository.GroupSplitCountry(data);
  21904. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21905. }
  21906. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  21907. List<string> areaArray = new List<string>(); //GetGroupCityLine
  21908. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  21909. foreach (var item in areaItem)
  21910. {
  21911. string areaStr = item.Value;
  21912. if (!string.IsNullOrEmpty(areaStr))
  21913. {
  21914. string[] str1 = areaStr.Split("-");
  21915. if (str1.Length > 0)
  21916. {
  21917. areaArray.AddRange(str1);
  21918. }
  21919. }
  21920. }
  21921. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  21922. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  21923. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  21924. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  21925. .ToList();
  21926. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  21927. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  21928. .Where(it => countriesIds.Contains(it.Id))
  21929. .Select(it => new { it.Id, Name = it.Name_CN })
  21930. .ToList();
  21931. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  21932. .Select(it => it.TeamName).ToList();
  21933. stopwatch.Stop();
  21934. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  21935. }
  21936. ///// <summary>
  21937. ///// 匹配op行程单
  21938. ///// Init 查询区域数据
  21939. ///// </summary>
  21940. ///// <param name="dto">团组列表请求dto</param>
  21941. ///// <returns></returns>
  21942. //[HttpPost]
  21943. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21944. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  21945. //{
  21946. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21947. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  21948. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  21949. // if (string.IsNullOrEmpty(countriesDataStr))
  21950. // {
  21951. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  21952. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  21953. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  21954. // }
  21955. // else
  21956. // {
  21957. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  21958. // }
  21959. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  21960. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  21961. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  21962. // List<dynamic> childList = new List<dynamic>();
  21963. // int parentId = dto.CountriesId;
  21964. // if (provinceData.Count > 1)
  21965. // {
  21966. // foreach (var item1 in provinceData)
  21967. // {
  21968. // List<dynamic> childList1 = new List<dynamic>();
  21969. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  21970. // foreach (var item2 in citiesData1)
  21971. // {
  21972. // List<dynamic> childList2 = new List<dynamic>();
  21973. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21974. // foreach (var item3 in countiesData1)
  21975. // {
  21976. // childList2.Add(new
  21977. // {
  21978. // id = item3.Id,
  21979. // parentId = item2.Id,
  21980. // level = "district",
  21981. // name = item3.Name_CN,
  21982. // });
  21983. // }
  21984. // childList1.Add(new
  21985. // {
  21986. // id = item2.Id,
  21987. // parentId = item1.Id,
  21988. // level = "city",
  21989. // name = item2.Name_CN,
  21990. // childList = childList2
  21991. // });
  21992. // }
  21993. // childList.Add(new
  21994. // {
  21995. // id = item1.Id,
  21996. // parentId = parentId,
  21997. // level = "province",
  21998. // name = item1.Name_CN,
  21999. // childList = childList1
  22000. // });
  22001. // }
  22002. // //城市
  22003. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  22004. // foreach (var item2 in citiesData2)
  22005. // {
  22006. // List<dynamic> childList22 = new List<dynamic>();
  22007. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  22008. // foreach (var item3 in countiesData1)
  22009. // {
  22010. // childList22.Add(new
  22011. // {
  22012. // id = item3.Id,
  22013. // parentId = item2.Id,
  22014. // level = "district",
  22015. // name = item3.Name_CN,
  22016. // });
  22017. // }
  22018. // childList.Add(new
  22019. // {
  22020. // id = item2.Id,
  22021. // parentId = parentId,
  22022. // level = "city",
  22023. // name = item2.Name_CN,
  22024. // childList = childList22
  22025. // });
  22026. // }
  22027. // }
  22028. // else
  22029. // {
  22030. // foreach (var item2 in citiesData)
  22031. // {
  22032. // string cname = item2.Name_CN;
  22033. // List<dynamic> childList1 = new List<dynamic>();
  22034. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  22035. // foreach (var item3 in countiesData1)
  22036. // {
  22037. // childList1.Add(new
  22038. // {
  22039. // Id = item3.Id,
  22040. // parentId = item2.Id,
  22041. // level = "district",
  22042. // name = item3.Name_CN
  22043. // });
  22044. // }
  22045. // childList.Add(new
  22046. // {
  22047. // id = item2.Id,
  22048. // parentId = parentId,
  22049. // level = "city",
  22050. // name = item2.Name_CN,
  22051. // childList = childList1
  22052. // });
  22053. // }
  22054. // }
  22055. // stopwatch.Stop();
  22056. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  22057. //}
  22058. /// <summary>
  22059. /// 匹配op行程单
  22060. /// 接团信息列表 Page
  22061. /// </summary>
  22062. /// <param name="dto">团组列表请求dto</param>
  22063. /// <returns></returns>
  22064. [HttpPost]
  22065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22066. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  22067. {
  22068. var swatch = new Stopwatch();
  22069. swatch.Start();
  22070. #region 参数验证
  22071. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  22072. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  22073. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22074. #region 页面操作权限验证
  22075. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  22076. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  22077. #endregion
  22078. #endregion
  22079. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  22080. {
  22081. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  22082. //string sqlWhere = "";
  22083. if (!string.IsNullOrEmpty(dto.Country))
  22084. {
  22085. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  22086. }
  22087. if (!string.IsNullOrEmpty(dto.Area))
  22088. {
  22089. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  22090. }
  22091. if (!string.IsNullOrEmpty(dto.TeamName))
  22092. {
  22093. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  22094. }
  22095. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  22096. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  22097. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  22098. swatch.Stop();
  22099. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  22100. }
  22101. else
  22102. {
  22103. return Ok(JsonView(false, "查询失败"));
  22104. }
  22105. }
  22106. /// <summary>
  22107. /// 匹配op行程单
  22108. /// 行程单下载
  22109. /// </summary>
  22110. /// <param name="dto">团组列表请求dto</param>
  22111. /// <returns></returns>
  22112. [HttpPost]
  22113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22114. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  22115. {
  22116. #region 参数验证
  22117. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  22118. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  22119. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22120. #region 页面操作权限验证
  22121. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  22122. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  22123. #endregion
  22124. #endregion
  22125. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  22126. {
  22127. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  22128. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  22129. }
  22130. else
  22131. {
  22132. return Ok(JsonView(false, "下载失败!"));
  22133. }
  22134. }
  22135. #endregion
  22136. #region 国家信息 数据 注释
  22137. //[HttpPost]
  22138. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  22139. //{
  22140. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  22141. // foreach (var item in dto)
  22142. // {
  22143. // infos.Add(new Grp_GroupsTaskAssignment()
  22144. // {
  22145. // DIId = item,
  22146. // CTId = 82,
  22147. // UId = 248,
  22148. // IsEnable = 1,
  22149. // CreateUserId = 233,
  22150. // CreateTime = DateTime.Now,
  22151. // IsDel = 0
  22152. // });
  22153. // infos.Add(new Grp_GroupsTaskAssignment()
  22154. // {
  22155. // DIId = item,
  22156. // CTId = 82,
  22157. // UId = 286,
  22158. // IsEnable = 1,
  22159. // CreateUserId = 233,
  22160. // CreateTime = DateTime.Now,
  22161. // IsDel = 0
  22162. // });
  22163. // }
  22164. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  22165. // return Ok("操作成功");
  22166. //}
  22167. //public class paramJsonDto
  22168. //{
  22169. // public List<CountriesInfo> str { get; set; }
  22170. //}
  22171. //[HttpPost]
  22172. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  22173. //{
  22174. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  22175. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  22176. // List<Sys_Cities> cities = new List<Sys_Cities>();
  22177. // List<Sys_Cities> districts = new List<Sys_Cities>();
  22178. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22179. // _sqlSugar.BeginTran();
  22180. // int countitiesIndex = 0;
  22181. // foreach (var item in dto.str)
  22182. // {
  22183. // dynamic data = item.c;
  22184. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  22185. // if (data != null)
  22186. // {
  22187. // countitiesIndex++;
  22188. // foreach (var item1 in data)
  22189. // {
  22190. // string cnname = item1.cn;
  22191. // string enname = item1.en;
  22192. // Sys_Cities provinceInfo = new Sys_Cities()
  22193. // {
  22194. // CountriesId = countriesId,
  22195. // Name_CN = cnname,
  22196. // Name_EN = enname,
  22197. // ParentId = 0,
  22198. // IsCapital = 1,
  22199. // CreateUserId = 208,
  22200. // CreateTime = DateTime.Now,
  22201. // IsDel = 0
  22202. // };
  22203. // if (item1.lv == "province") //省份
  22204. // {
  22205. // provinceInfo.Level = 1;
  22206. // int provinceId = 0;
  22207. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  22208. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  22209. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22210. // var data1 = item1.c;
  22211. // foreach (var item2 in data1)
  22212. // {
  22213. // if (item2.lv == "city")
  22214. // {
  22215. // string citycnname = item2.cn;
  22216. // string cityenname = item2.en;
  22217. // Sys_Cities cityInfo = new Sys_Cities()
  22218. // {
  22219. // CountriesId = countriesId,
  22220. // ParentId = provinceId,
  22221. // Level = 2,
  22222. // Name_CN = citycnname,
  22223. // Name_EN = cityenname,
  22224. // IsCapital = 1,
  22225. // CreateUserId = 208,
  22226. // CreateTime = DateTime.Now,
  22227. // IsDel = 0
  22228. // };
  22229. // if (item2.c != null)
  22230. // {
  22231. // int cityId = 0;
  22232. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  22233. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22234. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  22235. // foreach (var item3 in item2.c)
  22236. // {
  22237. // if (item3.lv == "district")
  22238. // {
  22239. // var districtInfo = new Sys_Cities()
  22240. // {
  22241. // CountriesId = countriesId,
  22242. // Name_CN = item3.cn,
  22243. // Name_EN = item3.en,
  22244. // Level = 3,
  22245. // ParentId = cityId,
  22246. // IsCapital = 1,
  22247. // CreateUserId = 208,
  22248. // CreateTime = DateTime.Now,
  22249. // IsDel = 0
  22250. // };
  22251. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22252. // //{
  22253. // districts.Add(districtInfo);
  22254. // //}
  22255. // }
  22256. // }
  22257. // }
  22258. // else
  22259. // {
  22260. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  22261. // //{
  22262. // cities.Add(cityInfo);
  22263. // //}
  22264. // }
  22265. // }
  22266. // }
  22267. // }
  22268. // else if (item1.lv == "city")//城市
  22269. // {
  22270. // provinceInfo.Level = 2;
  22271. // if (item1.c != null)
  22272. // {
  22273. // int cityId = 0;
  22274. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  22275. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22276. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22277. // foreach (var item3 in item1.c)
  22278. // {
  22279. // if (item3.lv == "district")
  22280. // {
  22281. // var districtInfo = new Sys_Cities()
  22282. // {
  22283. // CountriesId = countriesId,
  22284. // Name_CN = item3.cn,
  22285. // Name_EN = item3.en,
  22286. // Level = 3,
  22287. // ParentId = cityId,
  22288. // IsCapital = 1,
  22289. // CreateUserId = 208,
  22290. // CreateTime = DateTime.Now,
  22291. // IsDel = 0
  22292. // };
  22293. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22294. // //{
  22295. // districts.Add(districtInfo);
  22296. // //}
  22297. // }
  22298. // }
  22299. // }
  22300. // else
  22301. // {
  22302. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  22303. // //{
  22304. // cities.Add(provinceInfo);
  22305. // //}
  22306. // }
  22307. // }
  22308. // }
  22309. // }
  22310. // }
  22311. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  22312. // cities = cities.Distinct().ToList();
  22313. // districts = districts.Distinct().ToList();
  22314. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  22315. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  22316. // cities.AddRange(districts);
  22317. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  22318. // //_sqlSugar.RollbackTran();
  22319. // _sqlSugar.CommitTran();
  22320. // return Ok(JsonView(false, "操作成功!"));
  22321. //}
  22322. //[HttpPost]
  22323. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  22324. //{
  22325. // List<CountitiesInfo> infos = dto.MyProperty;
  22326. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  22327. // _sqlSugar.BeginTran();
  22328. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22329. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  22330. // foreach (var item in infos)
  22331. // {
  22332. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  22333. // if (countryInfo != null)
  22334. // {
  22335. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  22336. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  22337. // if (cityInfo1 != null)
  22338. // {
  22339. // cityInfo1.IsCapital = 0;
  22340. // cityInfos.Add(cityInfo1);
  22341. // }
  22342. // }
  22343. // }
  22344. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  22345. // .UpdateColumns(it => it.IsCapital)
  22346. // .WhereColumns(it => it.Id)
  22347. // .ExecuteCommand();
  22348. // //_sqlSugar.RollbackTran();
  22349. // _sqlSugar.CommitTran();
  22350. // return Ok(JsonView(false, "操作成功!"));
  22351. //}
  22352. //public class CounrtiesDto
  22353. //{
  22354. // public List<CountitiesInfo> MyProperty { get; set; }
  22355. //}
  22356. //public class CountitiesInfo
  22357. //{
  22358. // /// <summary>
  22359. // /// 圣约翰
  22360. // /// </summary>
  22361. // public string capital_name_chinese { get; set; }
  22362. // /// <summary>
  22363. // ///
  22364. // /// </summary>
  22365. // public string capital_name { get; set; }
  22366. // /// <summary>
  22367. // ///
  22368. // /// </summary>
  22369. // public string country_type { get; set; }
  22370. // /// <summary>
  22371. // /// 安提瓜和巴布达
  22372. // /// </summary>
  22373. // public string country_name_chinese { get; set; }
  22374. // /// <summary>
  22375. // /// 安提瓜和巴布达
  22376. // /// </summary>
  22377. // public string country_name_chinese_short { get; set; }
  22378. // /// <summary>
  22379. // /// 安提瓜和巴布达
  22380. // /// </summary>
  22381. // public string country_name_chinese_UN { get; set; }
  22382. // /// <summary>
  22383. // ///
  22384. // /// </summary>
  22385. // public string country_name_english_abbreviation { get; set; }
  22386. // /// <summary>
  22387. // ///
  22388. // /// </summary>
  22389. // public string country_name_english_formal { get; set; }
  22390. // /// <summary>
  22391. // ///
  22392. // /// </summary>
  22393. // public string country_name_english_UN { get; set; }
  22394. // /// <summary>
  22395. // ///
  22396. // /// </summary>
  22397. // public string continent_name { get; set; }
  22398. // /// <summary>
  22399. // ///
  22400. // /// </summary>
  22401. // public string subregion_name { get; set; }
  22402. // /// <summary>
  22403. // ///
  22404. // /// </summary>
  22405. // public string country_code2 { get; set; }
  22406. // /// <summary>
  22407. // ///
  22408. // /// </summary>
  22409. // public string country_code3 { get; set; }
  22410. // /// <summary>
  22411. // ///
  22412. // /// </summary>
  22413. // public string phone_code { get; set; }
  22414. //}
  22415. //public class CountriesInfo : BasicInfo
  22416. //{
  22417. // public List<CitiesInfo> c { get; set; }
  22418. //}
  22419. //public class CitiesInfo : BasicInfo
  22420. //{
  22421. // public List<AreaInfo> c { get; set; }
  22422. //}
  22423. //public class AreaInfo : BasicInfo
  22424. //{
  22425. // public List<AreaInfo> c { get; set; }
  22426. //}
  22427. //public class BasicInfo
  22428. //{
  22429. // public string code { get; set; }
  22430. // public string cn { get; set; }
  22431. // public string lv { get; set; }
  22432. // public string en { get; set; }
  22433. //}
  22434. #endregion
  22435. #region 查看邀请方
  22436. /// <summary>
  22437. /// 查看邀请方
  22438. /// 邀请方信息 Init
  22439. /// </summary>
  22440. /// <param name="dto"></param>
  22441. /// <returns></returns>
  22442. [HttpPost]
  22443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22444. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  22445. {
  22446. string sqlWhere = string.Empty;
  22447. if (!string.IsNullOrEmpty(dto.Search))
  22448. {
  22449. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  22450. }
  22451. string sql = string.Format($@"Select
  22452. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  22453. Id,
  22454. UnitName
  22455. From Res_InvitationOfficialActivityData
  22456. Where IsDel = 0
  22457. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  22458. RefAsync<int> total = 0;
  22459. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22460. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  22461. }
  22462. /// <summary>
  22463. /// 查看邀请方
  22464. /// 国家信息 Init
  22465. /// </summary>
  22466. /// <param name="dto"></param>
  22467. /// <returns></returns>
  22468. [HttpPost]
  22469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22470. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  22471. {
  22472. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  22473. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  22474. var diids = groupInfos.Select(it => it.Id).ToList();
  22475. List<string> countrys = new List<string>();
  22476. foreach (var item in country)
  22477. {
  22478. var data = _groupRepository.FormartTeamName(item);
  22479. var dataArray = _groupRepository.GroupSplitCountry(data);
  22480. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  22481. }
  22482. countrys = countrys.Distinct().ToList();
  22483. for (int i = 0; i < countrys.Count; i++)
  22484. {
  22485. string item = countrys[i];
  22486. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  22487. {
  22488. countrys.Remove(item);
  22489. i--;
  22490. }
  22491. }
  22492. RefAsync<int> total = 0;
  22493. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  22494. .Where(it => countrys.Contains(it.Name_CN))
  22495. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22496. .Select(it => new { id = it.Id, name = it.Name_CN })
  22497. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22498. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22499. }
  22500. /// <summary>
  22501. /// 查看邀请方
  22502. /// 城市信息 Init
  22503. /// </summary>
  22504. /// <param name="dto"></param>
  22505. /// <returns></returns>
  22506. [HttpPost]
  22507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22508. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  22509. {
  22510. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  22511. RefAsync<int> total = 0;
  22512. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  22513. .Where(it => it.CountriesId == dto.CountiesId)
  22514. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22515. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  22516. .Select(it => new { id = it.Id, name = it.Name_CN })
  22517. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22518. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22519. }
  22520. /// <summary>
  22521. /// 查看邀请方
  22522. /// 团组名称 Init
  22523. /// </summary>
  22524. /// <param name="dto"></param>
  22525. /// <returns></returns>
  22526. [HttpPost]
  22527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22528. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  22529. {
  22530. var watch = new Stopwatch();
  22531. watch.Start();
  22532. RefAsync<int> total = 0;
  22533. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  22534. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  22535. .Where((oa, di) => oa.IsDel == 0)
  22536. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  22537. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  22538. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  22539. .Distinct()
  22540. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22541. watch.Stop();
  22542. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  22543. }
  22544. /// <summary>
  22545. /// 查看邀请方
  22546. /// 团组 & 邀请方信息
  22547. /// </summary>
  22548. /// <param name="dto"></param>
  22549. /// <returns></returns>
  22550. [HttpPost]
  22551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22552. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  22553. {
  22554. var watch = new Stopwatch();
  22555. watch.Start();
  22556. RefAsync<int> total = 0;
  22557. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  22558. .AS("Grp_DelegationInfo")
  22559. .Includes(x => x.InvitingInfos)
  22560. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  22561. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  22562. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  22563. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  22564. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  22565. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  22566. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22567. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  22568. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  22569. infos.ForEach(x =>
  22570. {
  22571. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  22572. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  22573. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  22574. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  22575. });
  22576. watch.Stop();
  22577. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  22578. }
  22579. #endregion
  22580. #region 报批行程
  22581. /// <summary>
  22582. /// 报批行程初始化
  22583. /// </summary>
  22584. /// <param name="dto"></param>
  22585. /// <returns></returns>
  22586. [HttpPost]
  22587. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  22588. {
  22589. const int chiNumber = 5;
  22590. var jw = JsonView(false);
  22591. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  22592. var group = groupList.First();
  22593. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  22594. group = groupList.First(x => x.Id == diid);
  22595. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22596. .Where(x => x.DiId == diid && x.IsDel == 0)
  22597. .ToArray();
  22598. var count = 1;
  22599. foreach (var item in blackCodeList)
  22600. {
  22601. if (string.IsNullOrWhiteSpace(item.Title))
  22602. {
  22603. item.Title = "未设置名称数据" + count;
  22604. }
  22605. count++;
  22606. }
  22607. ;
  22608. if (group == null)
  22609. {
  22610. jw.Msg = "暂无团组!";
  22611. return Ok(jw);
  22612. }
  22613. var data = new
  22614. {
  22615. groupList = groupList.Select(x => new
  22616. {
  22617. x.TeamName,
  22618. x.Id
  22619. }),
  22620. content = new ArrayList(),
  22621. groupInfo = new
  22622. {
  22623. group.VisitDays,
  22624. group.TourCode,
  22625. group.VisitPNumber,
  22626. group.TeamName,
  22627. group.Id,
  22628. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  22629. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  22630. group.ClientUnit
  22631. },
  22632. blackCodeList = blackCodeList.Select(x => new
  22633. {
  22634. x.Title,
  22635. x.Id
  22636. }),
  22637. FileTempList = new ArrayList()
  22638. {
  22639. new { Index = 1,FileName = "旧模板" },
  22640. new { Index = 2,FileName = "省外办" },
  22641. new { Index = 3,FileName = "市外办" },
  22642. }
  22643. };
  22644. var resultArr = new ArrayList();
  22645. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  22646. #region 默认不生成行程
  22647. //if (content.Count == 0)
  22648. //{
  22649. // var stay = "-";
  22650. // var cityPath = "-";
  22651. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22652. // .Where(x => x.DiId == diid && x.IsDel == 0)
  22653. // .ToList();
  22654. // //添加城市路径以及住宿地
  22655. // //黑屏代码数据
  22656. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  22657. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22658. // {
  22659. // jw = JsonView(true, "黑屏代码有误!", data);
  22660. // return Ok(jw);
  22661. // }
  22662. // data = data with
  22663. // {
  22664. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  22665. // {
  22666. // x.Title,
  22667. // x.Id,
  22668. // }).ToArray())
  22669. // };
  22670. // foreach (DataRow row in dtBlack.Rows)
  22671. // {
  22672. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22673. // {
  22674. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  22675. // return Ok(jw);
  22676. // }
  22677. // }
  22678. // //黑屏代码获取时间区间
  22679. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22680. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22681. // _sqlSugar.BeginTran();
  22682. // for (int i = 0; i < timeArr.Count; i++)
  22683. // {
  22684. // stay = "-";
  22685. // cityPath = "-";
  22686. // DateTime NewData = DateTime.Parse(timeArr[i]);
  22687. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22688. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22689. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22690. // if (tbSelect.Length > 0)
  22691. // {
  22692. // List<string> threeCodeStr = new List<string>();
  22693. // foreach (var item in tbSelect)
  22694. // {
  22695. // var threeCode = item["Three"].ToString() ?? "";
  22696. // if (threeCode.Length == 6)
  22697. // {
  22698. // var start = threeCode.Substring(0, 3);
  22699. // var end = threeCode.Substring(3, 3);
  22700. // if (threeCodeStr.Count == 0)
  22701. // {
  22702. // threeCodeStr.Add(start);
  22703. // threeCodeStr.Add(end);
  22704. // }
  22705. // else
  22706. // {
  22707. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22708. // {
  22709. // threeCodeStr.Add(end);
  22710. // }
  22711. // else
  22712. // {
  22713. // threeCodeStr.Add(start);
  22714. // threeCodeStr.Add(end);
  22715. // }
  22716. // }
  22717. // }
  22718. // }
  22719. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22720. // var last = threeCodeStr.Last();
  22721. // foreach (var item in threeCodeStr)
  22722. // {
  22723. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22724. // if (item.Equals(last))
  22725. // {
  22726. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22727. // }
  22728. // }
  22729. // cityPath = cityPath.Trim('-');
  22730. // }
  22731. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  22732. // appro.Diid = diid ?? -1;
  22733. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22734. // appro.Id = thisId;
  22735. // appro.CreateUserId = dto.UserId;
  22736. // appro.CreateTime = DateTime.Now;
  22737. // content.Add(appro);
  22738. // }
  22739. // _sqlSugar.CommitTran();
  22740. //}
  22741. #endregion
  22742. foreach (var x in content)
  22743. {
  22744. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  22745. if (chiList.Count < chiNumber)
  22746. {
  22747. for (int i = chiList.Count; i < chiNumber; i++)
  22748. {
  22749. chiList.Add(new Grp_ApprovalTravelDetails());
  22750. }
  22751. }
  22752. resultArr.Add(new
  22753. {
  22754. x.Id,
  22755. x.Date,
  22756. x.Diid,
  22757. chiList = chiList.Select(x1 => new
  22758. {
  22759. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22760. x1.Details,
  22761. x1.ParentId,
  22762. x1.Id
  22763. })
  22764. });
  22765. }
  22766. data = data with
  22767. {
  22768. content = resultArr,
  22769. };
  22770. jw = JsonView(true, "获取成功!", data);
  22771. return Ok(jw);
  22772. }
  22773. /// <summary>
  22774. /// 报批行程删除
  22775. /// </summary>
  22776. /// <param name="dto"></param>
  22777. /// <returns></returns>
  22778. [HttpPost]
  22779. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  22780. {
  22781. var jw = JsonView(false);
  22782. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22783. if (group == null)
  22784. {
  22785. jw.Msg = "团组参数有误!";
  22786. return Ok(jw);
  22787. }
  22788. try
  22789. {
  22790. _sqlSugar.BeginTran();
  22791. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  22792. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  22793. {
  22794. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22795. DeleteUserId = dto.uesrId,
  22796. IsDel = 1
  22797. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  22798. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  22799. {
  22800. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22801. DeleteUserId = dto.uesrId,
  22802. IsDel = 1
  22803. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  22804. _sqlSugar.CommitTran();
  22805. jw = JsonView(true, "删除成功");
  22806. }
  22807. catch (Exception ex)
  22808. {
  22809. jw = JsonView(false, ex.Message);
  22810. }
  22811. return Ok(jw);
  22812. }
  22813. /// <summary>
  22814. /// 报批行程保存
  22815. /// </summary>
  22816. /// <param name="dto"></param>
  22817. /// <returns></returns>
  22818. [HttpPost]
  22819. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  22820. {
  22821. var jw = JsonView(false);
  22822. var Find = dto.Arr.Find(x => x.id == 0);
  22823. if (Find != null)
  22824. {
  22825. jw.Msg = "生成的ID为0!";
  22826. return Ok(jw);
  22827. }
  22828. foreach (var item in dto.Arr)
  22829. {
  22830. foreach (var chi in item.chiList)
  22831. {
  22832. if (chi.parentId == 0)
  22833. {
  22834. chi.parentId = item.id;
  22835. }
  22836. }
  22837. }
  22838. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  22839. _sqlSugar.BeginTran();
  22840. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  22841. {
  22842. var parentIds = dto.Arr.Select(x => x.id).ToList();
  22843. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  22844. {
  22845. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22846. DeleteUserId = dto.UserId,
  22847. IsDel = 1
  22848. }).ExecuteCommand();
  22849. }
  22850. try
  22851. {
  22852. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  22853. {
  22854. CreateTime = DateTime.Now,
  22855. CreateUserId = dto.UserId,
  22856. Details = x.details,
  22857. ParentId = x.parentId,
  22858. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22859. Remark = "",
  22860. IsDel = 0
  22861. }).ToList()).ExecuteCommand();
  22862. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22863. {
  22864. Id = x.id,
  22865. Details = x.details,
  22866. ParentId = x.parentId,
  22867. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22868. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22869. {
  22870. Details = x.Details,
  22871. ParentId = x.ParentId,
  22872. Time = x.Time
  22873. }).ExecuteCommand();
  22874. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22875. {
  22876. Id = x.id,
  22877. Date = x.date,
  22878. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22879. {
  22880. Date = x.Date
  22881. }).ExecuteCommand();
  22882. _sqlSugar.CommitTran();
  22883. jw = JsonView(true, "保存成功!");
  22884. }
  22885. catch (Exception ex)
  22886. {
  22887. _sqlSugar.RollbackTran();
  22888. jw = JsonView(false, "保存失败!" + ex.Message);
  22889. }
  22890. return Ok(jw);
  22891. }
  22892. /// <summary>
  22893. /// 报批行程生成
  22894. /// </summary>
  22895. /// <param name="dto"></param>
  22896. /// <returns></returns>
  22897. [HttpPost]
  22898. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22899. {
  22900. var jw = JsonView(false);
  22901. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22902. if (group == null)
  22903. {
  22904. jw.Msg = "暂无该团组!";
  22905. return Ok(jw);
  22906. }
  22907. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  22908. //黑屏代码数据
  22909. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  22910. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22911. {
  22912. jw.Msg = "黑屏代码有误!";
  22913. return Ok(jw);
  22914. }
  22915. foreach (DataRow row in dtBlack.Rows)
  22916. {
  22917. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22918. {
  22919. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  22920. return Ok(jw);
  22921. }
  22922. }
  22923. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  22924. var resultArr = new ArrayList();
  22925. //if (officialActivitiesArr.Count == 0)
  22926. //{
  22927. // jw.Msg = "暂无公务出访信息!";
  22928. // return Ok(jw);
  22929. //}
  22930. try
  22931. {
  22932. _sqlSugar.BeginTran();
  22933. DeleteApprovalJourney(new
  22934. Domain.Dtos.Groups.DeleteApprovalJourney
  22935. {
  22936. Diid = dto.Diid,
  22937. uesrId = dto.Userid
  22938. });
  22939. var stay = "-";
  22940. var cityPath = "-";
  22941. var arriveCountry = string.Empty;
  22942. //添加城市路径以及住宿地
  22943. //黑屏代码获取时间区间
  22944. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22945. var empty = "【未收入该三字码!请机票同事录入】";
  22946. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22947. #region 配置公务活动时间
  22948. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  22949. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  22950. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  22951. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  22952. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  22953. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22954. {
  22955. 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" }),
  22956. 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"}),
  22957. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22958. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  22959. };
  22960. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22961. {
  22962. 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" }),
  22963. 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"}),
  22964. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22965. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  22966. };
  22967. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  22968. {
  22969. 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" }),
  22970. 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"}),
  22971. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  22972. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  22973. };
  22974. #endregion
  22975. var nextDayNum = 0;
  22976. for (int i = 0; i < timeArr.Count; i++)
  22977. {
  22978. stay = "-";
  22979. cityPath = "-";
  22980. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22981. DateTime NewData = DateTime.Parse(timeArr[i]);
  22982. //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();
  22983. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22984. if (nextDayNum > 0)
  22985. {
  22986. nextDayNum--;
  22987. }
  22988. if (tbSelect.Length > 0)
  22989. {
  22990. List<string> threeCodeStr = new List<string>();
  22991. bool isTrade = false;
  22992. string trip = string.Empty;
  22993. foreach (var item in tbSelect)
  22994. {
  22995. if (nextDayNum == 0)
  22996. {
  22997. nextDayNum = Convert.ToInt32(item["Sign"]);
  22998. }
  22999. var airStartTime = item["StartTime"].ToString() ?? "0000";
  23000. var airEndTime = item["EndTime"].ToString() ?? "0000";
  23001. var takeOffTime = DateTime.Parse(timeArr[i]);
  23002. var fallToTime = DateTime.Parse(timeArr[i]);
  23003. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  23004. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  23005. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  23006. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  23007. if (nextDayNum > 0)
  23008. {
  23009. fallToTime = fallToTime.AddDays(nextDayNum);
  23010. }
  23011. trip = string.Empty;
  23012. var start = string.Empty;
  23013. var end = string.Empty;
  23014. var threeCode = item["Three"].ToString() ?? "";
  23015. if (threeCode.Length == 6)
  23016. {
  23017. start = threeCode.Substring(0, 3);
  23018. end = threeCode.Substring(3, 3);
  23019. if (threeCodeStr.Count == 0)
  23020. {
  23021. threeCodeStr.Add(start);
  23022. threeCodeStr.Add(end);
  23023. }
  23024. else
  23025. {
  23026. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  23027. {
  23028. threeCodeStr.Add(end);
  23029. }
  23030. else
  23031. {
  23032. threeCodeStr.Add(start);
  23033. threeCodeStr.Add(end);
  23034. }
  23035. }
  23036. }
  23037. //处理机票信息
  23038. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  23039. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  23040. if (start_Object == null)
  23041. {
  23042. start_Object = new Res_ThreeCode()
  23043. {
  23044. AirPort = empty,
  23045. AirPort_En = empty,
  23046. City = empty,
  23047. Country = empty,
  23048. Four = empty,
  23049. Three = empty,
  23050. };
  23051. }
  23052. if (end_Object == null)
  23053. {
  23054. end_Object = new Res_ThreeCode()
  23055. {
  23056. AirPort = empty,
  23057. AirPort_En = empty,
  23058. City = empty,
  23059. Country = empty,
  23060. Four = empty,
  23061. Three = empty,
  23062. };
  23063. }
  23064. //机型判断
  23065. string airModel = item["AirModel"].ToString();
  23066. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  23067. string flightTime = item["FlightTime"].ToString();
  23068. flightTime = ParseBlackTime(flightTime);
  23069. //航班号
  23070. string flightcode = item["Fliagtcode"].ToString();
  23071. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  23072. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  23073. if (aircompany == null)
  23074. {
  23075. aircompany = new Res_AirCompany
  23076. {
  23077. CnName = hsEmpty,
  23078. EnName = hsEmpty,
  23079. ShortCode = hsEmpty,
  23080. };
  23081. }
  23082. //航班前公务安排
  23083. if (tbSelect.First().Equals(item) && i != 0)
  23084. {
  23085. foreach (var takeoff in takeoffTimes)
  23086. {
  23087. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  23088. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  23089. {
  23090. foreach (var addTime in takeoff.Item2)
  23091. {
  23092. chiarr.Add(new Grp_ApprovalTravelDetails
  23093. {
  23094. Time = addTime,
  23095. CreateTime = DateTime.Now,
  23096. CreateUserId = dto.Userid,
  23097. ParentId = 0,
  23098. Details = "公务活动"
  23099. });
  23100. }
  23101. break;
  23102. }
  23103. }
  23104. }
  23105. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  23106. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  23107. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  23108. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  23109. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  23110. if (isTrade)
  23111. {
  23112. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  23113. trip += "(转机不出机场)。";
  23114. }
  23115. //else
  23116. //{
  23117. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  23118. //}
  23119. chiarr.Add(new Grp_ApprovalTravelDetails
  23120. {
  23121. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  23122. CreateTime = DateTime.Now,
  23123. CreateUserId = dto.Userid,
  23124. ParentId = 0,
  23125. Details = trip
  23126. });
  23127. //最后一条到达的时间安排公务
  23128. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  23129. {
  23130. bool isCheckCountry = false;
  23131. if (end_Object.Country != arriveCountry)
  23132. {
  23133. arriveCountry = end_Object.Country;
  23134. isCheckCountry = true;
  23135. }
  23136. if (nextDayNum == 0)
  23137. {
  23138. //需要入境的情况
  23139. if (isCheckCountry)
  23140. {
  23141. foreach (var fallTime in fallTimesCheckCountry)
  23142. {
  23143. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23144. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23145. {
  23146. foreach (var addTime in fallTime.Item2)
  23147. {
  23148. chiarr.Add(new Grp_ApprovalTravelDetails
  23149. {
  23150. Time = addTime,
  23151. CreateTime = DateTime.Now,
  23152. CreateUserId = dto.Userid,
  23153. ParentId = 0,
  23154. Details = "公务活动"
  23155. });
  23156. }
  23157. break;
  23158. }
  23159. }
  23160. }
  23161. else
  23162. {
  23163. foreach (var fallTime in fallTimesNotCheckCountry)
  23164. {
  23165. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23166. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23167. {
  23168. foreach (var addTime in fallTime.Item2)
  23169. {
  23170. chiarr.Add(new Grp_ApprovalTravelDetails
  23171. {
  23172. Time = addTime,
  23173. CreateTime = DateTime.Now,
  23174. CreateUserId = dto.Userid,
  23175. ParentId = 0,
  23176. Details = "公务活动"
  23177. });
  23178. }
  23179. break;
  23180. }
  23181. }
  23182. }
  23183. }
  23184. }
  23185. }
  23186. //添加乘车语句
  23187. //chiarr.Add(new Grp_ApprovalTravelDetails
  23188. //{
  23189. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  23190. // CreateTime = DateTime.Now,
  23191. // CreateUserId = dto.Userid,
  23192. // ParentId = 0,
  23193. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  23194. //});
  23195. //if (i != timeArr.Count - 1)
  23196. //{
  23197. // fallToTime = fallToTime.AddHours(2.5);
  23198. // foreach (var item in Times)
  23199. // {
  23200. // //排列公务时间
  23201. // if (fallToTime.Hour < item.Item1)
  23202. // {
  23203. // chiarr.Add(new Grp_ApprovalTravelDetails
  23204. // {
  23205. // Time = $"{item.Item2} - {item.Item3}",
  23206. // CreateTime = DateTime.Now,
  23207. // CreateUserId = dto.Userid,
  23208. // ParentId = 0,
  23209. // Details = "公务活动"
  23210. // });
  23211. // }
  23212. // }
  23213. //}
  23214. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  23215. var last = threeCodeStr.Last();
  23216. foreach (var item in threeCodeStr)
  23217. {
  23218. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  23219. if (item.Equals(last))
  23220. {
  23221. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  23222. }
  23223. }
  23224. cityPath = cityPath.Trim('-');
  23225. }
  23226. else
  23227. {
  23228. foreach (var item in Times)
  23229. {
  23230. chiarr.Add(new Grp_ApprovalTravelDetails
  23231. {
  23232. Time = $"{item.Item2} - {item.Item3}",
  23233. CreateTime = DateTime.Now,
  23234. CreateUserId = dto.Userid,
  23235. ParentId = 0,
  23236. Details = "公务活动"
  23237. });
  23238. }
  23239. }
  23240. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  23241. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  23242. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  23243. appro.Diid = dto.Diid;
  23244. appro.CreateUserId = dto.Userid;
  23245. appro.CreateTime = DateTime.Now;
  23246. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  23247. appro.Id = thisId;
  23248. //foreach (var item in gwinfo)
  23249. //{
  23250. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  23251. // chi.Details = "拜访" + item.Client;
  23252. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  23253. // {
  23254. // chi.Details += "," + item.ReqSample;
  23255. // }
  23256. // chi.ParentId = thisId;
  23257. // chi.Time = item.Time;
  23258. // chiarr.Add(chi);
  23259. //}
  23260. if (chiarr.Count < 6)
  23261. {
  23262. for (int j = chiarr.Count; j < 6; j++)
  23263. {
  23264. chiarr.Add(new
  23265. Grp_ApprovalTravelDetails());
  23266. }
  23267. }
  23268. resultArr.Add(new
  23269. {
  23270. appro.Id,
  23271. appro.Date,
  23272. appro.Diid,
  23273. chiList = chiarr.Select(x1 => new
  23274. {
  23275. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  23276. x1.Details,
  23277. x1.ParentId,
  23278. x1.Id
  23279. })
  23280. });
  23281. }
  23282. _sqlSugar.CommitTran();
  23283. jw = JsonView(true, "生成成功!", resultArr);
  23284. }
  23285. catch (Exception ex)
  23286. {
  23287. jw.Code = 400;
  23288. jw.Msg = "生成失败!" + ex.Message;
  23289. }
  23290. return Ok(jw);
  23291. }
  23292. /// <summary>
  23293. /// 报批行程word导出
  23294. /// </summary>
  23295. /// <param name="dto"></param>
  23296. /// <returns></returns>
  23297. [HttpPost]
  23298. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  23299. {
  23300. var jw = JsonView(false);
  23301. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  23302. if (group == null)
  23303. {
  23304. jw.Msg = "暂无该团组!";
  23305. return Ok(jw);
  23306. }
  23307. //模板路径
  23308. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  23309. var fileName = string.Empty;
  23310. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  23311. bool bold = false;
  23312. if (dto.FileIndex == 1)
  23313. {
  23314. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  23315. }
  23316. else if (dto.FileIndex == 2)
  23317. {
  23318. fileName = "省外办-报批.docx";
  23319. bold = false;
  23320. titleFont = "方正黑体简体";
  23321. timeFont = "Times New Roman";
  23322. contentFont = "方正仿宋_GBK";
  23323. }
  23324. else if (dto.FileIndex == 3)
  23325. {
  23326. fileName = "市外办-报批.docx";
  23327. titleFont = "方正黑体简体";
  23328. timeFont = "Times New Roman";
  23329. contentFont = "方正仿宋简体";
  23330. }
  23331. tempPath = tempPath + fileName;
  23332. //载入模板
  23333. Document doc = new Document(tempPath);
  23334. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  23335. //获取所填表格的序数
  23336. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  23337. Aspose.Words.Tables.Row titleRowClone = null;
  23338. Aspose.Words.Tables.Row CenterRowClone = null;
  23339. int index = 0;
  23340. int indexChi = 0;
  23341. int SetIndex = 0;
  23342. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  23343. //获取数据,放到datatable
  23344. foreach (var item in ApprovalTravelArr)
  23345. {
  23346. if (index > 0)
  23347. {
  23348. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  23349. tableOne.AppendChild(titleRowClone);
  23350. }
  23351. var textTime = item.Date;
  23352. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  23353. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  23354. SetIndex++;
  23355. if (ChiRep.Count > 0)
  23356. {
  23357. foreach (var itemChi in ChiRep)
  23358. {
  23359. var txtTime = itemChi.Time;
  23360. var txtDetail = itemChi.Details;
  23361. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  23362. {
  23363. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  23364. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23365. //indexChi++;
  23366. //SetIndex++;
  23367. break;
  23368. }
  23369. if (indexChi > 0)
  23370. {
  23371. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23372. tableOne.AppendChild(CenterRowClone);
  23373. }
  23374. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  23375. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  23376. indexChi++;
  23377. SetIndex++;
  23378. }
  23379. }
  23380. //else
  23381. //{
  23382. // if (indexChi > 0)
  23383. // {
  23384. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23385. // tableOne.AppendChild(CenterRowClone);
  23386. // }
  23387. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  23388. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23389. // indexChi++;
  23390. // SetIndex++;
  23391. //}
  23392. index++;
  23393. }
  23394. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  23395. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23396. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23397. jw.Code = 200;
  23398. jw.Msg = "";
  23399. return Ok(jw);
  23400. }
  23401. private string ParseBlackTime(string time)
  23402. {
  23403. // 匹配可能只有分钟的情况
  23404. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  23405. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  23406. if (match.Success)
  23407. {
  23408. string hours = match.Groups[1].Value;
  23409. string minutes = match.Groups[2].Value;
  23410. // 如果小时部分为空,则只显示分钟
  23411. if (string.IsNullOrEmpty(hours))
  23412. {
  23413. return $"{minutes}分钟";
  23414. }
  23415. // 如果分钟部分为空,则只显示小时
  23416. else if (string.IsNullOrEmpty(minutes))
  23417. {
  23418. return $"{hours}小时";
  23419. }
  23420. // 否则显示完整格式
  23421. else
  23422. {
  23423. return $"{hours}小时{minutes}分钟";
  23424. }
  23425. }
  23426. else
  23427. {
  23428. return "未知时长";
  23429. }
  23430. }
  23431. private string intToString(int numberVal)
  23432. {
  23433. string numberval = numberVal.ToString();
  23434. Dictionary<char, string> Number = new Dictionary<char, string>();
  23435. Number.Add('1', "一");
  23436. Number.Add('2', "二");
  23437. Number.Add('3', "三");
  23438. Number.Add('4', "四");
  23439. Number.Add('5', "五");
  23440. Number.Add('6', "六");
  23441. Number.Add('7', "七");
  23442. Number.Add('8', "八");
  23443. Number.Add('9', "九");
  23444. string stringNumberVal = string.Empty;
  23445. for (int i = 0; i < numberval.Length; i++)
  23446. {
  23447. if (i == 0)
  23448. {
  23449. stringNumberVal += Number[numberval[i]];
  23450. }
  23451. else if (i >= 1)
  23452. {
  23453. if (numberval[i] == '0')
  23454. {
  23455. stringNumberVal = "十";
  23456. }
  23457. else
  23458. {
  23459. stringNumberVal += "十" + Number[numberval[i]];
  23460. }
  23461. }
  23462. }
  23463. return stringNumberVal;
  23464. }
  23465. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  23466. {
  23467. //获取table中的某个单元格,从0开始
  23468. Cell lshCell = table.Rows[rows].Cells[cells];
  23469. //将单元格中段落移除
  23470. foreach (Paragraph item in lshCell.Paragraphs)
  23471. {
  23472. lshCell.Paragraphs.Remove(item);
  23473. }
  23474. if (val.Contains("\r\n"))
  23475. {
  23476. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  23477. foreach (var item in spArr)
  23478. {
  23479. //新建一个段落
  23480. Paragraph p = new Paragraph(doc);
  23481. var r = new Run(doc, item);
  23482. //设置字体
  23483. if (!string.IsNullOrEmpty(font))
  23484. {
  23485. r.Font.Name = font;
  23486. }
  23487. r.Font.Bold = bold;
  23488. //把设置的值赋给之前新建的段落
  23489. p.AppendChild(r);
  23490. //将此段落加到单元格内
  23491. lshCell.AppendChild(p);
  23492. }
  23493. }
  23494. else
  23495. {
  23496. //新建一个段落
  23497. Paragraph p = new Paragraph(doc);
  23498. var r = new Run(doc, val);
  23499. //设置字体
  23500. if (!string.IsNullOrEmpty(font))
  23501. {
  23502. r.Font.Name = font;
  23503. }
  23504. r.Font.Bold = bold;
  23505. //把设置的值赋给之前新建的段落
  23506. p.AppendChild(r);
  23507. //将此段落加到单元格内
  23508. lshCell.AppendChild(p);
  23509. }
  23510. }
  23511. /// <summary>
  23512. /// 报批行程AI续写
  23513. /// </summary>
  23514. /// <returns></returns>
  23515. [HttpPost]
  23516. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  23517. {
  23518. var jw = JsonView(false);
  23519. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  23520. {
  23521. jw.Msg = "参数有误!";
  23522. return Ok(jw);
  23523. }
  23524. KiMiApiClient kiMi = new KiMiApiClient();
  23525. List<SeedMessages> messages = new List<SeedMessages>() {
  23526. new SeedMessages
  23527. {
  23528. Role = KimiRole.system,
  23529. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  23530. },
  23531. new SeedMessages
  23532. {
  23533. Role = KimiRole.user,
  23534. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  23535. }
  23536. };
  23537. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  23538. string data = kimi_result.Choices[0]?.Message.Content;
  23539. if (string.IsNullOrWhiteSpace(data))
  23540. {
  23541. jw.Data = "Ai续写失败!";
  23542. }
  23543. else
  23544. {
  23545. jw = JsonView(true, "success!", data);
  23546. }
  23547. return Ok(jw);
  23548. }
  23549. #endregion
  23550. #region 团组接待意见调查
  23551. /// <summary>
  23552. /// 团组接待意见调查 - 信息管理
  23553. /// 基础数据(团组)
  23554. /// </summary>
  23555. /// <returns></returns>
  23556. [HttpGet]
  23557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23558. public async Task<IActionResult> OpinionaireInit()
  23559. {
  23560. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  23561. .Select(x => new
  23562. {
  23563. x.Id,
  23564. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  23565. })
  23566. .OrderByDescending(x => x.Id)
  23567. .ToListAsync();
  23568. return Ok(JsonView(groupData, groupData.Count));
  23569. }
  23570. /// <summary>
  23571. /// 团组接待意见调查 - 信息管理
  23572. /// 列表
  23573. /// </summary>
  23574. /// <param name="groupId"></param>
  23575. /// <returns></returns>
  23576. [HttpGet("{groupId}")]
  23577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23578. public async Task<IActionResult> OpinionaireManageList(int groupId)
  23579. {
  23580. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23581. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  23582. .Select(x => new
  23583. {
  23584. x.Id,
  23585. x.TourGuideName,
  23586. x.CityName,
  23587. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  23588. x.CreateTime
  23589. })
  23590. .OrderBy(x => x.Id)
  23591. .ToListAsync();
  23592. return Ok(JsonView(data));
  23593. }
  23594. /// <summary>
  23595. /// 团组接待意见调查 - 信息管理
  23596. /// 保存
  23597. /// </summary>
  23598. /// <param name="dto"></param>
  23599. /// <returns></returns>
  23600. [HttpPost]
  23601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23602. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  23603. {
  23604. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23605. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23606. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23607. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  23608. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  23609. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  23610. _opinionaireRep.BeginTran();
  23611. if (addData != null && addData.Count > 0)
  23612. {
  23613. foreach (var item in addData)
  23614. {
  23615. item.CreateUserId = currUserInfo.UserId;
  23616. item.DiId = dto.DiId;
  23617. }
  23618. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  23619. }
  23620. if (updData != null && updData.Count > 0)
  23621. {
  23622. var upd = await _opinionaireRep._sqlSugar
  23623. .Updateable(updData)
  23624. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  23625. .WhereColumns(x => new { x.Id })
  23626. .ExecuteCommandAsync();
  23627. }
  23628. _opinionaireRep.CommitTran();
  23629. return Ok(JsonView("操作成功!"));
  23630. }
  23631. /// <summary>
  23632. /// 团组接待意见调查 - 信息管理
  23633. /// 删除
  23634. /// </summary>
  23635. /// <param name="id"></param>
  23636. /// <returns></returns>
  23637. [HttpDelete("{id}")]
  23638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23639. public async Task<IActionResult> OpinionaireManageDel(int id)
  23640. {
  23641. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23642. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23643. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  23644. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  23645. if (!del) return Ok(JsonView("操作失败!"));
  23646. return Ok(JsonView("操作成功!"));
  23647. }
  23648. /// <summary>
  23649. /// 团组接待意见调查 - 用户
  23650. /// 列表
  23651. /// </summary>
  23652. /// <param name="diId"></param>
  23653. /// <returns></returns>
  23654. [HttpGet("{diId}")]
  23655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23656. public async Task<IActionResult> OpinionaireUserList(int diId)
  23657. {
  23658. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23659. var sql = string.Format(@"
  23660. SELECT
  23661. o.Id,
  23662. o.DiId,
  23663. di.TeamName AS 'GroupName',
  23664. di.VisitPNumber AS 'PeopleNumber',
  23665. di.ClientName AS 'LeadGroup',
  23666. di.VisitCountry AS 'Travel',
  23667. di.VisitDays AS 'Days',
  23668. o.CityName,
  23669. o.TourGuideName,
  23670. o.Catering,
  23671. o.CateringReason,
  23672. o.Stay,
  23673. o.StayReason,
  23674. o.[Route],
  23675. o.RouteReason,
  23676. o.OfficialActivity,
  23677. o.OfficialActivityReason,
  23678. o.TourGuide,
  23679. o.TourGuideReason,
  23680. o.[Translate],
  23681. o.TranslateReason,
  23682. o.Trip,
  23683. o.TripReason,
  23684. o.ESFileName,
  23685. o.SignatureDate,
  23686. o.Remark
  23687. FROM
  23688. Grp_Opinionaire o
  23689. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  23690. WHERE
  23691. o.IsDel = 0
  23692. AND o.DiId = {0}
  23693. ORDER BY
  23694. o.Id ASC", diId);
  23695. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  23696. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  23697. return Ok(JsonView(data));
  23698. }
  23699. /// <summary>
  23700. /// 团组接待意见调查 - 用户
  23701. /// 保存
  23702. /// </summary>
  23703. /// <param name="dto"></param>
  23704. /// <returns></returns>
  23705. [HttpPost]
  23706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23707. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  23708. {
  23709. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  23710. foreach (var item in dto)
  23711. {
  23712. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  23713. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  23714. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  23715. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  23716. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  23717. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  23718. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  23719. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  23720. }
  23721. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  23722. if (!Directory.Exists(filePathBase))
  23723. {
  23724. Directory.CreateDirectory(filePathBase);
  23725. }
  23726. #region 上传文件
  23727. var filePaths = new List<string>();
  23728. foreach (var item in dto)
  23729. {
  23730. var file = item.File;
  23731. // 将文件保存到指定位置
  23732. var filePath = Path.Combine(filePathBase, file.FileName);
  23733. using (var stream = new FileStream(filePath, FileMode.Create))
  23734. {
  23735. await file.CopyToAsync(stream);
  23736. }
  23737. //验证文件是否上传成功
  23738. if (!System.IO.File.Exists(filePath))
  23739. {
  23740. foreach (var filePathStr in filePaths)
  23741. {
  23742. System.IO.File.Delete(filePathStr);
  23743. }
  23744. return Ok(JsonView(false, "文件上传失败!"));
  23745. }
  23746. item.ESFileName = file.FileName;
  23747. }
  23748. #endregion
  23749. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  23750. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  23751. .UpdateColumns(x => new
  23752. {
  23753. x.Catering,
  23754. x.CateringReason,
  23755. x.Stay,
  23756. x.StayReason,
  23757. x.Route,
  23758. x.RouteReason,
  23759. x.OfficialActivity,
  23760. x.OfficialActivityReason,
  23761. x.TourGuide,
  23762. x.TourGuideReason,
  23763. x.Translate,
  23764. x.TranslateReason,
  23765. x.Trip,
  23766. x.TripReason,
  23767. x.ESFileName,
  23768. x.SignatureDate,
  23769. x.Remark
  23770. })
  23771. .WhereColumns(x => new { x.Id })
  23772. .ExecuteCommandAsync();
  23773. if (upd < 1)
  23774. {
  23775. foreach (var filePathStr in filePaths)
  23776. {
  23777. System.IO.File.Delete(filePathStr);
  23778. }
  23779. return Ok(JsonView(false));
  23780. }
  23781. return Ok(JsonView(true));
  23782. }
  23783. #endregion
  23784. #region 团组餐厅相关信息
  23785. /// <summary>
  23786. /// 团组相关餐厅信息
  23787. /// 基础数据(团组)
  23788. /// </summary>
  23789. /// <returns></returns>
  23790. [HttpGet]
  23791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23792. public async Task<IActionResult> RestaurantInit()
  23793. {
  23794. return Ok(await _restaurantRep.InitAsync());
  23795. }
  23796. /// <summary>
  23797. /// 团组相关餐厅信息
  23798. /// Item
  23799. /// </summary>
  23800. /// <param name="dto"></param>
  23801. /// <returns></returns>
  23802. [HttpPost]
  23803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23804. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  23805. {
  23806. int portType = dto.PortType,
  23807. groupId = dto.GroupId;
  23808. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23809. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23810. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  23811. }
  23812. /// <summary>
  23813. /// 团组相关餐厅信息
  23814. /// List
  23815. /// </summary>
  23816. /// <param name="dto"></param>
  23817. /// <returns></returns>
  23818. [HttpPost]
  23819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23820. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  23821. {
  23822. int portType = dto.PortType,
  23823. groupId = dto.GroupId;
  23824. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23825. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23826. var sql = string.Format(@" SELECT
  23827. ri.Id,
  23828. ri.GroupId,
  23829. ri.Date,
  23830. ri.StartTime,
  23831. ri.EndTime,
  23832. CASE WHEN ri.Type = 1 THEN '早餐'
  23833. WHEN ri.Type = 2 THEN '午餐'
  23834. WHEN ri.Type = 3 THEN '晚餐'
  23835. ELSE '其他'
  23836. END AS 'Type',
  23837. ri.Name,
  23838. ri.Address,
  23839. ri.Tel,
  23840. ri.Remark,
  23841. ri.CreateTime,
  23842. u.CnName AS CreateUserName
  23843. FROM
  23844. Grp_RestaurantInfo ri
  23845. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  23846. WHERE
  23847. ri.IsDel = 0
  23848. AND ri.GroupId = {0}
  23849. ORDER BY
  23850. ri.Date ASC
  23851. ", groupId);
  23852. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  23853. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  23854. return Ok(JsonView(infos));
  23855. }
  23856. /// <summary>
  23857. /// 团组相关餐厅信息
  23858. /// Info
  23859. /// </summary>
  23860. /// <param name="dto"></param>
  23861. /// <returns></returns>
  23862. [HttpPost]
  23863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23864. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23865. {
  23866. int portType = dto.PortType,
  23867. id = dto.Id;
  23868. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23869. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23870. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23871. }
  23872. /// <summary>
  23873. /// 团组相关餐厅信息
  23874. /// Op
  23875. /// </summary>
  23876. /// <param name="dto"></param>
  23877. /// <returns></returns>
  23878. [HttpPost]
  23879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23880. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23881. {
  23882. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23883. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23884. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23885. return Ok(await _restaurantRep.OpAsync(dto));
  23886. }
  23887. /// <summary>
  23888. /// 团组相关餐厅信息
  23889. /// Del
  23890. /// </summary>
  23891. /// <param name="dto"></param>
  23892. /// <returns></returns>
  23893. [HttpPost]
  23894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23895. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23896. {
  23897. int userId = dto.DeleteUserId;
  23898. var id = dto.Id;
  23899. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23900. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23901. return Ok(await _restaurantRep.DelAsync(dto));
  23902. }
  23903. #endregion
  23904. #region 团组会务成本
  23905. /// <summary>
  23906. /// 团组会务成本数据初始化
  23907. /// </summary>
  23908. /// <returns></returns>
  23909. [HttpPost]
  23910. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  23911. {
  23912. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23913. .OrderByDescending(x => x.CreateTime)
  23914. .Where(x => x.IsDel == 0)
  23915. .Select<DelegationEasyView>();
  23916. DelegationEasyView di = Dto.GroupId == 0 ?
  23917. expr.First() :
  23918. expr.First(x => x.Id == Dto.GroupId);
  23919. if (di == null)
  23920. {
  23921. return Ok(JsonView(false, "团组信息不存在!"));
  23922. }
  23923. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  23924. .Where(x => x.IsDel == 0 && x.STid == 21)
  23925. .Select(x => new { x.Id, Text = x.Name })
  23926. .ToListAsync();
  23927. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  23928. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  23929. .Select(x => x.Id)
  23930. .ToList();
  23931. //仅检索会务团组
  23932. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23933. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  23934. .OrderByDescending(x => x.VisitDate)
  23935. .Select(x => new { x.Id, x.TeamName })
  23936. .ToListAsync();
  23937. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  23938. var userList = await _sqlSugar.Queryable<Sys_Users>()
  23939. .Where(x => x.IsDel == 0)
  23940. .Select(x => new { x.Id, x.CnName })
  23941. .ToListAsync();
  23942. var units = await _sqlSugar.Queryable<Sys_SetData>()
  23943. .Where(x => x.IsDel == 0 && x.STid == 119)
  23944. .Select(x => new { x.Id, Text = x.Name })
  23945. .ToListAsync();
  23946. var FileType = new[]
  23947. {
  23948. new { Id = 0 , Name = "成本下载" },
  23949. new { Id = 1 , Name = "报价下载" },
  23950. new { Id = 2 , Name = "总表下载" },
  23951. };
  23952. var GM = new List<int>();
  23953. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  23954. try
  23955. {
  23956. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  23957. }
  23958. catch (Exception ex)
  23959. {
  23960. GM = new List<int>() { 21 };
  23961. }
  23962. var isReview = Dto.UserId == 21;
  23963. var isGM = GM.Contains(Dto.UserId);
  23964. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23965. .Where(x => x.IsDel == 0)
  23966. .Select<ConferenceAffairsCostView>()
  23967. .First(x => x.Diid == di.Id);
  23968. if (ConferenceAffairsCost == null)
  23969. {
  23970. ConferenceAffairsCost = new ConferenceAffairsCostView();
  23971. ConferenceAffairsCost.Diid = di.Id;
  23972. }
  23973. #region 权限校验
  23974. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  23975. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  23976. .Select(x => x.UserId)
  23977. .Distinct()
  23978. .ToList();
  23979. if (!ids.Contains(Dto.UserId) && !isGM)
  23980. {
  23981. return Ok(JsonView(201, "暂无权限!", new
  23982. {
  23983. typeData,
  23984. groupList,
  23985. currenyList,
  23986. isGM,
  23987. userList,
  23988. units,
  23989. isReview,
  23990. operatorUser = ids,
  23991. di,
  23992. FileType
  23993. }));
  23994. }
  23995. #endregion
  23996. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23997. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23998. .Select<ConferenceAffairsCostChildView>()
  23999. .OrderBy(x => x.Index)
  24000. .ToList();
  24001. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  24002. {
  24003. ConferenceAffairsCostChi[i - 1].Index = i;
  24004. }
  24005. var backData = new
  24006. {
  24007. ConferenceAffairsCost,
  24008. ConferenceAffairsCostChi,
  24009. typeData,
  24010. groupList,
  24011. currenyList,
  24012. isGM,
  24013. userList,
  24014. units,
  24015. isReview,
  24016. operatorUser = ids,
  24017. di,
  24018. FileType
  24019. };
  24020. return Ok(JsonView(true, "SUCCESS", backData));
  24021. }
  24022. /// <summary>
  24023. /// 会务成本保存
  24024. /// </summary>
  24025. /// <returns></returns>
  24026. [HttpPost]
  24027. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  24028. {
  24029. _sqlSugar.BeginTran();
  24030. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  24031. var childResult = new
  24032. {
  24033. success = 0,
  24034. error = 0
  24035. };
  24036. try
  24037. {
  24038. if (data.Id == 0)
  24039. {
  24040. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  24041. .Where(x => x.Diid == Dto.GroupId)
  24042. .SetColumns(x => new Grp_ConferenceAffairsCost
  24043. {
  24044. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24045. DeleteUserId = Dto.UserId
  24046. })
  24047. .ExecuteCommand();
  24048. data.Diid = Dto.GroupId;
  24049. data.CreateTime = DateTime.Now;
  24050. data.CreateUserId = Dto.UserId;
  24051. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  24052. .ExecuteReturnIdentity();
  24053. }
  24054. else
  24055. {
  24056. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  24057. .ExecuteCommand();
  24058. data.Id = data.Id;
  24059. }
  24060. if (Dto.ConferenceAffairsCostChild.Any())
  24061. {
  24062. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  24063. var insertArr = datas.Where(x => x.Id == 0).ToList();
  24064. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  24065. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  24066. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  24067. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  24068. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  24069. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  24070. .ExecuteCommand() : 0;
  24071. childResult = childResult with
  24072. {
  24073. error = notUpdateArr.Count(),
  24074. success = inrsetCount + updateCount
  24075. };
  24076. }
  24077. _sqlSugar.CommitTran();
  24078. }
  24079. catch (Exception ex)
  24080. {
  24081. _sqlSugar.RollbackTran();
  24082. return Ok(JsonView(false, "失败!" + ex.Message));
  24083. }
  24084. return Ok(JsonView(true, "操作成功!", childResult));
  24085. }
  24086. [HttpPost]
  24087. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  24088. {
  24089. var count = 0;
  24090. if (Dto.ConferenceAffairsCostChildids.Any())
  24091. {
  24092. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  24093. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  24094. SetColumns(x => new Grp_ConferenceAffairsCostChild
  24095. {
  24096. ReviewStatus = Dto.ReviewStatus
  24097. }).
  24098. ExecuteCommand();
  24099. }
  24100. return Ok(JsonView(true, "操作成功!", count));
  24101. }
  24102. /// <summary>
  24103. /// 会务成本所有数据清除
  24104. /// </summary>
  24105. /// <param name="Dto"></param>
  24106. /// <returns></returns>
  24107. [HttpPost]
  24108. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  24109. {
  24110. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24111. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  24112. _sqlSugar.BeginTran();
  24113. try
  24114. {
  24115. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  24116. .Where(x => x.Diid == Dto.GroupId)
  24117. .SetColumns(x => new Grp_ConferenceAffairsCost
  24118. {
  24119. IsDel = 1,
  24120. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24121. DeleteUserId = Dto.UserId
  24122. })
  24123. .ExecuteCommand();
  24124. if (delCount > 0)
  24125. {
  24126. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24127. .Where(x => x.Diid == Dto.GroupId)
  24128. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24129. {
  24130. IsDel = 1,
  24131. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24132. DeleteUserId = Dto.UserId
  24133. })
  24134. .ExecuteCommand();
  24135. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24136. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24137. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24138. {
  24139. IsDel = 1,
  24140. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24141. DeleteUserId = Dto.UserId
  24142. })
  24143. .ExecuteCommand();
  24144. }
  24145. _sqlSugar.CommitTran();
  24146. }
  24147. catch (Exception ex)
  24148. {
  24149. _sqlSugar.RollbackTran();
  24150. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24151. }
  24152. return Ok(JsonView(true, "操作成功!"));
  24153. }
  24154. /// <summary>
  24155. /// 子项数据删除
  24156. /// </summary>
  24157. /// <param name="Dto"></param>
  24158. /// <returns></returns>
  24159. [HttpPost]
  24160. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  24161. {
  24162. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  24163. .Any(x => x.ReviewStatus == 1);
  24164. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  24165. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24166. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  24167. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24168. {
  24169. IsDel = 1,
  24170. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24171. DeleteUserId = Dto.UserId
  24172. })
  24173. .ExecuteCommand();
  24174. return Ok(JsonView(true, "SUCCESS!", count));
  24175. }
  24176. /// <summary>
  24177. /// 会务成本权限分配
  24178. /// </summary>
  24179. /// <param name="Dto"></param>
  24180. /// <returns></returns>
  24181. [HttpPost]
  24182. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  24183. {
  24184. _sqlSugar.BeginTran();
  24185. var count = 0;
  24186. try
  24187. {
  24188. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24189. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24190. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24191. {
  24192. IsDel = 1,
  24193. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24194. DeleteUserId = Dto.CreateUserId
  24195. })
  24196. .ExecuteCommand();
  24197. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  24198. {
  24199. CreateTime = DateTime.Now,
  24200. CreateUserId = Dto.CreateUserId,
  24201. UserId = x,
  24202. Diid = Dto.GroupId,
  24203. }).ToList()).ExecuteCommand();
  24204. _sqlSugar.CommitTran();
  24205. }
  24206. catch (Exception ex)
  24207. {
  24208. _sqlSugar.RollbackTran();
  24209. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24210. }
  24211. return Ok(JsonView(true, "操作成功!", count));
  24212. }
  24213. /// <summary>
  24214. /// 团组会务成本文件下载
  24215. /// </summary>
  24216. /// <returns></returns>
  24217. [HttpPost]
  24218. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  24219. {
  24220. var FileType = new[]
  24221. {
  24222. new { Id = 0 , Name = "成本下载" },
  24223. new { Id = 1 , Name = "报价下载" },
  24224. new { Id = 2 , Name = "总表下载" },
  24225. };
  24226. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24227. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  24228. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  24229. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  24230. .Select<DelegationEasyView>()
  24231. .First();
  24232. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  24233. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  24234. if (main == null)
  24235. {
  24236. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  24237. }
  24238. JsonView jw = JsonView(false);
  24239. //总表下载
  24240. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  24241. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  24242. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  24243. var field = string.Empty;
  24244. var fileTypeName = string.Empty;
  24245. field = @$"
  24246. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  24247. b.Name as PriceTypeStr ,
  24248. c.Name as CurrencyStr ,
  24249. d.Name as UnitStr ,
  24250. case a.ReviewStatus
  24251. WHEN 1 THEN '已通过'
  24252. WHEN 0 THEN '未审核'
  24253. WHEN -1 THEN '未通过'
  24254. ELSE '未审核'
  24255. END AS ReviewStatusStr
  24256. ";
  24257. if (Dto.FileTypeId == 0)
  24258. {
  24259. fileTypeName = "会务成本成本表";
  24260. loadPath += $"{fileTypeName}.xlsx";
  24261. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24262. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24263. }
  24264. else if (Dto.FileTypeId == 1)
  24265. {
  24266. fileTypeName = "会务成本报价表";
  24267. loadPath += $"{fileTypeName}.xlsx";
  24268. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24269. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24270. }
  24271. else if (Dto.FileTypeId == 2)
  24272. {
  24273. fileTypeName = "会务成本总表";
  24274. loadPath += $"{fileTypeName}.xlsx";
  24275. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24276. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24277. }
  24278. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  24279. SELECT
  24280. {field}
  24281. FROM Grp_ConferenceAffairsCostChild a
  24282. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  24283. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  24284. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  24285. WHERE a.isdel = 0
  24286. AND a.Diid = {main.Diid}
  24287. AND a.ConferenceAffairsCostId = {main.Id}
  24288. ").ToList();
  24289. var currLists = chiExcelContent.Select(x => new CurrList
  24290. {
  24291. CurrName = x.CurrencyStr,
  24292. CurrRate = x.Rate
  24293. })
  24294. .Distinct()
  24295. .ToList();
  24296. var designer = new WorkbookDesigner
  24297. {
  24298. Workbook = new Workbook(loadPath)
  24299. };
  24300. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  24301. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  24302. designer.SetDataSource("TeamName", di.TeamName);
  24303. designer.SetDataSource("City", main.City);
  24304. designer.SetDataSource("AllCost", main.CostAll);
  24305. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  24306. designer.SetDataSource("Curr", MostCurr.Name);
  24307. designer.SetDataSource("Curr1", MostCurr.Name);
  24308. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  24309. dt.TableName = "TB";
  24310. designer.SetDataSource(dt);
  24311. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  24312. dt1.TableName = "currTb";
  24313. designer.SetDataSource(dt1);
  24314. designer.Process();
  24315. designer.Workbook.Save(outputPath);
  24316. jw = JsonView(true, "操作成功!", new
  24317. {
  24318. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  24319. FilePath = networkPath
  24320. });
  24321. return Ok(jw);
  24322. }
  24323. [HttpPost]
  24324. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  24325. {
  24326. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  24327. .Select(x => x.PriceName).ToList()));
  24328. }
  24329. #endregion
  24330. #region 会务流程
  24331. /// <summary>
  24332. /// 会务流程 - 数据初始化
  24333. /// </summary>
  24334. /// <param name="dto"></param>
  24335. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  24336. [HttpPost]
  24337. public async Task<IActionResult> ConferenceProceduresInit(ConferenceProceduresInitDto dto)
  24338. {
  24339. try
  24340. {
  24341. Grp_DelegationInfo targetGroup = null;
  24342. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24343. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  24344. .FirstAsync();
  24345. if (targetGroup == null)
  24346. {
  24347. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24348. .Where(x => x.IsDel == 0)
  24349. .OrderByDescending(x => x.CreateTime)
  24350. .FirstAsync();
  24351. }
  24352. if (targetGroup == null)
  24353. {
  24354. return Ok(JsonView(false, "未找到任何团组信息"));
  24355. }
  24356. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24357. .Where(x => x.IsDel == 0)
  24358. .OrderByDescending(x => x.CreateTime)
  24359. .Select(x => new { x.Id, x.TeamName })
  24360. .ToListAsync();
  24361. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24362. .Where(x => x.DiId == targetGroup.Id && x.IsDel == 0)
  24363. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  24364. .ToListAsync();
  24365. if (!conferenceProceduresList.Any())
  24366. {
  24367. conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24368. .Where(x => x.DiId == -1 && x.IsDel == 0)
  24369. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  24370. .ToListAsync();
  24371. }
  24372. var conferenceProceduresGroupByTitle = conferenceProceduresList
  24373. .GroupBy(x => x.Title)
  24374. .Select(x => new
  24375. {
  24376. title = x.Key,
  24377. itmes = x.Select(y => new
  24378. {
  24379. y.Id,
  24380. y.DataDetails,
  24381. y.Details,
  24382. y.Remark
  24383. }).ToList()
  24384. })
  24385. .ToList();
  24386. var response = new
  24387. {
  24388. GroupInfo = new
  24389. {
  24390. targetGroup.Id,
  24391. targetGroup.TeamName,
  24392. targetGroup.VisitDate,
  24393. targetGroup.VisitDays,
  24394. targetGroup.VisitPNumber,
  24395. targetGroup.VisitCountry,
  24396. targetGroup.VisitStartDate,
  24397. targetGroup.VisitEndDate,
  24398. targetGroup.ClientName,
  24399. targetGroup.ClientUnit
  24400. },
  24401. GroupList = groupList,
  24402. ConferenceProceduresList = conferenceProceduresList,
  24403. conferenceProceduresGroupByTitle = conferenceProceduresGroupByTitle
  24404. };
  24405. return Ok(JsonView(true, "SUCCESS", response));
  24406. }
  24407. catch (Exception ex)
  24408. {
  24409. _logger.LogError(ex, "数据初始化失败");
  24410. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  24411. }
  24412. }
  24413. /// <summary>
  24414. /// 会务流程 - 保存
  24415. /// </summary>
  24416. /// <param name="dto"></param>
  24417. /// <returns></returns>
  24418. [HttpPost]
  24419. public async Task<IActionResult> ConferenceProceduresSave(ConferenceProceduresSaveDto dto)
  24420. {
  24421. _sqlSugar.BeginTran();
  24422. try
  24423. {
  24424. //删除旧数据
  24425. _sqlSugar.Updateable<Grp_ConferenceProcedures>()
  24426. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  24427. .SetColumns(x => new Grp_ConferenceProcedures
  24428. {
  24429. IsDel = 1,
  24430. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24431. DeleteUserId = dto.UserId
  24432. })
  24433. .ExecuteCommand();
  24434. //添加新数据
  24435. var newData = new List<Grp_ConferenceProcedures>();
  24436. foreach (var item in dto.ConferenceProceduresSaveItem)
  24437. {
  24438. foreach (var item2 in item.itmes)
  24439. {
  24440. newData.Add(new Grp_ConferenceProcedures
  24441. {
  24442. DiId = dto.GroupId,
  24443. Title = item.title,
  24444. DataDetails = item2.DataDetails,
  24445. Details = item2.details,
  24446. Remark = item2.Remark,
  24447. CreateTime = DateTime.Now,
  24448. CreateUserId = dto.UserId
  24449. });
  24450. }
  24451. }
  24452. _sqlSugar.Insertable(newData).ExecuteCommand();
  24453. _sqlSugar.CommitTran();
  24454. }
  24455. catch (Exception ex)
  24456. {
  24457. _sqlSugar.RollbackTran();
  24458. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  24459. }
  24460. return Ok(JsonView(true, "SUCCESS"));
  24461. }
  24462. [HttpPost]
  24463. public async Task<IActionResult> ConferenceProceduresFileDown(ConferenceProceduresFileDownDto dto)
  24464. {
  24465. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24466. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  24467. .FirstAsync();
  24468. if (groupInfo == null)
  24469. {
  24470. return Ok(JsonView(false, "团组信息不存在"));
  24471. }
  24472. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24473. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  24474. .ToListAsync();
  24475. if (!conferenceProceduresList.Any())
  24476. {
  24477. return Ok(JsonView(false, "会务流程信息不存在"));
  24478. }
  24479. var filePath = $"{AppSettingsHelper.Get("ExcelBasePath")}Template/会务流程.xlsx";
  24480. if (!System.IO.File.Exists(filePath))
  24481. {
  24482. return Ok(JsonView(false, "模板文件不存在"));
  24483. }
  24484. var designer = new WorkbookDesigner();
  24485. designer.Workbook = new Workbook(filePath);
  24486. designer.SetDataSource("TB", conferenceProceduresList);
  24487. designer.Process();
  24488. var sheet = designer.Workbook.Worksheets[0];
  24489. var cells = sheet.Cells;
  24490. int col = 0; // 第一列
  24491. int startRow = 2; // 若第0行为表头,则从第1行开始;无表头请改为0
  24492. int endRow = cells.MaxDataRow;
  24493. if (endRow >= startRow)
  24494. {
  24495. int mergeStart = startRow;
  24496. string prev = cells[mergeStart, col].StringValue?.Trim() ?? string.Empty;
  24497. for (int r = startRow + 1; r <= endRow; r++)
  24498. {
  24499. string cur = cells[r, col].StringValue?.Trim() ?? string.Empty;
  24500. if (!string.Equals(cur, prev, StringComparison.Ordinal))
  24501. {
  24502. int count = r - mergeStart;
  24503. if (count > 1)
  24504. cells.Merge(mergeStart, col, count, 1);
  24505. mergeStart = r;
  24506. prev = cur;
  24507. }
  24508. }
  24509. int tailCount = endRow - mergeStart + 1;
  24510. if (tailCount > 1)
  24511. cells.Merge(mergeStart, col, tailCount, 1);
  24512. }
  24513. // byte[] bytes = null;
  24514. // using (MemoryStream stream = new MemoryStream())
  24515. // {
  24516. // designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  24517. // bytes = stream.ToArray();
  24518. // }
  24519. // return File(bytes, "application/excel", $"{groupInfo.TeamName}_会务流程.xlsx");
  24520. string savePath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceProcedures";
  24521. if (!System.IO.Directory.Exists(savePath))
  24522. {
  24523. System.IO.Directory.CreateDirectory(savePath);
  24524. }
  24525. designer.Workbook.Save($"{savePath}/{groupInfo.TeamName}_会务流程.xlsx");
  24526. string rst = savePath.replace(AppSettingsHelper.Get("ExcelBasePath"),
  24527. AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  24528. return Ok(JsonView(true, "SUCCESS", $"{rst}/{groupInfo.TeamName}_会务流程.xlsx"));
  24529. }
  24530. #endregion
  24531. #region 团组签证流程
  24532. /// <summary>
  24533. /// 团组签证流程 - 团组列表(分页)
  24534. /// </summary>
  24535. /// <returns></returns>
  24536. [HttpPost]
  24537. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  24538. {
  24539. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  24540. string groupName = dto.GroupName.Trim();
  24541. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  24542. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  24543. int portType = dto.PortType;
  24544. RefAsync<int> total = 0;
  24545. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  24546. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  24547. .InnerJoin<Grp_VisaProcessSteps>((x, y, z) => x.DIId == z.GroupId)
  24548. .Where((x, y, z) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId && z.IsDel == 0);
  24549. //构建单字模糊查询
  24550. if (!string.IsNullOrEmpty(groupName))
  24551. {
  24552. var characters = groupName.ToCharArray();
  24553. foreach (var character in characters)
  24554. {
  24555. var charString = character.ToString();
  24556. query = query.Where((x, y) =>
  24557. SqlFunc.Contains(y.TeamName, charString));
  24558. }
  24559. }
  24560. var groups = await query
  24561. .OrderByDescending((x, y) => y.VisitDate)
  24562. .Select((x, y) => new
  24563. {
  24564. y.Id,
  24565. GroupName = y.TeamName,
  24566. y.VisitDate,
  24567. // 加入子查询统计子表条数
  24568. CompletedCount = SqlFunc.Subqueryable<Grp_VisaProcessSteps>()
  24569. .Where(sub => sub.GroupId == y.Id && sub.IsCompleted && sub.IsDel == 0)
  24570. .Count()
  24571. })
  24572. .Distinct()
  24573. .ToPageListAsync(pageIndex, pageSize, total);
  24574. var msg = "SUCCESS";
  24575. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  24576. var groups1 = groups.Select(x => new {
  24577. x.Id,
  24578. x.GroupName,
  24579. x.CompletedCount
  24580. }).ToList();
  24581. return Ok(JsonView(true, msg, groups1, total));
  24582. }
  24583. /// <summary>
  24584. /// 团组签证流程 - 详情
  24585. /// </summary>
  24586. /// <returns></returns>
  24587. [HttpPost]
  24588. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  24589. {
  24590. var res = await _visaProcessRep.Info(dto);
  24591. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24592. return Ok(JsonView(true, res.Msg, res.Data));
  24593. }
  24594. /// <summary>
  24595. /// 团组签证流程 - 流程创建测试
  24596. /// </summary>
  24597. /// <returns></returns>
  24598. [HttpPost]
  24599. public async Task<IActionResult> VisaProcessAdd(int groupId, int currUserId)
  24600. {
  24601. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  24602. }
  24603. /// <summary>
  24604. /// 团组签证流程 - 流程Top4Init 测试
  24605. /// </summary>
  24606. /// <returns></returns>
  24607. [HttpPost]
  24608. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  24609. {
  24610. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  24611. }
  24612. /// <summary>
  24613. /// 团组签证流程 - 设置状态 完成/未完成
  24614. /// </summary>
  24615. /// <returns></returns>
  24616. [HttpPost]
  24617. public async Task<IActionResult> VisaProcessSetCompleted(VisaProcessSetCompletedDto dto)
  24618. {
  24619. //参数验证
  24620. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).AnyAsync();
  24621. if (!stepValid) return Ok(JsonView(false, "签证流程ID无效。"));
  24622. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24623. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24624. var res = await _visaProcessRep.SetCompleted(dto.StepId, dto.CurrUserId, dto.IsCompleted);
  24625. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24626. return Ok(JsonView(true, res.Msg));
  24627. }
  24628. /// <summary>
  24629. /// 团组签证流程 - 修改各步骤内容
  24630. /// </summary>
  24631. /// <returns></returns>
  24632. [HttpPost]
  24633. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  24634. {
  24635. //参数验证
  24636. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24637. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24638. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24639. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24640. if (dto.StepContents == null && dto.StepContents.Count < 1)
  24641. {
  24642. return Ok(JsonView(false, "步骤内容无效。"));
  24643. }
  24644. //各步骤值处理
  24645. object stepVal;
  24646. if (stepValid.Step == 7) stepVal = dto.StepContents;
  24647. else stepVal = dto.StepContents[0].ToString();
  24648. var stepInfo = new Grp_VisaProcessSteps
  24649. {
  24650. Id = dto.StepId,
  24651. DataType = stepValid.DataType,
  24652. TypedValue = stepVal,
  24653. LastUpdateUserId = dto.CurrUserId
  24654. };
  24655. var res = await _visaProcessRep.Update(stepInfo);
  24656. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24657. return Ok(JsonView(true, res.Msg));
  24658. }
  24659. /// <summary>
  24660. /// 团组签证流程 - 上传文件
  24661. /// </summary>
  24662. /// <returns></returns>
  24663. [HttpPost]
  24664. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  24665. {
  24666. //参数验证
  24667. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24668. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24669. var before = stepValid;
  24670. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24671. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24672. //验证文件是否存在
  24673. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  24674. //验证该步骤是否可以上传文件
  24675. var uploadSteps = new List<int>() {
  24676. 5, //实际出签时间
  24677. 6, //是否需要开出境证明
  24678. 7, //是否需要办理电子入境卡手续
  24679. };
  24680. if (!uploadSteps.Contains(stepValid.Step))
  24681. {
  24682. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  24683. }
  24684. //验证根目录
  24685. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  24686. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  24687. if (!System.IO.Directory.Exists(rootPath))
  24688. {
  24689. System.IO.Directory.CreateDirectory(rootPath);
  24690. }
  24691. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  24692. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24693. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  24694. .Select(x => $"{x.TeamName}({x.Id})")
  24695. .FirstAsync();
  24696. //创建团组文件夹
  24697. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  24698. if (!System.IO.Directory.Exists(groupPath))
  24699. {
  24700. System.IO.Directory.CreateDirectory(groupPath);
  24701. }
  24702. List<string> filePaths = new List<string>();
  24703. //保存文件
  24704. foreach (var file in dto.Files)
  24705. {
  24706. // 生成存储文件名
  24707. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  24708. var filePath = Path.Combine(groupPath, fileName);
  24709. // 保存文件到磁盘
  24710. using (var stream = new FileStream(filePath, FileMode.Create))
  24711. {
  24712. await file.CopyToAsync(stream);
  24713. }
  24714. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  24715. }
  24716. //数据库存储
  24717. stepValid.TypedFileNameValue = filePaths;
  24718. stepValid.LastUpdateUserId = dto.CurrUserId;
  24719. stepValid.LastUpdateTime = DateTime.Now;
  24720. var res = await _sqlSugar.Updateable(stepValid)
  24721. .UpdateColumns(it => new { it.TypedFileNameValue, it.LastUpdateUserId, it.LastUpdateTime })
  24722. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  24723. .ExecuteCommandAsync();
  24724. if (res < 1) Ok(JsonView(false, "文件上传失败。"));
  24725. //记录上传文件
  24726. await _visaProcessRep.LogOperationAsync(before, stepValid, "Upload", dto.CurrUserId);
  24727. return Ok(JsonView(true));
  24728. }
  24729. /// <summary>
  24730. /// 团组签证流程 - step 7 资料下载
  24731. /// </summary>
  24732. /// <returns></returns>
  24733. [HttpGet]
  24734. public async Task<IActionResult> VisaProcessDownload(int groupId,int currUserId)
  24735. {
  24736. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  24737. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24738. //验证根目录
  24739. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  24740. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  24741. if (!System.IO.Directory.Exists(rootPath))
  24742. {
  24743. System.IO.Directory.CreateDirectory(rootPath);
  24744. }
  24745. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  24746. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24747. .Where(x => x.IsDel == 0 && x.Id == groupId)
  24748. .Select(x => $"{x.TeamName}({x.Id})")
  24749. .FirstAsync();
  24750. //创建团组文件夹
  24751. var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
  24752. var randomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24753. var dirName = $"{groupName}_相关资料_{timestamp}";
  24754. var sourceDirectoryPath = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}";
  24755. var path = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}/{dirName}";
  24756. if (!System.IO.Directory.Exists(path))
  24757. {
  24758. System.IO.Directory.CreateDirectory(path);
  24759. }
  24760. //验证接团客户名单
  24761. string sql = string.Format(@"
  24762. SELECT
  24763. tcl.Id,
  24764. tcl.DiId,
  24765. tcl.IsAccompany,
  24766. temp.*,
  24767. u.CnName AS Operator,
  24768. tcl.CreateTime AS OperatingTime,
  24769. ssd.name AS ShippingSpaceType
  24770. FROM
  24771. Grp_TourClientList tcl
  24772. LEFT JOIN (
  24773. SELECT
  24774. dc.Id AS DcId,
  24775. dc.LastName,
  24776. dc.FirstName,
  24777. ccom.CompanyFullName,
  24778. dc.Job,
  24779. cc.CertNo AS IDCardNo,
  24780. dc.Sex,
  24781. dc.BirthDay
  24782. FROM
  24783. Crm_DeleClient dc
  24784. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  24785. AND ccom.IsDel = 0
  24786. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  24787. AND cc.SdId = 773
  24788. AND cc.IsDel = 0
  24789. WHERE
  24790. dc.IsDel = 0
  24791. ) temp ON temp.DcId = tcl.ClientId
  24792. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  24793. LEFT JOIN sys_setdata ssd ON ssd.isdel = 0 AND ssd.id = tcl.ShippingSpaceTypeid
  24794. WHERE
  24795. tcl.IsDel = 0
  24796. AND tcl.DiId = {0}", groupId);
  24797. var groupClientList = await _sqlSugar.SqlQueryable<TourClientInfosView>(sql).ToListAsync();
  24798. //解密
  24799. foreach (var item in groupClientList)
  24800. {
  24801. EncryptionProcessor.DecryptProperties(item);
  24802. }
  24803. if (groupClientList == null || groupClientList.Count < 1)
  24804. {
  24805. return Ok(JsonView(false, $"团组客户名单未录入客户信息,不可生成相关资料。"));
  24806. }
  24807. #region 生成文件
  24808. //酒店信息
  24809. var hotelInfos = await _sqlSugar.Queryable<Grp_HotelReservations>()
  24810. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  24811. .OrderBy(x => x.CheckInDate)
  24812. .ToListAsync();
  24813. //航班信息
  24814. var airInfos = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  24815. .Where(x => x.IsDel == 0 && x.DIId == groupId)
  24816. .OrderBy(x => x.FlightsDate)
  24817. .ToListAsync();
  24818. foreach (var clientInfo in groupClientList)
  24819. {
  24820. var clientId = clientInfo.DcId;
  24821. var guestName = $"{clientInfo.LastName}{clientInfo.FirstName}";
  24822. #region 个人信息资料
  24823. #endregion
  24824. #region 机票航班信息
  24825. var clientAirInfos = airInfos.Where(x => x.ClientName.Contains(clientId.ToString())).ToList();
  24826. if (clientAirInfos != null && clientAirInfos.Count > 0)
  24827. {
  24828. //创建表格
  24829. Document airDoc = new Document();
  24830. DocumentBuilder airBuilder = new DocumentBuilder(airDoc);
  24831. GeneralMethod.SetupDocumentStyles(airBuilder);
  24832. GeneralMethod.AddTitle(airBuilder, $"{guestName} - 机票信息");
  24833. GeneralMethod.AddAirInfoSections(airBuilder, clientAirInfos, "机票航班信息");
  24834. var airRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24835. var airFileName = $"{guestName}_机票信息_{airRandomStr}.docx";
  24836. airDoc.Save($"{path}/{airFileName}");
  24837. }
  24838. #endregion
  24839. #region 酒店信息
  24840. var clientHotelInfos = hotelInfos.Where(x => x.GuestName.Contains(clientId.ToString())).ToList();
  24841. if (clientHotelInfos != null && clientHotelInfos.Count > 0)
  24842. {
  24843. //创建表格
  24844. Document hotelDoc = new Document();
  24845. DocumentBuilder HotelBuilder = new DocumentBuilder(hotelDoc);
  24846. GeneralMethod.SetupDocumentStyles(HotelBuilder);
  24847. GeneralMethod.AddTitle(HotelBuilder, $"{guestName} - 酒店信息");
  24848. GeneralMethod.AddHotelInfoSections(HotelBuilder, clientHotelInfos, "酒店信息");
  24849. var hotelRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24850. var hotelFileName = $"{guestName}_酒店信息_{hotelRandomStr}.docx";
  24851. hotelDoc.Save($"{path}/{hotelFileName}");
  24852. }
  24853. #endregion
  24854. }
  24855. #endregion
  24856. //打包文件夹
  24857. var sourceDirectory = $"{sourceDirectoryPath}/{dirName}";
  24858. var zipFilePath = $"{sourceDirectoryPath}/{dirName}.zip";
  24859. if (System.IO.File.Exists(zipFilePath))
  24860. {
  24861. System.IO.File.Delete(zipFilePath);
  24862. }
  24863. ZipFile.CreateFromDirectory(sourceDirectory, zipFilePath, CompressionLevel.Fastest, false);
  24864. // 等待并验证
  24865. await Task.Delay(100); // 给系统时间完成文件操作
  24866. if (System.IO.File.Exists(zipFilePath))
  24867. {
  24868. var fileInfo = new FileInfo(zipFilePath);
  24869. var url = $"{rootRrl}Office/GrpFile/VisaProcessFiles/{groupName}/{dirName}.zip";
  24870. //记录下载日志
  24871. await _visaProcessRep.LogOperationAsync(null, null, "Download", currUserId);
  24872. return Ok(JsonView(StatusCodes.Status200OK, "操作成功!", url));
  24873. }
  24874. return Ok(JsonView(false));
  24875. }
  24876. /// <summary>
  24877. /// 团组签证流程 - 根据步骤记录ID获取该步骤的所有操作日志
  24878. /// </summary>
  24879. /// <returns></returns>
  24880. [HttpGet]
  24881. public async Task<IActionResult> VisaProcessLogByStepId(int stepId)
  24882. {
  24883. //参数验证
  24884. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == stepId && x.IsDel == 0).FirstAsync();
  24885. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24886. var logs = await _visaProcessRep.GetStepLogsAsync(stepId);
  24887. return Ok(JsonView(logs));
  24888. }
  24889. /// <summary>
  24890. /// 团组签证流程 - 根据团组ID获取该团组下所有步骤的操作日志
  24891. /// </summary>
  24892. /// <returns></returns>
  24893. [HttpGet]
  24894. public async Task<IActionResult> VisaProcessLogByGroupId(int groupId)
  24895. {
  24896. //参数验证
  24897. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.GroupId == groupId && x.IsDel == 0).FirstAsync();
  24898. if (stepValid == null) return Ok(JsonView(false, "团组ID无效。"));
  24899. var logs = await _visaProcessRep.GetGroupStepLogsAsync(groupId);
  24900. return Ok(JsonView(logs));
  24901. }
  24902. #endregion
  24903. #region 团组总览进程
  24904. /// <summary>
  24905. /// 团组总览进程 - 流程创建测试
  24906. /// </summary>
  24907. /// <returns></returns>
  24908. [HttpGet]
  24909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24910. public async Task<IActionResult> GroupProcessInitTest(int groupId,int currUserId)
  24911. {
  24912. return Ok(await _processOverviewRep.ProcessInitAsync(groupId, currUserId));
  24913. }
  24914. /// <summary>
  24915. /// 团组总览进程 - 团组名称集合
  24916. /// </summary>
  24917. /// <returns></returns>
  24918. [HttpGet]
  24919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24920. public async Task<IActionResult> GroupProcessGroupNames()
  24921. {
  24922. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24923. .Where(x => x.IsDel == 0)
  24924. .OrderByDescending(x => x.VisitDate)
  24925. .Select(x => new
  24926. {
  24927. x.Id,
  24928. GroupName = x.TeamName,
  24929. HasProcess = SqlFunc.Subqueryable<Grp_ProcessOverview>()
  24930. .Where(po => po.GroupId == x.Id && po.IsDel == 0)
  24931. .Any()
  24932. })
  24933. .ToListAsync();
  24934. return Ok(JsonView(groupNames));
  24935. }
  24936. /// <summary>
  24937. /// 团组总览进程 - 流程详情
  24938. /// </summary>
  24939. /// <returns></returns>
  24940. [HttpGet]
  24941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24942. public async Task<IActionResult> GroupProcessDetails(int groupId)
  24943. {
  24944. var res = await _processOverviewRep.ProcessesDetailsAsync(groupId);
  24945. if (res.Code == StatusCodes.Status200OK)
  24946. {
  24947. return Ok(JsonView(res.Data));
  24948. }
  24949. return Ok(JsonView(false, res.Msg));
  24950. }
  24951. /// <summary>
  24952. /// 团组总览进程 - 更新节点状态
  24953. /// </summary>
  24954. /// <returns></returns>
  24955. [HttpPost]
  24956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24957. public async Task<IActionResult> GroupProcessUpdateNodeStatus(GroupProcessUpdateNodeStatusDto dto)
  24958. {
  24959. var res = await _processOverviewRep.UpdateNodeStatusAsync(dto.NodeId, dto.CurrUserId);
  24960. if (res.Code == StatusCodes.Status200OK)
  24961. {
  24962. return Ok(JsonView(res.Data));
  24963. }
  24964. return Ok(JsonView(false, res.Msg));
  24965. }
  24966. /// <summary>
  24967. /// 团组总览进程 - 更新签证节点信息
  24968. /// </summary>
  24969. /// <returns></returns>
  24970. [HttpPost]
  24971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24972. public async Task<IActionResult> GroupProcessUpdateVisaNodeDetails(GroupProcessUpdateVisaNodeDetailsDto dto)
  24973. {
  24974. //验证签证信息
  24975. if (dto.VisaSubNodes.Count < 1) return Ok(JsonView(false, "请传入有效的签证节点信息。"));
  24976. var res = await _processOverviewRep.UpdateVisaNodeDetailsAsync(dto);
  24977. if (res.Code == StatusCodes.Status200OK)
  24978. {
  24979. return Ok(JsonView(res.Data));
  24980. }
  24981. return Ok(JsonView(false, res.Msg));
  24982. }
  24983. #endregion
  24984. /// <summary>
  24985. /// 123132123
  24986. /// </summary>
  24987. /// <param name="_dto"></param>
  24988. /// <returns></returns>
  24989. [HttpPost]
  24990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24991. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  24992. {
  24993. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  24994. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  24995. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  24996. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  24997. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  24998. dicDetail.Add(789, 1034);
  24999. dicDetail.Add(790, 1035);
  25000. dicDetail.Add(791, 1036);
  25001. dicDetail.Add(792, 1037);
  25002. dicDetail.Add(793, 1038);
  25003. dicDetail.Add(794, 1039);
  25004. dicDetail.Add(795, 1040);
  25005. dicDetail.Add(796, 1041);
  25006. dicDetail.Add(797, 1042);
  25007. dicDetail.Add(798, 1043);
  25008. dicDetail.Add(801, 1044);
  25009. dicDetail.Add(802, 1045);
  25010. dicDetail.Add(803, 1046);
  25011. Dictionary<int, int> dic = new Dictionary<int, int>();
  25012. dic.Add(806, 1027);
  25013. dic.Add(807, 1028);
  25014. dic.Add(808, 1029);
  25015. dic.Add(809, 1030);
  25016. dic.Add(810, 1031);
  25017. dic.Add(811, 1032);
  25018. dic.Add(812, 1033);
  25019. foreach (var item in list_visa)
  25020. {
  25021. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  25022. temp.Coefficient = item.coefficient;
  25023. DateTime dtCrt;
  25024. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  25025. if (b1)
  25026. {
  25027. temp.CreateTime = dtCrt;
  25028. }
  25029. else
  25030. {
  25031. temp.CreateTime = DateTime.Now;
  25032. }
  25033. temp.CreateUserId = item.Operators;
  25034. temp.DeleteTime = "";
  25035. temp.DeleteUserId = 0;
  25036. temp.DiId = int.Parse(item.DIID);
  25037. temp.FilePath = item.FilePath;
  25038. temp.IsDel = item.IsDel;
  25039. temp.Price = item.Price;
  25040. temp.PriceCount = 1;
  25041. temp.PriceCurrency = item.Currency;
  25042. int detailId = 0;
  25043. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  25044. {
  25045. detailId = dicDetail[item.PriceTypeDetail];
  25046. }
  25047. temp.PriceDetailType = detailId;
  25048. temp.PriceDt = DateTime.Now;
  25049. temp.PriceName = item.PriceName;
  25050. temp.PriceSum = item.Price;
  25051. int tid = 0;
  25052. if (dic.ContainsKey(item.PriceType))
  25053. {
  25054. tid = dic[item.PriceType];
  25055. }
  25056. temp.PriceType = tid;
  25057. temp.Remark = item.Remark;
  25058. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  25059. }
  25060. return Ok(JsonView(true, "操作成功!"));
  25061. }
  25062. [HttpPost]
  25063. public IActionResult TimeTest()
  25064. {
  25065. var jw = JsonView(false, "error");
  25066. _sqlSugar.BeginTran();
  25067. try
  25068. {
  25069. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  25070. .Select(x => new Crm_NewClientData
  25071. {
  25072. Id = x.Id,
  25073. Client = x.Client,
  25074. Contact = x.Contact,
  25075. Location = x.Location,
  25076. })
  25077. .ToList();
  25078. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  25079. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  25080. Stopwatch stopwatch = new Stopwatch();
  25081. // 开始计时
  25082. stopwatch.Start();
  25083. foreach (var item in clientList)
  25084. {
  25085. EncryptionProcessor.DecryptProperties(item);
  25086. }
  25087. stopwatch.Stop();
  25088. jw.Code = 200;
  25089. jw.Data = stopwatch.ElapsedMilliseconds;
  25090. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  25091. }
  25092. catch (Exception ex)
  25093. {
  25094. jw.Code = 400;
  25095. jw.Msg = ex.Message;
  25096. }
  25097. return Ok(jw);
  25098. }
  25099. [HttpPost]
  25100. public async Task<IActionResult> TimeTest1()
  25101. {
  25102. var infos = await _sqlSugar.Queryable<Crm_DeleClient>().ToListAsync();
  25103. return Ok(infos);
  25104. }
  25105. }
  25106. }